commit d25739f069102b5394e2806fbe00dbfa8f65a1f9
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Mon May 12 00:12:07 2014 -0400
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Mon May 12 00:12:07 2014 -0400
opl: Handle negative time division values.
A negative time division file indicates the MIDI file uses SMPTE time
rather than the normal time system. This is not supported yet, but for
the time being, return a sensible time division value that doesn't
cause the sound to stutter and the game to become unplayable.
This fixes #352, although the affected MIDIs do not yet play properly.
---
src/midifile.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/midifile.c b/src/midifile.c
index 6e40a274..94ec4441 100644
--- a/src/midifile.c
+++ b/src/midifile.c
@@ -699,7 +699,19 @@ int MIDI_GetNextEvent(midi_track_iter_t *iter, midi_event_t **event)
unsigned int MIDI_GetFileTimeDivision(midi_file_t *file)
{
- return SHORT(file->header.time_division);
+ short result = SHORT(file->header.time_division);
+
+ // Negative time division indicates SMPTE time and must be handled
+ // differently.
+ if (result < 0)
+ {
+ // TODO: Figure this out.
+ return 96;
+ }
+ else
+ {
+ return result;
+ }
}
void MIDI_RestartIterator(midi_track_iter_t *iter)