[Scummvm-git-logs] scummvm master -> 974c51b4cd1e8154eb3a98f90b0641566f8aed3f
bluegr
noreply at scummvm.org
Sun Jun 5 06:11:02 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8eba7fb4fb SCI: fix bug no. 13496 (LSL6 music plays all instruments / tracks at â¦
974c51b4cd SCI: improve sound (mute handling) related comments
Commit: 8eba7fb4fbb7c84ec2831a605afb38cc0bb7ab3f
https://github.com/scummvm/scummvm/commit/8eba7fb4fbb7c84ec2831a605afb38cc0bb7ab3f
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T09:10:59+03:00
Commit Message:
SCI: fix bug no. 13496 (LSL6 music plays all instruments / tracks at â¦
â¦once)
I am not sure if this bug ticket is about just one or about several bugs. This is at least something I could reproduce. The reason is that there can be channels that should start up muted. We didn't support that. I also fixed a couple of other things about the mute state that I noticed.
Changed paths:
engines/sci/sound/midiparser_sci.cpp
engines/sci/sound/midiparser_sci.h
engines/sci/sound/music.cpp
engines/sci/sound/music.h
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index 3dc158009a9..46d7cacf8f0 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -87,7 +87,6 @@ bool MidiParser_SCI::loadMusic(SoundResource::Track *track, MusicEntry *psnd, in
for (int i = 0; i < 16; i++) {
_channelUsed[i] = false;
- _channelMuted[i] = false;
_channelVolume[i] = 127;
if (_soundVersion <= SCI_VERSION_0_LATE)
@@ -433,7 +432,6 @@ void MidiParser_SCI::sendInitCommands() {
sendToDriver(0xB0 | i, 0x07, 127); // Reset volume to maximum
sendToDriver(0xB0 | i, 0x0A, 64); // Reset panning to center
sendToDriver(0xB0 | i, 0x40, 0); // Reset hold pedal to none
- sendToDriver(0xB0 | i, 0x4E, 0); // Reset velocity to none
sendToDriver(0xE0 | i, 0, 64); // Reset pitch wheel to center
}
}
@@ -462,9 +460,31 @@ void MidiParser_SCI::sendFromScriptToDriver(uint32 midi) {
if (!_channelUsed[midiChannel]) {
// trying to send to an unused channel
- // this happens for cmdSendMidi at least in sq1vga right at the start, it's a script issue
+ // this happens for cmdSendMidi at least in sq1vga right at the start, it's a script issue
return;
}
+
+ if ((midi & 0xFFF0) == 0x4EB0 && _soundVersion > SCI_VERSION_1_EARLY) {
+ // This can't be sent into our trackState() method, since that method would handle
+ // the _mute setting differently than what we do here...
+ byte channel = midi & 0xf;
+ bool op = (midi >> 16) & 0x7f;
+ uint8 m = _pSnd->_chan[channel]._mute;
+
+ if (op && _pSnd->_chan[channel]._mute < 0xF0)
+ _pSnd->_chan[channel]._mute += 0x10;
+ else if (!op && _pSnd->_chan[channel]._mute >= 0x10)
+ _pSnd->_chan[channel]._mute -= 0x10;
+
+ if (_pSnd->_chan[channel]._mute != m) {
+ // CHECKME: Should we directly call remapChannels() if _mainThreadCalled?
+ _music->needsRemap();
+ debugC(2, kDebugLevelSound, "Dynamic mute change (arg = %d, mainThread = %d)", m, _mainThreadCalled);
+ }
+
+ return;
+ }
+
sendToDriver(midi);
}
@@ -558,7 +578,7 @@ void MidiParser_SCI::trackState(uint32 b) {
// (It's velocity control for sci0, but we don't need state in sci0)
if (_soundVersion > SCI_VERSION_1_EARLY) {
// FIXME: mute is a level, not a bool, in some SCI versions
- bool m = op2;
+ uint8 m = (_pSnd->_chan[channel]._mute & 0xf0) | (op2 & 1);
if (_pSnd->_chan[channel]._mute != m) {
_pSnd->_chan[channel]._mute = m;
// CHECKME: Should we directly call remapChannels() if _mainThreadCalled?
diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h
index 5084e09446c..12b21814803 100644
--- a/engines/sci/sound/midiparser_sci.h
+++ b/engines/sci/sound/midiparser_sci.h
@@ -114,7 +114,6 @@ protected:
bool _channelUsed[16];
int16 _channelRemap[16];
- bool _channelMuted[16];
byte _channelVolume[16];
struct ChannelState {
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index d62afe79473..5dfbb3b79c4 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -504,6 +504,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
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;
// CHECKME: Some SCI versions use chan.flags & 1 for this:
pSnd->_chan[chan.number]._dontMap = false;
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h
index 68e11eddff9..3e32bc7bad8 100644
--- a/engines/sci/sound/music.h
+++ b/engines/sci/sound/music.h
@@ -65,7 +65,7 @@ struct MusicEntryChannel {
int8 _voices;
bool _dontRemap;
bool _dontMap;
- bool _mute;
+ uint8 _mute;
};
Commit: 974c51b4cd1e8154eb3a98f90b0641566f8aed3f
https://github.com/scummvm/scummvm/commit/974c51b4cd1e8154eb3a98f90b0641566f8aed3f
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T09:10:59+03:00
Commit Message:
SCI: improve sound (mute handling) related comments
Changed paths:
engines/sci/sound/midiparser_sci.cpp
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index 46d7cacf8f0..a1f900b97a6 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -465,8 +465,11 @@ void MidiParser_SCI::sendFromScriptToDriver(uint32 midi) {
}
if ((midi & 0xFFF0) == 0x4EB0 && _soundVersion > SCI_VERSION_1_EARLY) {
- // This can't be sent into our trackState() method, since that method would handle
- // the _mute setting differently than what we do here...
+ // We have to handle this here instead of inside the trackState() method (which handles the input from
+ // the actual midi data). The mute command when sent from the script is independent from the mute
+ // command sent by the actual midi data. The script mute is stacked on the high nibble, while the midi
+ // data mute is stored on the low nibble. So the script cannot undo a mute set by the midi data and vice
+ // versa.
byte channel = midi & 0xf;
bool op = (midi >> 16) & 0x7f;
uint8 m = _pSnd->_chan[channel]._mute;
@@ -493,8 +496,7 @@ void MidiParser_SCI::sendToDriver(uint32 midi) {
trackState(midi);
if ((midi & 0xFFF0) == 0x4EB0 && _soundVersion >= SCI_VERSION_1_EARLY) {
- // Mute. Handled in trackState().
- // CHECKME: Should we send this on to the driver?
+ // Mute. Handled in trackState()/sendFromScriptToDriver().
return;
}
@@ -577,7 +579,9 @@ void MidiParser_SCI::trackState(uint32 b) {
// This is channel mute only for sci1.
// (It's velocity control for sci0, but we don't need state in sci0)
if (_soundVersion > SCI_VERSION_1_EARLY) {
- // FIXME: mute is a level, not a bool, in some SCI versions
+ // This is handled slightly differently than what we do in sendFromScriptToDriver(). The script mute is stacked
+ // on the high nibble, while the midi data mute (this one here) is stored on the low nibble. So the script cannot
+ // undo a mute set by the midi data and vice versa.
uint8 m = (_pSnd->_chan[channel]._mute & 0xf0) | (op2 & 1);
if (_pSnd->_chan[channel]._mute != m) {
_pSnd->_chan[channel]._mute = m;
More information about the Scummvm-git-logs
mailing list