diff --git a/source/frontend/frontend.cpp b/source/frontend/frontend.cpp index 5449ad59b..d4707cf68 100644 --- a/source/frontend/frontend.cpp +++ b/source/frontend/frontend.cpp @@ -54,6 +54,10 @@ #include "locale\textdbase.h" #endif +#ifndef __SOUND_SOUND_H__ +#include "sound\sound.h" +#endif + /* Std Lib ------- */ @@ -135,6 +139,9 @@ void CFrontEndScene::init() m_font=new ("frontendfont") FontBank(); m_font->initialise(&standardFont); m_font->setJustification(FontBank::JUST_CENTRE); + + CSoundMediator::setSong(CSoundMediator::SONG_TITLE); + CSoundMediator::playSong(); } @@ -153,6 +160,8 @@ void CFrontEndScene::shutdown() { s_modeCodes[i]->shutdown(); } + + CSoundMediator::dumpSong(); } diff --git a/source/frontend/options.cpp b/source/frontend/options.cpp index 1570441c6..e118f36ff 100644 --- a/source/frontend/options.cpp +++ b/source/frontend/options.cpp @@ -286,9 +286,9 @@ void CFrontEndOptions::init() &m_nextMode,MODE__OPTIONS); } - m_bgmVolume=CSoundMediator::getVolume(CSoundMediator::SONG); - m_sfxVolume=CSoundMediator::getVolume(CSoundMediator::SFX); - m_speechVolume=CSoundMediator::getVolume(CSoundMediator::SPEECH); + m_bgmVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SONG); + m_sfxVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SFX); + m_speechVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SPEECH); m_controlStyle=CPadConfig::getConfig(); m_screenXOff=VidGetXOfs(); m_screenYOff=VidGetYOfs(); @@ -393,19 +393,19 @@ void CFrontEndOptions::think(int _frames) if(m_mode==MODE__SOUND) { - if(m_bgmVolume!=CSoundMediator::getVolume(CSoundMediator::SONG)) + if(m_bgmVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SONG)) { - CSoundMediator::setVolume(CSoundMediator::SONG,m_bgmVolume); + CSoundMediator::setVolume(CSoundMediator::VOL_SONG,m_bgmVolume); PAUL_DBGMSG("SONG"); } - if(m_sfxVolume!=CSoundMediator::getVolume(CSoundMediator::SFX)) + if(m_sfxVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SFX)) { - CSoundMediator::setVolume(CSoundMediator::SFX,m_sfxVolume); + CSoundMediator::setVolume(CSoundMediator::VOL_SFX,m_sfxVolume); PAUL_DBGMSG("SFX"); } - if(m_speechVolume!=CSoundMediator::getVolume(CSoundMediator::SPEECH)) + if(m_speechVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SPEECH)) { - CSoundMediator::setVolume(CSoundMediator::SPEECH,m_speechVolume); + CSoundMediator::setVolume(CSoundMediator::VOL_SPEECH,m_speechVolume); PAUL_DBGMSG("SPEECH"); } } diff --git a/source/gfx/fader.cpp b/source/gfx/fader.cpp index adbc38be5..1dba1fd2b 100644 --- a/source/gfx/fader.cpp +++ b/source/gfx/fader.cpp @@ -26,6 +26,10 @@ #include "gfx\bubicles.h" #endif +#ifndef __SOUND_SOUND_H__ +#include "sound\sound.h" +#endif + /* Std Lib ------- */ @@ -193,7 +197,23 @@ void CFader::think(int _frames) s_fadeLine-=_frames*FADE_SPEED; if(s_fadeLine<-FADE_BORDER_SIZE) { - s_fadeMode=s_fadeMode==FADING_OUT?FADED_OUT:FADED_IN; + if(s_fadeMode==FADING_OUT) + { + s_fadeMode=FADED_OUT; + CSoundMediator::setVolume(CSoundMediator::VOL_FADE,0); + } + else + { + s_fadeMode=FADED_IN; + CSoundMediator::setVolume(CSoundMediator::VOL_FADE,255); + } + } + else + { + if(s_fadeLine>=0&&s_fadeLine<=255) + { + CSoundMediator::setVolume(CSoundMediator::VOL_FADE,s_fadeMode==FADING_OUT?s_fadeLine:255-s_fadeLine); + } } } } diff --git a/source/sound/sound.cpp b/source/sound/sound.cpp index 9372b6044..aafb1643f 100644 --- a/source/sound/sound.cpp +++ b/source/sound/sound.cpp @@ -88,15 +88,17 @@ static CXMPlaySound *s_xmplaySound; // Songs static XMFILEDATA s_xmSongData[CSoundMediator::NUM_SONGIDS]= { - { MUSIC_HYPERMMX_VH, MUSIC_HYPERMMX_VB, MUSIC_HYPERMMX_PXM }, // HYPERMMX - { MUSIC_DROPPOP_VH, MUSIC_DROPPOP_VB, MUSIC_DROPPOP_PXM }, // DROPPOP - { MUSIC_MUSIC_VH, MUSIC_MUSIC_VB, MUSIC_MUSIC_PXM }, // MUSIC + { MUSIC_HYPERMMX_VH, MUSIC_HYPERMMX_VB, MUSIC_HYPERMMX_PXM }, // SONG_HYPERMMX + { MUSIC_DROPPOP_VH, MUSIC_DROPPOP_VB, MUSIC_DROPPOP_PXM }, // SONG_DROPPOP + { MUSIC_MUSIC_VH, MUSIC_MUSIC_VB, MUSIC_MUSIC_PXM }, // SONG_MUSIC + { MUSIC_INGAME_VH, MUSIC_INGAME_VB, MUSIC_INGAME_PXM }, // SONG_INGAME + { MUSIC_TITLE_VH, MUSIC_TITLE_VB, MUSIC_TITLE_PXM }, // SONG_TITLE }; // SFX banks static XMFILEDATA s_xmSfxData[CSoundMediator::NUM_SFXBANKIDS]= { - { SFX_INGAME_VH, SFX_INGAME_VB, SFX_INGAME_PXM }, // INGAME + { SFX_INGAME_VH, SFX_INGAME_VB, SFX_INGAME_PXM }, // SFX_INGAME }; // Individual SFX details @@ -112,8 +114,8 @@ static SFXDETAILS s_sfxDetails[]= // Reverb details static ReverbDetails s_reverbDetails[CSoundMediator::NUM_REVERBTYPES]= { - { SPU_REV_MODE_OFF, 0, 0, 0 }, // NONE - { SPU_REV_MODE_ECHO, 75, 0x3000, 100 }, // ECHO_TEST + { SPU_REV_MODE_OFF, 0, 0, 0 }, // REV_NONE + { SPU_REV_MODE_ECHO, 75, 0x3000, 100 }, // REV_ECHOTEST }; @@ -145,7 +147,7 @@ void CSoundMediator::initialise() ASSERT(CXAStream::MAX_VOLUME==32767); // Initial reverb settings - setReverbType(NONE);//ECHO_TEST); + setReverbType(REV_NONE);//REV_ECHOTEST); SOUND_DBGMSG("Sound mediator initialised"); s_initialised=true; @@ -220,21 +222,27 @@ if(_frames==0)_frames=1; // Push through any changes in volume - if(s_volumeDirty[SONG]) + if(s_volumeDirty[VOL_FADE]) { - s_xmplaySound->setMasterSongVolume(s_currentVolume[SONG]); - s_volumeDirty[SONG]=false; + s_volumeDirty[VOL_SONG]=true; + s_volumeDirty[VOL_SFX]=true; + s_volumeDirty[VOL_SPEECH]=true; } - if(s_volumeDirty[SFX]) + if(s_volumeDirty[VOL_SONG]) { - s_xmplaySound->setMasterSfxVolume(s_currentVolume[SFX]); - s_volumeDirty[SFX]=false; + s_xmplaySound->setMasterSongVolume((s_currentVolume[VOL_SONG]*s_currentVolume[VOL_FADE])>>8); + s_volumeDirty[VOL_SONG]=false; } - if(s_volumeDirty[SPEECH]) + if(s_volumeDirty[VOL_SFX]) { - int vol=s_currentVolume[SPEECH]<<7; + s_xmplaySound->setMasterSfxVolume((s_currentVolume[VOL_SFX]*s_currentVolume[VOL_FADE])>>8); + s_volumeDirty[VOL_SFX]=false; + } + if(s_volumeDirty[VOL_SPEECH]) + { + int vol=((s_currentVolume[VOL_SPEECH]*s_currentVolume[VOL_FADE])>>8)<<7; CXAStream::setMasterVolume(vol,vol); - s_volumeDirty[SPEECH]=false; + s_volumeDirty[VOL_SPEECH]=false; } } diff --git a/source/sound/sound.h b/source/sound/sound.h index 1aa864030..020533dd7 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -49,22 +49,26 @@ class CSoundMediator public: typedef enum SONGID { - HYPERMMX, - DROPPOP, - MUSIC, + SONG_HYPERMMX, + SONG_DROPPOP, + SONG_MUSIC, + SONG_INGAME, + SONG_TITLE, NUM_SONGIDS, }; typedef enum SFXBANKID { - INGAME, + SFX_INGAME, NUM_SFXBANKIDS, }; typedef enum VOLUMETYPE { - SONG, - SFX, - SPEECH, + VOL_SONG, + VOL_SFX, + VOL_SPEECH, + + VOL_FADE, NUM_VOLUMETYPES, }; @@ -77,8 +81,8 @@ public: typedef enum REVERBTYPE { - NONE, - ECHO_TEST, + REV_NONE, + REV_ECHOTEST, NUM_REVERBTYPES, };