stage 1 of TimingSegment cleanup: consolidate genericizable code in TimingData, use a proper variable name

This commit is contained in:
Mark Cannon
2011-09-10 03:08:59 +00:00
parent 5c7e13af14
commit 0d4e43f9e3
12 changed files with 239 additions and 542 deletions
+9 -9
View File
@@ -267,7 +267,7 @@ void AdjustSync::AutosyncTempo()
GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += fIntercept; GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += fIntercept;
const float fScaleBPM = 1.0f/(1.0f - fSlope); const float fScaleBPM = 1.0f/(1.0f - fSlope);
TimingData &timing = GAMESTATE->m_pCurSong->m_SongTiming; TimingData &timing = GAMESTATE->m_pCurSong->m_SongTiming;
vector<TimingSegment *> &bpms = timing.allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = timing.m_avpTimingSegments[SEGMENT_BPM];
for (unsigned i = 0; i < bpms.size(); i++) for (unsigned i = 0; i < bpms.size(); i++)
{ {
BPMSegment *b = static_cast<BPMSegment *>(bpms[i]); BPMSegment *b = static_cast<BPMSegment *>(bpms[i]);
@@ -277,14 +277,14 @@ void AdjustSync::AutosyncTempo()
/* We assume that the stops were measured as a number of beats. /* We assume that the stops were measured as a number of beats.
* Therefore, if we change the bpms, we need to make a similar * Therefore, if we change the bpms, we need to make a similar
* change to the stops. */ * change to the stops. */
vector<TimingSegment *> &stops = timing.allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stops = timing.m_avpTimingSegments[SEGMENT_STOP];
for (unsigned i = 0; i < stops.size(); i++) for (unsigned i = 0; i < stops.size(); i++)
{ {
StopSegment *s = static_cast<StopSegment *>(stops[i]); StopSegment *s = static_cast<StopSegment *>(stops[i]);
s->SetPause(s->GetPause() * (1.0f - fSlope)); s->SetPause(s->GetPause() * (1.0f - fSlope));
} }
// Do the same for delays. // Do the same for delays.
vector<TimingSegment *> &delays = timing.allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &delays = timing.m_avpTimingSegments[SEGMENT_DELAY];
for (unsigned i = 0; i < delays.size(); i++) for (unsigned i = 0; i < delays.size(); i++)
{ {
DelaySegment *s = static_cast<DelaySegment *>(delays[i]); DelaySegment *s = static_cast<DelaySegment *>(delays[i]);
@@ -359,8 +359,8 @@ void AdjustSync::GetSyncChangeTextSong( vector<RString> &vsAddTo )
} }
} }
vector<TimingSegment *> &bpmTest = testing.allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpmTest = testing.m_avpTimingSegments[SEGMENT_BPM];
vector<TimingSegment *> &bpmOrig = original.allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpmOrig = original.m_avpTimingSegments[SEGMENT_BPM];
for( unsigned i=0; i< bpmTest.size(); i++ ) for( unsigned i=0; i< bpmTest.size(); i++ )
{ {
BPMSegment *bT = static_cast<BPMSegment *>(bpmTest[i]); BPMSegment *bT = static_cast<BPMSegment *>(bpmTest[i]);
@@ -384,8 +384,8 @@ void AdjustSync::GetSyncChangeTextSong( vector<RString> &vsAddTo )
} }
} }
vector<TimingSegment *> &stopTest = testing.allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stopTest = testing.m_avpTimingSegments[SEGMENT_STOP];
vector<TimingSegment *> &stopOrig = original.allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stopOrig = original.m_avpTimingSegments[SEGMENT_STOP];
for( unsigned i=0; i< stopTest.size(); i++ ) for( unsigned i=0; i< stopTest.size(); i++ )
{ {
StopSegment *sT = static_cast<StopSegment *>(stopTest[i]); StopSegment *sT = static_cast<StopSegment *>(stopTest[i]);
@@ -409,8 +409,8 @@ void AdjustSync::GetSyncChangeTextSong( vector<RString> &vsAddTo )
} }
} }
vector<TimingSegment *> &delyTest = testing.allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &delyTest = testing.m_avpTimingSegments[SEGMENT_DELAY];
vector<TimingSegment *> &delyOrig = original.allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &delyOrig = original.m_avpTimingSegments[SEGMENT_DELAY];
for( unsigned i=0; i< delyTest.size(); i++ ) for( unsigned i=0; i< delyTest.size(); i++ )
{ {
DelaySegment *sT = static_cast<DelaySegment *>(delyTest[i]); DelaySegment *sT = static_cast<DelaySegment *>(delyTest[i]);
+2 -2
View File
@@ -421,7 +421,7 @@ void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const Bac
const TimingData &timing = m_pSong->m_SongTiming; const TimingData &timing = m_pSong->m_SongTiming;
// change BG every time signature change or 4 measures // change BG every time signature change or 4 measures
const vector<TimingSegment *> &tSigs = timing.allTimingSegments[SEGMENT_TIME_SIG]; const vector<TimingSegment *> &tSigs = timing.m_avpTimingSegments[SEGMENT_TIME_SIG];
for (unsigned i = 0; i < tSigs.size(); i++) for (unsigned i = 0; i < tSigs.size(); i++)
{ {
@@ -448,7 +448,7 @@ void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const Bac
} }
// change BG every BPM change that is at the beginning of a measure // change BG every BPM change that is at the beginning of a measure
const vector<TimingSegment *> &bpms = timing.allTimingSegments[SEGMENT_BPM]; const vector<TimingSegment *> &bpms = timing.m_avpTimingSegments[SEGMENT_BPM];
for( unsigned i=0; i<bpms.size(); i++ ) for( unsigned i=0; i<bpms.size(); i++ )
{ {
bool bAtBeginningOfMeasure = false; bool bAtBeginningOfMeasure = false;
+1 -1
View File
@@ -856,7 +856,7 @@ void NoteField::DrawPrimitives()
} }
const TimingData *pTiming = GetDisplayedTiming(m_pPlayerState); const TimingData *pTiming = GetDisplayedTiming(m_pPlayerState);
const vector<TimingSegment *> *segs = pTiming->allTimingSegments; const vector<TimingSegment *> *segs = pTiming->m_avpTimingSegments;
unsigned i = 0; unsigned i = 0;
// Draw beat bars // Draw beat bars
if( ( GAMESTATE->IsEditing() || SHOW_BEAT_BARS ) && pTiming != NULL ) if( ( GAMESTATE->IsEditing() || SHOW_BEAT_BARS ) && pTiming != NULL )
+2 -2
View File
@@ -41,8 +41,8 @@ static void Deserialize(TimingSegment &seg_, const Json::Value &root)
static void Deserialize(TimingData &td, const Json::Value &root) static void Deserialize(TimingData &td, const Json::Value &root)
{ {
JsonUtil::DeserializeVectorPointers( td.allTimingSegments[SEGMENT_BPM], Deserialize, root["BpmSegments"] ); JsonUtil::DeserializeVectorPointers( td.m_avpTimingSegments[SEGMENT_BPM], Deserialize, root["BpmSegments"] );
JsonUtil::DeserializeVectorPointers( td.allTimingSegments[SEGMENT_STOP], Deserialize, root["StopSegments"] ); JsonUtil::DeserializeVectorPointers( td.m_avpTimingSegments[SEGMENT_STOP], Deserialize, root["StopSegments"] );
} }
static void Deserialize(LyricSegment &o, const Json::Value &root) static void Deserialize(LyricSegment &o, const Json::Value &root)
+1 -1
View File
@@ -927,7 +927,7 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache
} }
// Ensure all warps from negative time changes are in order. // Ensure all warps from negative time changes are in order.
vector<TimingSegment *> &warps = out.m_SongTiming.allTimingSegments[SEGMENT_WARP]; vector<TimingSegment *> &warps = out.m_SongTiming.m_avpTimingSegments[SEGMENT_WARP];
sort(warps.begin(), warps.end()); sort(warps.begin(), warps.end());
TidyUpData( out, bFromCache ); TidyUpData( out, bFromCache );
return true; return true;
+2 -2
View File
@@ -354,7 +354,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
f.PutLine( ssprintf("#TITLE:%s;", DwiEscape(out.GetTranslitFullTitle()).c_str()) ); f.PutLine( ssprintf("#TITLE:%s;", DwiEscape(out.GetTranslitFullTitle()).c_str()) );
f.PutLine( ssprintf("#ARTIST:%s;", DwiEscape(out.GetTranslitArtist()).c_str()) ); f.PutLine( ssprintf("#ARTIST:%s;", DwiEscape(out.GetTranslitArtist()).c_str()) );
const vector<TimingSegment *> &bpms = out.m_SongTiming.allTimingSegments[SEGMENT_BPM]; const vector<TimingSegment *> &bpms = out.m_SongTiming.m_avpTimingSegments[SEGMENT_BPM];
ASSERT_M(bpms[0]->GetRow() == 0, ASSERT_M(bpms[0]->GetRow() == 0,
ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) ); ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) );
@@ -382,7 +382,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
} }
// TODO: Also check for delays, add them as stops minus one row? // TODO: Also check for delays, add them as stops minus one row?
const vector<TimingSegment *> &stops = out.m_SongTiming.allTimingSegments[SEGMENT_STOP]; const vector<TimingSegment *> &stops = out.m_SongTiming.m_avpTimingSegments[SEGMENT_STOP];
if( !stops.empty() ) if( !stops.empty() )
{ {
f.Write( "#FREEZE:" ); f.Write( "#FREEZE:" );
+2 -2
View File
@@ -24,8 +24,8 @@ static void Serialize(const TimingSegment &seg, Json::Value &root)
static void Serialize(const TimingData &td, Json::Value &root) static void Serialize(const TimingData &td, Json::Value &root)
{ {
JsonUtil::SerializeVectorPointers( td.allTimingSegments[SEGMENT_BPM], Serialize, root["BpmSegments"] ); JsonUtil::SerializeVectorPointers( td.m_avpTimingSegments[SEGMENT_BPM], Serialize, root["BpmSegments"] );
JsonUtil::SerializeVectorPointers( td.allTimingSegments[SEGMENT_STOP], Serialize, root["StopSegments"] ); JsonUtil::SerializeVectorPointers( td.m_avpTimingSegments[SEGMENT_STOP], Serialize, root["StopSegments"] );
} }
static void Serialize(const LyricSegment &o, Json::Value &root) static void Serialize(const LyricSegment &o, Json::Value &root)
+4 -4
View File
@@ -75,7 +75,7 @@ static void WriteGlobalTags( RageFile &f, Song &out )
f.Write( "#BPMS:" ); f.Write( "#BPMS:" );
vector<TimingSegment *> &bpms = timing.allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = timing.m_avpTimingSegments[SEGMENT_BPM];
for( unsigned i=0; i<bpms.size(); i++ ) for( unsigned i=0; i<bpms.size(); i++ )
{ {
const BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]); const BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]);
@@ -86,7 +86,7 @@ static void WriteGlobalTags( RageFile &f, Song &out )
} }
f.PutLine( ";" ); f.PutLine( ";" );
vector<TimingSegment *> &warps = timing.allTimingSegments[SEGMENT_WARP]; vector<TimingSegment *> &warps = timing.m_avpTimingSegments[SEGMENT_WARP];
unsigned wSize = warps.size(); unsigned wSize = warps.size();
if( wSize > 0 ) if( wSize > 0 )
{ {
@@ -102,8 +102,8 @@ static void WriteGlobalTags( RageFile &f, Song &out )
} }
// TODO: make Delays into Stops that start one row before. // TODO: make Delays into Stops that start one row before.
vector<TimingSegment *> &stops = timing.allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stops = timing.m_avpTimingSegments[SEGMENT_STOP];
vector<TimingSegment *> &delays = timing.allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &delays = timing.m_avpTimingSegments[SEGMENT_DELAY];
map<float, float> allPauses; map<float, float> allPauses;
for( unsigned i=0; i<stops.size(); i++ ) for( unsigned i=0; i<stops.size(); i++ )
+11 -11
View File
@@ -68,7 +68,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
unsigned i = 0; unsigned i = 0;
w.Init( "BPMS" ); w.Init( "BPMS" );
vector<TimingSegment *> &bpms = timing.allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = timing.m_avpTimingSegments[SEGMENT_BPM];
for (; i < bpms.size(); i++) for (; i < bpms.size(); i++)
{ {
BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]); BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]);
@@ -77,7 +77,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Finish(); w.Finish();
w.Init( "STOPS" ); w.Init( "STOPS" );
vector<TimingSegment *> &stops = timing.allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stops = timing.m_avpTimingSegments[SEGMENT_STOP];
for (i = 0; i < stops.size(); i++) for (i = 0; i < stops.size(); i++)
{ {
StopSegment *ss = static_cast<StopSegment *>(stops[i]); StopSegment *ss = static_cast<StopSegment *>(stops[i]);
@@ -86,7 +86,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Finish(); w.Finish();
w.Init( "DELAYS" ); w.Init( "DELAYS" );
vector<TimingSegment *> &delays = timing.allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &delays = timing.m_avpTimingSegments[SEGMENT_DELAY];
for (i = 0; i < delays.size(); i++) for (i = 0; i < delays.size(); i++)
{ {
DelaySegment *ss = static_cast<DelaySegment *>(delays[i]); DelaySegment *ss = static_cast<DelaySegment *>(delays[i]);
@@ -95,7 +95,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Finish(); w.Finish();
w.Init( "WARPS" ); w.Init( "WARPS" );
vector<TimingSegment *> &warps = timing.allTimingSegments[SEGMENT_WARP]; vector<TimingSegment *> &warps = timing.m_avpTimingSegments[SEGMENT_WARP];
for (i = 0; i < warps.size(); i++) for (i = 0; i < warps.size(); i++)
{ {
WarpSegment *ws = static_cast<WarpSegment *>(warps[i]); WarpSegment *ws = static_cast<WarpSegment *>(warps[i]);
@@ -103,7 +103,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
} }
w.Finish(); w.Finish();
vector<TimingSegment *> &tSigs = timing.allTimingSegments[SEGMENT_TIME_SIG]; vector<TimingSegment *> &tSigs = timing.m_avpTimingSegments[SEGMENT_TIME_SIG];
ASSERT( !tSigs.empty() ); ASSERT( !tSigs.empty() );
w.Init( "TIMESIGNATURES" ); w.Init( "TIMESIGNATURES" );
for (i = 0; i < tSigs.size(); i++) for (i = 0; i < tSigs.size(); i++)
@@ -113,7 +113,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
} }
w.Finish(); w.Finish();
vector<TimingSegment *> &ticks = timing.allTimingSegments[SEGMENT_TICKCOUNT]; vector<TimingSegment *> &ticks = timing.m_avpTimingSegments[SEGMENT_TICKCOUNT];
ASSERT( !ticks.empty() ); ASSERT( !ticks.empty() );
w.Init( "TICKCOUNTS" ); w.Init( "TICKCOUNTS" );
for (i = 0; i < ticks.size(); i++) for (i = 0; i < ticks.size(); i++)
@@ -123,7 +123,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
} }
w.Finish(); w.Finish();
vector<TimingSegment *> &combos = timing.allTimingSegments[SEGMENT_COMBO]; vector<TimingSegment *> &combos = timing.m_avpTimingSegments[SEGMENT_COMBO];
ASSERT( !combos.empty() ); ASSERT( !combos.empty() );
w.Init( "COMBOS" ); w.Init( "COMBOS" );
for (i = 0; i < combos.size(); i++) for (i = 0; i < combos.size(); i++)
@@ -137,7 +137,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Finish(); w.Finish();
// Song Timing should only have the initial value. // Song Timing should only have the initial value.
vector<TimingSegment *> &speeds = timing.allTimingSegments[SEGMENT_SPEED]; vector<TimingSegment *> &speeds = timing.m_avpTimingSegments[SEGMENT_SPEED];
w.Init( "SPEEDS" ); w.Init( "SPEEDS" );
for (i = 0; i < speeds.size(); i++) for (i = 0; i < speeds.size(); i++)
{ {
@@ -147,7 +147,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Finish(); w.Finish();
w.Init( "SCROLLS" ); w.Init( "SCROLLS" );
vector<TimingSegment *> &scrolls = timing.allTimingSegments[SEGMENT_SCROLL]; vector<TimingSegment *> &scrolls = timing.m_avpTimingSegments[SEGMENT_SCROLL];
for (i = 0; i < scrolls.size(); i++) for (i = 0; i < scrolls.size(); i++)
{ {
ScrollSegment *ss = static_cast<ScrollSegment *>(scrolls[i]); ScrollSegment *ss = static_cast<ScrollSegment *>(scrolls[i]);
@@ -157,7 +157,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
if( !bIsSong ) if( !bIsSong )
{ {
vector<TimingSegment *> &fakes = timing.allTimingSegments[SEGMENT_FAKE]; vector<TimingSegment *> &fakes = timing.m_avpTimingSegments[SEGMENT_FAKE];
w.Init( "FAKES" ); w.Init( "FAKES" );
for (i = 0; i < fakes.size(); i++) for (i = 0; i < fakes.size(); i++)
{ {
@@ -168,7 +168,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
} }
w.Init( "LABELS" ); w.Init( "LABELS" );
vector<TimingSegment *> &labels = timing.allTimingSegments[SEGMENT_LABEL]; vector<TimingSegment *> &labels = timing.m_avpTimingSegments[SEGMENT_LABEL];
for (i = 0; i < labels.size(); i++) for (i = 0; i < labels.size(); i++)
{ {
LabelSegment *ls = static_cast<LabelSegment *>(labels[i]); LabelSegment *ls = static_cast<LabelSegment *>(labels[i]);
+6 -6
View File
@@ -1893,7 +1893,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
fDelta *= 40; fDelta *= 40;
} }
unsigned i; unsigned i;
vector<TimingSegment *> &stops = GetAppropriateTiming().allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stops = GetAppropriateTiming().m_avpTimingSegments[SEGMENT_STOP];
for( i=0; i<stops.size(); i++ ) for( i=0; i<stops.size(); i++ )
{ {
if( stops[i]->GetRow() == GetRow() ) if( stops[i]->GetRow() == GetRow() )
@@ -4315,10 +4315,10 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector<int> &iAns
{ {
/* TODO: Maybe wipe out the already there timing data first? /* TODO: Maybe wipe out the already there timing data first?
* We need to identify the max row within the timing data first. */ * We need to identify the max row within the timing data first. */
for (unsigned i = 0; i < this->clipboardTiming.allTimingSegments[tst].size(); i++) for (unsigned i = 0; i < this->clipboardTiming.m_avpTimingSegments[tst].size(); i++)
{ {
// TODO: This REALLY needs improving. // TODO: This REALLY needs improving.
TimingSegment * org = this->clipboardTiming.allTimingSegments[tst][i]; TimingSegment * org = this->clipboardTiming.m_avpTimingSegments[tst][i];
TimingSegment * cpy; TimingSegment * cpy;
switch (tst) switch (tst)
@@ -4665,7 +4665,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice
break; break;
case time_signature: case time_signature:
{ {
TimeSignatureSegment * ts = GetAppropriateTiming().GetTimeSignatureSegmentAtBeat( GetBeat() ); const TimeSignatureSegment *ts = GetAppropriateTiming().GetTimeSignatureSegmentAtBeat( GetBeat() );
ScreenTextEntry::TextEntry( ScreenTextEntry::TextEntry(
SM_BackFromTimeSignatureChange, SM_BackFromTimeSignatureChange,
ENTER_TIME_SIGNATURE_VALUE, ENTER_TIME_SIGNATURE_VALUE,
@@ -4684,7 +4684,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice
break; break;
case combo: case combo:
{ {
ComboSegment *cs = GetAppropriateTiming().GetComboSegmentAtBeat(GetBeat()); const ComboSegment *cs = GetAppropriateTiming().GetComboSegmentAtBeat(GetBeat());
ScreenTextEntry::TextEntry(SM_BackFromComboChange, ScreenTextEntry::TextEntry(SM_BackFromComboChange,
ENTER_COMBO_VALUE, ENTER_COMBO_VALUE,
ssprintf( "%d/%d", ssprintf( "%d/%d",
@@ -4999,7 +4999,7 @@ void ScreenEdit::CheckNumberOfNotesAndUndo()
if( EDIT_MODE.GetValue() != EditMode_Home ) if( EDIT_MODE.GetValue() != EditMode_Home )
return; return;
TimeSignatureSegment * curTime = GAMESTATE->m_pCurSong->m_SongTiming.GetTimeSignatureSegmentAtBeat( GAMESTATE->m_pPlayerState[PLAYER_1]->m_Position.m_fSongBeat ); const TimeSignatureSegment * curTime = GAMESTATE->m_pCurSong->m_SongTiming.GetTimeSignatureSegmentAtBeat( GAMESTATE->m_pPlayerState[PLAYER_1]->m_Position.m_fSongBeat );
int rowsPerMeasure = curTime->GetDen() * curTime->GetNum(); int rowsPerMeasure = curTime->GetDen() * curTime->GetNum();
for( int row=0; row<=m_NoteDataEdit.GetLastRow(); row+=rowsPerMeasure ) for( int row=0; row<=m_NoteDataEdit.GetLastRow(); row+=rowsPerMeasure )
+106 -196
View File
@@ -8,8 +8,7 @@
#include <float.h> #include <float.h>
TimingData::TimingData(float fOffset) : TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset)
m_fBeat0OffsetInSeconds(fOffset)
{ {
} }
@@ -21,7 +20,7 @@ bool TimingData::empty() const
{ {
for (unsigned i = 0; i < NUM_TimingSegmentType; i++) for (unsigned i = 0; i < NUM_TimingSegmentType; i++)
{ {
if (this->allTimingSegments[i].size() > 0) if (m_avpTimingSegments[i].size() > 0)
return false; return false;
} }
return true; return true;
@@ -34,13 +33,13 @@ TimingData TimingData::CopyRange(int startRow, int endRow) const
FOREACH_ENUM(TimingSegmentType, tst) FOREACH_ENUM(TimingSegmentType, tst)
{ {
unsigned cnt = 0; unsigned cnt = 0;
for (unsigned j = 0; j < this->allTimingSegments[tst].size(); j++) for (unsigned j = 0; j < m_avpTimingSegments[tst].size(); j++)
{ {
int row = this->allTimingSegments[tst][j]->GetRow(); int row = m_avpTimingSegments[tst][j]->GetRow();
if (row >= startRow && row < endRow) if (row >= startRow && row < endRow)
{ {
// TODO: This REALLY needs improving. // TODO: This REALLY needs improving.
TimingSegment * org = this->allTimingSegments[tst][j]; TimingSegment * org = m_avpTimingSegments[tst][j];
TimingSegment * cpy; TimingSegment * cpy;
switch (tst) switch (tst)
@@ -117,7 +116,7 @@ void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut, float highe
{ {
fMinBPMOut = FLT_MAX; fMinBPMOut = FLT_MAX;
fMaxBPMOut = 0; fMaxBPMOut = 0;
const vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; const vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
for (unsigned i = 0; i < bpms.size(); i++) for (unsigned i = 0; i < bpms.size(); i++)
{ {
BPMSegment *seg = static_cast<BPMSegment *>(bpms[i]); BPMSegment *seg = static_cast<BPMSegment *>(bpms[i]);
@@ -135,31 +134,14 @@ struct ts_less : binary_function <TimingSegment *, TimingSegment *, bool> {
void TimingData::AddSegment(TimingSegmentType tst, TimingSegment * seg) void TimingData::AddSegment(TimingSegmentType tst, TimingSegment * seg)
{ {
vector<TimingSegment *> &segs = this->allTimingSegments[tst]; vector<TimingSegment *> &segs = m_avpTimingSegments[tst];
// Unsure if this uses the proper comparison. // Unsure if this uses the proper comparison.
segs.insert(upper_bound(segs.begin(), segs.end(), seg, ts_less()), seg); segs.insert(upper_bound(segs.begin(), segs.end(), seg, ts_less()), seg);
} }
int TimingData::GetSegmentIndexAtRow(TimingSegmentType tst, float TimingData::GetNextSegmentBeatAtRow(TimingSegmentType tst, int row) const
int row) const
{ {
const vector<TimingSegment *> &segs = this->allTimingSegments[tst]; const vector<TimingSegment *> segs = m_avpTimingSegments[tst];
unsigned i = 0;
for (; i < segs.size() - 1; i++)
{
TimingSegment *seg = segs[i+1];
if (seg->GetRow() > row)
{
break;
}
}
return static_cast<int>(i);
}
float TimingData::GetNextSegmentBeatAtRow(TimingSegmentType tst,
int row) const
{
const vector<TimingSegment *> segs = this->allTimingSegments[tst];
for (unsigned i = 0; i < segs.size(); i++ ) for (unsigned i = 0; i < segs.size(); i++ )
{ {
if( segs[i]->GetRow() <= row ) if( segs[i]->GetRow() <= row )
@@ -171,11 +153,10 @@ float TimingData::GetNextSegmentBeatAtRow(TimingSegmentType tst,
return NoteRowToBeat(row); return NoteRowToBeat(row);
} }
float TimingData::GetPreviousSegmentBeatAtRow(TimingSegmentType tst, float TimingData::GetPreviousSegmentBeatAtRow(TimingSegmentType tst, int row) const
int row) const
{ {
float backup = -1; float backup = -1;
const vector<TimingSegment *> segs = this->allTimingSegments[tst]; const vector<TimingSegment *> segs = m_avpTimingSegments[tst];
for (unsigned i = 0; i < segs.size(); i++ ) for (unsigned i = 0; i < segs.size(); i++ )
{ {
if( segs[i]->GetRow() >= row ) if( segs[i]->GetRow() >= row )
@@ -187,13 +168,28 @@ float TimingData::GetPreviousSegmentBeatAtRow(TimingSegmentType tst,
return (backup > -1) ? backup : NoteRowToBeat(row); return (backup > -1) ? backup : NoteRowToBeat(row);
} }
unsigned TimingData::GetSegmentIndexAtRow(TimingSegmentType tst, int iRow ) const
{
const vector<TimingSegment*> &vSegments = m_avpTimingSegments[tst];
unsigned i = 0;
// seek to the last segment that goes into effect before iRow.
// OPTIMIZATION OPPORTUNITY: use std::upper_bound instead?
for( ; i < vSegments.size() - 1; ++i )
if( iRow < vSegments[i+1]->GetRow() )
break;
return i;
}
// TODO: Find a way to combine all of these SetAtRows to one. // 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. */ /* Change an existing BPM segment, merge identical segments together or insert a new one. */
void TimingData::SetBPMAtRow( int iNoteRow, float fBPM ) void TimingData::SetBPMAtRow( int iNoteRow, float fBPM )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
for( i=0; i<bpms.size(); i++ ) for( i=0; i<bpms.size(); i++ )
if( bpms[i]->GetRow() >= iNoteRow ) if( bpms[i]->GetRow() >= iNoteRow )
break; break;
@@ -219,7 +215,7 @@ void TimingData::SetBPMAtRow( int iNoteRow, float fBPM )
void TimingData::SetStopAtRow( int iRow, float fSeconds ) void TimingData::SetStopAtRow( int iRow, float fSeconds )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_STOP]; vector<TimingSegment *> &stops = m_avpTimingSegments[SEGMENT_STOP];
for( i=0; i<stops.size(); i++ ) for( i=0; i<stops.size(); i++ )
if (stops[i]->GetRow() == iRow) if (stops[i]->GetRow() == iRow)
break; break;
@@ -247,7 +243,7 @@ void TimingData::SetStopAtRow( int iRow, float fSeconds )
void TimingData::SetDelayAtRow( int iRow, float fSeconds ) void TimingData::SetDelayAtRow( int iRow, float fSeconds )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_DELAY]; vector<TimingSegment *> &stops = m_avpTimingSegments[SEGMENT_DELAY];
for( i=0; i<stops.size(); i++ ) for( i=0; i<stops.size(); i++ )
if (stops[i]->GetRow() == iRow) if (stops[i]->GetRow() == iRow)
break; break;
@@ -275,7 +271,7 @@ void TimingData::SetDelayAtRow( int iRow, float fSeconds )
void TimingData::SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominator ) void TimingData::SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominator )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &tSigs = this->allTimingSegments[SEGMENT_TIME_SIG]; vector<TimingSegment *> &tSigs = m_avpTimingSegments[SEGMENT_TIME_SIG];
for( i = 0; i < tSigs.size(); i++ ) for( i = 0; i < tSigs.size(); i++ )
{ {
if( tSigs[i]->GetRow() >= iRow) if( tSigs[i]->GetRow() >= iRow)
@@ -304,24 +300,22 @@ void TimingData::SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominat
} }
} }
void TimingData::SetTimeSignatureNumeratorAtRow( int iRow, int iNumerator ) void TimingData::SetTimeSignatureNumeratorAtRow( int iRow, int iNum )
{ {
this->SetTimeSignatureAtRow(iRow, unsigned iDenom = GetTimeSignatureSegmentAtRow(iRow)->GetDen();
iNumerator, SetTimeSignatureAtRow(iRow, iNum, iDenom );
GetTimeSignatureSegmentAtRow(iRow)->GetDen());
} }
void TimingData::SetTimeSignatureDenominatorAtRow( int iRow, int iDenominator ) void TimingData::SetTimeSignatureDenominatorAtRow( int iRow, int iDenom )
{ {
this->SetTimeSignatureAtRow(iRow, unsigned iNum = GetTimeSignatureSegmentAtRow(iRow)->GetNum();
GetTimeSignatureSegmentAtRow(iRow)->GetNum(), SetTimeSignatureAtRow( iRow, iNum, iDenom );
iDenominator);
} }
void TimingData::SetWarpAtRow( int iRow, float fNew ) void TimingData::SetWarpAtRow( int iRow, float fNew )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &warps = this->allTimingSegments[SEGMENT_WARP]; vector<TimingSegment *> &warps = m_avpTimingSegments[SEGMENT_WARP];
for( i=0; i<warps.size(); i++ ) for( i=0; i<warps.size(); i++ )
if( warps[i]->GetRow() == iRow ) if( warps[i]->GetRow() == iRow )
break; break;
@@ -348,7 +342,7 @@ void TimingData::SetWarpAtRow( int iRow, float fNew )
void TimingData::SetTickcountAtRow( int iRow, int iTicks ) void TimingData::SetTickcountAtRow( int iRow, int iTicks )
{ {
unsigned i = 0; unsigned i = 0;
vector<TimingSegment *> &ticks = this->allTimingSegments[SEGMENT_TICKCOUNT]; vector<TimingSegment *> &ticks = m_avpTimingSegments[SEGMENT_TICKCOUNT];
for( i=0; i<ticks.size(); i++ ) for( i=0; i<ticks.size(); i++ )
if( ticks[i]->GetRow() >= iRow ) if( ticks[i]->GetRow() >= iRow )
break; break;
@@ -373,7 +367,7 @@ void TimingData::SetTickcountAtRow( int iRow, int iTicks )
void TimingData::SetComboAtRow( int iRow, int iCombo, int iMiss ) void TimingData::SetComboAtRow( int iRow, int iCombo, int iMiss )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &combos = this->allTimingSegments[SEGMENT_COMBO]; vector<TimingSegment *> &combos = m_avpTimingSegments[SEGMENT_COMBO];
for( i=0; i<combos.size(); i++ ) for( i=0; i<combos.size(); i++ )
if( combos[i]->GetRow() >= iRow ) if( combos[i]->GetRow() >= iRow )
break; break;
@@ -401,22 +395,22 @@ void TimingData::SetComboAtRow( int iRow, int iCombo, int iMiss )
void TimingData::SetHitComboAtRow(int iRow, int iCombo) void TimingData::SetHitComboAtRow(int iRow, int iCombo)
{ {
this->SetComboAtRow(iRow, SetComboAtRow(iRow,
iCombo, iCombo,
this->GetComboSegmentAtRow(iRow)->GetMissCombo()); GetComboSegmentAtRow(iRow)->GetMissCombo());
} }
void TimingData::SetMissComboAtRow(int iRow, int iMiss) void TimingData::SetMissComboAtRow(int iRow, int iMiss)
{ {
this->SetComboAtRow(iRow, SetComboAtRow(iRow,
this->GetComboSegmentAtRow(iRow)->GetCombo(), GetComboSegmentAtRow(iRow)->GetCombo(),
iMiss); iMiss);
} }
void TimingData::SetLabelAtRow( int iRow, const RString sLabel ) void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &labels = this->allTimingSegments[SEGMENT_LABEL]; vector<TimingSegment *> &labels = m_avpTimingSegments[SEGMENT_LABEL];
for( i=0; i<labels.size(); i++ ) for( i=0; i<labels.size(); i++ )
if( labels[i]->GetRow() >= iRow ) if( labels[i]->GetRow() >= iRow )
break; break;
@@ -441,7 +435,7 @@ void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned short usMode ) void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned short usMode )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &speeds = this->allTimingSegments[SEGMENT_SPEED]; vector<TimingSegment *> &speeds = m_avpTimingSegments[SEGMENT_SPEED];
for( i = 0; i < speeds.size(); i++ ) for( i = 0; i < speeds.size(); i++ )
{ {
if( speeds[i]->GetRow() >= iRow) if( speeds[i]->GetRow() >= iRow)
@@ -473,7 +467,7 @@ void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned
void TimingData::SetScrollAtRow( int iRow, float fPercent ) void TimingData::SetScrollAtRow( int iRow, float fPercent )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &scrolls = this->allTimingSegments[SEGMENT_SCROLL]; vector<TimingSegment *> &scrolls = m_avpTimingSegments[SEGMENT_SCROLL];
for( i = 0; i < scrolls.size(); i++ ) for( i = 0; i < scrolls.size(); i++ )
{ {
if( scrolls[i]->GetRow() >= iRow) if( scrolls[i]->GetRow() >= iRow)
@@ -503,7 +497,7 @@ void TimingData::SetScrollAtRow( int iRow, float fPercent )
void TimingData::SetFakeAtRow( int iRow, float fNew ) void TimingData::SetFakeAtRow( int iRow, float fNew )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &fakes = this->allTimingSegments[SEGMENT_FAKE]; vector<TimingSegment *> &fakes = m_avpTimingSegments[SEGMENT_FAKE];
for( i=0; i<fakes.size(); i++ ) for( i=0; i<fakes.size(); i++ )
if( fakes[i]->GetRow() == iRow ) if( fakes[i]->GetRow() == iRow )
break; break;
@@ -552,7 +546,7 @@ void TimingData::SetSpeedModeAtRow( int iRow, unsigned short usMode )
float TimingData::GetStopAtRow( int iRow ) const float TimingData::GetStopAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_STOP]; const vector<TimingSegment *> &stops = m_avpTimingSegments[SEGMENT_STOP];
for( unsigned i=0; i<stops.size(); i++ ) for( unsigned i=0; i<stops.size(); i++ )
{ {
const StopSegment *s = static_cast<StopSegment *>(stops[i]); const StopSegment *s = static_cast<StopSegment *>(stops[i]);
@@ -567,7 +561,7 @@ float TimingData::GetStopAtRow( int iRow ) const
float TimingData::GetDelayAtRow( int iRow ) const float TimingData::GetDelayAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_DELAY]; const vector<TimingSegment *> &stops = m_avpTimingSegments[SEGMENT_DELAY];
for( unsigned i=0; i<stops.size(); i++ ) for( unsigned i=0; i<stops.size(); i++ )
{ {
const DelaySegment *s = static_cast<DelaySegment *>(stops[i]); const DelaySegment *s = static_cast<DelaySegment *>(stops[i]);
@@ -581,28 +575,28 @@ float TimingData::GetDelayAtRow( int iRow ) const
int TimingData::GetComboAtRow( int iNoteRow ) const int TimingData::GetComboAtRow( int iNoteRow ) const
{ {
const vector<TimingSegment *> &c = this->allTimingSegments[SEGMENT_COMBO]; const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO];
const int index = this->GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow); const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow);
return static_cast<ComboSegment *>(c[index])->GetCombo(); return static_cast<ComboSegment *>(c[index])->GetCombo();
} }
int TimingData::GetMissComboAtRow(int iNoteRow) const int TimingData::GetMissComboAtRow(int iNoteRow) const
{ {
const vector<TimingSegment *> &c = this->allTimingSegments[SEGMENT_COMBO]; const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO];
const int index = this->GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow); const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow);
return static_cast<ComboSegment *>(c[index])->GetMissCombo(); return static_cast<ComboSegment *>(c[index])->GetMissCombo();
} }
RString TimingData::GetLabelAtRow( int iRow ) const RString TimingData::GetLabelAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &l = this->allTimingSegments[SEGMENT_LABEL]; const vector<TimingSegment *> &l = m_avpTimingSegments[SEGMENT_LABEL];
const int index = this->GetSegmentIndexAtRow(SEGMENT_LABEL, iRow); const int index = GetSegmentIndexAtRow(SEGMENT_LABEL, iRow);
return static_cast<LabelSegment *>(l[index])->GetLabel(); return static_cast<LabelSegment *>(l[index])->GetLabel();
} }
float TimingData::GetWarpAtRow( int iWarpRow ) const float TimingData::GetWarpAtRow( int iWarpRow ) const
{ {
const vector<TimingSegment *> &warps = this->allTimingSegments[SEGMENT_WARP]; const vector<TimingSegment *> &warps = m_avpTimingSegments[SEGMENT_WARP];
for( unsigned i=0; i<warps.size(); i++ ) for( unsigned i=0; i<warps.size(); i++ )
{ {
if( warps[i]->GetRow() == iWarpRow ) if( warps[i]->GetRow() == iWarpRow )
@@ -635,7 +629,7 @@ float TimingData::GetScrollAtRow( int iRow )
float TimingData::GetFakeAtRow( int iFakeRow ) const float TimingData::GetFakeAtRow( int iFakeRow ) const
{ {
const vector<TimingSegment *> &fakes = this->allTimingSegments[SEGMENT_FAKE]; const vector<TimingSegment *> &fakes = m_avpTimingSegments[SEGMENT_FAKE];
for( unsigned i=0; i<fakes.size(); i++ ) for( unsigned i=0; i<fakes.size(); i++ )
{ {
if( fakes[i]->GetRow() == iFakeRow ) if( fakes[i]->GetRow() == iFakeRow )
@@ -650,7 +644,7 @@ float TimingData::GetFakeAtRow( int iFakeRow ) const
void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor ) void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor )
{ {
// Change all other BPM segments in this range. // Change all other BPM segments in this range.
vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
for( unsigned i=0; i<bpms.size(); i++ ) for( unsigned i=0; i<bpms.size(); i++ )
{ {
BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]); BPMSegment *bs = static_cast<BPMSegment *>(bpms[i]);
@@ -692,7 +686,7 @@ void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float f
float TimingData::GetBPMAtRow( int iNoteRow ) const float TimingData::GetBPMAtRow( int iNoteRow ) const
{ {
unsigned i; unsigned i;
const vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; const vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
for( i=0; i<bpms.size()-1; i++ ) for( i=0; i<bpms.size()-1; i++ )
if( bpms[i+1]->GetRow() > iNoteRow ) if( bpms[i+1]->GetRow() > iNoteRow )
break; break;
@@ -701,7 +695,7 @@ float TimingData::GetBPMAtRow( int iNoteRow ) const
bool TimingData::IsWarpAtRow( int iNoteRow ) const bool TimingData::IsWarpAtRow( int iNoteRow ) const
{ {
const vector<TimingSegment *> &warps = this->allTimingSegments[SEGMENT_WARP]; const vector<TimingSegment *> &warps = m_avpTimingSegments[SEGMENT_WARP];
if( warps.empty() ) if( warps.empty() )
return false; return false;
@@ -711,7 +705,7 @@ bool TimingData::IsWarpAtRow( int iNoteRow ) const
if( s->GetBeat() <= beatRow && beatRow < (s->GetBeat() + s->GetLength() ) ) if( s->GetBeat() <= beatRow && beatRow < (s->GetBeat() + s->GetLength() ) )
{ {
// Allow stops inside warps to allow things like stop, warp, stop, warp, stop, and so on. // Allow stops inside warps to allow things like stop, warp, stop, warp, stop, and so on.
if( this->allTimingSegments[SEGMENT_STOP].empty() && this->allTimingSegments[SEGMENT_DELAY].empty() ) if( m_avpTimingSegments[SEGMENT_STOP].empty() && m_avpTimingSegments[SEGMENT_DELAY].empty() )
{ {
return true; return true;
} }
@@ -726,7 +720,7 @@ bool TimingData::IsWarpAtRow( int iNoteRow ) const
bool TimingData::IsFakeAtRow( int iNoteRow ) const bool TimingData::IsFakeAtRow( int iNoteRow ) const
{ {
const vector<TimingSegment *> &fakes = this->allTimingSegments[SEGMENT_FAKE]; const vector<TimingSegment *> &fakes = m_avpTimingSegments[SEGMENT_FAKE];
if( fakes.empty() ) if( fakes.empty() )
return false; return false;
@@ -740,44 +734,30 @@ bool TimingData::IsFakeAtRow( int iNoteRow ) const
return false; return false;
} }
BPMSegment* TimingData::GetBPMSegmentAtRow( int iNoteRow ) // TODO: make this part of the TimingSegment struct
enum SegmentEffectArea
{ {
vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; EffectArea_Row, // takes effect on a single row
if( bpms.empty() ) EffectArea_Range, // takes effect until the next segment of its type
return new BPMSegment(); NUM_EffectArea,
EffectArea_Invalid,
};
int i = GetSegmentIndexAtRow( SEGMENT_BPM, iNoteRow ); TimingSegment* TimingData::GetSegmentAtRow( int iNoteRow, TimingSegmentType tst )
return static_cast<BPMSegment *>(bpms[i]);
}
TimeSignatureSegment* TimingData::GetTimeSignatureSegmentAtRow( int iRow )
{ {
unsigned i; vector<TimingSegment*> vSegments = m_avpTimingSegments[tst];
vector<TimingSegment *> &tSigs = this->allTimingSegments[SEGMENT_TIME_SIG];
for( i=0; i<tSigs.size()-1; i++ ) if( vSegments.empty() )
if( tSigs[i+1]->GetRow() > iRow ) FAIL_M( ssprintf("GetSegmentAtRow: %s is empty (blame vyhd)", TimingSegmentTypeToString(tst).c_str()) );
unsigned index = -1;
// seek to the last segment before this row
for( index = 0; index < vSegments.size() - 1; ++index )
if( iNoteRow < vSegments[index+1]->GetRow() )
break; break;
return static_cast<TimeSignatureSegment *>(tSigs[i]);
}
SpeedSegment* TimingData::GetSpeedSegmentAtRow( int iRow ) return vSegments[index];
{
unsigned i;
vector<TimingSegment *> &speeds = this->allTimingSegments[SEGMENT_SPEED];
for( i=0; i<speeds.size()-1; i++ )
if( speeds[i+1]->GetRow() > iRow )
break;
return static_cast<SpeedSegment *>(speeds[i]);
}
ScrollSegment* TimingData::GetScrollSegmentAtRow( int iRow )
{
unsigned i;
vector<TimingSegment *> &scrolls = this->allTimingSegments[SEGMENT_SCROLL];
for( i=0; i<scrolls.size()-1; i++ )
if( scrolls[i+1]->GetRow() > iRow )
break;
return static_cast<ScrollSegment *>(scrolls[i]);
} }
int TimingData::GetTimeSignatureNumeratorAtRow( int iRow ) int TimingData::GetTimeSignatureNumeratorAtRow( int iRow )
@@ -790,86 +770,16 @@ int TimingData::GetTimeSignatureDenominatorAtRow( int iRow )
return GetTimeSignatureSegmentAtRow( iRow )->GetDen(); return GetTimeSignatureSegmentAtRow( iRow )->GetDen();
} }
ComboSegment* TimingData::GetComboSegmentAtRow( int iRow )
{
unsigned i;
vector<TimingSegment *> &combos = this->allTimingSegments[SEGMENT_COMBO];
for( i=0; i<combos.size()-1; i++ )
if( combos[i+1]->GetRow() > iRow )
break;
return static_cast<ComboSegment *>(combos[i]);
}
LabelSegment* TimingData::GetLabelSegmentAtRow( int iRow )
{
unsigned i;
vector<TimingSegment *> &labels = this->allTimingSegments[SEGMENT_LABEL];
for( i=0; i<labels.size()-1; i++ )
if( labels[i+1]->GetRow() > iRow )
break;
return static_cast<LabelSegment *>(labels[i]);
}
StopSegment* TimingData::GetStopSegmentAtRow( int iNoteRow )
{
vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_STOP];
if( stops.empty() )
return new StopSegment();
int i = GetSegmentIndexAtRow( SEGMENT_STOP, iNoteRow );
return static_cast<StopSegment *>(stops[i]);
}
DelaySegment* TimingData::GetDelaySegmentAtRow( int iNoteRow )
{
vector<TimingSegment *> &stops = this->allTimingSegments[SEGMENT_DELAY];
if( stops.empty() )
return new DelaySegment();
int i = GetSegmentIndexAtRow( SEGMENT_DELAY, iNoteRow );
return static_cast<DelaySegment *>(stops[i]);
}
WarpSegment* TimingData::GetWarpSegmentAtRow( int iRow )
{
vector<TimingSegment *> &warps = this->allTimingSegments[SEGMENT_WARP];
if( warps.empty() )
return new WarpSegment();
int i = GetSegmentIndexAtRow( SEGMENT_WARP, iRow );
return static_cast<WarpSegment *>(warps[i]);
}
FakeSegment* TimingData::GetFakeSegmentAtRow( int iRow )
{
vector<TimingSegment *> &fakes = this->allTimingSegments[SEGMENT_FAKE];
if( fakes.empty() )
return new FakeSegment();
int i = GetSegmentIndexAtRow( SEGMENT_FAKE, iRow );
return static_cast<FakeSegment *>(fakes[i]);
}
TickcountSegment* TimingData::GetTickcountSegmentAtRow( int iRow )
{
vector<TimingSegment *> &ticks = this->allTimingSegments[SEGMENT_TICKCOUNT];
if( ticks.empty() )
return new TickcountSegment();
int i = GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow );
return static_cast<TickcountSegment *>(ticks[i]);
}
int TimingData::GetTickcountAtRow( int iRow ) const int TimingData::GetTickcountAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &ticks = this->allTimingSegments[SEGMENT_TICKCOUNT]; const vector<TimingSegment *> &ticks = m_avpTimingSegments[SEGMENT_TICKCOUNT];
const int index = GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow ); const int index = GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow );
return static_cast<TickcountSegment *>(ticks[index])->GetTicks(); return static_cast<TickcountSegment *>(ticks[index])->GetTicks();
} }
bool TimingData::DoesLabelExist( RString sLabel ) const bool TimingData::DoesLabelExist( RString sLabel ) const
{ {
const vector<TimingSegment *> &labels = this->allTimingSegments[SEGMENT_LABEL]; const vector<TimingSegment *> &labels = m_avpTimingSegments[SEGMENT_LABEL];
for (unsigned i = 0; i < labels.size(); i++) for (unsigned i = 0; i < labels.size(); i++)
{ {
if (static_cast<LabelSegment *>(labels[i])->GetLabel() == sLabel) if (static_cast<LabelSegment *>(labels[i])->GetLabel() == sLabel)
@@ -899,7 +809,7 @@ enum
void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &fWarpDestinationOut ) const void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &fWarpDestinationOut ) const
{ {
const vector<TimingSegment *> * segs = this->allTimingSegments; const vector<TimingSegment *> * segs = m_avpTimingSegments;
vector<TimingSegment *>::const_iterator itBPMS = segs[SEGMENT_BPM].begin(); vector<TimingSegment *>::const_iterator itBPMS = segs[SEGMENT_BPM].begin();
vector<TimingSegment *>::const_iterator itWS = segs[SEGMENT_WARP].begin(); vector<TimingSegment *>::const_iterator itWS = segs[SEGMENT_WARP].begin();
vector<TimingSegment *>::const_iterator itSS = segs[SEGMENT_STOP].begin(); vector<TimingSegment *>::const_iterator itSS = segs[SEGMENT_STOP].begin();
@@ -1037,7 +947,7 @@ float TimingData::GetElapsedTimeFromBeat( float fBeat ) const
float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
{ {
const vector<TimingSegment *> * segs = this->allTimingSegments; const vector<TimingSegment *> * segs = m_avpTimingSegments;
vector<TimingSegment *>::const_iterator itBPMS = segs[SEGMENT_BPM].begin(); vector<TimingSegment *>::const_iterator itBPMS = segs[SEGMENT_BPM].begin();
vector<TimingSegment *>::const_iterator itWS = segs[SEGMENT_WARP].begin(); vector<TimingSegment *>::const_iterator itWS = segs[SEGMENT_WARP].begin();
vector<TimingSegment *>::const_iterator itSS = segs[SEGMENT_STOP].begin(); vector<TimingSegment *>::const_iterator itSS = segs[SEGMENT_STOP].begin();
@@ -1138,7 +1048,7 @@ float TimingData::GetDisplayedBeat( float fBeat ) const
{ {
float fOutBeat = 0; float fOutBeat = 0;
unsigned i; unsigned i;
const vector<TimingSegment *> &scrolls = this->allTimingSegments[SEGMENT_SCROLL]; const vector<TimingSegment *> &scrolls = m_avpTimingSegments[SEGMENT_SCROLL];
for( i=0; i<scrolls.size()-1; i++ ) for( i=0; i<scrolls.size()-1; i++ )
{ {
if( scrolls[i+1]->GetBeat() > fBeat ) if( scrolls[i+1]->GetBeat() > fBeat )
@@ -1160,9 +1070,9 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
for (unsigned i = 0; i < NUM_TimingSegmentType; i++) for (unsigned i = 0; i < NUM_TimingSegmentType; i++)
{ {
for (unsigned j = 0; j < this->allTimingSegments[i].size(); j++) for (unsigned j = 0; j < m_avpTimingSegments[i].size(); j++)
{ {
this->allTimingSegments[i][j]->Scale(iStartIndex, length, newLength); m_avpTimingSegments[i][j]->Scale(iStartIndex, length, newLength);
} }
} }
@@ -1171,7 +1081,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
{ {
int iNewEndIndex = iStartIndex + newLength; int iNewEndIndex = iStartIndex + newLength;
float fEndBPMBeforeScaling = GetBPMAtRow(iNewEndIndex); float fEndBPMBeforeScaling = GetBPMAtRow(iNewEndIndex);
vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
// adjust BPM changes "between" iStartIndex and iNewEndIndex // adjust BPM changes "between" iStartIndex and iNewEndIndex
for ( unsigned i = 0; i < bpms.size(); i++ ) for ( unsigned i = 0; i < bpms.size(); i++ )
@@ -1197,7 +1107,7 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
{ {
for (unsigned i = 0; i < NUM_TimingSegmentType; i++) for (unsigned i = 0; i < NUM_TimingSegmentType; i++)
{ {
vector<TimingSegment *> &segs = this->allTimingSegments[i]; vector<TimingSegment *> &segs = m_avpTimingSegments[i];
for (unsigned j = 0; j < segs.size(); j++) for (unsigned j = 0; j < segs.size(); j++)
{ {
TimingSegment *seg = segs[j]; TimingSegment *seg = segs[j];
@@ -1211,7 +1121,7 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
{ {
/* If we're shifting up at the beginning, we just shifted up the first /* If we're shifting up at the beginning, we just shifted up the first
* BPMSegment. That segment must always begin at 0. */ * BPMSegment. That segment must always begin at 0. */
vector<TimingSegment *> &bpms = this->allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = m_avpTimingSegments[SEGMENT_BPM];
ASSERT_M( bpms.size() > 0, "There must be at least one BPM Segment in the chart!" ); ASSERT_M( bpms.size() > 0, "There must be at least one BPM Segment in the chart!" );
bpms[0]->SetRow(0); bpms[0]->SetRow(0);
} }
@@ -1221,13 +1131,13 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
void TimingData::DeleteRows( int iStartRow, int iRowsToDelete ) void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
{ {
/* Remember the BPM at the end of the region being deleted. */ /* Remember the BPM at the end of the region being deleted. */
float fNewBPM = this->GetBPMAtBeat( NoteRowToBeat(iStartRow+iRowsToDelete) ); float fNewBPM = GetBPMAtBeat( NoteRowToBeat(iStartRow+iRowsToDelete) );
/* We're moving rows up. Delete any BPM changes and stops in the region /* We're moving rows up. Delete any BPM changes and stops in the region
* being deleted. */ * being deleted. */
for (unsigned i = 0; i < NUM_TimingSegmentType; i++) for (unsigned i = 0; i < NUM_TimingSegmentType; i++)
{ {
vector<TimingSegment *> &segs = this->allTimingSegments[i]; vector<TimingSegment *> &segs = m_avpTimingSegments[i];
for (unsigned j = 0; j < segs.size(); j++) for (unsigned j = 0; j < segs.size(); j++)
{ {
TimingSegment *seg = segs[j]; TimingSegment *seg = segs[j];
@@ -1248,7 +1158,7 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
} }
} }
this->SetBPMAtRow( iStartRow, fNewBPM ); SetBPMAtRow( iStartRow, fNewBPM );
} }
float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds ) const float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds ) const
@@ -1259,7 +1169,7 @@ float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds
* isn't existing. */ * isn't existing. */
if (!this) return 1.0f; if (!this) return 1.0f;
const vector<TimingSegment *> &speeds = this->allTimingSegments[SEGMENT_SPEED]; const vector<TimingSegment *> &speeds = m_avpTimingSegments[SEGMENT_SPEED];
if( speeds.size() == 0 ) if( speeds.size() == 0 )
return 1.0f; return 1.0f;
@@ -1310,7 +1220,7 @@ float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds
void TimingData::TidyUpData() void TimingData::TidyUpData()
{ {
// If there are no BPM segments, provide a default. // If there are no BPM segments, provide a default.
vector<TimingSegment *> *segs = this->allTimingSegments; vector<TimingSegment *> *segs = m_avpTimingSegments;
if( segs[SEGMENT_BPM].empty() ) if( segs[SEGMENT_BPM].empty() )
{ {
LOG->UserLog( "Song file", m_sFile, "has no BPM segments, default provided." ); LOG->UserLog( "Song file", m_sFile, "has no BPM segments, default provided." );
@@ -1367,39 +1277,39 @@ void TimingData::TidyUpData()
bool TimingData::HasBpmChanges() const bool TimingData::HasBpmChanges() const
{ {
return this->allTimingSegments[SEGMENT_BPM].size()>1; return m_avpTimingSegments[SEGMENT_BPM].size()>1;
} }
bool TimingData::HasStops() const bool TimingData::HasStops() const
{ {
return this->allTimingSegments[SEGMENT_STOP].size()>0; return m_avpTimingSegments[SEGMENT_STOP].size()>0;
} }
bool TimingData::HasDelays() const bool TimingData::HasDelays() const
{ {
return this->allTimingSegments[SEGMENT_DELAY].size()>0; return m_avpTimingSegments[SEGMENT_DELAY].size()>0;
} }
bool TimingData::HasWarps() const bool TimingData::HasWarps() const
{ {
return this->allTimingSegments[SEGMENT_WARP].size()>0; return m_avpTimingSegments[SEGMENT_WARP].size()>0;
} }
bool TimingData::HasFakes() const bool TimingData::HasFakes() const
{ {
return this->allTimingSegments[SEGMENT_FAKE].size()>0; return m_avpTimingSegments[SEGMENT_FAKE].size()>0;
} }
bool TimingData::HasSpeedChanges() const bool TimingData::HasSpeedChanges() const
{ {
const vector<TimingSegment *> &speeds = this->allTimingSegments[SEGMENT_SPEED]; const vector<TimingSegment *> &speeds = m_avpTimingSegments[SEGMENT_SPEED];
return (speeds.size()>1 || return (speeds.size()>1 ||
static_cast<SpeedSegment *>(speeds[0])->GetRatio() != 1); static_cast<SpeedSegment *>(speeds[0])->GetRatio() != 1);
} }
bool TimingData::HasScrollChanges() const bool TimingData::HasScrollChanges() const
{ {
const vector<TimingSegment *> &scrolls = this->allTimingSegments[SEGMENT_SCROLL]; const vector<TimingSegment *> &scrolls = m_avpTimingSegments[SEGMENT_SCROLL];
return (scrolls.size()>1 || return (scrolls.size()>1 ||
static_cast<ScrollSegment *>(scrolls[0])->GetRatio() != 1); static_cast<ScrollSegment *>(scrolls[0])->GetRatio() != 1);
} }
@@ -1407,7 +1317,7 @@ bool TimingData::HasScrollChanges() const
void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const
{ {
iMeasureIndexOut = 0; iMeasureIndexOut = 0;
const vector<TimingSegment *> &tSigs = this->allTimingSegments[SEGMENT_TIME_SIG]; const vector<TimingSegment *> &tSigs = m_avpTimingSegments[SEGMENT_TIME_SIG];
for (unsigned i = 0; i < tSigs.size(); i++) for (unsigned i = 0; i < tSigs.size(); i++)
{ {
TimeSignatureSegment *curSig = static_cast<TimeSignatureSegment *>(tSigs[i]); TimeSignatureSegment *curSig = static_cast<TimeSignatureSegment *>(tSigs[i]);
@@ -1441,7 +1351,7 @@ void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, i
vector<RString> TimingData::ToVectorString(TimingSegmentType tst, int dec) const vector<RString> TimingData::ToVectorString(TimingSegmentType tst, int dec) const
{ {
const vector<TimingSegment *> segs = this->allTimingSegments[tst]; const vector<TimingSegment *> segs = m_avpTimingSegments[tst];
vector<RString> ret; vector<RString> ret;
for (unsigned i = 0; i < segs.size(); i++) for (unsigned i = 0; i < segs.size(); i++)
@@ -1513,7 +1423,7 @@ public:
static int GetBPMs( T* p, lua_State *L ) static int GetBPMs( T* p, lua_State *L )
{ {
vector<float> vBPMs; vector<float> vBPMs;
vector<TimingSegment *> &bpms = p->allTimingSegments[SEGMENT_BPM]; vector<TimingSegment *> &bpms = p->m_avpTimingSegments[SEGMENT_BPM];
for (unsigned i = 0; i < bpms.size(); i++) for (unsigned i = 0; i < bpms.size(); i++)
{ {
BPMSegment *seg = static_cast<BPMSegment *>(bpms[i]); BPMSegment *seg = static_cast<BPMSegment *>(bpms[i]);
+65 -278
View File
@@ -18,31 +18,22 @@ class TimingData
public: public:
void AddSegment(TimingSegmentType tst, TimingSegment * seg); void AddSegment(TimingSegmentType tst, TimingSegment * seg);
int GetSegmentIndexAtRow(TimingSegmentType tst, unsigned GetSegmentIndexAtRow(TimingSegmentType tst, int row) const;
int row) const; unsigned GetSegmentIndexAtBeat(TimingSegmentType tst, float beat) const
int GetSegmentIndexAtBeat(TimingSegmentType tst,
float beat) const
{ {
return this->GetSegmentIndexAtRow(tst, BeatToNoteRow(beat)); return GetSegmentIndexAtRow( tst, BeatToNoteRow(beat) );
} }
float GetNextSegmentBeatAtRow(TimingSegmentType tst, float GetNextSegmentBeatAtRow(TimingSegmentType tst, int row) const;
int row) const; float GetNextSegmentBeatAtBeat(TimingSegmentType tst, float beat) const
float GetNextSegmentBeatAtBeat(TimingSegmentType tst,
float beat) const
{ {
return this->GetNextSegmentBeatAtRow(tst, BeatToNoteRow(beat)); return GetNextSegmentBeatAtRow( tst, BeatToNoteRow(beat) );
} }
float GetPreviousSegmentBeatAtRow(TimingSegmentType tst, float GetPreviousSegmentBeatAtRow(TimingSegmentType tst, int row) const;
int row) const; float GetPreviousSegmentBeatAtBeat(TimingSegmentType tst, float beat) const
float GetPreviousSegmentBeatAtBeat(TimingSegmentType tst,
float beat) const
{ {
return this->GetPreviousSegmentBeatAtRow(tst, BeatToNoteRow(beat)); return GetPreviousSegmentBeatAtRow( tst, BeatToNoteRow(beat) );
} }
bool empty() const; bool empty() const;
@@ -51,7 +42,6 @@ public:
* @brief Sets up initial timing data with a defined offset. * @brief Sets up initial timing data with a defined offset.
* @param fOffset the offset from the 0th beat. */ * @param fOffset the offset from the 0th beat. */
TimingData(float fOffset = 0); TimingData(float fOffset = 0);
~TimingData(); ~TimingData();
TimingData CopyRange(int startRow, int endRow) const; TimingData CopyRange(int startRow, int endRow) const;
@@ -89,18 +79,53 @@ public:
* @param fBPM the BPM. * @param fBPM the BPM.
*/ */
void SetBPMAtBeat( float fBeat, float fBPM ) { SetBPMAtRow( BeatToNoteRow(fBeat), fBPM ); } void SetBPMAtBeat( float fBeat, float fBPM ) { SetBPMAtRow( BeatToNoteRow(fBeat), fBPM ); }
/** /**
* @brief Retrieve the BPMSegment at the specified row. * @brief Retrieve the TimingSegment at the specified row.
* @param iNoteRow the row that has a BPMSegment. * @param iNoteRow the row that has a TimingSegment.
* @return the BPMSegment in question. * @param tst the TimingSegmentType requested.
* @return the segment in question.
*/ */
BPMSegment* GetBPMSegmentAtRow( int iNoteRow ); TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst );
/** /**
* @brief Retrieve the BPMSegment at the specified beat. * @brief Retrieve the TimingSegment at the given beat.
* @param fBeat the beat that has a BPMSegment. * @param fBeat the beat that has a TimingSegment.
* @return the BPMSegment in question. * @param tst the TimingSegmentType requested.
* @return the segment in question.
*/ */
BPMSegment* GetBPMSegmentAtBeat( float fBeat ) { return GetBPMSegmentAtRow( (int)BeatToNoteRow(fBeat)); } TimingSegment* GetSegmentAtBeat( float fBeat, TimingSegmentType tst )
{
return GetSegmentAtRow( BeatToNoteRow(fBeat), tst );
}
/* XXX: convenience shortcuts. We should get rid of these later. */
#define GetSegmentWithName(Seg, SegType) \
Seg* Get##Seg##AtRow( int iNoteRow ) \
{ \
TimingSegment *t = GetSegmentAtRow( iNoteRow, SegType ); \
return static_cast<Seg*>( t ); \
} \
Seg* Get##Seg##AtBeat( float fBeat ) \
{ \
TimingSegment *t = GetSegmentAtBeat( fBeat, SegType ); \
return static_cast<Seg*>( t ); \
}
// (TimeSignature,TIME_SIG) -> (TimeSignatureSegment,SEGMENT_TIME_SIG)
#define GetSegment(Seg, SegType ) \
GetSegmentWithName( Seg##Segment, SEGMENT_##SegType )
GetSegment( BPM, BPM );
GetSegment( Stop, STOP );
GetSegment( Delay, DELAY );
GetSegment( Warp, WARP );
GetSegment( Label, LABEL );
GetSegment( Tickcount, TICKCOUNT );
GetSegment( Combo, COMBO );
GetSegment( Speed, SPEED );
GetSegment( Scroll, SCROLL );
GetSegment( Fake, FAKE );
GetSegment( TimeSignature, TIME_SIG );
/** /**
* @brief Retrieve the stop time at the given row. * @brief Retrieve the stop time at the given row.
@@ -127,19 +152,6 @@ public:
* @param fSeconds the new stop time. * @param fSeconds the new stop time.
*/ */
void SetStopAtBeat( float fBeat, float fSeconds ) { SetStopAtRow( BeatToNoteRow(fBeat), fSeconds); } void SetStopAtBeat( float fBeat, float fSeconds ) { SetStopAtRow( BeatToNoteRow(fBeat), fSeconds); }
/**
* @brief Retrieve the StopSegment at the specified row.
* @param iNoteRow the row that has a StopSegment.
* @return the StopSegment in question.
*/
StopSegment* GetStopSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the StopSegment at the specified beat.
* @param fBeat the beat that has a StopSegment.
* @return the StopSegment in question.
*/
StopSegment* GetStopSegmentAtBeat( float fBeat ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat)); }
/** /**
* @brief Retrieve the delay time at the given row. * @brief Retrieve the delay time at the given row.
@@ -170,18 +182,6 @@ public:
* @param fSeconds the new delay time. * @param fSeconds the new delay time.
*/ */
void SetDelayAtBeat( float fBeat, float fSeconds ) { SetDelayAtRow( BeatToNoteRow(fBeat), fSeconds); } void SetDelayAtBeat( float fBeat, float fSeconds ) { SetDelayAtRow( BeatToNoteRow(fBeat), fSeconds); }
/**
* @brief Retrieve the DelaySegment at the specified row.
* @param iNoteRow the row that has a DelaySegment.
* @return the DelaySegment in question.
*/
DelaySegment* GetDelaySegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the DelaySegment at the specified beat.
* @param fBeat the beat that has a DelaySegment.
* @return the DelaySegment in question.
*/
DelaySegment* GetDelaySegmentAtBeat( float fBeat ) { return GetDelaySegmentAtRow( BeatToNoteRow(fBeat)); }
/** /**
* @brief Retrieve the Time Signature's numerator at the given row. * @brief Retrieve the Time Signature's numerator at the given row.
@@ -245,18 +245,6 @@ public:
* @param iDenominator the denominator. * @param iDenominator the denominator.
*/ */
void SetTimeSignatureDenominatorAtBeat( float fBeat, int iDenominator ) { SetTimeSignatureDenominatorAtRow( BeatToNoteRow(fBeat), iDenominator); } void SetTimeSignatureDenominatorAtBeat( float fBeat, int iDenominator ) { SetTimeSignatureDenominatorAtRow( BeatToNoteRow(fBeat), iDenominator); }
/**
* @brief Retrieve the TimeSignatureSegment at the specified row.
* @param iNoteRow the row that has a TimeSignatureSegment.
* @return the TimeSignatureSegment in question.
*/
TimeSignatureSegment* GetTimeSignatureSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the TimeSignatureSegment at the specified beat.
* @param fBeat the beat that has a TimeSignatureSegment.
* @return the TimeSignatureSegment in question.
*/
TimeSignatureSegment* GetTimeSignatureSegmentAtBeat( float fBeat ) { return GetTimeSignatureSegmentAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Determine the beat to warp to. * @brief Determine the beat to warp to.
@@ -282,18 +270,7 @@ public:
* @param fNew The destination beat. * @param fNew The destination beat.
*/ */
void SetWarpAtBeat( float fBeat, float fNew ) { SetWarpAtRow( BeatToNoteRow( fBeat ), fNew ); } 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 Checks if the row is inside a warp. * @brief Checks if the row is inside a warp.
* @param iRow the row to focus on. * @param iRow the row to focus on.
@@ -331,18 +308,6 @@ public:
* @param iTicks the tickcount. * @param iTicks the tickcount.
*/ */
void SetTickcountAtBeat( float fBeat, int iTicks ) { SetTickcountAtRow( BeatToNoteRow( fBeat ), iTicks ); } void SetTickcountAtBeat( float fBeat, int iTicks ) { SetTickcountAtRow( BeatToNoteRow( fBeat ), iTicks ); }
/**
* @brief Retrieve the TickcountSegment at the specified row.
* @param iNoteRow the row that has a TickcountSegment.
* @return the TickcountSegment in question.
*/
TickcountSegment* GetTickcountSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the TickcountSegment at the specified beat.
* @param fBeat the beat that has a TickcountSegment.
* @return the TickcountSegment in question.
*/
TickcountSegment* GetTickcountSegmentAtBeat( float fBeat ) { return GetTickcountSegmentAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Retrieve the Combo at the given row. * @brief Retrieve the Combo at the given row.
@@ -418,18 +383,6 @@ public:
* @param iCombo the Miss Combo. * @param iCombo the Miss Combo.
*/ */
void SetMissComboAtBeat( float fBeat, int iCombo ) { SetMissComboAtRow( BeatToNoteRow( fBeat ), iCombo ); } void SetMissComboAtBeat( float fBeat, int iCombo ) { SetMissComboAtRow( BeatToNoteRow( fBeat ), iCombo ); }
/**
* @brief Retrieve the ComboSegment at the specified row.
* @param iNoteRow the row that has a ComboSegment.
* @return the ComboSegment in question.
*/
ComboSegment* GetComboSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the ComboSegment at the specified beat.
* @param fBeat the beat that has a ComboSegment.
* @return the ComboSegment in question.
*/
ComboSegment* GetComboSegmentAtBeat( float fBeat ) { return GetComboSegmentAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Retrieve the Label at the given row. * @brief Retrieve the Label at the given row.
@@ -455,25 +408,12 @@ public:
* @param sLabel the Label. * @param sLabel the Label.
*/ */
void SetLabelAtBeat( float fBeat, const RString sLabel ) { SetLabelAtRow( BeatToNoteRow( fBeat ), sLabel ); } void SetLabelAtBeat( float fBeat, const RString sLabel ) { SetLabelAtRow( BeatToNoteRow( fBeat ), sLabel ); }
/**
* @brief Retrieve the LabelSegment at the specified row.
* @param iNoteRow the row that has a LabelSegment.
* @return the LabelSegment in question.
*/
LabelSegment* GetLabelSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the LabelSegment at the specified beat.
* @param fBeat the beat that has a LabelSegment.
* @return the LabelSegment in question.
*/
LabelSegment* GetLabelSegmentAtBeat( float fBeat ) { return GetLabelSegmentAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Determine if the requisite label already exists. * @brief Determine if the requisite label already exists.
* @param sLabel the label to check. * @param sLabel the label to check.
* @return true if it exists, false otherwise. */ * @return true if it exists, false otherwise. */
bool DoesLabelExist( RString sLabel ) const; bool DoesLabelExist( RString sLabel ) const;
/** /**
* @brief Retrieve the Speed's percent at the given row. * @brief Retrieve the Speed's percent at the given row.
* @param iNoteRow the row in question. * @param iNoteRow the row in question.
@@ -562,18 +502,6 @@ public:
* @param usMode the mode. * @param usMode the mode.
*/ */
void SetSpeedModeAtBeat( float fBeat, unsigned short usMode ) { SetSpeedModeAtRow( BeatToNoteRow(fBeat), usMode); } void SetSpeedModeAtBeat( float fBeat, unsigned short usMode ) { SetSpeedModeAtRow( BeatToNoteRow(fBeat), usMode); }
/**
* @brief Retrieve the SpeedSegment at the specified row.
* @param iNoteRow the row that has a SpeedSegment.
* @return the SpeedSegment in question.
*/
SpeedSegment* GetSpeedSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the SpeedSegment at the specified beat.
* @param fBeat the beat that has a SpeedSegment.
* @return the SpeedSegment in question.
*/
SpeedSegment* GetSpeedSegmentAtBeat( float fBeat ) { return GetSpeedSegmentAtRow( BeatToNoteRow(fBeat) ); }
float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const; float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const;
@@ -603,19 +531,6 @@ public:
*/ */
void SetScrollAtBeat( float fBeat, float fPercent ) { SetScrollAtRow( BeatToNoteRow(fBeat), fPercent ); } void SetScrollAtBeat( float fBeat, float fPercent ) { SetScrollAtRow( BeatToNoteRow(fBeat), fPercent ); }
/**
* @brief Retrieve the ScrollSegment at the specified row.
* @param iNoteRow the row that has a ScrollSegment.
* @return the ScrollSegment in question.
*/
ScrollSegment* GetScrollSegmentAtRow( int iNoteRow );
/**
* @brief Retrieve the ScrollSegment at the specified beat.
* @param fBeat the beat that has a ScrollSegment.
* @return the ScrollSegment in question.
*/
ScrollSegment* GetScrollSegmentAtBeat( float fBeat ) { return GetScrollSegmentAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Determine when the fakes end. * @brief Determine when the fakes end.
* @param iRow The row you start on. * @param iRow The row you start on.
@@ -640,18 +555,7 @@ public:
* @param fNew The destination beat. * @param fNew The destination beat.
*/ */
void SetFakeAtBeat( float fBeat, float fNew ) { SetFakeAtRow( BeatToNoteRow( fBeat ), fNew ); } void SetFakeAtBeat( float fBeat, float fNew ) { SetFakeAtRow( BeatToNoteRow( fBeat ), fNew ); }
/**
* @brief Retrieve the FakeSegment at the specified row.
* @param iRow the row to focus on.
* @return the FakeSegment in question.
*/
FakeSegment* GetFakeSegmentAtRow( int iRow );
/**
* @brief Retrieve the FakeSegment at the specified beat.
* @param fBeat the beat to focus on.
* @return the FakeSegment in question.
*/
FakeSegment* GetFakeSegmentAtBeat( float fBeat ) { return GetFakeSegmentAtRow( BeatToNoteRow( fBeat ) ); }
/** /**
* @brief Checks if the row is inside a fake. * @brief Checks if the row is inside a fake.
* @param iRow the row to focus on. * @param iRow the row to focus on.
@@ -741,144 +645,28 @@ public:
bool HasScrollChanges() const; bool HasScrollChanges() const;
/** /**
* @brief Compare two sets of timing data to see if they are equal. * @brief Compare two sets of timing data to see if they are equal.
*
* TODO: Make doubly sure that we're using the operator== on the proper segments,
* not the generic TimingSegment.
* @param other the other TimingData. * @param other the other TimingData.
* @return the equality or lack thereof of the two TimingData. * @return the equality or lack thereof of the two TimingData.
*/ */
bool operator==( const TimingData &other ) bool operator==( const TimingData &other )
{ {
unsigned i; FOREACH_ENUM( TimingSegmentType, tst )
COMPARE(allTimingSegments[SEGMENT_BPM].size());
for (i = 0; i < allTimingSegments[SEGMENT_BPM].size(); i++)
{ {
BPMSegment * segT = const vector<TimingSegment*> &us = m_avpTimingSegments[tst];
static_cast<BPMSegment *>(this->allTimingSegments[SEGMENT_BPM][i]); const vector<TimingSegment*> &them = other.m_avpTimingSegments[tst];
BPMSegment * segO =
static_cast<BPMSegment *>(other.allTimingSegments[SEGMENT_BPM][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetBPS() != segO->GetBPS()) return false;
}
COMPARE(allTimingSegments[SEGMENT_STOP].size()); // optimization: check vector sizes before contents
for (i = 0; i < allTimingSegments[SEGMENT_STOP].size(); i++) if( us.size() != them.size() )
{ return false;
StopSegment * segT =
static_cast<StopSegment *>(this->allTimingSegments[SEGMENT_STOP][i]);
StopSegment * segO =
static_cast<StopSegment *>(other.allTimingSegments[SEGMENT_STOP][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetPause() != segO->GetPause()) return false;
}
COMPARE(allTimingSegments[SEGMENT_DELAY].size()); if( !std::equal(us.begin(), us.end(), them.begin()) )
for (i = 0; i < allTimingSegments[SEGMENT_DELAY].size(); i++) return false;
{
DelaySegment * segT =
static_cast<DelaySegment *>(this->allTimingSegments[SEGMENT_DELAY][i]);
DelaySegment * segO =
static_cast<DelaySegment *>(other.allTimingSegments[SEGMENT_DELAY][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetPause() != segO->GetPause()) return false;
}
COMPARE(allTimingSegments[SEGMENT_WARP].size());
for (i = 0; i < allTimingSegments[SEGMENT_WARP].size(); i++)
{
WarpSegment * segT =
static_cast<WarpSegment *>(this->allTimingSegments[SEGMENT_WARP][i]);
WarpSegment * segO =
static_cast<WarpSegment *>(other.allTimingSegments[SEGMENT_WARP][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetLength() != segO->GetLength()) return false;
}
COMPARE(allTimingSegments[SEGMENT_TIME_SIG].size());
for (i = 0; i < allTimingSegments[SEGMENT_TIME_SIG].size(); i++)
{
TimeSignatureSegment * segT =
static_cast<TimeSignatureSegment *>(this->allTimingSegments[SEGMENT_TIME_SIG][i]);
TimeSignatureSegment * segO =
static_cast<TimeSignatureSegment *>(other.allTimingSegments[SEGMENT_TIME_SIG][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetNum() != segO->GetNum()) return false;
if (segT->GetDen() != segO->GetDen()) return false;
}
COMPARE(allTimingSegments[SEGMENT_TICKCOUNT].size());
for (i = 0; i < allTimingSegments[SEGMENT_TICKCOUNT].size(); i++)
{
TickcountSegment * segT =
static_cast<TickcountSegment *>(this->allTimingSegments[SEGMENT_TICKCOUNT][i]);
TickcountSegment * segO =
static_cast<TickcountSegment *>(other.allTimingSegments[SEGMENT_TICKCOUNT][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetTicks() != segO->GetTicks()) return false;
}
COMPARE(allTimingSegments[SEGMENT_COMBO].size());
for (i = 0; i < allTimingSegments[SEGMENT_COMBO].size(); i++)
{
ComboSegment * segT =
static_cast<ComboSegment *>(this->allTimingSegments[SEGMENT_COMBO][i]);
ComboSegment * segO =
static_cast<ComboSegment *>(other.allTimingSegments[SEGMENT_COMBO][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetCombo() != segO->GetCombo()) return false;
if (segT->GetMissCombo() != segO->GetMissCombo()) return false;
}
COMPARE(allTimingSegments[SEGMENT_SPEED].size());
for (i = 0; i < allTimingSegments[SEGMENT_SPEED].size(); i++)
{
SpeedSegment * segT =
static_cast<SpeedSegment *>(this->allTimingSegments[SEGMENT_SPEED][i]);
SpeedSegment * segO =
static_cast<SpeedSegment *>(other.allTimingSegments[SEGMENT_SPEED][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetRatio() != segO->GetRatio()) return false;
if (segT->GetLength() != segO->GetLength()) return false;
if (segT->GetUnit() != segO->GetUnit()) return false;
}
COMPARE(allTimingSegments[SEGMENT_SCROLL].size());
for (i = 0; i < allTimingSegments[SEGMENT_SCROLL].size(); i++)
{
ScrollSegment * segT =
static_cast<ScrollSegment *>(this->allTimingSegments[SEGMENT_SCROLL][i]);
ScrollSegment * segO =
static_cast<ScrollSegment *>(other.allTimingSegments[SEGMENT_SCROLL][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetRatio() != segO->GetRatio()) return false;
}
COMPARE(allTimingSegments[SEGMENT_LABEL].size());
for (i = 0; i < allTimingSegments[SEGMENT_LABEL].size(); i++)
{
LabelSegment * segT =
static_cast<LabelSegment *>(this->allTimingSegments[SEGMENT_LABEL][i]);
LabelSegment * segO =
static_cast<LabelSegment *>(other.allTimingSegments[SEGMENT_LABEL][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetLabel() != segO->GetLabel()) return false;
}
COMPARE(allTimingSegments[SEGMENT_FAKE].size());
for (i = 0; i < allTimingSegments[SEGMENT_FAKE].size(); i++)
{
FakeSegment * segT =
static_cast<FakeSegment *>(this->allTimingSegments[SEGMENT_FAKE][i]);
FakeSegment * segO =
static_cast<FakeSegment *>(other.allTimingSegments[SEGMENT_FAKE][i]);
if (segT->GetRow() != segO->GetRow()) return false;
if (segT->GetLength() != segO->GetLength()) return false;
} }
COMPARE( m_fBeat0OffsetInSeconds ); COMPARE( m_fBeat0OffsetInSeconds );
return true; return true;
} }
/** /**
* @brief Compare two sets of timing data to see if they are not equal. * @brief Compare two sets of timing data to see if they are not equal.
* @param other the other TimingData. * @param other the other TimingData.
@@ -903,10 +691,9 @@ public:
* This is for informational purposes only. * This is for informational purposes only.
*/ */
RString m_sFile; RString m_sFile;
// All of the following vectors must be sorted before gameplay. // All of the following vectors must be sorted before gameplay.
vector<TimingSegment *> m_avpTimingSegments[NUM_TimingSegmentType];
vector<TimingSegment *> allTimingSegments[NUM_TimingSegmentType];
/** /**
* @brief The initial offset of a song. * @brief The initial offset of a song.