wyskoj / midis2jam2

🎶 A remaster of MIDIJam, a 3D MIDI file visualizer.
https://midis2jam2.xyz
GNU General Public License v3.0
152 stars 21 forks source link

Absence of a tempo event at the beginning of MIDI file incurs a crash #160

Closed Big-coconut closed 1 year ago

Big-coconut commented 1 year ago

Describe the bug When I try to run the file, a popup says:

Error in Application

Uncaught exception thrown in Thread[jME3 Main,5,main]
NoSuchElementException: List contains no element matching the predicate.

Offending MIDI file Christmas_Medley.zip

Screenshots image

System Windows 11

Additional context It works on the original midijam.

wyskoj commented 1 year ago

This exception is thrown because midis2jam2 assumes there is a tempo event at the beginning of the file. I considered files that have zero tempo events, but not when the count is non-zero and the first event occurs after the beginning.

The fix is just to assume that the file starts at 120 BPM per the SMF specification.

wyskoj commented 1 year ago

A printout of the tempo events in the files reveals that the first tempo event occurs at 17760.

image