|
From: Tapio V. <aa...@us...> - 2010-05-16 16:30:29
|
Module: performous
Branch: instrumentgraph
Commit: e87fb7d5e5c73908a2951a34be02657b0185cf3c
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Apr 21 02:25:52 2010 +0300
Fix MIDI parser handling of events 0xC and 0xD that would b0rk parsing until now
---
game/midifile.cc | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/game/midifile.cc b/game/midifile.cc
index f70465c..054707d 100644
--- a/game/midifile.cc
+++ b/game/midifile.cc
@@ -218,7 +218,13 @@ MidiFileParser::Track MidiFileParser::read_track(MidiStream& stream) {
} else {
// Midi event
uint8_t arg1 = riff.read_uint8();
- uint8_t arg2 = riff.read_uint8();
+ uint8_t arg2 = 0;
+ uint8_t ev = event >> 4;
+ switch (ev) {
+ case 0x8: case 0x9: case 0xA: case 0xB: case 0xE: arg2 = riff.read_uint8(); break;
+ case 0xC: case 0xD: break; // These only take one argument
+ default: throw std::runtime_error("Unknown MIDI event"); // Quite possibly this is impossible, but I am too tired to prove it.
+ }
process_midi_event(track, event >> 4, arg1, arg2, miditime);
}
}
|