From 191d6aa8fda762943bcae4cf144662e7037f627d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 18 Oct 2002 01:09:59 +0000 Subject: [PATCH] Bring ticks in edit closer to gameplay; perhaps move this to Player to get rid of the dupe ... --- stepmania/src/ScreenEdit.cpp | 58 ++++++++++++++++++++---------------- stepmania/src/ScreenEdit.h | 6 ++-- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 0e9489cbad..36c873649d 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -317,6 +317,37 @@ ScreenEdit::~ScreenEdit() m_soundMusic.Stop(); } +// play assist ticks +bool ScreenEdit::PlayTicks() const +{ + // Sound cards have a latency between when a sample is Play()ed and when the sound + // will start coming out the speaker. Compensate for this by boosting + // fPositionSeconds ahead + + if( GAMESTATE->m_SongOptions.m_AssistType != SongOptions::ASSIST_TICK ) + return false; + + float fPositionSeconds = GAMESTATE->m_fMusicSeconds; + float fSongBeat, fBPS; + bool bFreeze; + + // HACK: Play the sound a little bit early to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing. + fPositionSeconds += (SOUND->GetPlayLatency()+0.018f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.015 seconds to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing. + GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); + + int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); + iRowNow = max( 0, iRowNow ); + static int iRowLastCrossed = 0; + + bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed + + for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update + bAnyoneHasANote |= m_Player.IsThereANoteAtRow( r ); + + iRowLastCrossed = iRowNow; + + return bAnyoneHasANote; +} void ScreenEdit::Update( float fDeltaTime ) { @@ -413,31 +444,8 @@ void ScreenEdit::Update( float fDeltaTime ) m_NoteFieldEdit.Update( fDeltaTime ); - // - // play assist ticks - // - // Sound cards have a latency between when a sample is Play()ed and when the sound - // will start coming out the speaker. Compensate for this by boosting - // fPositionSeconds ahead - if( m_EditMode == MODE_PLAYING && GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) - { - fPositionSeconds += (SOUND->GetPlayLatency()+0.018f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.015 seconds to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing. - GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); - - int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); - iRowNow = max( 0, iRowNow ); - static int iRowLastCrossed = 0; - - bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed - - for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update - bAnyoneHasANote |= m_Player.IsThereANoteAtRow( r ); - - if( bAnyoneHasANote ) - m_soundAssistTick.Play(); - - iRowLastCrossed = iRowNow; - } + if(m_EditMode == MODE_PLAYING && PlayTicks()) + m_soundAssistTick.Play(); diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index f300021023..6cdd016818 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -40,10 +40,12 @@ public: void InputRecord( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); void InputPlay( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); virtual void HandleScreenMessage( const ScreenMessage SM ); - void TransitionFromRecordToEdit(); - void TransitionToEdit(); protected: + void TransitionFromRecordToEdit(); + void TransitionToEdit(); + bool PlayTicks() const; + void OnSnapModeChange(); void MenuItemGainFocus( BitmapText* menuitem ); void MenuItemLoseFocus( BitmapText* menuitem );