From 8c7173f26cfed501b75be75d68e79fe1571e4c81 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 10 Dec 2006 00:43:51 +0000 Subject: [PATCH] use RageSoundReader_Pan for panning --- stepmania/src/Player.cpp | 32 +++++++++++++++++--------------- stepmania/src/RageSound.cpp | 9 +++++---- stepmania/src/RageSound.h | 6 +++--- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index c6d26dd11a..33a94dc632 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -291,7 +291,9 @@ void Player::Init( m_sMessageToSendOnStep = ssprintf("StepP%d",pn+1); - m_soundMine.Load( THEME->GetPathS(sType,"mine"), true ); + RageSoundLoadParams SoundParams; + SoundParams.m_bSupportPan = true; + m_soundMine.Load( THEME->GetPathS(sType,"mine"), true, &SoundParams ); /* Attacks can be launched in course modes and in battle modes. They both come * here to play, but allow loading a different sound for different modes. */ @@ -299,22 +301,20 @@ void Player::Init( { case PLAY_MODE_RAVE: case PLAY_MODE_BATTLE: - m_soundAttackLaunch.Load( THEME->GetPathS(sType,"battle attack launch"), true ); - m_soundAttackEnding.Load( THEME->GetPathS(sType,"battle attack ending"), true ); + m_soundAttackLaunch.Load( THEME->GetPathS(sType,"battle attack launch"), true, &SoundParams ); + m_soundAttackEnding.Load( THEME->GetPathS(sType,"battle attack ending"), true, &SoundParams ); break; default: - m_soundAttackLaunch.Load( THEME->GetPathS(sType,"course attack launch"), true ); - m_soundAttackEnding.Load( THEME->GetPathS(sType,"course attack ending"), true ); + m_soundAttackLaunch.Load( THEME->GetPathS(sType,"course attack launch"), true, &SoundParams ); + m_soundAttackEnding.Load( THEME->GetPathS(sType,"course attack ending"), true, &SoundParams ); break; } - RageSoundParams p; - p.m_Balance = GameSoundManager::GetPlayerBalance( pn ); - - m_soundMine.SetParams( p ); - m_soundAttackLaunch.SetParams( p ); - m_soundAttackEnding.SetParams( p ); + float fBalance = GameSoundManager::GetPlayerBalance( pn ); + m_soundMine.SetProperty( "Pan", fBalance ); + m_soundAttackLaunch.SetProperty( "Pan", fBalance ); + m_soundAttackEnding.SetProperty( "Pan", fBalance ); if( m_pCombo ) { @@ -465,15 +465,17 @@ void Player::Load() RString sSongDir = pSong->GetSongDir(); m_vKeysounds.resize( pSong->m_vsKeysoundFile.size() ); - RageSoundParams p; - p.m_Balance = GameSoundManager::GetPlayerBalance( pn ); + RageSoundLoadParams SoundParams; + SoundParams.m_bSupportPan = true; + + float fBalance = GameSoundManager::GetPlayerBalance( pn ); for( unsigned i=0; im_vsKeysoundFile[i]; RageSound& sound = m_vKeysounds[i]; if( sound.GetLoadedFilePath() != sKeysoundFilePath ) - sound.Load( sKeysoundFilePath, true ); - sound.SetParams( p ); + sound.Load( sKeysoundFilePath, true, &SoundParams ); + sound.SetProperty( "Pan", fBalance ); } if( m_pPlayerStageStats ) diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index f90b54b2ae..a75194e231 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -29,6 +29,7 @@ #include "arch/ArchHooks/ArchHooks.h" #include "RageSoundUtil.h" +#include "RageSoundReader_Pan.h" #include "RageSoundReader_PitchChange.h" #include "RageSoundReader_Preload.h" #include "RageSoundReader_Resample_Good.h" @@ -45,7 +46,6 @@ RageSoundParams::RageSoundParams(): m_LengthSeconds = -1; m_FadeLength = 0; m_Volume = 1.0f; - m_Balance = 0; // center m_fPitch = 1.0f; m_fSpeed = 1.0f; m_bAccurateSync = false; @@ -56,6 +56,7 @@ RageSoundParams::RageSoundParams(): RageSoundLoadParams::RageSoundLoadParams() { m_bSupportRateChanging = false; + m_bSupportPan = false; } RageSound::RageSound(): @@ -225,6 +226,9 @@ bool RageSound::Load( RString sSoundFilePath, bool bPrecache, const RageSoundLoa m_pSource = pRate; } + if( pParams->m_bSupportPan ) + m_pSource = new RageSoundReader_Pan( m_pSource ); + m_sFilePath = sSoundFilePath; m_Mutex.SetName( ssprintf("RageSound (%s)", Basename(sSoundFilePath).c_str() ) ); @@ -418,9 +422,6 @@ bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFr } } - /* This block goes from iStreamFrame to iStreamFrame+iGotFrames. */ - RageSoundUtil::Pan( pBuffer, iGotFrames, m_Param.m_Balance ); - iFramesStored += iGotFrames; iFrames -= iGotFrames; pBuffer += iGotFrames * channels; diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index ccba300079..64a50b4d99 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -41,9 +41,6 @@ struct RageSoundParams float m_Volume; // multiplies with SOUNDMAN->GetMixVolume() - /* Pan: -1, left; 1, right */ - float m_Balance; - /* Number of samples input and output when changing speed. Currently, * this is either 1/1, 5/4 or 4/5. */ float m_fPitch; @@ -79,6 +76,9 @@ struct RageSoundLoadParams /* If true, speed and pitch changes will be supported for this sound, at a * small memory penalty if not used. */ bool m_bSupportRateChanging; + + /* If true, panning will be supported for this sound. */ + bool m_bSupportPan; }; class RageSound: public RageSoundBase