diff options
author | Jamieson Christian | 2003-05-23 15:04:41 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-05-23 15:04:41 +0000 |
commit | 982883c6371133dca8c861391a07920a9a96c2ff (patch) | |
tree | 727ef1835ed5c8f1eefef41457b045712e4cce7e /sound | |
parent | 4c0f8eda9ac1256920fec5794230c447402af11c (diff) | |
download | scummvm-rg350-982883c6371133dca8c861391a07920a9a96c2ff.tar.gz scummvm-rg350-982883c6371133dca8c861391a07920a9a96c2ff.tar.bz2 scummvm-rg350-982883c6371133dca8c861391a07920a9a96c2ff.zip |
Fixed problem with hanging notes on some synth modules.
Various little MidiParser fixes.
svn-id: r7863
Diffstat (limited to 'sound')
-rw-r--r-- | sound/midiparser.cpp | 17 | ||||
-rw-r--r-- | sound/midiparser.h | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/sound/midiparser.cpp b/sound/midiparser.cpp index 6af0a568ef..488443cc2f 100644 --- a/sound/midiparser.cpp +++ b/sound/midiparser.cpp @@ -117,14 +117,23 @@ void MidiParser::hangingNote (byte channel, byte note, uint32 time_left) { if (ptr->time_left && ptr->time_left < time_left) return; best = ptr; - if (ptr->time_left) + if (ptr->time_left) { + _driver->send (0x80 | channel | note << 8); --_hanging_notes_count; + } break; } else if (!best && ptr->time_left == 0) { best = ptr; } } + // Occassionally we might get a zero or negative note + // length, if the note should be turned on and off in + // the same iteration. For now just set it to 1 and + // we'll turn it off in the next cycle. + if (!time_left || time_left & 0x80000000) + time_left = 1; + if (best) { best->channel = channel; best->note = note; @@ -187,12 +196,12 @@ void MidiParser::onTimer() { if (info.ext.type == 0x2F) { // End of Track must be processed by us, // as well as sending it to the output device. - allNotesOff(); if (_autoLoop) { - _position._play_pos = _tracks[_active_track]; + jumpToTick (0); parseNextEvent (_next_event); } else { - _position._play_pos = 0; + allNotesOff(); + resetTracking(); _driver->metaEvent (info.ext.type, info.ext.data, (uint16) info.length); } return; diff --git a/sound/midiparser.h b/sound/midiparser.h index d8c2c373e4..4c31ecc73c 100644 --- a/sound/midiparser.h +++ b/sound/midiparser.h @@ -157,7 +157,7 @@ public: public: MidiParser(); - virtual ~MidiParser() { } + virtual ~MidiParser() { allNotesOff(); } virtual bool loadMusic (byte *data, uint32 size) = 0; virtual void unloadMusic() = 0; |