Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Big-coconut opened this issue Dec 31, 2022 · 2 comments · Fixed by #163
Closed

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

Big-coconut opened this issue Dec 31, 2022 · 2 comments · Fixed by #163
Assignees
Labels
bug Something isn't working or is incorrect

Comments

@Big-coconut
Copy link

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.

@Big-coconut Big-coconut added the bug Something isn't working or is incorrect label Dec 31, 2022
@wyskoj wyskoj changed the title Won't run a certain midi file Absence of a tempo event at the beginning of MIDI file incurs a crash Jun 1, 2023
@wyskoj wyskoj self-assigned this Jun 1, 2023
@wyskoj
Copy link
Owner

wyskoj commented Jun 1, 2023

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
Copy link
Owner

wyskoj commented Jun 1, 2023

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

image

wyskoj added a commit that referenced this issue Jun 1, 2023
Fix the issue where an exception is thrown if the first tempo event in
a MIDI file does not occur at time zero.

Per the SMF specification, the tempo shall be assumed to be 120 BPM. The
easiest fix to this is just to add a tempo event of 120 BPM at time zero
if no tempo event occurs then.

Fixes #160
@wyskoj wyskoj linked a pull request Jun 1, 2023 that will close this issue
wyskoj added a commit that referenced this issue Jun 1, 2023
Fix the issue where an exception is thrown if the first tempo event in
a MIDI file does not occur at time zero.

Per the SMF specification, the tempo shall be assumed to be 120 BPM. The
easiest fix to this is just to add a tempo event of 120 BPM at time zero
if no tempo event occurs then.

Fixes #160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants