[Scummvm-cvs-logs] SF.net SVN: scummvm:[55746] scummvm/trunk

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Feb 3 00:27:59 CET 2011


Revision: 55746
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55746&view=rev
Author:   thebluegr
Date:     2011-02-02 23:27:59 +0000 (Wed, 02 Feb 2011)

Log Message:
-----------
MIDI: Fix for bug #3170988 - "MONKEY2: Messed up MT-32 music"

This is a regression from r55256. Apparently, SCUMM has issues when sending a sustain
off on a notes off event. Thus, this has been turned into a feature, which is disabled
by default. Since MADE, SAGA and tinsel all share the same music code and play regular
MIDI files, and this feature fixes hanging notes for them, it has been enabled for them.
Also, applied a patch for a bug regarding the notes off event in MADE and tinsel,
which has been applied in SAGA already

Modified Paths:
--------------
    scummvm/trunk/engines/made/music.cpp
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/engines/tinsel/music.cpp
    scummvm/trunk/sound/midiparser.cpp
    scummvm/trunk/sound/midiparser.h

Modified: scummvm/trunk/engines/made/music.cpp
===================================================================
--- scummvm/trunk/engines/made/music.cpp	2011-02-02 23:22:45 UTC (rev 55745)
+++ scummvm/trunk/engines/made/music.cpp	2011-02-02 23:27:59 UTC (rev 55746)
@@ -113,9 +113,9 @@
 		b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8;
 	}
 	else if ((b & 0xFFF0) == 0x007BB0) {
-		//Only respond to All Notes Off if this channel
-		//has currently been allocated
-		if (_channel[b & 0x0F])
+		// Only respond to All Notes Off if this channel
+		// has currently been allocated
+		if (!_channel[b & 0x0F])
 			return;
 	}
 
@@ -165,6 +165,7 @@
 		parser->setMidiDriver(this);
 		parser->setTimerRate(getBaseTempo());
 		parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+		parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
 
 		_parser = parser;
 

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2011-02-02 23:22:45 UTC (rev 55745)
+++ scummvm/trunk/engines/saga/music.cpp	2011-02-02 23:27:59 UTC (rev 55746)
@@ -184,6 +184,7 @@
 	_parser->setMidiDriver(_driver);
 	_parser->setTimerRate(_driver->getBaseTempo());
 	_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+	_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
 
 	_digitalMusic = false;
 }

Modified: scummvm/trunk/engines/tinsel/music.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/music.cpp	2011-02-02 23:22:45 UTC (rev 55745)
+++ scummvm/trunk/engines/tinsel/music.cpp	2011-02-02 23:27:59 UTC (rev 55746)
@@ -466,9 +466,9 @@
 		volume = volume * _masterVolume / 255;
 		b = (b & 0xFF00FFFF) | (volume << 16);
 	} else if ((b & 0xFFF0) == 0x007BB0) {
-		//Only respond to All Notes Off if this channel
-		//has currently been allocated
-		if (_channel[b & 0x0F])
+		// Only respond to All Notes Off if this channel
+		// has currently been allocated
+		if (!_channel[b & 0x0F])
 			return;
 	}
 
@@ -533,6 +533,7 @@
 		parser->setMidiDriver(this);
 		parser->setTimerRate(getBaseTempo());
 		parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+		parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
 
 		_parser = parser;
 

Modified: scummvm/trunk/sound/midiparser.cpp
===================================================================
--- scummvm/trunk/sound/midiparser.cpp	2011-02-02 23:22:45 UTC (rev 55745)
+++ scummvm/trunk/sound/midiparser.cpp	2011-02-02 23:27:59 UTC (rev 55746)
@@ -43,6 +43,7 @@
 _autoLoop(false),
 _smartJump(false),
 _centerPitchWheelOnUnload(false),
+_sendSustainOffOnNotesOff(false),
 _num_tracks(0),
 _active_track(255),
 _abort_parse(0) {
@@ -64,6 +65,9 @@
 	case mpCenterPitchWheelOnUnload:
 		_centerPitchWheelOnUnload = (value != 0);
 		break;
+	case mpSendSustainOffOnNotesOff:
+		_sendSustainOffOnNotesOff = (value != 0);
+		break;
 	}
 }
 
@@ -281,7 +285,8 @@
 
 	for (i = 0; i < 16; ++i) {
 		sendToDriver(0xB0 | i, 0x7b, 0); // All notes off
-		sendToDriver(0xB0 | i, 0x40, 0); // Also send a sustain off event (bug #3116608)
+		if (_sendSustainOffOnNotesOff)
+			sendToDriver(0xB0 | i, 0x40, 0); // Also send a sustain off event (bug #3116608)
 	}
 
 	memset(_active_notes, 0, sizeof(_active_notes));

Modified: scummvm/trunk/sound/midiparser.h
===================================================================
--- scummvm/trunk/sound/midiparser.h	2011-02-02 23:22:45 UTC (rev 55745)
+++ scummvm/trunk/sound/midiparser.h	2011-02-02 23:27:59 UTC (rev 55746)
@@ -281,7 +281,7 @@
 	bool   _autoLoop;       ///< For lightweight clients that don't provide their own flow control.
 	bool   _smartJump;      ///< Support smart expiration of hanging notes when jumping
 	bool   _centerPitchWheelOnUnload;  ///< Center the pitch wheels when unloading a song
-
+	bool   _sendSustainOffOnNotesOff;   ///< Send a sustain off on a notes off event, stopping hanging notes
 	byte  *_tracks[120];    ///< Multi-track MIDI formats are supported, up to 120 tracks.
 	byte   _num_tracks;     ///< Count of total tracks for multi-track MIDI formats. 1 for single-track formats.
 	byte   _active_track;   ///< Keeps track of the currently active track, in multi-track formats.
@@ -361,7 +361,13 @@
 		 * Center the pitch wheels when unloading music in preparation
 		 * for the next piece of music.
 		 */
-		mpCenterPitchWheelOnUnload = 4
+		mpCenterPitchWheelOnUnload = 4,
+
+		/**
+		 * Sends a sustain off event when a notes off event is triggered.
+		 * Stops hanging notes.
+		 */
+		 mpSendSustainOffOnNotesOff = 5
 	};
 
 public:


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list