kovaxis/midly

Support for midi files with RIFF header?

Closed this issue · 1 comments

It would be great if midi files that have a RIFF header could be loaded, too :)

E.g.:
http://www.midiarchive.co.uk/downloadfile/Classics/Beethoven/Beethoven.rmi

image

It just requires skipping those header bytes:

https://www.loc.gov/preservation/digital/formats/fdd/fdd000120.shtml

Hex: 52 49 46 46 xx xx xx xx 52 4D 49 44 64 61 74 61
ASCII: RIFF....RMIDdata

https://www.garykessler.net/library/file_sigs.html

52 49 46 46 xx xx xx xx52 4D 49 44 64 61 74 61 RIFF....RMIDdata
RMI   Resource Interchange File Format -- Windows MusicalInstrument Digital Interface file, where xx xx xx xx is the filesize (little endian)

Not sure what those 4 bytes before MThd are but they can also be skipped.


Btw, here is how I implemented this for rimd a while ago:
https://github.com/RustAudio/rimd/blob/54fd9bd2bd3caaa6fe1c31fbf71c0f3c6597fd1a/src/reader.rs#L14-L25

At first it reads 14 bytes because the normal midi file header is 14 bytes (MThd.........ð in the case above). But if the first 4 bytes are RIFF, it skips 6 bytes so that it has skipped the first 20 bytes in total, and then it reads the real midi header into the header buffer.

Hello again, sorry for the late reply.

I've currently implemented this in the 0.4.1 version, but cargo seems to refuse to upload it with a 500 HTTP error :/

It's currently there in the master branch though, and I'll upload it as soon as I can.

Never seen that kind of RMID files before. Pretty niche huh. Anyways it's a nice self-contained addition to the library.