SCI: Rename _bMultiMidi to _useDigitalSFX and only initialize it inside SoundCommandParser

This commit is contained in:
Filippos Karapetis 2011-12-28 13:07:14 +02:00
parent 6898ab9174
commit 7f088096cb
4 changed files with 18 additions and 17 deletions

View file

@ -37,8 +37,8 @@
namespace Sci { namespace Sci {
SciMusic::SciMusic(SciVersion soundVersion) SciMusic::SciMusic(SciVersion soundVersion, bool useDigitalSFX)
: _soundVersion(soundVersion), _soundOn(true), _masterVolume(0), _globalReverb(0) { : _soundVersion(soundVersion), _soundOn(true), _masterVolume(0), _globalReverb(0), _useDigitalSFX(useDigitalSFX) {
// Reserve some space in the playlist, to avoid expensive insertion // Reserve some space in the playlist, to avoid expensive insertion
// operations // operations
@ -110,8 +110,6 @@ void SciMusic::init() {
error("Failed to initialize sound driver"); error("Failed to initialize sound driver");
} }
_bMultiMidi = ConfMan.getBool("multi_midi");
// Find out what the first possible channel is (used, when doing channel // Find out what the first possible channel is (used, when doing channel
// remapping). // remapping).
_driverFirstChannel = _pMidiDrv->getFirstChannel(); _driverFirstChannel = _pMidiDrv->getFirstChannel();
@ -273,10 +271,10 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
SoundResource::Track *track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId()); SoundResource::Track *track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId());
// If MIDI device is selected but there is no digital track in sound // If MIDI device is selected but there is no digital track in sound
// resource try to use adlib's digital sample if possible. Also, if the // resource try to use Adlib's digital sample if possible. Also, if the
// track couldn't be found, load the digital track, as some games depend on // track couldn't be found, load the digital track, as some games depend on
// this (e.g. the Longbow demo). // this (e.g. the Longbow demo).
if (!track || (_bMultiMidi && track->digitalChannelNr == -1)) { if (!track || (_useDigitalSFX && track->digitalChannelNr == -1)) {
SoundResource::Track *digital = pSnd->soundRes->getDigitalTrack(); SoundResource::Track *digital = pSnd->soundRes->getDigitalTrack();
if (digital) if (digital)
track = digital; track = digital;

View file

@ -120,7 +120,7 @@ typedef Common::Array<uint32> MidiCommandQueue;
class SciMusic : public Common::Serializable { class SciMusic : public Common::Serializable {
public: public:
SciMusic(SciVersion soundVersion); SciMusic(SciVersion soundVersion, bool useDigitalSFX);
~SciMusic(); ~SciMusic();
void init(); void init();
@ -210,9 +210,8 @@ protected:
MidiPlayer *_pMidiDrv; MidiPlayer *_pMidiDrv;
uint32 _dwTempo; uint32 _dwTempo;
// Mixed AdLib/MIDI mode: when enabled from the ScummVM sound options screen, // If true and a sound has a digital track, the sound from the AdLib track is played
// and a sound has a digital track, the sound from the AdLib track is played bool _useDigitalSFX;
bool _bMultiMidi;
private: private:
MusicList _playList; MusicList _playList;

View file

@ -35,17 +35,19 @@ namespace Sci {
SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) : SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) :
_resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) { _resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) {
_music = new SciMusic(_soundVersion);
_music->init();
// Check if the user wants synthesized or digital sound effects in SCI1.1 // Check if the user wants synthesized or digital sound effects in SCI1.1
// or later games // or later games
_bMultiMidi = ConfMan.getBool("multi_midi"); _useDigitalSFX = ConfMan.getBool("multi_midi");
// In SCI2 and later games, this check should always be true - there was // In SCI2 and later games, this check should always be true - there was
// always only one version of each sound effect or digital music track // always only one version of each sound effect or digital music track
// (e.g. the menu music in GK1 - there is a sound effect with the same // (e.g. the menu music in GK1 - there is a sound effect with the same
// resource number, but it's totally unrelated to the menu music). // resource number, but it's totally unrelated to the menu music).
if (getSciVersion() >= SCI_VERSION_2) if (getSciVersion() >= SCI_VERSION_2)
_bMultiMidi = true; _useDigitalSFX = true;
_music = new SciMusic(_soundVersion, _useDigitalSFX);
_music->init();
} }
SoundCommandParser::~SoundCommandParser() { SoundCommandParser::~SoundCommandParser() {
@ -93,7 +95,7 @@ void SoundCommandParser::initSoundResource(MusicEntry *newSound) {
// Found a relevant audio resource, create an audio stream if there is // Found a relevant audio resource, create an audio stream if there is
// no associated sound resource, or if both resources exist and the // no associated sound resource, or if both resources exist and the
// user wants the digital version. // user wants the digital version.
if (_bMultiMidi || !newSound->soundRes) { if (_useDigitalSFX || !newSound->soundRes) {
int sampleLen; int sampleLen;
newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen); newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen);
newSound->soundType = Audio::Mixer::kSpeechSoundType; newSound->soundType = Audio::Mixer::kSpeechSoundType;
@ -485,7 +487,7 @@ void SoundCommandParser::processUpdateCues(reg_t obj) {
} else { } else {
// Slot actually has no data (which would mean that a sound-resource w/ // Slot actually has no data (which would mean that a sound-resource w/
// unsupported data is used. // unsupported data is used.
// (example lsl5 - sound resource 744 - it's roland exclusive // (example lsl5 - sound resource 744 - it's Roland exclusive
writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET); writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
// If we don't set signal here, at least the switch to the mud wrestling // If we don't set signal here, at least the switch to the mud wrestling
// room in lsl5 will not work. // room in lsl5 will not work.

View file

@ -111,7 +111,9 @@ private:
SciMusic *_music; SciMusic *_music;
AudioPlayer *_audio; AudioPlayer *_audio;
SciVersion _soundVersion; SciVersion _soundVersion;
bool _bMultiMidi; // If true and an alternative digital sound effect exists, the digital
// sound effect is preferred instead
bool _useDigitalSFX;
void processInitSound(reg_t obj); void processInitSound(reg_t obj);
void processDisposeSound(reg_t obj); void processDisposeSound(reg_t obj);