diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 20f9e47642..b63a5fc7d2 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -753,6 +753,283 @@ int TimingData::GetTickcountAtRow( int iRow ) const return m_TickcountSegments[GetTickcountSegmentIndexAtRow( iRow )].GetTicks(); } +float TimingData::GetPreviousBPMSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_BPMSegments.size(); i++ ) + { + if( m_BPMSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_BPMSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextBPMSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_BPMSegments.size(); i++ ) + { + if( m_BPMSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_BPMSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousStopSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_StopSegments.size(); i++ ) + { + const StopSegment &s = m_StopSegments[i]; + if( !s.GetDelay() && s.GetRow() >= iRow ) + { + break; + } + backup = s.GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextStopSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_StopSegments.size(); i++ ) + { + const StopSegment &s = m_StopSegments[i]; + if( !s.GetDelay() && s.GetRow() <= iRow ) + { + continue; + } + return s.GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousDelaySegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_StopSegments.size(); i++ ) + { + const StopSegment &s = m_StopSegments[i]; + if( s.GetDelay() && s.GetRow() >= iRow ) + { + break; + } + backup = s.GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextDelaySegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_StopSegments.size(); i++ ) + { + const StopSegment &s = m_StopSegments[i]; + if( s.GetDelay() && s.GetRow() <= iRow ) + { + continue; + } + return s.GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousTimeSignatureSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ ) + { + if( m_vTimeSignatureSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_vTimeSignatureSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextTimeSignatureSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ ) + { + if( m_vTimeSignatureSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_vTimeSignatureSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + + +float TimingData::GetPreviousTickcountSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_TickcountSegments.size(); i++ ) + { + if( m_TickcountSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_TickcountSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextTickcountSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_TickcountSegments.size(); i++ ) + { + if( m_TickcountSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_TickcountSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousComboSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_ComboSegments.size(); i++ ) + { + if( m_ComboSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_ComboSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextComboSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_ComboSegments.size(); i++ ) + { + if( m_ComboSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_ComboSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + + + +float TimingData::GetPreviousWarpSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_WarpSegments.size(); i++ ) + { + if( m_WarpSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_WarpSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextWarpSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_WarpSegments.size(); i++ ) + { + if( m_WarpSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_WarpSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousFakeSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_FakeSegments.size(); i++ ) + { + if( m_FakeSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_FakeSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextFakeSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_FakeSegments.size(); i++ ) + { + if( m_FakeSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_FakeSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousSpeedSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_SpeedSegments.size(); i++ ) + { + if( m_SpeedSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_SpeedSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextSpeedSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_SpeedSegments.size(); i++ ) + { + if( m_SpeedSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_SpeedSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + +float TimingData::GetPreviousScrollSegmentBeatAtRow( int iRow ) const +{ + float backup = -1; + for (unsigned i = 0; i < m_ScrollSegments.size(); i++ ) + { + if( m_ScrollSegments[i].GetRow() >= iRow ) + { + break; + } + backup = m_ScrollSegments[i].GetBeat(); + } + return (backup > -1) ? backup : NoteRowToBeat(iRow); +} + +float TimingData::GetNextScrollSegmentBeatAtRow( int iRow ) const +{ + for (unsigned i = 0; i < m_ScrollSegments.size(); i++ ) + { + if( m_ScrollSegments[i].GetRow() <= iRow ) + { + continue; + } + return m_ScrollSegments[i].GetBeat(); + } + return NoteRowToBeat(iRow); +} + float TimingData::GetPreviousLabelSegmentBeatAtRow( int iRow ) const { float backup = -1; diff --git a/src/TimingData.h b/src/TimingData.h index 687016ea5b..b8119b4913 100644 --- a/src/TimingData.h +++ b/src/TimingData.h @@ -83,6 +83,38 @@ public: */ void AddBPMSegment( const BPMSegment &seg ); + /** + * @brief Retrieve the next beat that contains a BPMSegment. + * @param iRow the present row. + * @return the next beat with a BPMSegment, or fBeat if there is none ahead. + */ + float GetNextBPMSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a BPMSegment. + * @param fBeat the present beat. + * @return the next beat with a BPMSegment, or fBeat if there is none ahead. + */ + float GetNextBPMSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextBPMSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a BPMSegment. + * @param iRow the present row. + * @return the previous beat with a BPMSegment, or fBeat if there is none prior. + */ + float GetPreviousBPMSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a BPMSegment. + * @param fBeat the present beat. + * @return the previous beat with a BPMSegment, or fBeat if there is none prior. + */ + float GetPreviousBPMSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousBPMSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** * @brief Retrieve the Stop/Delay at the given row. * @param iNoteRow the row in question. @@ -249,6 +281,68 @@ public: */ void AddStopSegment( const StopSegment &seg ); + /** + * @brief Retrieve the next beat that contains a StopSegment. + * @param iRow the present row. + * @return the next beat with a StopSegment, or fBeat if there is none ahead. + */ + float GetNextStopSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a StopSegment. + * @param fBeat the present beat. + * @return the next beat with a StopSegment, or fBeat if there is none ahead. + */ + float GetNextStopSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextStopSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a StopSegment. + * @param iRow the present row. + * @return the previous beat with a StopSegment, or fBeat if there is none prior. + */ + float GetPreviousStopSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a StopSegment. + * @param fBeat the present beat. + * @return the previous beat with a StopSegment, or fBeat if there is none prior. + */ + float GetPreviousStopSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousStopSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** + * @brief Retrieve the next beat that contains a DelaySegment. + * @param iRow the present row. + * @return the next beat with a DelaySegment, or fBeat if there is none ahead. + */ + float GetNextDelaySegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a DelaySegment. + * @param fBeat the present beat. + * @return the next beat with a DelaySegment, or fBeat if there is none ahead. + */ + float GetNextDelaySegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextDelaySegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a DelaySegment. + * @param iRow the present row. + * @return the previous beat with a DelaySegment, or fBeat if there is none prior. + */ + float GetPreviousDelaySegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a DelaySegment. + * @param fBeat the present beat. + * @return the previous beat with a DelaySegment, or fBeat if there is none prior. + */ + float GetPreviousDelaySegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousDelaySegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** * @brief Retrieve the Time Signature's numerator at the given row. * @param iNoteRow the row in question. @@ -345,6 +439,39 @@ public: * @param iRow The row you start on. * @return the beat you warp to. */ + + /** + * @brief Retrieve the next beat that contains a TimeSignatureSegment. + * @param iRow the present row. + * @return the next beat with a TimeSignatureSegment, or fBeat if there is none ahead. + */ + float GetNextTimeSignatureSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a TimeSignatureSegment. + * @param fBeat the present beat. + * @return the next beat with a TimeSignatureSegment, or fBeat if there is none ahead. + */ + float GetNextTimeSignatureSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextTimeSignatureSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a TimeSignatureSegment. + * @param iRow the present row. + * @return the previous beat with a TimeSignatureSegment, or fBeat if there is none prior. + */ + float GetPreviousTimeSignatureSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a TimeSignatureSegment. + * @param fBeat the present beat. + * @return the previous beat with a TimeSignatureSegment, or fBeat if there is none prior. + */ + float GetPreviousTimeSignatureSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousTimeSignatureSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + float GetWarpAtRow( int iRow ) const; /** * @brief Determine the beat to warp to. @@ -405,6 +532,39 @@ public: * @param seg the new WarpSegment. */ void AddWarpSegment( const WarpSegment &seg ); + + + /** + * @brief Retrieve the next beat that contains a WarpSegment. + * @param iRow the present row. + * @return the next beat with a WarpSegment, or fBeat if there is none ahead. + */ + float GetNextWarpSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a WarpSegment. + * @param fBeat the present beat. + * @return the next beat with a WarpSegment, or fBeat if there is none ahead. + */ + float GetNextWarpSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextWarpSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a WarpSegment. + * @param iRow the present row. + * @return the previous beat with a WarpSegment, or fBeat if there is none prior. + */ + float GetPreviousWarpSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a WarpSegment. + * @param fBeat the present beat. + * @return the previous beat with a WarpSegment, or fBeat if there is none prior. + */ + float GetPreviousWarpSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousWarpSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** * @brief Retrieve the Tickcount at the given row. * @param iNoteRow the row in question. @@ -459,6 +619,38 @@ public: */ void AddTickcountSegment( const TickcountSegment &seg ); + /** + * @brief Retrieve the next beat that contains a TickcountSegment. + * @param iRow the present row. + * @return the next beat with a TickcountSegment, or fBeat if there is none ahead. + */ + float GetNextTickcountSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a TickcountSegment. + * @param fBeat the present beat. + * @return the next beat with a TickcountSegment, or fBeat if there is none ahead. + */ + float GetNextTickcountSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextTickcountSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a TickcountSegment. + * @param iRow the present row. + * @return the previous beat with a TickcountSegment, or fBeat if there is none prior. + */ + float GetPreviousTickcountSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a TickcountSegment. + * @param fBeat the present beat. + * @return the previous beat with a TickcountSegment, or fBeat if there is none prior. + */ + float GetPreviousTickcountSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousTickcountSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** * @brief Retrieve the Combo at the given row. * @param iNoteRow the row in question. @@ -513,6 +705,38 @@ public: */ void AddComboSegment( const ComboSegment &seg ); + /** + * @brief Retrieve the next beat that contains a ComboSegment. + * @param iRow the present row. + * @return the next beat with a ComboSegment, or fBeat if there is none ahead. + */ + float GetNextComboSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a ComboSegment. + * @param fBeat the present beat. + * @return the next beat with a ComboSegment, or fBeat if there is none ahead. + */ + float GetNextComboSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextComboSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a ComboSegment. + * @param iRow the present row. + * @return the previous beat with a ComboSegment, or fBeat if there is none prior. + */ + float GetPreviousComboSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a ComboSegment. + * @param fBeat the present beat. + * @return the previous beat with a ComboSegment, or fBeat if there is none prior. + */ + float GetPreviousComboSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousComboSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** * @brief Retrieve the Label at the given row. * @param iNoteRow the row in question. @@ -578,7 +802,10 @@ public: * @param fBeat the present beat. * @return the previous beat with a LabelSegment, or fBeat if there is none prior. */ - float GetPreviousLabelSegmentBeatAtBeat( float fBeat ) const { return GetPreviousLabelSegmentBeatAtRow( BeatToNoteRow(fBeat) ); } + float GetPreviousLabelSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousLabelSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } /** * @brief Determine if the requisite label already exists. @@ -597,7 +824,10 @@ public: * @param fBeat the present beat. * @return the next beat with a LabelSegment, or fBeat if there is none ahead. */ - float GetNextLabelSegmentBeatAtBeat( float fBeat ) const { return GetNextLabelSegmentBeatAtRow( BeatToNoteRow(fBeat) ); } + float GetNextLabelSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextLabelSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } /** @@ -720,6 +950,38 @@ public: float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const; + /** + * @brief Retrieve the next beat that contains a SpeedSegment. + * @param iRow the present row. + * @return the next beat with a SpeedSegment, or fBeat if there is none ahead. + */ + float GetNextSpeedSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a SpeedSegment. + * @param fBeat the present beat. + * @return the next beat with a SpeedSegment, or fBeat if there is none ahead. + */ + float GetNextSpeedSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextSpeedSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a SpeedSegment. + * @param iRow the present row. + * @return the previous beat with a SpeedSegment, or fBeat if there is none prior. + */ + float GetPreviousSpeedSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a SpeedSegment. + * @param fBeat the present beat. + * @return the previous beat with a SpeedSegment, or fBeat if there is none prior. + */ + float GetPreviousSpeedSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousSpeedSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** * @brief Retrieve the scrolling factor at the given row. * @param iNoteRow the row in question. @@ -778,6 +1040,37 @@ public: */ void AddScrollSegment( const ScrollSegment &seg ); + /** + * @brief Retrieve the next beat that contains a ScrollSegment. + * @param iRow the present row. + * @return the next beat with a ScrollSegment, or fBeat if there is none ahead. + */ + float GetNextScrollSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a ScrollSegment. + * @param fBeat the present beat. + * @return the next beat with a ScrollSegment, or fBeat if there is none ahead. + */ + float GetNextScrollSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextScrollSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a ScrollSegment. + * @param iRow the present row. + * @return the previous beat with a ScrollSegment, or fBeat if there is none prior. + */ + float GetPreviousScrollSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a ScrollSegment. + * @param fBeat the present beat. + * @return the previous beat with a ScrollSegment, or fBeat if there is none prior. + */ + float GetPreviousScrollSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousScrollSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** * @brief Determine when the fakes end. @@ -845,6 +1138,38 @@ public: */ void AddFakeSegment( const FakeSegment &seg ); + /** + * @brief Retrieve the next beat that contains a FakeSegment. + * @param iRow the present row. + * @return the next beat with a FakeSegment, or fBeat if there is none ahead. + */ + float GetNextFakeSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a FakeSegment. + * @param fBeat the present beat. + * @return the next beat with a FakeSegment, or fBeat if there is none ahead. + */ + float GetNextFakeSegmentBeatAtBeat( float fBeat ) const + { + return this->GetNextFakeSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + /** + * @brief Retrieve the previous beat that contains a FakeSegment. + * @param iRow the present row. + * @return the previous beat with a FakeSegment, or fBeat if there is none prior. + */ + float GetPreviousFakeSegmentBeatAtRow( int iRow ) const; + /** + * @brief Retrieve the previous beat that contains a FakeSegment. + * @param fBeat the present beat. + * @return the previous beat with a FakeSegment, or fBeat if there is none prior. + */ + float GetPreviousFakeSegmentBeatAtBeat( float fBeat ) const + { + return this->GetPreviousFakeSegmentBeatAtRow( BeatToNoteRow(fBeat) ); + } + + /** * @brief Determine if this notes on this row can be judged. * @param row the row to focus on.