aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-14 22:35:49 +0000
committerFilippos Karapetis2010-06-14 22:35:49 +0000
commita6a482b83cb8f924f920ac16c8a48a321e89ecc9 (patch)
tree71045208f41222adf396c474675a8f35f20d4340 /engines
parent22e9fe8291b2f7f2111823614de4976f058ef524 (diff)
downloadscummvm-rg350-a6a482b83cb8f924f920ac16c8a48a321e89ecc9.tar.gz
scummvm-rg350-a6a482b83cb8f924f920ac16c8a48a321e89ecc9.tar.bz2
scummvm-rg350-a6a482b83cb8f924f920ac16c8a48a321e89ecc9.zip
SCI: Added a version of allNotesOff() which sends messages only to the channels used by the associated song instead of all channels
svn-id: r49673
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/sound/midiparser_sci.cpp34
-rw-r--r--engines/sci/sound/midiparser_sci.h2
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