diff --git a/src/NoteField.cpp b/src/NoteField.cpp index 08d86b9441..241c782310 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -800,7 +800,7 @@ void NoteField::DrawPrimitives() { float fBeat = NoteRowToBeat(aWarpSegments[i].m_iStartRow); if( IS_ON_SCREEN(fBeat) ) - DrawWarpText( fBeat, aWarpSegments[i].m_fWarpBeats ); + DrawWarpText( fBeat, aWarpSegments[i].m_fEndBeat ); } } diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 3f6acabab2..36c170b475 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -150,7 +150,7 @@ static void WriteGlobalTags( RageFile &f, const Song &out ) { const WarpSegment &ws = out.m_Timing.m_WarpSegments[i]; - f.PutLine( ssprintf( "%.6f=%.6f", NoteRowToBeat(ws.m_iStartRow), ws.m_fWarpBeats ) ); + f.PutLine( ssprintf( "%.6f=%.6f", NoteRowToBeat(ws.m_iStartRow), ws.m_fEndBeat ) ); if( i != out.m_Timing.m_WarpSegments.size()-1 ) f.Write( "," ); } diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 7eb82e36eb..a8eaaf2704 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -150,12 +150,30 @@ void TimingData::SetTimeSignatureDenominatorAtRow( int iRow, int iDenominator ) SetTimeSignatureAtRow( iRow, GetTimeSignatureSegmentAtBeat( NoteRowToBeat( iRow ) ).m_iNumerator, iDenominator ); } -/* -void TimingData::SetWarpAtRow( int iRowAt, float fLengthBeats ) +void TimingData::SetWarpAtRow( int iRow, float fNew ) { - // todo: code this -aj + unsigned i; + for( i=0; i 0 && NoteRowToBeat(iRow) < fNew; + if( i == m_WarpSegments.size() ) + { + if( valid ) + { + AddWarpSegment( WarpSegment(iRow, fNew) ); + } + } + else + { + if( valid ) + { + m_WarpSegments[i].m_fEndBeat = fNew; + } + else + m_WarpSegments.erase( m_WarpSegments.begin()+i, m_WarpSegments.begin()+i+1 ); + } } -*/ /* Change an existing Tickcount segment, merge identical segments together or insert a new one. */ void TimingData::SetTickcountAtRow( int iRow, int iTicks ) @@ -229,13 +247,13 @@ int TimingData::GetComboAtRow( int iNoteRow ) const return m_ComboSegments[GetComboSegmentIndexAtRow( iNoteRow )].m_iCombo; } -int TimingData::GetWarpToRow( int iWarpBeginRow ) const +float TimingData::GetWarpAtRow( int iWarpRow ) const { for( unsigned i=0; i iNoteRow ) break; - return (int)i; + return static_cast(i); } int TimingData::GetStopSegmentIndexAtRow( int iNoteRow, bool bDelay ) const @@ -308,16 +326,50 @@ int TimingData::GetStopSegmentIndexAtRow( int iNoteRow, bool bDelay ) const if( s.m_iStartRow > iNoteRow && s.m_bDelay == bDelay ) break; } - return (int)i; + return static_cast(i); +} + +int TimingData::GetWarpSegmentIndexAtRow( int iNoteRow ) const +{ + unsigned i; + for( i=0; i iNoteRow ) + break; + } + return static_cast(i); } int TimingData::GetTimeSignatureSegmentIndexAtRow( int iRow ) const { - int i; - for (i=0; i < (int)(m_vTimeSignatureSegments.size()) - 1; i++ ) + unsigned i; + for (i=0; i < m_vTimeSignatureSegments.size() - 1; i++ ) if( m_vTimeSignatureSegments[i+1].m_iStartRow > iRow ) break; - return i; + return static_cast(i); +} + +int TimingData::GetComboSegmentIndexAtRow( int iRow ) const +{ + unsigned i; + for( i=0; i iRow ) + break; + } + return static_cast(i); +} + +BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow ) +{ + static BPMSegment empty; + if( m_BPMSegments.empty() ) + return empty; + + int i = GetBPMSegmentIndexAtRow( iNoteRow ); + return m_BPMSegments[i]; } TimeSignatureSegment& TimingData::GetTimeSignatureSegmentAtRow( int iRow ) @@ -339,28 +391,6 @@ int TimingData::GetTimeSignatureDenominatorAtRow( int iRow ) return GetTimeSignatureSegmentAtRow( iRow ).m_iDenominator; } -int TimingData::GetComboSegmentIndexAtRow( int iRow ) const -{ - unsigned i; - for( i=0; i iRow ) - break; - } - return (int)i; -} - -BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow ) -{ - static BPMSegment empty; - if( m_BPMSegments.empty() ) - return empty; - - int i = GetBPMSegmentIndexAtRow( iNoteRow ); - return m_BPMSegments[i]; -} - ComboSegment& TimingData::GetComboSegmentAtRow( int iRow ) { unsigned i; @@ -380,6 +410,16 @@ StopSegment& TimingData::GetStopSegmentAtRow( int iNoteRow, bool bDelay ) return m_StopSegments[i]; } +WarpSegment& TimingData::GetWarpSegmentAtRow( int iRow ) +{ + static WarpSegment empty; + if( m_WarpSegments.empty() ) + return empty; + + int i = GetWarpSegmentIndexAtRow( iRow ); + return m_WarpSegments[i]; +} + int TimingData::GetTickcountSegmentIndexAtRow( int iRow ) const { int i; @@ -478,7 +518,7 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float */ // the freeze segment is <= current time - //fElapsedTime -= m_WarpSegments[j].m_fWarpBeats; + //fElapsedTime -= m_WarpSegments[j].m_fEndBeat; // this warp lies within this BPMSegment. /* @@ -492,7 +532,7 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float bFreezeOut = false; bDelayOut = false; iWarpBeginOut = m_WarpSegments[j].m_iStartRow; - fWarpLengthOut = m_WarpSegments[j].m_fWarpBeats; + fWarpLengthOut = m_WarpSegments[j].m_fEndBeat; return; } */ diff --git a/src/TimingData.h b/src/TimingData.h index c03d67965b..b2300d61a1 100644 --- a/src/TimingData.h +++ b/src/TimingData.h @@ -322,21 +322,21 @@ struct WarpSegment * * It is best to override the values as soon as possible. */ - WarpSegment() : m_iStartRow(-1), m_fWarpBeats(-1) { } + WarpSegment() : m_iStartRow(-1), m_fEndBeat(-1) { } /** * @brief Creates a Warp Segment with the specified starting row and row to warp to. * @param s the starting row of this segment. * @param r the row to warp to. */ WarpSegment( int s, int r ): m_iStartRow(max(0, (s < r ? s : r))), - m_fWarpBeats(max(0, NoteRowToBeat((r > s ? r : s)))) {} + m_fEndBeat(max(0, NoteRowToBeat((r > s ? r : s)))) {} /** * @brief Creates a Warp Segment with the specified starting row and beat to warp to. * @param s the starting row of this segment. * @param b the beat to warp to. */ WarpSegment( int s, float b ): m_iStartRow(max(0, s)), - m_fWarpBeats(max(0, b)) {} + m_fEndBeat(max(0, b)) {} /** * @brief The row in which the WarpSegment activates. */ @@ -344,7 +344,7 @@ struct WarpSegment /** * @brief The beat to warp to. */ - float m_fWarpBeats; + float m_fEndBeat; /** * @brief Compares two WarpSegments to see if they are equal to each other. * @param other the other WarpSegment to compare to. @@ -353,7 +353,7 @@ struct WarpSegment bool operator==( const WarpSegment &other ) const { COMPARE( m_iStartRow ); - COMPARE( m_fWarpBeats ); + COMPARE( m_fEndBeat ); return true; } /** @@ -370,7 +370,7 @@ struct WarpSegment bool operator<( const WarpSegment &other ) const { return m_iStartRow < other.m_iStartRow || - ( m_iStartRow == other.m_iStartRow && m_fWarpBeats < other.m_fWarpBeats ); + ( m_iStartRow == other.m_iStartRow && m_fEndBeat < other.m_fEndBeat ); } /** * @brief Compares two WarpSegments to see if one is less than or equal to the other. @@ -875,19 +875,59 @@ public: * @param seg the new TimeSignatureSegment. */ void AddTimeSignatureSegment( const TimeSignatureSegment &seg ); - /** - * @brief Determine the row to warp to. - * @param iWarpBeginRow The row you start on. - * @return the row you warp to. + * @brief Determine the beat to warp to. + * @param iRow The row you start on. + * @return the beat you warp to. */ - int GetWarpToRow( int iWarpBeginRow ) const; + float GetWarpAtRow( int iRow ) const; + /** + * @brief Determine the beat to warp to. + * @param fBeat The beat you start on. + * @return the beat you warp to. + */ + float GetWarpAtBeat( float fBeat ) const { return GetWarpAtRow( BeatToNoteRow( fBeat ) ); } + /** + * @brief Set the beat to warp to given a starting row. + * @param iRow The row to start on. + * @param fNew The destination beat. + */ + void SetWarpAtRow( int iRow, float fNew ); + /** + * @brief Set the beat to warp to given a starting beat. + * @param fBeat The beat to start on. + * @param fNew The destination beat. + */ + void SetWarpAtBeat( float fBeat, float fNew ) { SetWarpAtRow( BeatToNoteRow( fBeat ), fNew ); } + /** + * @brief Retrieve the WarpSegment at the specified row. + * @param iRow the row to focus on. + * @return the WarpSegment in question. + */ + WarpSegment& GetWarpSegmentAtRow( int iRow ); + /** + * @brief Retrieve the WarpSegment at the specified beat. + * @param fBeat the beat to focus on. + * @return the WarpSegment in question. + */ + WarpSegment& GetWarpSegmentAtBeat( float fBeat ) { return GetWarpSegmentAtRow( BeatToNoteRow( fBeat ) ); } + /** + * @brief Retrieve the index of the WarpSegment at the specified row. + * @param iRow the row to focus on. + * @return the index in question. + */ + int GetWarpSegmentIndexAtRow( int iRow ) const; + /** + * @brief Retrieve the index of the WarpSegment at the specified beat. + * @param fBeat the beat to focus on. + * @return the index in question. + */ + int GetWarpSegmentIndexAtBeat( float fBeat ) const { return GetWarpSegmentIndexAtRow( BeatToNoteRow( fBeat ) ); } /** * @brief Add the WarpSegment to the TimingData. * @param seg the new WarpSegment. */ void AddWarpSegment( const WarpSegment &seg ); - /** * @brief Retrieve the Tickcount at the given row. * @param iNoteRow the row in question.