[timing] Convert the others to use AddSegment.

I was given enough confirmation to continue on.
This commit is contained in:
Jason Felds
2011-07-14 19:23:29 -04:00
parent 199af25f31
commit 7399f19865
7 changed files with 73 additions and 66 deletions
+2 -2
View File
@@ -60,8 +60,8 @@ struct MusicPlaying
RageSound *m_Music; RageSound *m_Music;
MusicPlaying( RageSound *Music ) MusicPlaying( RageSound *Music )
{ {
m_Timing.AddBPMSegment( BPMSegment(0,120) ); m_Timing.AddSegment( SEGMENT_BPM, new BPMSegment(0,120) );
m_NewTiming.AddBPMSegment( BPMSegment(0,120) ); m_NewTiming.AddSegment( SEGMENT_BPM, new BPMSegment(0,120) );
m_bHasTiming = false; m_bHasTiming = false;
m_bTimingDelayed = false; m_bTimingDelayed = false;
m_bApplyMusicRate = false; m_bApplyMusicRate = false;
+12 -11
View File
@@ -590,8 +590,7 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( fBPM > 0.0f ) if( fBPM > 0.0f )
{ {
BPMSegment newSeg( 0, fBPM ); out.m_SongTiming.AddSegment( SEGMENT_BPM, new BPMSegment(0, fBPM) );
out.m_SongTiming.AddBPMSegment( newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", NoteRowToBeat(0), fBPM ); LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", NoteRowToBeat(0), fBPM );
} }
else else
@@ -693,9 +692,9 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( fBPM > 0.0f ) if( fBPM > 0.0f )
{ {
BPMSegment newSeg( BeatToNoteRow(fBeat), fBPM ); BPMSegment * newSeg = new BPMSegment( fBeat, fBPM );
out.m_SongTiming.AddBPMSegment( newSeg ); out.m_SongTiming.AddSegment( SEGMENT_BPM, newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", fBeat, newSeg.GetBPM() ); LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", fBeat, newSeg->GetBPM() );
} }
else else
{ {
@@ -720,9 +719,9 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
float fBeats = StringToFloat( sBeats ) / 48.0f; float fBeats = StringToFloat( sBeats ) / 48.0f;
float fFreezeSecs = fBeats / fBPS; float fFreezeSecs = fBeats / fBPS;
StopSegment newSeg( BeatToNoteRow(fBeat), fFreezeSecs ); StopSegment * newSeg = new StopSegment( fBeat, fFreezeSecs );
out.m_SongTiming.AddStopSegment( newSeg ); out.m_SongTiming.AddSegment( SEGMENT_STOP_DELAY, newSeg );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.GetPause() ); LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg->GetPause() );
} }
else else
{ {
@@ -749,9 +748,11 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( fBPM > 0.0f ) if( fBPM > 0.0f )
{ {
BPMSegment newSeg( iStepIndex, fBPM ); BPMSegment * newSeg = new BPMSegment( iStepIndex, fBPM );
out.m_SongTiming.AddBPMSegment( newSeg ); out.m_SongTiming.AddSegment( SEGMENT_BPM, newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", newSeg.GetBeat(), newSeg.GetBPM() ); LOG->Trace("Inserting new BPM change at beat %f, BPM %f",
newSeg->GetBeat(),
newSeg->GetBPM() );
} }
else else
+34 -32
View File
@@ -251,8 +251,8 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
if( negBPM < 0 ) if( negBPM < 0 )
{ {
float endBeat = fBeat + (fNewBPM / -negBPM) * (fBeat - negBeat); float endBeat = fBeat + (fNewBPM / -negBPM) * (fBeat - negBeat);
WarpSegment new_seg(negBeat, endBeat - negBeat); out.AddSegment(SEGMENT_WARP,
out.AddWarpSegment( new_seg ); new WarpSegment(negBeat, endBeat - negBeat));
negBeat = -1; negBeat = -1;
negBPM = 1; negBPM = 1;
@@ -267,13 +267,13 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
// add in a warp. // add in a warp.
if( highspeedBeat > 0 ) if( highspeedBeat > 0 )
{ {
WarpSegment new_seg(highspeedBeat, fBeat - highspeedBeat); out.AddSegment(SEGMENT_WARP,
out.AddWarpSegment( new_seg ); new WarpSegment(highspeedBeat, fBeat - highspeedBeat) );
highspeedBeat = -1; highspeedBeat = -1;
} }
{ {
BPMSegment new_seg( BeatToNoteRow( fBeat ), fNewBPM ); out.AddSegment(SEGMENT_BPM,
out.AddBPMSegment( new_seg ); new BPMSegment(fBeat, fNewBPM));
} }
} }
} }
@@ -317,8 +317,7 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
if( negBeat + fSkipBeats > fFreezeBeat ) if( negBeat + fSkipBeats > fFreezeBeat )
fSkipBeats = fFreezeBeat - negBeat; fSkipBeats = fFreezeBeat - negBeat;
WarpSegment ws( negBeat, fSkipBeats); out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats));
out.AddWarpSegment( ws );
negBeat = -1; negBeat = -1;
negPause = 0; negPause = 0;
@@ -331,8 +330,8 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
} }
else if( fFreezeSeconds > 0.0f ) else if( fFreezeSeconds > 0.0f )
{ {
StopSegment ss( BeatToNoteRow(fFreezeBeat), fFreezeSeconds ); out.AddSegment(SEGMENT_STOP_DELAY,
out.AddStopSegment( ss ); new StopSegment(fFreezeBeat, fFreezeSeconds));
} }
} }
@@ -340,12 +339,11 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
// Process the prior stop if there was one. // Process the prior stop if there was one.
if( negPause > 0 ) if( negPause > 0 )
{ {
BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat)); BPMSegment oldBPM = out.GetBPMSegmentAtBeat(negBeat);
float fSecondsPerBeat = 60 / oldBPM.GetBPM(); float fSecondsPerBeat = 60 / oldBPM.GetBPM();
float fSkipBeats = negPause / fSecondsPerBeat; float fSkipBeats = negPause / fSecondsPerBeat;
WarpSegment ws( negBeat, fSkipBeats); out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats));
out.AddWarpSegment( ws );
} }
} }
@@ -370,15 +368,14 @@ void SMLoader::ProcessDelays( TimingData &out, const RString line, const int row
const float fFreezeBeat = RowToBeat( arrayDelayValues[0], rowsPerBeat ); const float fFreezeBeat = RowToBeat( arrayDelayValues[0], rowsPerBeat );
const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] ); const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] );
StopSegment new_seg( fFreezeBeat, fFreezeSeconds, true ); StopSegment * new_seg = new StopSegment(fFreezeBeat,
// XXX: Remove Negatives Bug? fFreezeSeconds,
new_seg.SetBeat(fFreezeBeat); true);
new_seg.SetPause(fFreezeSeconds);
// LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); // LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
if(fFreezeSeconds > 0.0f) if(fFreezeSeconds > 0.0f)
out.AddStopSegment( new_seg ); out.AddSegment( SEGMENT_STOP_DELAY, new_seg );
else else
LOG->UserLog( LOG->UserLog(
"Song file", "Song file",
@@ -409,7 +406,10 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
const float fBeat = RowToBeat( vs2[0], rowsPerBeat ); const float fBeat = RowToBeat( vs2[0], rowsPerBeat );
TimeSignatureSegment seg( fBeat, StringToInt( vs2[1] ), StringToInt( vs2[2] )); TimeSignatureSegment * seg =
new TimeSignatureSegment(fBeat,
StringToInt( vs2[1] ),
StringToInt( vs2[2] ));
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -420,25 +420,25 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
continue; continue;
} }
if( seg.GetNum() < 1 ) if( seg->GetNum() < 1 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), this->GetSongTitle(),
"has an invalid time signature change with beat %f, iNumerator %i.", "has an invalid time signature change with beat %f, iNumerator %i.",
fBeat, seg.GetNum() ); fBeat, seg->GetNum() );
continue; continue;
} }
if( seg.GetDen() < 1 ) if( seg->GetDen() < 1 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), this->GetSongTitle(),
"has an invalid time signature change with beat %f, iDenominator %i.", "has an invalid time signature change with beat %f, iDenominator %i.",
fBeat, seg.GetDen() ); fBeat, seg->GetDen() );
continue; continue;
} }
out.AddTimeSignatureSegment( seg ); out.AddSegment( SEGMENT_TIME_SIG, seg );
} }
} }
@@ -463,8 +463,8 @@ void SMLoader::ProcessTickcounts( TimingData &out, const RString line, const int
const float fTickcountBeat = RowToBeat( arrayTickcountValues[0], rowsPerBeat ); const float fTickcountBeat = RowToBeat( arrayTickcountValues[0], rowsPerBeat );
int iTicks = clamp(atoi( arrayTickcountValues[1] ), 0, ROWS_PER_BEAT); int iTicks = clamp(atoi( arrayTickcountValues[1] ), 0, ROWS_PER_BEAT);
TickcountSegment new_seg( fTickcountBeat, iTicks ); out.AddSegment( SEGMENT_TICKCOUNT,
out.AddTickcountSegment( new_seg ); new TickcountSegment(fTickcountBeat, iTicks) );
} }
} }
@@ -499,8 +499,10 @@ void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int row
const float fBeat = RowToBeat( vs2[0], rowsPerBeat ); const float fBeat = RowToBeat( vs2[0], rowsPerBeat );
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] )); SpeedSegment * seg = new SpeedSegment(fBeat,
seg.SetUnit(StringToInt(vs2[3])); StringToFloat( vs2[1] ),
StringToFloat( vs2[2] ));
seg->SetUnit(StringToInt(vs2[3]));
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -511,16 +513,16 @@ void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int row
continue; continue;
} }
if( seg.GetLength() < 0 ) if( seg->GetLength() < 0 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), this->GetSongTitle(),
"has an speed change with beat %f, length %f.", "has an speed change with beat %f, length %f.",
fBeat, seg.GetLength() ); fBeat, seg->GetLength() );
continue; continue;
} }
out.AddSpeedSegment( seg ); out.AddSegment( SEGMENT_SPEED, seg );
} }
} }
@@ -546,7 +548,7 @@ void SMLoader::ProcessFakes( TimingData &out, const RString line, const int rows
const float fNewBeat = StringToFloat( arrayFakeValues[1] ); const float fNewBeat = StringToFloat( arrayFakeValues[1] );
if(fNewBeat > 0) if(fNewBeat > 0)
out.AddFakeSegment( FakeSegment(fBeat, fNewBeat) ); out.AddSegment( SEGMENT_FAKE, new FakeSegment(fBeat, fNewBeat) );
else else
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
+15 -11
View File
@@ -38,8 +38,8 @@ void SMALoader::ProcessMultipliers( TimingData &out, const int iRowsPerBeat, con
const int iMisses = (size == 2 || size == 4 ? const int iMisses = (size == 2 || size == 4 ?
iCombos : iCombos :
StringToInt(arrayMultiplierValues[2])); StringToInt(arrayMultiplierValues[2]));
ComboSegment new_seg( fComboBeat, iCombos, iMisses ); out.AddSegment(SEGMENT_COMBO,
out.AddComboSegment( new_seg ); new ComboSegment( fComboBeat, iCombos, iMisses ));
} }
} }
@@ -64,7 +64,9 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
const float fBeat = StringToFloat( vs2[0] ); const float fBeat = StringToFloat( vs2[0] );
TimeSignatureSegment seg( fBeat, StringToInt( vs2[1] ), 4 ); TimeSignatureSegment * seg = new TimeSignatureSegment(fBeat,
StringToInt(vs2[1]),
4 );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -75,16 +77,16 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
continue; continue;
} }
if( seg.GetNum() < 1 ) if( seg->GetNum() < 1 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), this->GetSongTitle(),
"has an invalid time signature change with beat %f, iNumerator %i.", "has an invalid time signature change with beat %f, iNumerator %i.",
fBeat, seg.GetNum() ); fBeat, seg->GetNum() );
continue; continue;
} }
out.AddTimeSignatureSegment( seg ); out.AddSegment( SEGMENT_TIME_SIG, seg );
} }
} }
@@ -123,8 +125,10 @@ void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int ro
unsigned short tmp = ((backup != vs2[2]) ? 1 : 0); unsigned short tmp = ((backup != vs2[2]) ? 1 : 0);
SpeedSegment seg(fBeat, StringToFloat( vs2[1] ), StringToFloat(vs2[2]), tmp); SpeedSegment * seg = new SpeedSegment(fBeat,
//seg.SetUnit(tmp); StringToFloat( vs2[1] ),
StringToFloat(vs2[2]),
tmp);
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -135,16 +139,16 @@ void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int ro
continue; continue;
} }
if( seg.GetLength() < 0 ) if( seg->GetLength() < 0 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), this->GetSongTitle(),
"has an speed change with beat %f, length %f.", "has an speed change with beat %f, length %f.",
fBeat, seg.GetLength() ); fBeat, seg->GetLength() );
continue; continue;
} }
out.AddSpeedSegment( seg ); out.AddSegment( SEGMENT_SPEED, seg );
} }
} }
+6 -7
View File
@@ -37,10 +37,10 @@ void SSCLoader::ProcessWarps( TimingData &out, const RString sParam, const float
// Early versions were absolute in beats. They should be relative. // Early versions were absolute in beats. They should be relative.
if( ( fVersion < VERSION_SPLIT_TIMING && fNewBeat > fBeat ) ) if( ( fVersion < VERSION_SPLIT_TIMING && fNewBeat > fBeat ) )
{ {
out.AddWarpSegment( WarpSegment(fBeat, fNewBeat - fBeat) ); out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat - fBeat) );
} }
else if( fNewBeat > 0 ) else if( fNewBeat > 0 )
out.AddWarpSegment( WarpSegment(fBeat, fNewBeat) ); out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat) );
else else
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
@@ -73,7 +73,7 @@ void SSCLoader::ProcessLabels( TimingData &out, const RString sParam )
RString sLabel = arrayLabelValues[1]; RString sLabel = arrayLabelValues[1];
TrimRight(sLabel); TrimRight(sLabel);
if( fBeat >= 0.0f ) if( fBeat >= 0.0f )
out.AddLabelSegment( LabelSegment(fBeat, sLabel) ); out.AddSegment( SEGMENT_LABEL, new LabelSegment(fBeat, sLabel) );
else else
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
@@ -106,8 +106,7 @@ void SSCLoader::ProcessCombos( TimingData &out, const RString line, const int ro
const float fComboBeat = StringToFloat( arrayComboValues[0] ); const float fComboBeat = StringToFloat( arrayComboValues[0] );
const int iCombos = StringToInt( arrayComboValues[1] ); const int iCombos = StringToInt( arrayComboValues[1] );
const int iMisses = (size == 2 ? iCombos : StringToInt(arrayComboValues[2])); const int iMisses = (size == 2 ? iCombos : StringToInt(arrayComboValues[2]));
ComboSegment new_seg( fComboBeat, iCombos, iMisses ); out.AddSegment( SEGMENT_COMBO, new ComboSegment( fComboBeat, iCombos, iMisses ) );
out.AddComboSegment( new_seg );
} }
} }
@@ -132,7 +131,7 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
const float fBeat = StringToFloat( vs2[0] ); const float fBeat = StringToFloat( vs2[0] );
ScrollSegment seg( fBeat, StringToFloat( vs2[1] ) ); ScrollSegment * seg = new ScrollSegment(fBeat, StringToFloat( vs2[1] ) );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -143,7 +142,7 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
continue; continue;
} }
out.AddScrollSegment( seg ); out.AddSegment( SEGMENT_SCROLL, seg );
} }
} }
+2 -2
View File
@@ -121,8 +121,8 @@ static void WriteGlobalTags( RageFile &f, Song &out )
int iRow = ws->GetRow(); int iRow = ws->GetRow();
float fBPS = 60 / out.m_SongTiming.GetBPMAtRow(iRow); float fBPS = 60 / out.m_SongTiming.GetBPMAtRow(iRow);
float fSkip = fBPS * ws->GetLength(); float fSkip = fBPS * ws->GetLength();
StopSegment ss(iRow, -fSkip, false); out.m_SongTiming.AddSegment(SEGMENT_STOP_DELAY,
out.m_SongTiming.AddStopSegment( ss ); new StopSegment(iRow, -fSkip, false) );
} }
} }
+2 -1
View File
@@ -1983,7 +1983,8 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
{ {
// create a new StopSegment // create a new StopSegment
if( fDelta > 0 ) if( fDelta > 0 )
GetAppropriateTiming().AddStopSegment( StopSegment( GetRow(), fDelta) ); GetAppropriateTiming().AddSegment(SEGMENT_STOP_DELAY,
new StopSegment( GetRow(), fDelta) );
} }
else // StopSegment being modified is m_SongTiming.m_StopSegments[i] else // StopSegment being modified is m_SongTiming.m_StopSegments[i]
{ {