SCI: Set default MT-32 reverb before each sound

Set the default reverb configuration present in either the MT-32
patch data or MT32.DRV of SCI0 games before playing each sound, as
a previously played sound may have changed it.

Also, do not perform a general reverb init, since the start of a
sound will do that now.

Closes gh-1023.
This commit is contained in:
Ruud Klaver 2016-09-18 21:01:51 +02:00 committed by Colin Snover
parent cedd9d3c40
commit 6843870af2
3 changed files with 17 additions and 9 deletions

View File

@ -158,6 +158,7 @@ public:
int getFirstChannel() const;
int getLastChannel() const;
void setVolume(byte volume);
virtual void onNewSound() override;
int getVolume();
void setReverb(int8 reverb);
void playSwitch(bool play);
@ -204,6 +205,7 @@ private:
int _masterVolume;
byte _reverbConfig[kReverbConfigNr][3];
int8 _defaultReverb;
Channel _channels[16];
uint8 _percussionMap[128];
int8 _keyShift[128];
@ -220,7 +222,7 @@ private:
byte _sysExBuf[kMaxSysExSize];
};
MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _mt32Type(kMt32TypeNone), _hasReverb(false), _useMT32Track(true) {
MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _mt32Type(kMt32TypeNone), _hasReverb(false), _defaultReverb(-1), _useMT32Track(true) {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI);
_driver = MidiDriver::createMidi(dev);
@ -477,6 +479,14 @@ int MidiPlayer_Midi::getVolume() {
return _masterVolume;
}
void MidiPlayer_Midi::onNewSound() {
if (_defaultReverb >= 0)
// SCI0 in combination with MT-32 requires a reset of the reverb to
// the default value that is present in either the MT-32 patch data
// or MT32.DRV itself.
setReverb(_defaultReverb);
}
void MidiPlayer_Midi::setReverb(int8 reverb) {
assert(reverb < kReverbConfigNr);
@ -610,7 +620,7 @@ void MidiPlayer_Midi::readMt32Patch(const SciSpan<const byte> &data) {
setMt32Volume(volume);
// Reverb default only used in (roughly) SCI0/SCI01
byte reverb = stream.readByte();
_defaultReverb = stream.readSByte();
_hasReverb = true;
@ -649,10 +659,6 @@ void MidiPlayer_Midi::readMt32Patch(const SciSpan<const byte> &data) {
sendMt32SysEx(0x100004, stream, 9);
}
// Reverb for SCI0
if (_version <= SCI_VERSION_0_LATE)
setReverb(reverb);
// Send after-SysEx text
stream.seek(0);
sendMt32SysEx(0x200000, stream, 20);
@ -780,7 +786,7 @@ void MidiPlayer_Midi::readMt32DrvData() {
if (size == 2771) {
// MT32.DRV in LSL2 early contains more data, like a normal patch
byte reverb = f.readByte();
_defaultReverb = f.readByte();
_hasReverb = true;
@ -800,8 +806,6 @@ void MidiPlayer_Midi::readMt32DrvData() {
sendMt32SysEx(0x50000, f, 256);
sendMt32SysEx(0x50200, f, 128);
setReverb(reverb);
// Send the after-SysEx text
f.seek(0x3d);
sendMt32SysEx(0x200000, f, 20);

View File

@ -106,6 +106,8 @@ public:
return _driver ? _driver->property(MIDI_PROP_MASTER_VOLUME, 0xffff) : 0;
}
virtual void onNewSound() {}
// Returns the current reverb, or -1 when no reverb is active
int8 getReverb() const { return _reverb; }
// Sets the current reverb, used mainly in MT-32

View File

@ -392,6 +392,8 @@ void MidiParser_SCI::sendInitCommands() {
// Set initial voice count
if (_pSnd) {
if (_soundVersion <= SCI_VERSION_0_LATE) {
static_cast<MidiPlayer *>(_driver)->onNewSound();
for (int i = 0; i < 15; ++i) {
byte voiceCount = 0;
if (_channelUsed[i]) {