nlaha / godot-midi

MIDI file parsing and event playback in Godot 4.1+
MIT License
52 stars 5 forks source link

Only first 12 seconds are being imported #15

Closed TheRedstoneScientist closed 4 months ago

TheRedstoneScientist commented 5 months ago

After importing Imagine dragons - Radioactive.zip (made it a zip since git doesn't support mid) I'm able to get it to print to the output but after about 12.1 seconds it always stops. In the inspector it only seems to have the first 12 seconds in the data there too.

TheRedstoneScientist commented 5 months ago

I'm unable to tell what happened but I had to reexport the midi

TheRedstoneScientist commented 5 months ago

Never mind. I accidentally commented that on this issue. It was a different issue that was solved. I am still only getting the first 12 seconds.

TheRedstoneScientist commented 5 months ago

When attempting with a different file I only get the first 27 seconds Armin Van Buuren - Imagine Piano Sequence.zip

nlaha commented 4 months ago

Thanks for reporting this bug! I'll look into it. It is likely the midi file you are using has some uncommon midi events present that I haven't added support for. Until I can do further testing, I recommend you import and export the midi file from a well-known DAW like FL Studio to convert it to a standard midi format.

nlaha commented 4 months ago

Looking into the midi parsing code, and viewing the midi file you provided with a hex editor, it seems like there are some issues with the format. I'm able to import the first midi file you sent into FL Studio fine, but the second one actually seems corrupted past 27 seconds in, I suggest you find a difference source.

Regarding the first file however: image

The midi file is storing the first control change event (event type 0xB0) as specified, but the events proceeding it don't have an event type field at all, and simply have the control subtype and value. I'm not sure how FL Studio gets around this inconsistency, but because I can't find any documentation regarding this anywhere online, I'm closing this issue for now. I have attached a version of your midi file re-exported through FL Studio that imports to Godot fine. Imagine dragons - Radioactive.zip