From c969090ef873ca8884908a1f30d2e37397905bd8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 18 Aug 2010 20:00:18 +0000 Subject: SCI: Only perform queuing of song signals for SCI0, where we handle the updating of song queues ourselves. Newer games handle signaling on their own, thus we shouldn't interfere with this. Fixes bug #3045913 - "PHARKAS CD: Crash at the start menu" (a regression from rev #52043) svn-id: r52195 --- engines/sci/sound/midiparser_sci.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'engines/sci/sound/midiparser_sci.cpp') diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 769df73365..598b394887 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -445,12 +445,8 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { } if (_signalSet) { _signalSet = false; - if (!_pSnd->signal) { - _pSnd->signal = _signalToSet; - } else { - // signal already set and waiting for getting to scripts, queue new one - _pSnd->signalQueue.push_back(_signalToSet); - } + _pSnd->setSignal(_signalToSet); + debugC(4, kDebugLevelSound, "signal %04x", _signalToSet); } @@ -613,12 +609,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { jumpToTick(_loopTick); } else { _pSnd->status = kSoundStopped; - if (!_pSnd->signal) { - _pSnd->signal = SIGNAL_OFFSET; - } else { - // signal already set and waiting for getting to scripts, queue new one - _pSnd->signalQueue.push_back(SIGNAL_OFFSET); - } + _pSnd->setSignal(SIGNAL_OFFSET); debugC(4, kDebugLevelSound, "signal EOT"); } -- cgit v1.2.3 From 64313cd7f10267c29d7e3b963c7bd0ff2e1c7f1a Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 1 Sep 2010 19:20:17 +0000 Subject: SCI: set master volume correctly and merge it together with global volume, fixes bug #3053104) svn-id: r52484 --- engines/sci/sound/midiparser_sci.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'engines/sci/sound/midiparser_sci.cpp') diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 598b394887..d53f919f8f 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -53,6 +53,7 @@ MidiParser_SCI::MidiParser_SCI(SciVersion soundVersion, SciMusic *music) : _ppqn = 1; setTempo(16667); + _masterVolume = 15; _volume = 127; _signalSet = false; @@ -418,7 +419,7 @@ void MidiParser_SCI::sendToDriver(uint32 midi) { int channelVolume = (midi >> 16) & 0xFF; // Remember, if we need to set it ourselves _channelVolume[midiChannel] = channelVolume; - // Adjust volume accordingly to current "global" volume + // Adjust volume accordingly to current local volume channelVolume = channelVolume * _volume / 127; midi = (midi & 0xFFF0) | ((channelVolume & 0xFF) << 16); } @@ -659,6 +660,28 @@ void MidiParser_SCI::allNotesOff() { memset(_active_notes, 0, sizeof(_active_notes)); } +void MidiParser_SCI::setMasterVolume(byte masterVolume) { + assert(masterVolume <= MUSIC_MASTERVOLUME_MAX); + _masterVolume = masterVolume; + switch (_soundVersion) { + case SCI_VERSION_0_EARLY: + case SCI_VERSION_0_LATE: + // update driver master volume + setVolume(_volume); + break; + + case SCI_VERSION_1_EARLY: + case SCI_VERSION_1_LATE: + case SCI_VERSION_2_1: + // directly set master volume (global volume is merged with channel volumes) + ((MidiPlayer *)_driver)->setVolume(masterVolume); + break; + + default: + error("MidiParser_SCI::setVolume: Unsupported soundVersion"); + } +} + void MidiParser_SCI::setVolume(byte volume) { assert(volume <= MUSIC_VOLUME_MAX); _volume = volume; @@ -667,8 +690,7 @@ void MidiParser_SCI::setVolume(byte volume) { case SCI_VERSION_0_EARLY: case SCI_VERSION_0_LATE: { // SCI0 adlib driver doesn't support channel volumes, so we need to go this way - // TODO: this should take the actual master volume into account - int16 globalVolume = _volume * 15 / 127; + int16 globalVolume = _volume * _masterVolume / MUSIC_VOLUME_MAX; ((MidiPlayer *)_driver)->setVolume(globalVolume); break; } -- cgit v1.2.3