use RageSoundReader_Pan for panning

This commit is contained in:
Glenn Maynard
2006-12-10 00:43:51 +00:00
parent 602db9c431
commit 8c7173f26c
3 changed files with 25 additions and 22 deletions
+17 -15
View File
@@ -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; i<m_vKeysounds.size(); i++ )
{
RString sKeysoundFilePath = sSongDir + pSong->m_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 )
+5 -4
View File
@@ -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;
+3 -3
View File
@@ -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