KYRA: (HOF) - fix bug #6314 (Wrong MIDI notes

sometimes heard at beginning of new s)

This is an attempt to fix that bug. It works for me, but it should see more testing.

I have tested the Windows "Microsoft GS Wavetable Synth" and our builtin MT-32 emulation. Both work fine with it. I presume the same will be true for all relevant hardware devices.

I haven't fully analyzed how the original driver silences the device (and I won't if I don't have to). My impression is that it does not send CC 0x78 (like I do). It seems to send only the CCs we have implemented (0x40, 0x60, 0x7B...). Maybe this whole bug is simply a race condition issue that the original didn't have...
This commit is contained in:
athrxx 2020-01-25 16:42:06 +01:00
parent f06e402f74
commit 70e62a757b
3 changed files with 14 additions and 1 deletions

View File

@ -352,4 +352,11 @@ void MidiOutput::stopNotesOnChannel(int channel) {
}
}
void MidiOutput::allSoundsOff() {
for (int i = 0; i < 16; ++i) {
stopNotesOnChannel(i);
sendIntern(0xB0, i, 0x78, 0);
}
}
} // End of namespace Kyra

View File

@ -37,6 +37,7 @@ public:
void initSource(int source);
void deinitSource(int source);
void stopNotesOnChannel(int channel);
void allSoundsOff();
void setSoundSource(int source) { _curSource = source; }

View File

@ -281,9 +281,14 @@ void SoundMidiPC::playTrack(uint8 track) {
haltTrack();
Common::StackLock lock(_mutex);
// The following two lines are meant as a fix for bug #6314.
// It is on purpose that they are outside the mutex lock.
_output->allSoundsOff();
_vm->delay(250);
Common::StackLock lock(_mutex);
_fadeMusicOut = false;
_output->setSourceVolume(0, _musicVolume, true);
_output->initSource(0);