diff options
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 34 | ||||
-rw-r--r-- | engines/sci/sound/midiparser_sci.h | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index bb353da780..c74a7eae11 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -325,6 +325,40 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { }// switch (info.command()) } +void MidiParser_SCI::allNotesOff() { + if (!_driver) + return; + + int i, j; + + // Turn off all active notes + for (i = 0; i < 128; ++i) { + for (j = 0; j < 16; ++j) { + if ((_active_notes[i] & (1 << j)) && isChannelUsed(j)){ + _driver->send(0x80 | j, i, 0); + } + } + } + + // Turn off all hanging notes + for (i = 0; i < ARRAYSIZE(_hanging_notes); i++) { + if (_hanging_notes[i].time_left) { + _driver->send(0x80 | _hanging_notes[i].channel, _hanging_notes[i].note, 0); + _hanging_notes[i].time_left = 0; + } + } + _hanging_notes_count = 0; + + // To be sure, send an "All Note Off" event (but not all MIDI devices + // support this...). + + for (i = 0; i < 16; ++i) { + if (isChannelUsed(i)) + _driver->send(0xB0 | i, 0x7b, 0); // All notes off + } + + memset(_active_notes, 0, sizeof(_active_notes)); +} byte MidiParser_SCI::midiGetNextChannel(long ticker) { byte curr = 0xFF; diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h index 8384c74cf6..80401460d2 100644 --- a/engines/sci/sound/midiparser_sci.h +++ b/engines/sci/sound/midiparser_sci.h @@ -71,6 +71,8 @@ public: jumpToTick(0); } + void allNotesOff(); + void remapChannel(byte channel, byte newChannel) { assert(channel < 0xF); // don't touch special SCI channel 15 assert(newChannel < 0xF); // don't touch special SCI channel 15 |