Log In  

16

Cart [#37156#] | Copy | Code | 2017-02-04 | Link
16

Hello there, I've been working on this piece of software called midi2pico
It does what it implies, converts midis into music for pico-8

I've recently just added proper drum support, so in celebration of that I want to release this little demo.

Come checkout midi2pico at github: https://github.com/gamax92/midi2pico

It's a very configurable midi conversion program, with the ability to mute channels, change volumes, and to shift pitches to fit into pico-8's audio range. midi2pico attempts to arrange midi data in a logical way, storing the beginning of a song at sfx 0 and the end of the song near the end of available sfx.

MIDI Format 0, pitch bends, sfx deduplication, silence removal, and now drums are supported. A midi instrument and drum to pico-8 translation table is supported, though not very populated and most instruments use a default conversion. Look for 'Instrument to PICO-8 Map' and 'Drums to PICO-8 Map' inside midi2pico.lua

A separate utility is also included for debugging midi files called midi2note. midi2note shows the end result after midi2opus, opus2score, and score2note conversions that midi2pico also uses.

Installation is easy, all you need is lua 5.2 and the MIDI library, which is available in luarocks as 'luarocks install midi' or download the MIDI library directly here and place it along side midi2pico.lua

lua 5.1 is also supported, but you will need a bit32 backport which is also available in luarocks as 'luarocks install bit32'

midi music tool
P#37155 2017-02-04 17:46

::

I'm getting an error

Notes:
Using Lua 5.1.4 on Windows.
Installed midi with luarocks

Error:
C:\Users\Gryphon\AppData\Roaming\pico-8\carts\music>lua midi2pico.lua invent13.mid songdata.p8
lua: .\argparse.lua:3: attempt to call field 'pack' (a nil value)
stack traceback:
        .\argparse.lua:3: in function 'parse'
        midi2pico.lua:4: in main chunk
        [C]: ?

I'm very excited about having more midi-conversion options.

P#37182 2017-02-05 15:16

::

Lua 5.1 does not have table.pack or a bit library, which is required by midi2pico

You may install a backport of bit32 via luarocks: luarocks install bit32
and then add

function table.pack(...) return {n=select("#", ...), ...} end

to the very top of the file

I'll add 5.1 compatibility soon

EDIT: Lua 5.1 and LuaJIT compatibility has been added

P#37188 2017-02-05 17:41

::

hooray for MIDI converter club! :)

drum support! nice! (mine doesn't do drums at all :X)

P#37191 2017-02-05 17:54

::

Cart [#37206#] | Copy | Code | 2017-02-06 | Link
2

Also just got my old streaming code fixed up, so now midi2pico has an option to generate a cart that streams sfx data from gfx area.

It's mostly for debugging, but it does technically allow a ~364% increase in music storage at the expense of your gfx and maps, possibly more if you use it right.

And a vumeter for fun.

P#37201 2017-02-05 20:40

::

Cart [#37270#] | Copy | Code | 2017-02-07 | Link
3

Just got MIDI CC11 (Expression) supported, which fixes missing volume effects in some midi files. So, have another demo, one of which uses this said Expression command.

Some files like to use CC7 (Volume) as an overall volume, relying on CC11 for dynamic volume control. And some use vice versa, yay midi!

More instrument to pico-8 mappings have been added too which improves the piano and organ sounds.

And a note+volume visualizer for fun

EDIT: Fixed the volume of the beginning 4 notes, sorry.

P#37226 2017-02-06 15:53

::

I've just added in some time correction options, so midis that were previously rejected by midi2pico for having odd timing may now be supported.

I'd notice in my ~1000 midi's marked as bad, a lot of them had common errors, timing that was close but off by a small bit, or only a few notes did not match the timing, so two options have been added to support these cases, --ignorediv and --fixdivone

There is also a new midi timing --analysis option that can go through and provide some suggestions for possible --div=n values. It will go through all the notes in a file and show which divisions would work best for most notes and also analysis the time spacing between notes.

Do note that some midi files are just really badly timed and cannot be salvaged by midi2pico without the help of some external midi editing tool.


I'll also be working on making MusicHAX an option that doesn't require p8convert, instead of spitting out binary files to be converted into pngs it'll spit out a p8 file

EDIT: Completed making MusicHAX work with p8 files, so now p8convert is not required to use this option.

P#37263 2017-02-07 14:08

::

I like the visualizer :)

I'm gonna have to look at your tempo stuff to see how it works 'cause that has always been a weak point for mine...

P#37271 2017-02-07 20:13

::

Tempo support is still rather limited but it supports a good number of cases:

Allows multiple tempo changes before any notes play
Allows multiple tempo changes before any time has passed from zero
Or takes the first tempo event it can get (there are possible problems with this one)

The first two were needed because some midis like to change configuration a bunch of times before actually doing anything.

It's kinda hard to make midi tempo work in pico-8 since in a midi it can change wherever it wants to but pico-8 can only change speed on every 32 note boundary. There's also no way to force the sfx to end early, looping parameters don't affect that.

Songs that don't change in the middle of them will work fine for now. A thing I was thinking of doing was seeing which tempo applies for most of the song and using the longest active one. Or just having an option for delayed/early tempo changes up to the closest sfx boundary

P#37290 2017-02-08 13:14

::

Just tried this out with the theme tune of the game I am trying to remake in PICO-8..... with outstanding results!

Many many thanks! :)


NOTE: not sure if this will help anyone ever, but I had to edit line 707 of the conversion program to read:

local time, track, channel, control, value=unpack(event, 2)

that is: i removed the 'table.' before unpack.... which i think may be something to do with my lua version (5.1.5)? Not sure though really, just stopped me getting an error regarding unpack() as a nil value.

P#37749 2017-02-23 10:16

::

Ahh thank you for mentioning that, forgot to fix that when adding in Lua 5.1 support

Fixed in latest version.

P#37838 2017-02-26 00:02

:: Info: Finished!

Hey gamax92,
Thanks a lot for sharing this code here.
I gave it a try and it took me arround 9h in 3 sessions to get to the point where it says Info: Finished!
At this moment I'm rly enjoying the success ^^ But I didn't listen to the result yet :D

Btw. My biggest problem was that was kinda new to the lua universe and had to learn a lot about lua and luarocks.
How to install rocks compile lua and that you should omit the hashtags "#" when using the Microsoft Command Line and that lua should be "lua53" when using lua 5.3 and much more of such things...
But finially I was using the cmd like this:

cd C:\lua
lua53 midi2pico.lua somesong.mid songdata.p8 --notrunc

Maybe that helps somebody else to get it faster running.
and now I'm going to listen the converted tune. :D

Thanks

P#45169 2017-10-13 05:24

::

ah yes, btw, I've been using it for a while! the only way for me to put music in there :)
a little hard to setup but then it works very well most of the time!
(a little buggy in sewers of doh but I like that (I'm weird))

though it seems I always have to "--analysis" first then use the result in "--div="

now if the resulting p8 could include

__lua__
music(0) function _update() end

that would be even more ace!

P#45171 2017-10-13 07:15

:: lemmigsport

I also thought that :D

Here is my first ported tune (LemmingsLEMMIN1P(PC).mid)
I had to preedit the mid with mudplugtracker to kick some channels, arrange the patterns new and auto clean the whole file to remove some unused stuff.

Enjoy

Cart [#45173#] | Copy | Code | 2017-10-13 | Link
0

P#45174 2017-10-13 08:19

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2017-10-17 11:19 | 0.237s | 1835k | Q:54