[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;
MusicPlaying( RageSound *Music )
{
m_Timing.AddBPMSegment( BPMSegment(0,120) );
m_NewTiming.AddBPMSegment( BPMSegment(0,120) );
m_Timing.AddSegment( SEGMENT_BPM, new BPMSegment(0,120) );
m_NewTiming.AddSegment( SEGMENT_BPM, new BPMSegment(0,120) );
m_bHasTiming = false;
m_bTimingDelayed = 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 )
{
BPMSegment newSeg( 0, fBPM );
out.m_SongTiming.AddBPMSegment( newSeg );
out.m_SongTiming.AddSegment( SEGMENT_BPM, new BPMSegment(0, fBPM) );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", NoteRowToBeat(0), fBPM );
}
else
@@ -693,9 +692,9 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( fBPM > 0.0f )
{
BPMSegment newSeg( BeatToNoteRow(fBeat), fBPM );
out.m_SongTiming.AddBPMSegment( newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", fBeat, newSeg.GetBPM() );
BPMSegment * newSeg = new BPMSegment( fBeat, fBPM );
out.m_SongTiming.AddSegment( SEGMENT_BPM, newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", fBeat, newSeg->GetBPM() );
}
else
{
@@ -720,9 +719,9 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
float fBeats = StringToFloat( sBeats ) / 48.0f;
float fFreezeSecs = fBeats / fBPS;
StopSegment newSeg( BeatToNoteRow(fBeat), fFreezeSecs );
out.m_SongTiming.AddStopSegment( newSeg );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.GetPause() );
StopSegment * newSeg = new StopSegment( fBeat, fFreezeSecs );
out.m_SongTiming.AddSegment( SEGMENT_STOP_DELAY, newSeg );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg->GetPause() );
}
else
{
@@ -749,9 +748,11 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( fBPM > 0.0f )
{
BPMSegment newSeg( iStepIndex, fBPM );
out.m_SongTiming.AddBPMSegment( newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", newSeg.GetBeat(), newSeg.GetBPM() );
BPMSegment * newSeg = new BPMSegment( iStepIndex, fBPM );
out.m_SongTiming.AddSegment( SEGMENT_BPM, newSeg );
LOG->Trace("Inserting new BPM change at beat %f, BPM %f",
newSeg->GetBeat(),
newSeg->GetBPM() );
}
else
+34 -32
View File
@@ -251,8 +251,8 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
if( negBPM < 0 )
{
float endBeat = fBeat + (fNewBPM / -negBPM) * (fBeat - negBeat);
WarpSegment new_seg(negBeat, endBeat - negBeat);
out.AddWarpSegment( new_seg );
out.AddSegment(SEGMENT_WARP,
new WarpSegment(negBeat, endBeat - negBeat));
negBeat = -1;
negBPM = 1;
@@ -267,13 +267,13 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
// add in a warp.
if( highspeedBeat > 0 )
{
WarpSegment new_seg(highspeedBeat, fBeat - highspeedBeat);
out.AddWarpSegment( new_seg );
out.AddSegment(SEGMENT_WARP,
new WarpSegment(highspeedBeat, fBeat - highspeedBeat) );
highspeedBeat = -1;
}
{
BPMSegment new_seg( BeatToNoteRow( fBeat ), fNewBPM );
out.AddBPMSegment( new_seg );
out.AddSegment(SEGMENT_BPM,
new BPMSegment(fBeat, fNewBPM));
}
}
}
@@ -317,8 +317,7 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
if( negBeat + fSkipBeats > fFreezeBeat )
fSkipBeats = fFreezeBeat - negBeat;
WarpSegment ws( negBeat, fSkipBeats);
out.AddWarpSegment( ws );
out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats));
negBeat = -1;
negPause = 0;
@@ -331,8 +330,8 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
}
else if( fFreezeSeconds > 0.0f )
{
StopSegment ss( BeatToNoteRow(fFreezeBeat), fFreezeSeconds );
out.AddStopSegment( ss );
out.AddSegment(SEGMENT_STOP_DELAY,
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.
if( negPause > 0 )
{
BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat));
BPMSegment oldBPM = out.GetBPMSegmentAtBeat(negBeat);
float fSecondsPerBeat = 60 / oldBPM.GetBPM();
float fSkipBeats = negPause / fSecondsPerBeat;
WarpSegment ws( negBeat, fSkipBeats);
out.AddWarpSegment( ws );
out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats));
}
}
@@ -370,15 +368,14 @@ void SMLoader::ProcessDelays( TimingData &out, const RString line, const int row
const float fFreezeBeat = RowToBeat( arrayDelayValues[0], rowsPerBeat );
const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] );
StopSegment new_seg( fFreezeBeat, fFreezeSeconds, true );
// XXX: Remove Negatives Bug?
new_seg.SetBeat(fFreezeBeat);
new_seg.SetPause(fFreezeSeconds);
StopSegment * new_seg = new StopSegment(fFreezeBeat,
fFreezeSeconds,
true);
// LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
if(fFreezeSeconds > 0.0f)
out.AddStopSegment( new_seg );
out.AddSegment( SEGMENT_STOP_DELAY, new_seg );
else
LOG->UserLog(
"Song file",
@@ -409,7 +406,10 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
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 )
{
@@ -420,25 +420,25 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
continue;
}
if( seg.GetNum() < 1 )
if( seg->GetNum() < 1 )
{
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid time signature change with beat %f, iNumerator %i.",
fBeat, seg.GetNum() );
fBeat, seg->GetNum() );
continue;
}
if( seg.GetDen() < 1 )
if( seg->GetDen() < 1 )
{
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid time signature change with beat %f, iDenominator %i.",
fBeat, seg.GetDen() );
fBeat, seg->GetDen() );
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 );
int iTicks = clamp(atoi( arrayTickcountValues[1] ), 0, ROWS_PER_BEAT);
TickcountSegment new_seg( fTickcountBeat, iTicks );
out.AddTickcountSegment( new_seg );
out.AddSegment( SEGMENT_TICKCOUNT,
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 );
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] ));
seg.SetUnit(StringToInt(vs2[3]));
SpeedSegment * seg = new SpeedSegment(fBeat,
StringToFloat( vs2[1] ),
StringToFloat( vs2[2] ));
seg->SetUnit(StringToInt(vs2[3]));
if( fBeat < 0 )
{
@@ -511,16 +513,16 @@ void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int row
continue;
}
if( seg.GetLength() < 0 )
if( seg->GetLength() < 0 )
{
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an speed change with beat %f, length %f.",
fBeat, seg.GetLength() );
fBeat, seg->GetLength() );
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] );
if(fNewBeat > 0)
out.AddFakeSegment( FakeSegment(fBeat, fNewBeat) );
out.AddSegment( SEGMENT_FAKE, new FakeSegment(fBeat, fNewBeat) );
else
{
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 ?
iCombos :
StringToInt(arrayMultiplierValues[2]));
ComboSegment new_seg( fComboBeat, iCombos, iMisses );
out.AddComboSegment( new_seg );
out.AddSegment(SEGMENT_COMBO,
new ComboSegment( fComboBeat, iCombos, iMisses ));
}
}
@@ -64,7 +64,9 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
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 )
{
@@ -75,16 +77,16 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
continue;
}
if( seg.GetNum() < 1 )
if( seg->GetNum() < 1 )
{
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid time signature change with beat %f, iNumerator %i.",
fBeat, seg.GetNum() );
fBeat, seg->GetNum() );
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);
SpeedSegment seg(fBeat, StringToFloat( vs2[1] ), StringToFloat(vs2[2]), tmp);
//seg.SetUnit(tmp);
SpeedSegment * seg = new SpeedSegment(fBeat,
StringToFloat( vs2[1] ),
StringToFloat(vs2[2]),
tmp);
if( fBeat < 0 )
{
@@ -135,16 +139,16 @@ void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int ro
continue;
}
if( seg.GetLength() < 0 )
if( seg->GetLength() < 0 )
{
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an speed change with beat %f, length %f.",
fBeat, seg.GetLength() );
fBeat, seg->GetLength() );
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.
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 )
out.AddWarpSegment( WarpSegment(fBeat, fNewBeat) );
out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat) );
else
{
LOG->UserLog("Song file",
@@ -73,7 +73,7 @@ void SSCLoader::ProcessLabels( TimingData &out, const RString sParam )
RString sLabel = arrayLabelValues[1];
TrimRight(sLabel);
if( fBeat >= 0.0f )
out.AddLabelSegment( LabelSegment(fBeat, sLabel) );
out.AddSegment( SEGMENT_LABEL, new LabelSegment(fBeat, sLabel) );
else
{
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 int iCombos = StringToInt( arrayComboValues[1] );
const int iMisses = (size == 2 ? iCombos : StringToInt(arrayComboValues[2]));
ComboSegment new_seg( fComboBeat, iCombos, iMisses );
out.AddComboSegment( new_seg );
out.AddSegment( SEGMENT_COMBO, new ComboSegment( fComboBeat, iCombos, iMisses ) );
}
}
@@ -132,7 +131,7 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
const float fBeat = StringToFloat( vs2[0] );
ScrollSegment seg( fBeat, StringToFloat( vs2[1] ) );
ScrollSegment * seg = new ScrollSegment(fBeat, StringToFloat( vs2[1] ) );
if( fBeat < 0 )
{
@@ -143,7 +142,7 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
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();
float fBPS = 60 / out.m_SongTiming.GetBPMAtRow(iRow);
float fSkip = fBPS * ws->GetLength();
StopSegment ss(iRow, -fSkip, false);
out.m_SongTiming.AddStopSegment( ss );
out.m_SongTiming.AddSegment(SEGMENT_STOP_DELAY,
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
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]
{