From 066ab75274b93f932df033a1578d25d7a190ffc5 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 29 Mar 2001 01:32:14 +0000 Subject: [PATCH] --- source/sound/sound.cpp | 70 +++++++++++++++++++++++++++++++++++------- source/sound/sound.h | 4 +++ 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/source/sound/sound.cpp b/source/sound/sound.cpp index 53d220cee..95de74b8a 100644 --- a/source/sound/sound.cpp +++ b/source/sound/sound.cpp @@ -82,7 +82,9 @@ int CSoundMediator::s_targetVolume[CSoundMediator::NUM_VOLUMETYPES]; int CSoundMediator::s_volumeDirty[CSoundMediator::NUM_VOLUMETYPES]; xmSampleId CSoundMediator::s_songSampleId=NO_SAMPLE; +FileEquate CSoundMediator::s_songVh=(FileEquate)-1; xmModId CSoundMediator::s_songModId=NO_SONG; +FileEquate CSoundMediator::s_songPxm=(FileEquate)-1; xmPlayingId CSoundMediator::s_songPlayingId=NOT_PLAYING; int CSoundMediator::s_songStartPattern=0; xmSampleId CSoundMediator::s_sfxSampleId=NO_SAMPLE; @@ -419,12 +421,30 @@ void CSoundMediator::setSong(SONGID _songId) { XMSONGDATA *song; - ASSERT(s_songSampleId==NO_SAMPLE); - ASSERT(s_songModId==NO_SONG); - song=&s_xmSongData[_songId]; - s_songModId=s_xmplaySound->loadModData(song->m_pxm); - s_songSampleId=s_xmplaySound->loadSampleData(song->m_vh,song->m_vb); + + if(s_songSampleId!=NO_SAMPLE&&s_songVh!=song->m_vh) + { + s_xmplaySound->dumpSampleData(s_songSampleId); + s_songSampleId=NO_SAMPLE; + } + if(s_songSampleId==NO_SAMPLE) + { + s_songSampleId=s_xmplaySound->loadSampleData(song->m_vh,song->m_vb); + } + s_songVh=song->m_vh; + + if(s_songModId!=NO_SONG&&s_songPxm!=song->m_pxm) + { + s_xmplaySound->dumpModData(s_songModId); + s_songModId=NO_SONG; + } + if(s_songModId==NO_SONG) + { + s_songModId=s_xmplaySound->loadModData(song->m_pxm); + } + s_songPxm=song->m_pxm; + s_songStartPattern=song->m_startPattern; } @@ -452,7 +472,7 @@ void CSoundMediator::playSong() Params: Returns: ---------------------------------------------------------------------- */ -void CSoundMediator::dumpSong() +void CSoundMediator::stopSong() { ASSERT(s_songSampleId!=NO_SAMPLE); ASSERT(s_songModId!=NO_SONG); @@ -462,15 +482,31 @@ void CSoundMediator::dumpSong() s_xmplaySound->stopPlayingId(s_songPlayingId); s_xmplaySound->unlockPlayingId(s_songPlayingId); } - s_xmplaySound->dumpSampleData(s_songSampleId); - s_xmplaySound->dumpModData(s_songModId); - - s_songSampleId=NO_SAMPLE; - s_songModId=NO_SONG; s_songPlayingId=NOT_PLAYING; } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSoundMediator::dumpSong() +{ + ASSERT(s_songSampleId!=NO_SAMPLE); + ASSERT(s_songModId!=NO_SONG); + + stopSong(); + s_xmplaySound->dumpSampleData(s_songSampleId); + s_songSampleId=NO_SAMPLE; + s_xmplaySound->dumpModData(s_songModId); + s_songModId=NO_SONG; + s_songVh=(FileEquate)-1; + s_songPxm=(FileEquate)-1; +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -567,6 +603,18 @@ void CSoundMediator::stopSfx(xmPlayingId _playingId) } +/*---------------------------------------------------------------------- + Function: + Purpose: NB: Will invalidate any locked sfx! + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSoundMediator::stopAllSfx() +{ + s_xmplaySound->stopAndUnlockAllSfx(); +} + + /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/sound/sound.h b/source/sound/sound.h index eef590c94..b1e0f1639 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -180,6 +180,7 @@ public: // Song interface static void setSong(SONGID _songId); static void playSong(); + static void stopSong(); static void dumpSong(); // SFX interface @@ -187,6 +188,7 @@ public: static xmPlayingId playSfx(SFXID _sfxId,int _lock=false); static void setposition(xmPlayingId _playingId,VECTOR *pos); static void stopSfx(xmPlayingId _playingId); + static void stopAllSfx(); // Speech interface static void playSpeech(SpeechEquate _speech); @@ -214,7 +216,9 @@ private: static int s_volumeDirty[NUM_VOLUMETYPES]; static xmSampleId s_songSampleId; + static FileEquate s_songVh; static xmModId s_songModId; + static FileEquate s_songPxm; static xmPlayingId s_songPlayingId; static int s_songStartPattern;