apply the music rate to the sample music

This commit is contained in:
Glenn Maynard
2007-05-27 06:22:20 +00:00
parent c3bd5565da
commit 982a134d2c
3 changed files with 23 additions and 2 deletions
+20 -2
View File
@@ -48,6 +48,7 @@ struct MusicPlaying
{
bool m_bTimingDelayed;
bool m_bHasTiming;
bool m_bApplyMusicRate;
/* The timing data that we're currently using. */
TimingData m_Timing;
NoteData m_Lights;
@@ -62,6 +63,7 @@ struct MusicPlaying
m_NewTiming.AddBPMSegment( BPMSegment(0,120) );
m_bHasTiming = false;
m_bTimingDelayed = false;
m_bApplyMusicRate = false;
m_Music = Music;
}
@@ -87,7 +89,7 @@ struct MusicToPlay
NoteData m_LightsData;
bool bForceLoop;
float fStartSecond, fLengthSeconds, fFadeInLengthSeconds, fFadeOutLengthSeconds;
bool bAlignBeat;
bool bAlignBeat, bApplyMusicRate;
MusicToPlay()
{
HasTiming = false;
@@ -123,7 +125,9 @@ static void StartMusic( MusicToPlay &ToPlay )
{
g_Mutex->Unlock();
RageSound *pSound = new RageSound;
pSound->Load( ToPlay.m_sFile, false );
RageSoundLoadParams params;
params.m_bSupportRateChanging = ToPlay.bApplyMusicRate;
pSound->Load( ToPlay.m_sFile, false, &params );
g_Mutex->Lock();
NewMusic = new MusicPlaying( pSound );
@@ -232,6 +236,7 @@ static void StartMusic( MusicToPlay &ToPlay )
if( ToPlay.HasTiming )
NewMusic->m_NewTiming = ToPlay.m_TimingData;
NewMusic->m_bTimingDelayed = true;
NewMusic->m_bApplyMusicRate = ToPlay.bApplyMusicRate;
// NewMusic->m_Music->Load( ToPlay.m_sFile, false );
RageSoundParams p;
@@ -468,6 +473,17 @@ void GameSoundManager::Update( float fDeltaTime )
{
{
g_Mutex->Lock();
if( g_Playing->m_bApplyMusicRate )
{
RageSoundParams p = g_Playing->m_Music->GetParams();
float fRate = GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate;
if( p.m_fSpeed != fRate )
{
p.m_fSpeed = fRate;
g_Playing->m_Music->SetParams( p );
}
}
bool bIsPlaying = g_Playing->m_Music->IsPlaying();
g_Mutex->Unlock();
if( !bIsPlaying && g_bWasPlayingOnLastUpdate && !g_FallbackMusic.sFile.empty() )
@@ -664,6 +680,7 @@ void GameSoundManager::PlayMusic(
params.fFadeInLengthSeconds = fFadeInLengthSeconds;
params.fFadeOutLengthSeconds = fFadeOutLengthSeconds;
params.bAlignBeat = bAlignBeat;
params.bApplyMusicRate = false;
PlayMusic( params );
}
@@ -693,6 +710,7 @@ void GameSoundManager::PlayMusic( PlayMusicParams params, PlayMusicParams Fallba
ToPlay.fFadeInLengthSeconds = params.fFadeInLengthSeconds;
ToPlay.fFadeOutLengthSeconds = params.fFadeOutLengthSeconds;
ToPlay.bAlignBeat = params.bAlignBeat;
ToPlay.bApplyMusicRate = params.bApplyMusicRate;
/* Add the MusicToPlay to the g_MusicsToPlay queue. */
g_Mutex->Lock();
+2
View File
@@ -27,6 +27,7 @@ public:
fFadeInLengthSeconds = 0;
fFadeOutLengthSeconds = 0;
bAlignBeat = true;
bApplyMusicRate = false;
}
RString sFile;
@@ -37,6 +38,7 @@ public:
float fFadeInLengthSeconds;
float fFadeOutLengthSeconds;
bool bAlignBeat;
bool bApplyMusicRate;
};
void PlayMusic( PlayMusicParams params, PlayMusicParams FallbackMusic = PlayMusicParams() );
void PlayMusic(
+1
View File
@@ -306,6 +306,7 @@ void ScreenSelectMusic::CheckBackgroundRequests( bool bForce )
PlayParams.fLengthSeconds = m_fSampleLengthSeconds;
PlayParams.fFadeOutLengthSeconds = 1.5f;
PlayParams.bAlignBeat = ALIGN_MUSIC_BEATS;
PlayParams.bApplyMusicRate = true;
GameSoundManager::PlayMusicParams FallbackMusic;
FallbackMusic.sFile = m_sLoopMusicPath;