[Scummvm-git-logs] scummvm master -> c646bda078d1224738637553fb5dffd9875576d8

bluegr bluegr at gmail.com
Sun Feb 16 11:33:51 UTC 2020


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
65f85a232d SCI: Add support for Roland GS drumkits
b2468d9442 SCI/MIDI: GS drumkits - comments and re-usability
18acefa6d2 KYRA: Apply correction for invalid GS drumkits
3628986b6d KYRA: Add debug message for GS drumkits
c646bda078 KYRA: Add debug level to GS drumkit log message


Commit: 65f85a232dab4552d07225f2868e269e356fd6ae
    https://github.com/scummvm/scummvm/commit/65f85a232dab4552d07225f2868e269e356fd6ae
Author: NMIError (crampen at gmail.com)
Date: 2020-02-16T13:33:45+02:00

Commit Message:
SCI: Add support for Roland GS drumkits

This adds support for the Roland GS drumkits used by SQ5 and QfG3.
The original Sierra GM driver does not pass the drumkit select MIDI
messages to the GM device, but they do exist in the MIDI data.

Another issue is that the drumkit numbers used are incorrect. This
does work on the original Roland SC-55 devices because they correct
the drumkit numbers. Later devices do not do this. Code has been
added to correct these wrong drumkit numbers.

Changed paths:
    engines/sci/sound/drivers/midi.cpp


diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 1024e78..669911b 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -124,6 +124,26 @@ static const byte defaultSci32GMPatch[] = {
 };
 #endif
 
