[timing] More abstraction.

This commit has 2 caveats.

1) Stops and Delays are treated the same in the editor right now.
2) TimingSegments.cpp: XToString should not require NUM_TimingSegmentTypes.

Ideas?
This commit is contained in:
Jason Felds
2011-07-14 23:54:06 -04:00
parent 6f5ab98dec
commit 01dacd9746
6 changed files with 86 additions and 757 deletions
+35 -308
View File
@@ -64,6 +64,41 @@ int TimingData::GetSegmentIndexAtRow(TimingSegmentType tst,
return static_cast<int>(i);
}
float TimingData::GetNextSegmentBeatAtRow(TimingSegmentType tst,
int row, bool isDelay) const
{
const vector<TimingSegment *> segs = this->allTimingSegments[tst];
for (unsigned i = 0; i < segs.size(); i++ )
{
if( segs[i]->GetRow() <= row )
{
continue;
}
if (tst != SEGMENT_STOP_DELAY ||
static_cast<StopSegment *>(segs[i])->GetDelay() == isDelay)
return segs[i]->GetBeat();
}
return NoteRowToBeat(row);
}
float TimingData::GetPreviousSegmentBeatAtRow(TimingSegmentType tst,
int row, bool isDelay) const
{
float backup = -1;
const vector<TimingSegment *> segs = this->allTimingSegments[tst];
for (unsigned i = 0; i < segs.size(); i++ )
{
if( segs[i]->GetRow() >= row )
{
break;
}
if (tst != SEGMENT_STOP_DELAY ||
static_cast<StopSegment *>(segs[i])->GetDelay() == isDelay)
backup = segs[i]->GetBeat();
}
return (backup > -1) ? backup : NoteRowToBeat(row);
}
// TODO: Find a way to combine all of these SetAtRows to one.
/* Change an existing BPM segment, merge identical segments together or insert a new one. */
@@ -715,314 +750,6 @@ int TimingData::GetTickcountAtRow( int iRow ) const
return static_cast<TickcountSegment *>(ticks[index])->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.GetRow() >= iRow )
{
break;
}
if (!s.GetDelay())
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.GetRow() <= iRow )
{
continue;
}
if (!s.GetDelay())
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.GetRow() >= iRow )
{
break;
}
if (s.GetDelay())
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.GetRow() <= iRow )
{
continue;
}
if (s.GetDelay())
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;
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
{
if( m_LabelSegments[i].GetRow() >= iRow )
{
break;
}
backup = m_LabelSegments[i].GetBeat();
}
return (backup > -1) ? backup : NoteRowToBeat(iRow);
}
float TimingData::GetNextLabelSegmentBeatAtRow( int iRow ) const
{
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
{
if( m_LabelSegments[i].GetRow() <= iRow )
{
continue;
}
return m_LabelSegments[i].GetBeat();
}
return NoteRowToBeat(iRow);
}
bool TimingData::DoesLabelExist( RString sLabel ) const
{
const vector<TimingSegment *> &labels = this->allTimingSegments[SEGMENT_LABEL];