diff --git a/source/sound/cdxa.cpp b/source/sound/cdxa.cpp index c6a790b3f..8078bfd19 100644 --- a/source/sound/cdxa.cpp +++ b/source/sound/cdxa.cpp @@ -322,11 +322,14 @@ SpuCommonAttr Attr; // SsSetSerialVol(SS_SERIAL_A,0,0); - Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX); - Attr.cd.volume.left =0; - Attr.cd.volume.right=0; - Attr.cd.mix=SPU_ON; - SpuSetCommonAttr(&Attr); +// Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX); +// Attr.cd.volume.left =0; +// Attr.cd.volume.right=0; +// Attr.cd.mix=SPU_ON; +// SpuSetCommonAttr(&Attr); +SpuSetCommonCDVolume(0,0); +SpuSetCommonCDMix(SPU_ON); + CDVol.val0 = 0; // CdL -> SpuL CDVol.val1 = 0; // CdL -> SpuR CDVol.val2 = 0; // CdR -> SpuR diff --git a/source/sound/sound.cpp b/source/sound/sound.cpp index 3fa1df958..dd4d75e24 100644 --- a/source/sound/sound.cpp +++ b/source/sound/sound.cpp @@ -1,5 +1,4 @@ /* -reverb ( trigger from map? ) position adjust channels ( watery-mario64 style music changes ) */ @@ -100,12 +99,18 @@ static XMFILEDATA s_xmSfxData[CSoundMediator::NUM_SFXBANKIDS]= static SFXDETAILS s_sfxDetails[]= { { 1, 6, 1 }, - { 1, 1, 0 }, - { 1, 2, 0 }, + { 1, 4, 0 }, + { 1, 5, 0 }, { 1, 0, 1 }, }; +// 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 +}; // int s_songChannelCount=10; @@ -127,7 +132,6 @@ void CSoundMediator::initialise() s_spuSound=new ("SPUSound") CSpuSound(); s_spuSound->initialise(); s_xmplaySound=new ("XMPlaySound") CXMPlaySound(); s_xmplaySound->initialise(); CXAStream::Init(); - for(i=0;isetReverbDetails(&s_reverbDetails[_type]); + s_spuSound->setReverbActive(true); +} + + /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/sound/sound.h b/source/sound/sound.h index 7f160d2e9..9205becca 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -77,6 +77,13 @@ public: MAX_VOLUME=255, }; + typedef enum REVERBTYPE + { + NONE, + ECHO_TEST, + + NUM_REVERBTYPES, + }; // General static void initialise(); @@ -84,6 +91,9 @@ public: static void think(int _frames); + // Reverb + static void setReverbType(REVERBTYPE _type); + // Song interface static void setSong(SONGID _songId); static void playSong(); diff --git a/source/sound/spu.cpp b/source/sound/spu.cpp index 9fd3188f2..ca83d41ff 100644 --- a/source/sound/spu.cpp +++ b/source/sound/spu.cpp @@ -63,7 +63,6 @@ char CSpuSound::s_spuManagementTable[SPU_MALLOC_RECSIZ*(MAX_SPU_MANAGEMENT+1)]; ---------------------------------------------------------------------- */ void CSpuSound::initialise() { - SpuReverbAttr rev; SpuEnv env; // SPU setup @@ -75,18 +74,6 @@ void CSpuSound::initialise() SpuInitMalloc(MAX_SPU_MANAGEMENT,s_spuManagementTable); SpuSetCommonMasterVolume(0x3fff,0x3fff); - // Reverb - rev.mask=(SPU_REV_MODE|SPU_REV_DEPTHL|SPU_REV_DEPTHR); - rev.mode=SPU_REV_MODE_SPACE; - rev.depth.left=0x1000; - rev.depth.right=0x1000; - SpuSetReverbModeParam(&rev); - SpuSetReverb(SPU_ON); - SpuReserveReverbWorkArea(SPU_ON); - SpuSetReverbVoice(SPU_BIT,0x000000); - rev.mask=(SPU_REV_DEPTHL|SPU_REV_DEPTHR); - SpuSetReverbDepth(&rev); - // Environment env.mask=SPU_ENV_EVENT_QUEUEING; env.queueing=SPU_OFF; @@ -109,5 +96,48 @@ void CSpuSound::shutdown() } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSpuSound::setReverbActive(int _active) +{ + SpuReverbAttr rev; + + if(_active) + { + // Reverb + SpuSetReverbModeType(m_currentDetails.m_type); + SpuSetReverb(SPU_ON); + SpuReserveReverbWorkArea(SPU_ON); + SpuSetReverbVoice(SPU_BIT,0xffffff); + SpuSetReverbModeDelayTime(m_currentDetails.m_delay); + SpuSetReverbModeDepth(m_currentDetails.m_depth,m_currentDetails.m_depth); + SpuSetReverbModeFeedback(m_currentDetails.m_feedback); + + m_reverbActive=true; + } + else + { + SpuSetReverb(SPU_OFF); + + m_reverbActive=false; + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSpuSound::setReverbDetails(ReverbDetails *_details) +{ + m_currentDetails=*_details; +} + /*=========================================================================== end */ \ No newline at end of file diff --git a/source/sound/spu.h b/source/sound/spu.h index b0b1eb090..e69376235 100644 --- a/source/sound/spu.h +++ b/source/sound/spu.h @@ -29,11 +29,33 @@ Structure defintions -------------------- */ +typedef struct ReverbDetails +{ + long m_type; + long m_delay; + short m_depth; + long m_feedback; +}; + + class CSpuSound { public: + enum + { + REVERB_MAX_DEPTH=0x7fff, + REVERB_MIN_DEPTH=-0x8000, + REVERB_MIN_MODE_DELAY=0, + REVERB_MAX_MODE_DELAY=127, + REVERB_MIN_MODE_FEEDBACK=0, + REVERB_MAX_MODE_FEEDBACK=127, + }; + void initialise(); void shutdown(); + + void setReverbActive(int _active); + void setReverbDetails(ReverbDetails *_details); private: enum @@ -43,7 +65,10 @@ private: }; static char s_spuManagementTable[]; - + + int m_reverbActive; + ReverbDetails m_currentDetails; + };