+static const uint8 gsDrumkitFallbackMap[] = {
+	 0,  0,  0,  0,  0,  0,  0,  0, // STANDARD
+	 8,  8,  8,  8,  8,  8,  8,  8, // ROOM
+	16, 16, 16, 16, 16, 16, 16, 16, // POWER
+	24, 25, 24, 24, 24, 24, 24, 24, // ELECTRONIC; TR-808 (25)
+	32, 32, 32, 32, 32, 32, 32, 32, // JAZZ
+	40, 40, 40, 40, 40, 40, 40, 40, // BRUSH
+	48, 48, 48, 48, 48, 48, 48, 48, // ORCHESTRA
+	56, 56, 56, 56, 56, 56, 56, 56, // SFX
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined (fall back to STANDARD)
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
+	 0,  0,  0,  0,  0,  0,  0, 127 // No drum kit defined; CM-64/32L (127)
+};
+
 Mt32ToGmMapList *Mt32dynamicMappings = NULL;
 
 class MidiPlayer_Midi : public MidiPlayer {
@@ -357,46 +377,53 @@ void MidiPlayer_Midi::setPatch(int channel, int patch) {
 
 	assert(channel <= 15);
 
-	if ((channel == MIDI_RHYTHM_CHANNEL) || (_channels[channel].patch == patch))
+	if ((this->_mt32Type != kMt32TypeNone && channel == MIDI_RHYTHM_CHANNEL) || (_channels[channel].patch == patch))
 		return;
 
-	_channels[channel].patch = patch;
-	_channels[channel].velocityMapIdx = _velocityMapIdx[patch];
+	int patchToSend;
+	if (channel != MIDI_RHYTHM_CHANNEL) {
+		_channels[channel].patch = patch;
+		_channels[channel].velocityMapIdx = _velocityMapIdx[patch];
 
-	if (_channels[channel].mappedPatch == MIDI_UNMAPPED)
-		resetVol = true;
+		if (_channels[channel].mappedPatch == MIDI_UNMAPPED)
+			resetVol = true;
 
-	_channels[channel].mappedPatch = _patchMap[patch];
+		_channels[channel].mappedPatch = patchToSend = _patchMap[patch];
 
-	if (_patchMap[patch] == MIDI_UNMAPPED) {
-		debugC(kDebugLevelSound, "[Midi] Channel %i set to unmapped patch %i", channel, patch);
-		_driver->send(0xb0 | channel, 0x7b, 0);
-		_driver->send(0xb0 | channel, 0x40, 0);
-		return;
-	}
+		if (_patchMap[patch] == MIDI_UNMAPPED) {
+			debugC(kDebugLevelSound, "[Midi] Channel %i set to unmapped patch %i", channel, patch);
+			_driver->send(0xb0 | channel, 0x7b, 0);
+			_driver->send(0xb0 | channel, 0x40, 0);
+			return;
+		}
 
-	if (_patchMap[patch] >= 128) {
-		// Mapped to rhythm, don't send channel commands
-		return;
-	}
+		if (_patchMap[patch] >= 128) {
+			// Mapped to rhythm, don't send channel commands
+			return;
+		}
 
-	if (_channels[channel].keyShift != _keyShift[patch]) {
-		_channels[channel].keyShift = _keyShift[patch];
-		_driver->send(0xb0 | channel, 0x7b, 0);
-		_driver->send(0xb0 | channel, 0x40, 0);
-		resetVol = true;
-	}
+		if (_channels[channel].keyShift != _keyShift[patch]) {
+			_channels[channel].keyShift = _keyShift[patch];
+			_driver->send(0xb0 | channel, 0x7b, 0);
+			_driver->send(0xb0 | channel, 0x40, 0);
+			resetVol = true;
+		}
 
-	if (resetVol || (_channels[channel].volAdjust != _volAdjust[patch])) {
-		_channels[channel].volAdjust = _volAdjust[patch];
-		controlChange(channel, 0x07, _channels[channel].volume);
-	}
+		if (resetVol || (_channels[channel].volAdjust != _volAdjust[patch])) {
+			_channels[channel].volAdjust = _volAdjust[patch];
+			controlChange(channel, 0x07, _channels[channel].volume);
+		}
 
-	uint8 bendRange = _pitchBendRange[patch];
-	if (bendRange != MIDI_UNMAPPED)
-		_driver->setPitchBendRange(channel, bendRange);
+		uint8 bendRange = _pitchBendRange[patch];
+		if (bendRange != MIDI_UNMAPPED)
+			_driver->setPitchBendRange(channel, bendRange);
+	} else {
+		// Apply drumkit fallback to correct invalid drumkit numbers
+		patchToSend = gsDrumkitFallbackMap[patch];
+		_channels[channel].patch = patchToSend;
+	}
 
-	_driver->send(0xc0 | channel, _patchMap[patch], 0);
+	_driver->send(0xc0 | channel, patchToSend, 0);
 
 	// Send a pointless command to work around a firmware bug in common
 	// USB-MIDI cables. If the first MIDI command in a USB packet is a


Commit: b2468d9442cdbef8190cb014cf2934aaa3a84666
    https://github.com/scummvm/scummvm/commit/b2468d9442cdbef8190cb014cf2934aaa3a84666
Author: NMIError (crampen at gmail.com)
Date: 2020-02-16T13:33:45+02:00

Commit Message:
SCI/MIDI: GS drumkits - comments and re-usability

- Move the GS drumkit fallback map to generic audio code for re-use
- Added comments and debug message

Changed paths:
    audio/mididrv.cpp
    audio/mididrv.h
    engines/sci/sound/drivers/midi.cpp


diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index 2b7463e..d75c098 100644
--- a/audio/mididrv.cpp
+++ b/audio/mididrv.cpp
@@ -56,6 +56,29 @@ const byte MidiDriver::_gmToMt32[128] = {
 	101, 103, 100, 120, 117, 113,  99, 128, 128, 128, 128, 124, 123, 128, 128, 128, // 7x
 };
 
+// This is the drum map for the Roland Sound Canvas SC-55 v1.xx. It had a fallback mechanism 
+// to correct invalid drumkit selections. Some games rely on this mechanism to select the 
+// correct Roland GS drumkit. Use this map to emulate this mechanism.
+// E.g. correct invalid drumkit 50: _gsDrumkitFallbackMap[50] == 48
+const uint8 MidiDriver::_gsDrumkitFallbackMap[128] = {
+	 0,  0,  0,  0,  0,  0,  0,  0, // STANDARD
+	 8,  8,  8,  8,  8,  8,  8,  8, // ROOM
+	16, 16, 16, 16, 16, 16, 16, 16, // POWER
+	24, 25, 24, 24, 24, 24, 24, 24, // ELECTRONIC; TR-808 (25)
+	32, 32, 32, 32, 32, 32, 32, 32, // JAZZ
+	40, 40, 40, 40, 40, 40, 40, 40, // BRUSH
+	48, 48, 48, 48, 48, 48, 48, 48, // ORCHESTRA
+	56, 56, 56, 56, 56, 56, 56, 56, // SFX
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined (fall back to STANDARD)
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0,  0, // No drumkit defined
+	 0,  0,  0,  0,  0,  0,  0, 127 // No drumkit defined; CM-64/32L (127)
+};
+
 static const struct {
 	uint32      type;
 	const char *guio;
diff --git a/audio/mididrv.h b/audio/mididrv.h
index 7fffb99..3b4c124 100644
--- a/audio/mididrv.h
+++ b/audio/mididrv.h
@@ -179,6 +179,8 @@ public:
 
 	static const byte _mt32ToGm[128];
 	static const byte _gmToMt32[128];
+	// Map for correcting Roland GS drumkit numbers.
+	static const uint8 _gsDrumkitFallbackMap[128];
 
 	/**
 	 * Error codes returned by open.
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 669911b..7c90adb 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -124,26 +124,6 @@ static const byte defaultSci32GMPatch[] = {
 };
 #endif
 
-static const uint8 gsDrumkitFallbackMap[] = {
-	 0,  0,  0,  0,  0,  0,  0,  0, // STANDARD
-	 8,  8,  8,  8,  8,  8,  8,  8, // ROOM
-	16, 16, 16, 16, 16, 16, 16, 16, // POWER
-	24, 25, 24, 24, 24, 24, 24, 24, // ELECTRONIC; TR-808 (25)
-	32, 32, 32, 32, 32, 32, 32, 32, // JAZZ
-	40, 40, 40, 40, 40, 40, 40, 40, // BRUSH
-	48, 48, 48, 48, 48, 48, 48, 48, // ORCHESTRA
-	56, 56, 56, 56, 56, 56, 56, 56, // SFX
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined (fall back to STANDARD)
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0,  0, // No drum kit defined
-	 0,  0,  0,  0,  0,  0,  0, 127 // No drum kit defined; CM-64/32L (127)
-};
-
 Mt32ToGmMapList *Mt32dynamicMappings = NULL;
 
 class MidiPlayer_Midi : public MidiPlayer {
@@ -377,7 +357,9 @@ void MidiPlayer_Midi::setPatch(int channel, int patch) {
 
 	assert(channel <= 15);
 
-	if ((this->_mt32Type != kMt32TypeNone && channel == MIDI_RHYTHM_CHANNEL) || (_channels[channel].patch == patch))
+	// No need to do anything if a patch change is sent on the rhythm channel of an MT-32
+	// or if the requested patch is the same as the current patch.
+	if ((_mt32Type != kMt32TypeNone && channel == MIDI_RHYTHM_CHANNEL) || (_channels[channel].patch == patch))
 		return;
 
 	int patchToSend;
@@ -418,9 +400,13 @@ void MidiPlayer_Midi::setPatch(int channel, int patch) {
 		if (bendRange != MIDI_UNMAPPED)
 			_driver->setPitchBendRange(channel, bendRange);
 	} else {
-		// Apply drumkit fallback to correct invalid drumkit numbers
-		patchToSend = gsDrumkitFallbackMap[patch];
+		// A patch change on the rhythm channel of a Roland GS device indicates a drumkit change.
+		// Some GM devices support the GS drumkits as well.
+
+		// Apply drumkit fallback to correct invalid drumkit numbers.
+		patchToSend = patch < 128 ? _driver->_gsDrumkitFallbackMap[patch] : 0;
 		_channels[channel].patch = patchToSend;
+		debugC(kDebugLevelSound, "[Midi] Selected drumkit %i (requested %i)", patchToSend, patch);
 	}
 
 	_driver->send(0xc0 | channel, patchToSend, 0);


Commit: 18acefa6d217010b3d11c9bca748dea370dd94ed
    https://github.com/scummvm/scummvm/commit/18acefa6d217010b3d11c9bca748dea370dd94ed
Author: NMIError (crampen at gmail.com)
Date: 2020-02-16T13:33:45+02:00

Commit Message:
KYRA: Apply correction for invalid GS drumkits

Lands of Lore sends several drumkit changes to Roland GS
devices with incorrect drumkit numbers. This would work
on some earlier devices like the SC-55, because they correct
these invalid selections. This change emulates the
corrections of the SC-55, so that the drumkit changes will
work on later Roland GS devices.

Changed paths:
    engines/kyra/sound/drivers/midi.cpp


diff --git a/engines/kyra/sound/drivers/midi.cpp b/engines/kyra/sound/drivers/midi.cpp
index 2ca1844..9df750b 100644
--- a/engines/kyra/sound/drivers/midi.cpp
+++ b/engines/kyra/sound/drivers/midi.cpp
@@ -178,6 +178,11 @@ void MidiOutput::sendIntern(const byte event, const byte channel, byte param1, c
 		// MT32 -> GM conversion
 		if (!_isMT32 && _defaultMT32)
 			param1 = MidiDriver::_mt32ToGm[param1];
+		// Program change on rhythm channel (drumkit selection)
+		else if (!_isMT32 && channel == 0x09) {
+			// Apply GS drumkit fallback to correct invalid drumkit numbers.
+			param1 = MidiDriver::_gsDrumkitFallbackMap[param1];
+		}
 	}
 
 	_output->send(event | channel, param1, param2);


Commit: 3628986b6df817a87da389251e93d64ea7596ec1
    https://github.com/scummvm/scummvm/commit/3628986b6df817a87da389251e93d64ea7596ec1
Author: NMIError (crampen at gmail.com)
Date: 2020-02-16T13:33:45+02:00

Commit Message:
KYRA: Add debug message for GS drumkits

Changed paths:
    engines/kyra/sound/drivers/midi.cpp


diff --git a/engines/kyra/sound/drivers/midi.cpp b/engines/kyra/sound/drivers/midi.cpp
index 9df750b..98d4250 100644
--- a/engines/kyra/sound/drivers/midi.cpp
+++ b/engines/kyra/sound/drivers/midi.cpp
@@ -174,18 +174,20 @@ void MidiOutput::send(uint32 b) {
 }
 
 void MidiOutput::sendIntern(const byte event, const byte channel, byte param1, const byte param2) {
+	byte param1ToSend = param1;
 	if (event == 0xC0) {
 		// MT32 -> GM conversion
 		if (!_isMT32 && _defaultMT32)
-			param1 = MidiDriver::_mt32ToGm[param1];
+			param1ToSend = MidiDriver::_mt32ToGm[param1];
 		// Program change on rhythm channel (drumkit selection)
 		else if (!_isMT32 && channel == 0x09) {
 			// Apply GS drumkit fallback to correct invalid drumkit numbers.
-			param1 = MidiDriver::_gsDrumkitFallbackMap[param1];
+			param1ToSend = MidiDriver::_gsDrumkitFallbackMap[param1];
+			debugC(kDebugLevelSound, "[Midi] Selected drumkit %i (requested %i)", param1ToSend, param1);
 		}
 	}
 
-	_output->send(event | channel, param1, param2);
+	_output->send(event | channel, param1ToSend, param2);
 }
 
 void MidiOutput::sysEx(const byte *msg, uint16 length) {


Commit: c646bda078d1224738637553fb5dffd9875576d8
    https://github.com/scummvm/scummvm/commit/c646bda078d1224738637553fb5dffd9875576d8
Author: NMIError (crampen at gmail.com)
Date: 2020-02-16T13:33:45+02:00

Commit Message:
KYRA: Add debug level to GS drumkit log message

Changed paths:
    engines/kyra/sound/drivers/midi.cpp


diff --git a/engines/kyra/sound/drivers/midi.cpp b/engines/kyra/sound/drivers/midi.cpp
index 98d4250..ad0ebe5 100644
--- a/engines/kyra/sound/drivers/midi.cpp
+++ b/engines/kyra/sound/drivers/midi.cpp
@@ -183,7 +183,7 @@ void MidiOutput::sendIntern(const byte event, const byte channel, byte param1, c
 		else if (!_isMT32 && channel == 0x09) {
 			// Apply GS drumkit fallback to correct invalid drumkit numbers.
 			param1ToSend = MidiDriver::_gsDrumkitFallbackMap[param1];
-			debugC(kDebugLevelSound, "[Midi] Selected drumkit %i (requested %i)", param1ToSend, param1);
+			debugC(7, kDebugLevelSound, "[Midi] Selected drumkit %i (requested %i)", param1ToSend, param1);
 		}
 	}
 




More information about the Scummvm-git-logs mailing list