From 9046f91eb2e493ce3cf736d927e11aefd53134a9 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 16 Jan 2007 01:39:04 +0000 Subject: [PATCH] use SoundEffectControl --- stepmania/src/RageSound.h | 4 ++++ stepmania/src/ScreenGameplay.cpp | 19 +++++++++++++++++++ stepmania/src/ScreenGameplay.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 848c4bbef5..aaecc1f37b 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -110,6 +110,10 @@ public: /* Load a RageSoundReader that you've set up yourself. Sample rate conversion will * be set up only if needed. Doesn't fail. */ void LoadSoundReader( RageSoundReader *pSound ); + + /* Get the loaded RageSoundReader. While playing, only properties can be set. */ + RageSoundReader *GetSoundReader() { return m_pSource; } + void Unload(); bool IsLoaded() const; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index d856f9c0a3..ad5e861a0f 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -980,6 +980,17 @@ void ScreenGameplay::SetupSong( int iSongIndex ) m_AutoKeysounds.Load( pi->GetStepsAndTrailIndex(), nd ); } + { + RString sType; + switch( GAMESTATE->m_SongOptions.GetCurrent().m_SoundEffectType ) + { + case SongOptions::SOUNDEFFECT_OFF: sType = ""; break; + case SongOptions::SOUNDEFFECT_SPEED: sType = "SoundEffectControl_Speed"; break; + case SongOptions::SOUNDEFFECT_PITCH: sType = "SoundEffectControl_Pitch"; break; + } + + pi->m_SoundEffectControl.Load( sType, pi->GetPlayerState(), &pi->m_NoteData ); + } // Put course options into effect. Do this after Player::Load so // that mods aren't double-applied. @@ -1254,6 +1265,12 @@ void ScreenGameplay::LoadNextSong() * to compete with other loading. */ m_AutoKeysounds.FinishLoading(); m_pSoundMusic = m_AutoKeysounds.GetSound(); + + /* Give SoundEffectControls the new RageSoundReaders. */ + FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + { + pi->m_SoundEffectControl.SetSoundReader( m_pSoundMusic->GetSoundReader() ); + } } void ScreenGameplay::LoadLights() @@ -1587,6 +1604,8 @@ void ScreenGameplay::Update( float fDeltaTime ) { pi->GetPlayerState()->m_HealthState = PlayerState::ALIVE; } + + pi->m_SoundEffectControl.Update( fDeltaTime ); } if( GAMESTATE->m_SongOptions.GetCurrent().m_fHaste != 0.0f ) diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 0aa6885c29..1f77bfb96c 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -18,6 +18,7 @@ #include "PlayerStageStats.h" #include "PlayerState.h" #include "InputEventPlus.h" +#include "SoundEffectControl.h" class LyricsLoader; class ActiveAttackList; @@ -67,6 +68,7 @@ public: bool m_bIsDummy; PlayerState m_PlayerStateDummy; PlayerStageStats m_PlayerStageStatsDummy; + SoundEffectControl m_SoundEffectControl; vector m_vpStepsQueue; // size may be >1 if playing a course vector m_asModifiersQueue;// size may be >1 if playing a course