[Scummvm-git-logs] scummvm master -> 4a659580e9c9a1c48ad874fdff037b532a31a1e8

sluicebox noreply at scummvm.org
Sun Apr 9 05:46:49 UTC 2023


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

Summary:
4a659580e9 SCI: Fix pSnd->_chan[i] handling in SciMusic::soundInitSnd


Commit: 4a659580e9c9a1c48ad874fdff037b532a31a1e8
    https://github.com/scummvm/scummvm/commit/4a659580e9c9a1c48ad874fdff037b532a31a1e8
Author: Scott Percival (code at moral.net.au)
Date: 2023-04-08T22:46:45-07:00

Commit Message:
SCI: Fix pSnd->_chan[i] handling in SciMusic::soundInitSnd

It is possible in SCI to have a MIDI track which defines _dontRemap twice
for the same channel. _dontRemap is needed for devices like the Roland
MT-32, where percussion sounds are only available on MIDI channel 10.
As such, we must assume that any use of _dontRemap in successsion is
legitimate, not just the final use.

athrxx checked the LSL6 disassembly and confirmed that all of the flags
follow this rule. In addition, we need to initialize the flags before use.

Fixes the percussion track on various bits of music in pq1sci when
played back on the MT-32 (e.g. the musical transition after handing
the ticket to the woman, followed by the music when driving in the car).
Also fixes some volume fade outs between driving and parking.

Changed paths:
    engines/sci/sound/music.cpp


diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 95526cce9e8..ce1ac0282b4 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -495,8 +495,14 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
 			// Find out what channels to filter for SCI0
 			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayId(), _pMidiDrv->hasRhythmChannel());
 
-			for (int i = 0; i < 16; ++i)
+			for (int i = 0; i < 16; ++i) {
 				pSnd->_usedChannels[i] = 0xFF;
+				pSnd->_chan[i]._dontMap = false;
+				pSnd->_chan[i]._dontRemap = false;
+				pSnd->_chan[i]._prio = -1;
+				pSnd->_chan[i]._voices = -1;
+				pSnd->_chan[i]._mute = 0;
+			}
 			for (int i = 0; i < track->channelCount; ++i) {
 				// skip digital channel
 				if (i == track->digitalChannelNr) {
@@ -513,11 +519,19 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
 				// independent of the channel mapping.
 				// For more info on the flags see the comment in
 				// SoundResource::SoundResource().
-				pSnd->_chan[chan.number]._dontMap = (chan.flags & 1);
-				pSnd->_chan[chan.number]._dontRemap = (chan.flags & 2);
-				pSnd->_chan[chan.number]._prio = chan.prio;
-				pSnd->_chan[chan.number]._voices = chan.poly;
-				pSnd->_chan[chan.number]._mute = (chan.flags & 4) ? 1 : 0;
+				pSnd->_chan[chan.number]._dontMap |= (bool)(chan.flags & 1);
+				// Flag 2 prevents the channel number from being remapped
+				// to a different free channel on the MIDI device.
+				// It's possible for a MIDI track to define the same channel
+				// multiple times with different values for dontRemap.
+				// This can be a problem if it is a dedicated percussion
+				// channel, so always err on the side of caution.
+				pSnd->_chan[chan.number]._dontRemap |= (bool)(chan.flags & 2);
+				if (pSnd->_chan[chan.number]._prio == -1)
+					pSnd->_chan[chan.number]._prio = chan.prio;
+				if (pSnd->_chan[chan.number]._voices == -1)
+					pSnd->_chan[chan.number]._voices = chan.poly;
+				pSnd->_chan[chan.number]._mute |= ((chan.flags & 4) ? 1 : 0);
 				// FIXME: Most MIDI tracks use the first 10 bytes for
 				// fixed MIDI commands. SSCI skips those the first iteration,
 				// but _does_ update channel state (including volume) with




More information about the Scummvm-git-logs mailing list