From 46c1b2ac057733b32b1d68235275d0a3c8f3a0c4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 9 Apr 2006 15:54:53 +0000 Subject: [PATCH] oops. Do keep the non-offset beat around, and use it for actor effects. (This should probably be used for more than this; this stuff needs a cleanup ...) (test case: pick a song with a stop near the beginning of the sample music, eg. Fly With Me; no matter what the offset is set to, it should always show the same pause on beat effects. This could do so while honoring the offset, but getting that right in GameSoundManager is very tricky, and it's usually not important for non-gameplay cosmetics.) --- stepmania/src/GameSoundManager.cpp | 16 ++++++++-------- stepmania/src/GameState.cpp | 4 +++- stepmania/src/GameState.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/stepmania/src/GameSoundManager.cpp b/stepmania/src/GameSoundManager.cpp index bf860a02bb..2d63858801 100644 --- a/stepmania/src/GameSoundManager.cpp +++ b/stepmania/src/GameSoundManager.cpp @@ -159,9 +159,9 @@ static void StartMusic( MusicToPlay &ToPlay ) /* Extend the loop period so it always starts and ends on the same fractional * beat. That is, if it starts on beat 1.5, and ends on beat 10.2, extend it * to end on beat 10.5. This way, effects always loop cleanly. */ - float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTime( ToPlay.start_sec ); + float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.start_sec ); float fEndSec = ToPlay.start_sec + ToPlay.length_sec; - float fEndBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTime( fEndSec ); + float fEndBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( fEndSec ); const float fStartBeatFraction = fmodfp( fStartBeat, 1 ); const float fEndBeatFraction = fmodfp( fEndBeat, 1 ); @@ -172,7 +172,7 @@ static void StartMusic( MusicToPlay &ToPlay ) fEndBeat += fBeatDifference; - const float fRealEndSec = NewMusic->m_NewTiming.GetElapsedTimeFromBeat( fEndBeat ); + const float fRealEndSec = NewMusic->m_NewTiming.GetElapsedTimeFromBeatNoOffset( fEndBeat ); const float fNewLengthSec = fRealEndSec - ToPlay.start_sec; /* Extend the fade_len, so the added time is faded out. */ @@ -185,8 +185,8 @@ static void StartMusic( MusicToPlay &ToPlay ) { /* This song has no real timing data. The offset is arbitrary. Change it so * the beat will line up to where we are now, so we don't have to delay. */ - float fDestBeat = fmodfp( GAMESTATE->m_fSongBeat, 1 ); - float fTime = NewMusic->m_NewTiming.GetElapsedTimeFromBeat( fDestBeat ); + float fDestBeat = fmodfp( GAMESTATE->m_fSongBeatNoOffset, 1 ); + float fTime = NewMusic->m_NewTiming.GetElapsedTimeFromBeatNoOffset( fDestBeat ); NewMusic->m_NewTiming.m_fBeat0OffsetInSeconds = fTime; @@ -208,17 +208,17 @@ static void StartMusic( MusicToPlay &ToPlay ) * probably take a little longer. Nudge the latency up. */ const float fPresumedLatency = SOUND->GetPlayLatency() + 0.040f; const float fCurSecond = GAMESTATE->m_fMusicSeconds + fPresumedLatency; - const float fCurBeat = g_Playing->m_Timing.GetBeatFromElapsedTime( fCurSecond ); + const float fCurBeat = g_Playing->m_Timing.GetBeatFromElapsedTimeNoOffset( fCurSecond ); /* The beat that the new sound will start on. */ - const float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTime( ToPlay.start_sec ); + const float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.start_sec ); const float fStartBeatFraction = fmodfp( fStartBeat, 1 ); float fCurBeatToStartOn = truncf(fCurBeat) + fStartBeatFraction; if( fCurBeatToStartOn < fCurBeat ) fCurBeatToStartOn += 1.0f; - const float fSecondToStartOn = g_Playing->m_Timing.GetElapsedTimeFromBeat( fCurBeatToStartOn ); + const float fSecondToStartOn = g_Playing->m_Timing.GetElapsedTimeFromBeatNoOffset( fCurBeatToStartOn ); const float fMaximumDistance = 2; const float fDistance = min( fSecondToStartOn - GAMESTATE->m_fMusicSeconds, fMaximumDistance ); diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 992270941b..62a56145a6 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -583,6 +583,7 @@ void GameState::ResetMusicStatistics() { m_fMusicSeconds = 0; // MUSIC_SECONDS_INVALID; m_fSongBeat = 0; + m_fSongBeatNoOffset = 0; m_fCurBPS = 10; m_bFreeze = false; Actor::SetBGMTime( 0, 0 ); @@ -653,7 +654,8 @@ void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &ti m_fMusicSeconds = fPositionSeconds; m_fLightSongBeat = timing.GetBeatFromElapsedTime( fPositionSeconds + g_fLightsAheadSeconds ); - Actor::SetBGMTime( fPositionSeconds, m_fSongBeat ); + m_fSongBeatNoOffset = timing.GetBeatFromElapsedTimeNoOffset( fPositionSeconds ); + Actor::SetBGMTime( fPositionSeconds, m_fSongBeatNoOffset ); // LOG->Trace( "m_fMusicSeconds = %f, m_fSongBeat = %f, m_fCurBPS = %f, m_bFreeze = %f", m_fMusicSeconds, m_fSongBeat, m_fCurBPS, m_bFreeze ); } diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 0ca0360e51..0077812224 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -158,6 +158,7 @@ public: // float m_fMusicSeconds; // time into the current song float m_fSongBeat; + float m_fSongBeatNoOffset; float m_fCurBPS; float m_fLightSongBeat; // g_fLightsFalloffSeconds ahead bool m_bFreeze; // in the middle of a freeze