diff options
Diffstat (limited to 'engines/sci/sound/music.cpp')
-rw-r--r-- | engines/sci/sound/music.cpp | 85 |
1 files changed, 71 insertions, 14 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index dca73c3f51..487d30e840 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -73,7 +73,7 @@ void SciMusic::init() { // Default to MIDI in SCI2.1+ games, as many don't have AdLib support. // Also, default to MIDI for Windows versions of SCI1.1 games, as their // soundtrack is written for GM. - if (getSciVersion() >= SCI_VERSION_2_1 || g_sci->_features->useAltWinGMSound()) + if (getSciVersion() >= SCI_VERSION_2_1_EARLY || g_sci->_features->useAltWinGMSound()) deviceFlags |= MDT_PREFER_GM; // Currently our CMS implementation only supports SCI1(.1) @@ -131,6 +131,12 @@ void SciMusic::init() { // HACK: The Fun Seeker's Guide demo doesn't have patch 3 and the version // of the Adlib driver (adl.drv) that it includes is unsupported. That demo // doesn't have any sound anyway, so this shouldn't be fatal. + } else if (g_sci->getGameId() == GID_MOTHERGOOSEHIRES) { + // HACK: Mixed-Up Mother Goose Deluxe does not seem to use synthesized music, + // so just set a default tempo (for fading) + // TODO: Review this + _dwTempo = 1000000 / 250; + warning("Temporary music hack for MUMG Deluxe"); } else { error("Failed to initialize sound driver"); } @@ -206,6 +212,13 @@ void SciMusic::clearPlayList() { void SciMusic::pauseAll(bool pause) { const MusicList::iterator end = _playList.end(); for (MusicList::iterator i = _playList.begin(); i != end; ++i) { +#ifdef ENABLE_SCI32 + // The entire DAC will have been paused by the caller; + // do not pause the individual samples too + if (_soundVersion >= SCI_VERSION_2_1_EARLY && (*i)->isSample) { + continue; + } +#endif soundToggle(*i, pause); } } @@ -341,12 +354,14 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) { pSnd->pStreamAud = Audio::makeRawStream(channelData + track->digitalSampleStart, track->digitalSampleSize - track->digitalSampleStart - endPart, track->digitalSampleRate, flags, DisposeAfterUse::NO); + assert(pSnd->pStreamAud); delete pSnd->pLoopStream; pSnd->pLoopStream = 0; pSnd->soundType = Audio::Mixer::kSFXSoundType; pSnd->hCurrentAud = Audio::SoundHandle(); pSnd->playBed = false; pSnd->overridePriority = false; + pSnd->isSample = true; } else { // play MIDI track Common::StackLock lock(_mutex); @@ -466,7 +481,16 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { } } - if (pSnd->pStreamAud) { + if (pSnd->isSample) { +#ifdef ENABLE_SCI32 + if (_soundVersion >= SCI_VERSION_2_1_EARLY) { + g_sci->_audio32->stop(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj); + + g_sci->_audio32->play(kNoExistingChannel, ResourceId(kResourceTypeAudio, pSnd->resourceId), true, pSnd->loop != 0 && pSnd->loop != 1, pSnd->volume, pSnd->soundObj, false); + + return; + } else +#endif if (!_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) { if ((_currentlyPlayingSample) && (_pMixer->isSoundHandleActive(_currentlyPlayingSample->hCurrentAud))) { // Another sample is already playing, we have to stop that one @@ -544,10 +568,18 @@ void SciMusic::soundStop(MusicEntry *pSnd) { pSnd->status = kSoundStopped; if (_soundVersion <= SCI_VERSION_0_LATE) pSnd->isQueued = false; - if (pSnd->pStreamAud) { - if (_currentlyPlayingSample == pSnd) - _currentlyPlayingSample = NULL; - _pMixer->stopHandle(pSnd->hCurrentAud); + if (pSnd->isSample) { +#ifdef ENABLE_SCI32 + if (_soundVersion >= SCI_VERSION_2_1_EARLY) { + g_sci->_audio32->stop(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj); + } else { +#endif + if (_currentlyPlayingSample == pSnd) + _currentlyPlayingSample = NULL; + _pMixer->stopHandle(pSnd->hCurrentAud); +#ifdef ENABLE_SCI32 + } +#endif } if (pSnd->pMidiParser) { @@ -566,9 +598,12 @@ void SciMusic::soundStop(MusicEntry *pSnd) { void SciMusic::soundSetVolume(MusicEntry *pSnd, byte volume) { assert(volume <= MUSIC_VOLUME_MAX); - if (pSnd->pStreamAud) { - // we simply ignore volume changes for samples, because sierra sci also - // doesn't support volume for samples via kDoSound + if (pSnd->isSample) { +#ifdef ENABLE_SCI32 + if (_soundVersion >= SCI_VERSION_2_1_EARLY) { + g_sci->_audio32->setVolume(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj, volume); + } +#endif } else if (pSnd->pMidiParser) { Common::StackLock lock(_mutex); pSnd->pMidiParser->mainThreadBegin(); @@ -608,16 +643,25 @@ void SciMusic::soundKill(MusicEntry *pSnd) { _mutex.unlock(); - if (pSnd->pStreamAud) { - if (_currentlyPlayingSample == pSnd) { - // Forget about this sound, in case it was currently playing - _currentlyPlayingSample = NULL; + if (pSnd->isSample) { +#ifdef ENABLE_SCI32 + if (_soundVersion >= SCI_VERSION_2_1_EARLY) { + g_sci->_audio32->stop(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj); + } else { +#endif + if (_currentlyPlayingSample == pSnd) { + // Forget about this sound, in case it was currently playing + _currentlyPlayingSample = NULL; + } + _pMixer->stopHandle(pSnd->hCurrentAud); +#ifdef ENABLE_SCI32 } - _pMixer->stopHandle(pSnd->hCurrentAud); +#endif delete pSnd->pStreamAud; pSnd->pStreamAud = NULL; delete pSnd->pLoopStream; pSnd->pLoopStream = 0; + pSnd->isSample = false; } _mutex.lock(); @@ -679,6 +723,18 @@ void SciMusic::soundResume(MusicEntry *pSnd) { } void SciMusic::soundToggle(MusicEntry *pSnd, bool pause) { +#ifdef ENABLE_SCI32 + if (_soundVersion >= SCI_VERSION_2_1_EARLY && pSnd->isSample) { + if (pause) { + g_sci->_audio32->pause(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj); + } else { + g_sci->_audio32->resume(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj); + } + + return; + } +#endif + if (pause) soundPause(pSnd); else @@ -807,6 +863,7 @@ MusicEntry::MusicEntry() { pStreamAud = 0; pLoopStream = 0; pMidiParser = 0; + isSample = false; for (int i = 0; i < 16; ++i) { _usedChannels[i] = 0xFF; |