segment renovation stage 2: redefine TimingSegments as simple structs, standardize names and functions, use only rows for constructors (we'll limit allocation through TimingData::AddSegment in the near future)

This commit is contained in:
Mark Cannon
2011-09-11 17:13:10 +00:00
parent a8f22ef178
commit df9c4d8142
13 changed files with 538 additions and 1247 deletions
+3 -3
View File
@@ -618,7 +618,7 @@ void NoteField::DrawLabelText( const float fBeat, RString sLabel )
m_textMeasureNumber.Draw(); m_textMeasureNumber.Draw();
} }
void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait, unsigned short usMode ) void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait, int iMode )
{ {
const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fBeat ); const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fBeat );
const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffset, m_fYReverseOffsetPixels ); const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffset, m_fYReverseOffsetPixels );
@@ -630,7 +630,7 @@ void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait, u
m_textMeasureNumber.SetHorizAlign( SPEED_IS_LEFT_SIDE ? align_right : align_left ); m_textMeasureNumber.SetHorizAlign( SPEED_IS_LEFT_SIDE ? align_right : align_left );
m_textMeasureNumber.SetDiffuse( SPEED_COLOR ); m_textMeasureNumber.SetDiffuse( SPEED_COLOR );
m_textMeasureNumber.SetGlow( RageColor(1,1,1,RageFastCos(RageTimer::GetTimeSinceStartFast()*2)/2+0.5f) ); m_textMeasureNumber.SetGlow( RageColor(1,1,1,RageFastCos(RageTimer::GetTimeSinceStartFast()*2)/2+0.5f) );
m_textMeasureNumber.SetText( ssprintf("%.3f\n%s\n%.3f", fPercent, (usMode == 1 ? "S" : "B"), fWait) ); m_textMeasureNumber.SetText( ssprintf("%.3f\n%s\n%.3f", fPercent, (iMode == 1 ? "S" : "B"), fWait) );
m_textMeasureNumber.SetXY( (SPEED_IS_LEFT_SIDE ? -xBase - xOffset : xBase + xOffset), fYPos ); m_textMeasureNumber.SetXY( (SPEED_IS_LEFT_SIDE ? -xBase - xOffset : xBase + xOffset), fYPos );
m_textMeasureNumber.Draw(); m_textMeasureNumber.Draw();
} }
@@ -1033,7 +1033,7 @@ void NoteField::DrawPrimitives()
float fBeat = seg->GetBeat(); float fBeat = seg->GetBeat();
if( IS_ON_SCREEN(fBeat) ) if( IS_ON_SCREEN(fBeat) )
DrawSpeedText(fBeat, seg->GetRatio(), DrawSpeedText(fBeat, seg->GetRatio(),
seg->GetLength(), seg->GetUnit() ); seg->GetDelay(), seg->GetUnit() );
} }
} }
} }
+1 -1
View File
@@ -65,7 +65,7 @@ protected:
void DrawTickcountText( const float fBeat, int iTicks ); void DrawTickcountText( const float fBeat, int iTicks );
void DrawComboText( const float fBeat, int iCombo, int iMiss ); void DrawComboText( const float fBeat, int iCombo, int iMiss );
void DrawLabelText( const float fBeat, RString sLabel ); void DrawLabelText( const float fBeat, RString sLabel );
void DrawSpeedText( const float fBeat, float fPercent, float fWait, unsigned short usMode ); void DrawSpeedText( const float fBeat, float fPercent, float fWait, int iMode );
void DrawScrollText( const float fBeat, float fPercent ); void DrawScrollText( const float fBeat, float fPercent );
void DrawFakeText( const float fBeat, const float fNewBeat ); void DrawFakeText( const float fBeat, const float fNewBeat );
void DrawAttackText( const float fBeat, const Attack &attack ); void DrawAttackText( const float fBeat, const Attack &attack );
+1 -1
View File
@@ -17,7 +17,7 @@ static void HandleBunki( TimingData &timing, const float fEarlyBPM,
const float beat = (fPos + fGap) * BeatsPerSecond; const float beat = (fPos + fGap) * BeatsPerSecond;
LOG->Trace( "BPM %f, BPS %f, BPMPos %f, beat %f", LOG->Trace( "BPM %f, BPS %f, BPMPos %f, beat %f",
fEarlyBPM, BeatsPerSecond, fPos, beat ); fEarlyBPM, BeatsPerSecond, fPos, beat );
timing.AddSegment( SEGMENT_BPM, new BPMSegment(beat, fCurBPM) ); timing.AddSegment( SEGMENT_BPM, new BPMSegment(BeatToNoteRow(beat), fCurBPM) );
} }
static bool LoadFromKSFFile( const RString &sPath, Steps &out, Song &song, bool bKIUCompliant ) static bool LoadFromKSFFile( const RString &sPath, Steps &out, Song &song, bool bKIUCompliant )
+2 -2
View File
@@ -695,7 +695,7 @@ static void ReadGlobalTags( const RString &sPath, const NameToData_t &mapNameToD
if( fBPM > 0.0f ) if( fBPM > 0.0f )
{ {
BPMSegment * newSeg = new BPMSegment( fBeat, fBPM ); BPMSegment * newSeg = new BPMSegment( BeatToNoteRow(fBeat), fBPM );
out.m_SongTiming.AddSegment( SEGMENT_BPM, 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() );
} }
@@ -722,7 +722,7 @@ static void ReadGlobalTags( const RString &sPath, const NameToData_t &mapNameToD
float fBeats = StringToFloat( sBeats ) / 48.0f; float fBeats = StringToFloat( sBeats ) / 48.0f;
float fFreezeSecs = fBeats / fBPS; float fFreezeSecs = fBeats / fBPS;
StopSegment * newSeg = new StopSegment( fBeat, fFreezeSecs ); StopSegment * newSeg = new StopSegment( BeatToNoteRow(fBeat), fFreezeSecs );
out.m_SongTiming.AddSegment( SEGMENT_STOP, newSeg ); out.m_SongTiming.AddSegment( SEGMENT_STOP, 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() );
} }
+21 -15
View File
@@ -245,7 +245,7 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
{ {
float endBeat = fBeat + (fNewBPM / -negBPM) * (fBeat - negBeat); float endBeat = fBeat + (fNewBPM / -negBPM) * (fBeat - negBeat);
out.AddSegment(SEGMENT_WARP, out.AddSegment(SEGMENT_WARP,
new WarpSegment(negBeat, endBeat - negBeat)); new WarpSegment(BeatToNoteRow(negBeat), endBeat - negBeat));
negBeat = -1; negBeat = -1;
negBPM = 1; negBPM = 1;
@@ -261,12 +261,12 @@ bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsP
if( highspeedBeat > 0 ) if( highspeedBeat > 0 )
{ {
out.AddSegment(SEGMENT_WARP, out.AddSegment(SEGMENT_WARP,
new WarpSegment(highspeedBeat, fBeat - highspeedBeat) ); new WarpSegment(BeatToNoteRow(highspeedBeat), fBeat - highspeedBeat) );
highspeedBeat = -1; highspeedBeat = -1;
} }
{ {
out.AddSegment(SEGMENT_BPM, out.AddSegment(SEGMENT_BPM,
new BPMSegment(fBeat, fNewBPM)); new BPMSegment(BeatToNoteRow(fBeat), fNewBPM));
} }
} }
} }
@@ -310,7 +310,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;
out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats)); out.AddSegment(SEGMENT_WARP, new WarpSegment(BeatToNoteRow(negBeat), fSkipBeats));
negBeat = -1; negBeat = -1;
negPause = 0; negPause = 0;
@@ -324,7 +324,7 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
else if( fFreezeSeconds > 0.0f ) else if( fFreezeSeconds > 0.0f )
{ {
out.AddSegment(SEGMENT_STOP, out.AddSegment(SEGMENT_STOP,
new StopSegment(fFreezeBeat, fFreezeSeconds)); new StopSegment(BeatToNoteRow(fFreezeBeat), fFreezeSeconds));
} }
} }
@@ -336,7 +336,7 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows
float fSecondsPerBeat = 60 / oldBPM->GetBPM(); float fSecondsPerBeat = 60 / oldBPM->GetBPM();
float fSkipBeats = negPause / fSecondsPerBeat; float fSkipBeats = negPause / fSecondsPerBeat;
out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats)); out.AddSegment(SEGMENT_WARP, new WarpSegment(BeatToNoteRow(negBeat), fSkipBeats));
} }
} }
@@ -361,7 +361,7 @@ 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] );
DelaySegment * new_seg = new DelaySegment(fFreezeBeat, DelaySegment * new_seg = new DelaySegment(BeatToNoteRow(fFreezeBeat),
fFreezeSeconds); 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 );
@@ -390,7 +390,7 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
if( vs2.size() < 3 ) if( vs2.size() < 3 )
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
this->GetSongTitle(), GetSongTitle(),
"has an invalid time signature change with %i values.", "has an invalid time signature change with %i values.",
static_cast<int>(vs2.size()) ); static_cast<int>(vs2.size()) );
continue; continue;
@@ -399,7 +399,7 @@ 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 = TimeSignatureSegment * seg =
new TimeSignatureSegment(fBeat, new TimeSignatureSegment( BeatToNoteRow(fBeat),
StringToInt( vs2[1] ), StringToInt( vs2[1] ),
StringToInt( vs2[2] )); StringToInt( vs2[2] ));
@@ -456,7 +456,7 @@ void SMLoader::ProcessTickcounts( TimingData &out, const RString line, const int
int iTicks = clamp(atoi( arrayTickcountValues[1] ), 0, ROWS_PER_BEAT); int iTicks = clamp(atoi( arrayTickcountValues[1] ), 0, ROWS_PER_BEAT);
out.AddSegment( SEGMENT_TICKCOUNT, out.AddSegment( SEGMENT_TICKCOUNT,
new TickcountSegment(fTickcountBeat, iTicks) ); new TickcountSegment(BeatToNoteRow(fTickcountBeat), iTicks) );
} }
} }
@@ -491,10 +491,16 @@ 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 = new SpeedSegment(fBeat, SpeedSegment * seg = new SpeedSegment( BeatToNoteRow(fBeat),
StringToFloat( vs2[1] ), StringToFloat( vs2[1] ),
StringToFloat( vs2[2] )); StringToFloat( vs2[2] ));
seg->SetUnit(StringToInt(vs2[3]));
// XXX: ugly...
int iUnit = StringToInt(vs2[3]);
SpeedSegment::BaseUnit unit = (iUnit == 0) ?
SpeedSegment::UNIT_BEATS : SpeedSegment::UNIT_SECONDS;
seg->SetUnit( unit );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -505,12 +511,12 @@ void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int row
continue; continue;
} }
if( seg->GetLength() < 0 ) if( seg->GetDelay() < 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->GetDelay() );
continue; continue;
} }
@@ -540,7 +546,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.AddSegment( SEGMENT_FAKE, new FakeSegment(fBeat, fNewBeat) ); out.AddSegment( SEGMENT_FAKE, new FakeSegment(BeatToNoteRow(fBeat), fNewBeat) );
else else
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
+10 -10
View File
@@ -39,7 +39,7 @@ void SMALoader::ProcessMultipliers( TimingData &out, const int iRowsPerBeat, con
iCombos : iCombos :
StringToInt(arrayMultiplierValues[2])); StringToInt(arrayMultiplierValues[2]));
out.AddSegment(SEGMENT_COMBO, out.AddSegment(SEGMENT_COMBO,
new ComboSegment( fComboBeat, iCombos, iMisses )); new ComboSegment( BeatToNoteRow(fComboBeat), iCombos, iMisses ));
} }
} }
@@ -61,10 +61,10 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
static_cast<int>(vs2.size()) ); static_cast<int>(vs2.size()) );
continue; continue;
} }
const float fBeat = StringToFloat( vs2[0] ); const float fBeat = StringToFloat( vs2[0] );
TimeSignatureSegment * seg = new TimeSignatureSegment(fBeat, TimeSignatureSegment * seg = new TimeSignatureSegment(
BeatToNoteRow(fBeat),
StringToInt(vs2[1]), StringToInt(vs2[1]),
4 ); 4 );
@@ -123,12 +123,12 @@ void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int ro
Trim(vs2[2], "s"); Trim(vs2[2], "s");
Trim(vs2[2], "S"); Trim(vs2[2], "S");
unsigned short tmp = ((backup != vs2[2]) ? 1 : 0);
SpeedSegment * seg = new SpeedSegment(fBeat, SpeedSegment::BaseUnit unit = ((backup != vs2[2]) ?
StringToFloat( vs2[1] ), SpeedSegment::UNIT_SECONDS : SpeedSegment::UNIT_BEATS);
StringToFloat(vs2[2]),
tmp); SpeedSegment * seg = new SpeedSegment( BeatToNoteRow(fBeat),
StringToFloat( vs2[1] ), StringToFloat(vs2[2]), unit);
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -139,12 +139,12 @@ void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int ro
continue; continue;
} }
if( seg->GetLength() < 0 ) if( seg->GetDelay() < 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->GetDelay() );
continue; continue;
} }
+5 -5
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.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat - fBeat) ); out.AddSegment( SEGMENT_WARP, new WarpSegment(BeatToNoteRow(fBeat), fNewBeat - fBeat) );
} }
else if( fNewBeat > 0 ) else if( fNewBeat > 0 )
out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat) ); out.AddSegment( SEGMENT_WARP, new WarpSegment(BeatToNoteRow(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.AddSegment( SEGMENT_LABEL, new LabelSegment(fBeat, sLabel) ); out.AddSegment( SEGMENT_LABEL, new LabelSegment(BeatToNoteRow(fBeat), sLabel) );
else else
{ {
LOG->UserLog("Song file", LOG->UserLog("Song file",
@@ -106,7 +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]));
out.AddSegment( SEGMENT_COMBO, new ComboSegment( fComboBeat, iCombos, iMisses ) ); out.AddSegment( SEGMENT_COMBO, new ComboSegment( BeatToNoteRow(fComboBeat), iCombos, iMisses ) );
} }
} }
@@ -131,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 = new ScrollSegment(fBeat, StringToFloat( vs2[1] ) ); ScrollSegment * seg = new ScrollSegment(BeatToNoteRow(fBeat), StringToFloat( vs2[1] ) );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
+1 -1
View File
@@ -142,7 +142,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
for (i = 0; i < speeds.size(); i++) for (i = 0; i < speeds.size(); i++)
{ {
SpeedSegment *ss = static_cast<SpeedSegment *>(speeds[i]); SpeedSegment *ss = static_cast<SpeedSegment *>(speeds[i]);
w.Write( ss->GetRow(), ss->GetRatio(), ss->GetLength(), ss->GetUnit() ); w.Write( ss->GetRow(), ss->GetRatio(), ss->GetDelay(), ss->GetUnit() );
} }
w.Finish(); w.Finish();
+8 -11
View File
@@ -3046,23 +3046,20 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
{ {
if( ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "b" || ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "B" ) if( ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "b" || ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "B" )
{ {
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 0 ); GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), SpeedSegment::UNIT_BEATS );
} }
else if( ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "s" || ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "S" ) else if( ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "s" || ScreenTextEntry::s_sLastAnswer.substr(0, 1) == "S" )
{ {
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 1 ); GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), SpeedSegment::UNIT_SECONDS );
} }
else else
{ {
int tmp = StringToInt(ScreenTextEntry::s_sLastAnswer ); int tmp = StringToInt(ScreenTextEntry::s_sLastAnswer );
if( tmp == 0 )
{ SpeedSegment::BaseUnit unit = (tmp == 0 ) ?
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 0 ); SpeedSegment::UNIT_BEATS : SpeedSegment::UNIT_SECONDS;
}
else GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), unit );
{
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 1 );
}
} }
SetDirty( true ); SetDirty( true );
} }
@@ -4729,7 +4726,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice
ScreenTextEntry::TextEntry( ScreenTextEntry::TextEntry(
SM_BackFromSpeedWaitChange, SM_BackFromSpeedWaitChange,
ENTER_SPEED_WAIT_VALUE, ENTER_SPEED_WAIT_VALUE,
ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() )->GetLength() ), ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() )->GetDelay() ),
10 10
); );
break; break;
+89 -90
View File
@@ -7,7 +7,6 @@
#include "Foreach.h" #include "Foreach.h"
#include <float.h> #include <float.h>
TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset) TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset)
{ {
} }
@@ -46,57 +45,57 @@ TimingData TimingData::CopyRange(int startRow, int endRow) const
{ {
case SEGMENT_BPM: case SEGMENT_BPM:
{ {
cpy = new BPMSegment(*(static_cast<BPMSegment *>(org))); cpy = new BPMSegment(*(ToBPM(org)));
break; break;
} }
case SEGMENT_STOP: case SEGMENT_STOP:
{ {
cpy = new StopSegment(*(static_cast<StopSegment *>(org))); cpy = new StopSegment(*(ToStop(org)));
break; break;
} }
case SEGMENT_DELAY: case SEGMENT_DELAY:
{ {
cpy = new DelaySegment(*(static_cast<DelaySegment *>(org))); cpy = new DelaySegment(*(ToDelay(org)));
break; break;
} }
case SEGMENT_TIME_SIG: case SEGMENT_TIME_SIG:
{ {
cpy = new TimeSignatureSegment(*(static_cast<TimeSignatureSegment *>(org))); cpy = new TimeSignatureSegment(*(ToTimeSignature(org)));
break; break;
} }
case SEGMENT_WARP: case SEGMENT_WARP:
{ {
cpy = new WarpSegment(*(static_cast<WarpSegment *>(org))); cpy = new WarpSegment(*(ToWarp(org)));
break; break;
} }
case SEGMENT_LABEL: case SEGMENT_LABEL:
{ {
cpy = new LabelSegment(*(static_cast<LabelSegment *>(org))); cpy = new LabelSegment(*(ToLabel(org)));
break; break;
} }
case SEGMENT_TICKCOUNT: case SEGMENT_TICKCOUNT:
{ {
cpy = new TickcountSegment(*(static_cast<TickcountSegment *>(org))); cpy = new TickcountSegment(*(ToTickcount(org)));
break; break;
} }
case SEGMENT_COMBO: case SEGMENT_COMBO:
{ {
cpy = new ComboSegment(*(static_cast<ComboSegment *>(org))); cpy = new ComboSegment(*(ToCombo(org)));
break; break;
} }
case SEGMENT_SPEED: case SEGMENT_SPEED:
{ {
cpy = new SpeedSegment(*(static_cast<SpeedSegment *>(org))); cpy = new SpeedSegment(*(ToSpeed(org)));
break; break;
} }
case SEGMENT_SCROLL: case SEGMENT_SCROLL:
{ {
cpy = new ScrollSegment(*(static_cast<ScrollSegment *>(org))); cpy = new ScrollSegment(*(ToScroll(org)));
break; break;
} }
case SEGMENT_FAKE: case SEGMENT_FAKE:
{ {
cpy = new FakeSegment(*(static_cast<FakeSegment *>(org))); cpy = new FakeSegment(*(ToFake(org)));
break; break;
} }
default: FAIL_M(ssprintf("An unknown timing segment type %d can't be copied over!", tst)); default: FAIL_M(ssprintf("An unknown timing segment type %d can't be copied over!", tst));
@@ -119,7 +118,7 @@ void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut, float highe
const vector<TimingSegment *> &bpms = m_avpTimingSegments[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 = ToBPM( bpms[i] );
const float fBPM = seg->GetBPM(); const float fBPM = seg->GetBPM();
fMaxBPMOut = clamp(max( fBPM, fMaxBPMOut ), 0, highest); fMaxBPMOut = clamp(max( fBPM, fMaxBPMOut ), 0, highest);
fMinBPMOut = min( fBPM, fMinBPMOut ); fMinBPMOut = min( fBPM, fMinBPMOut );
@@ -199,16 +198,16 @@ void TimingData::SetBPMAtRow( int iNoteRow, float fBPM )
// There is no BPMSegment at the specified beat. If the BPM being set differs // There is no BPMSegment at the specified beat. If the BPM being set differs
// from the last BPMSegment's BPM, create a new BPMSegment. // from the last BPMSegment's BPM, create a new BPMSegment.
if (i == 0 || if (i == 0 ||
fabsf(static_cast<BPMSegment *>(bpms[i-1])->GetBPM() - fBPM) > 1e-5f ) fabsf( ToBPM(bpms[i-1])->GetBPM() - fBPM) > 1e-5f )
AddSegment( SEGMENT_BPM, new BPMSegment(iNoteRow, fBPM) ); AddSegment( SEGMENT_BPM, new BPMSegment(iNoteRow, fBPM) );
} }
else // BPMSegment being modified is m_BPMSegments[i] else // BPMSegment being modified is m_BPMSegments[i]
{ {
if (i > 0 && if (i > 0 &&
fabsf(static_cast<BPMSegment *>(bpms[i-1])->GetBPM() - fBPM) < 1e-5f ) fabsf(ToBPM(bpms[i-1])->GetBPM() - fBPM) < 1e-5f )
bpms.erase( bpms.begin()+i, bpms.begin()+i+1 ); bpms.erase( bpms.begin()+i, bpms.begin()+i+1 );
else else
static_cast<BPMSegment *>(bpms[i])->SetBPM(fBPM); ToBPM(bpms[i])->SetBPM(fBPM);
} }
} }
@@ -230,7 +229,7 @@ void TimingData::SetStopAtRow( int iRow, float fSeconds )
} }
else // StopSegment being modified is m_StopSegments[i] else // StopSegment being modified is m_StopSegments[i]
{ {
StopSegment *ss = static_cast<StopSegment *>(stops[i]); StopSegment *ss = ToStop(stops[i]);
if( fSeconds > 0 ) if( fSeconds > 0 )
{ {
ss->SetPause(fSeconds); ss->SetPause(fSeconds);
@@ -258,7 +257,7 @@ void TimingData::SetDelayAtRow( int iRow, float fSeconds )
} }
else // DelaySegment being modified is present one else // DelaySegment being modified is present one
{ {
DelaySegment *ss = static_cast<DelaySegment *>(stops[i]); DelaySegment *ss = ToDelay(stops[i]);
if( fSeconds > 0 ) if( fSeconds > 0 )
{ {
ss->SetPause(fSeconds); ss->SetPause(fSeconds);
@@ -282,20 +281,20 @@ void TimingData::SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominat
{ {
// No specific segment here: place one if it differs. // No specific segment here: place one if it differs.
if (i == 0 || if (i == 0 ||
(static_cast<TimeSignatureSegment *>(tSigs[i-1])->GetNum() != iNumerator || (ToTimeSignature(tSigs[i-1])->GetNum() != iNumerator ||
static_cast<TimeSignatureSegment *>(tSigs[i-1])->GetDen() != iDenominator ) ) ToTimeSignature(tSigs[i-1])->GetDen() != iDenominator ) )
AddSegment( SEGMENT_TIME_SIG, new TimeSignatureSegment(iRow, iNumerator, iDenominator) ); AddSegment( SEGMENT_TIME_SIG, new TimeSignatureSegment(iRow, iNumerator, iDenominator) );
} }
else // TimeSignatureSegment being modified is m_vTimeSignatureSegments[i] else // TimeSignatureSegment being modified is m_vTimeSignatureSegments[i]
{ {
if (i > 0 && if (i > 0 &&
static_cast<TimeSignatureSegment *>(tSigs[i-1])->GetNum() == iNumerator && ToTimeSignature(tSigs[i-1])->GetNum() == iNumerator &&
static_cast<TimeSignatureSegment *>(tSigs[i-1])->GetDen() == iDenominator ) ToTimeSignature(tSigs[i-1])->GetDen() == iDenominator )
tSigs.erase( tSigs.begin()+i, tSigs.begin()+i+1 ); tSigs.erase( tSigs.begin()+i, tSigs.begin()+i+1 );
else else
{ {
static_cast<TimeSignatureSegment *>(tSigs[i])->SetNum(iNumerator); ToTimeSignature(tSigs[i])->SetNum(iNumerator);
static_cast<TimeSignatureSegment *>(tSigs[i])->SetDen(iDenominator); ToTimeSignature(tSigs[i])->SetDen(iDenominator);
} }
} }
} }
@@ -331,7 +330,7 @@ void TimingData::SetWarpAtRow( int iRow, float fNew )
{ {
if( valid ) if( valid )
{ {
static_cast<WarpSegment *>(warps[i])->SetLength(fNew); ToWarp(warps[i])->SetLength(fNew);
} }
else else
warps.erase( warps.begin()+i, warps.begin()+i+1 ); warps.erase( warps.begin()+i, warps.begin()+i+1 );
@@ -351,16 +350,16 @@ void TimingData::SetTickcountAtRow( int iRow, int iTicks )
{ {
// No TickcountSegment here. Make a new segment if required. // No TickcountSegment here. Make a new segment if required.
if (i == 0 || if (i == 0 ||
static_cast<TickcountSegment *>(ticks[i-1])->GetTicks() != iTicks ) ToTickcount(ticks[i-1])->GetTicks() != iTicks )
AddSegment( SEGMENT_TICKCOUNT, new TickcountSegment(iRow, iTicks ) ); AddSegment( SEGMENT_TICKCOUNT, new TickcountSegment(iRow, iTicks ) );
} }
else // TickcountSegment being modified is m_TickcountSegments[i] else // TickcountSegment being modified is m_TickcountSegments[i]
{ {
if (i > 0 && if (i > 0 &&
static_cast<TickcountSegment *>(ticks[i-1])->GetTicks() == iTicks ) ToTickcount(ticks[i-1])->GetTicks() == iTicks )
ticks.erase( ticks.begin()+i, ticks.begin()+i+1 ); ticks.erase( ticks.begin()+i, ticks.begin()+i+1 );
else else
static_cast<TickcountSegment *>(ticks[i])->SetTicks(iTicks); ToTickcount(ticks[i])->SetTicks(iTicks);
} }
} }
@@ -375,20 +374,20 @@ void TimingData::SetComboAtRow( int iRow, int iCombo, int iMiss )
if( i == combos.size() || combos[i]->GetRow() != iRow ) if( i == combos.size() || combos[i]->GetRow() != iRow )
{ {
if (i == 0 || if (i == 0 ||
static_cast<ComboSegment *>(combos[i-1])->GetCombo() != iCombo || ToCombo(combos[i-1])->GetCombo() != iCombo ||
static_cast<ComboSegment *>(combos[i-1])->GetMissCombo() != iMiss) ToCombo(combos[i-1])->GetMissCombo() != iMiss)
AddSegment( SEGMENT_COMBO, new ComboSegment(iRow, iCombo, iMiss ) ); AddSegment( SEGMENT_COMBO, new ComboSegment(iRow, iCombo, iMiss ) );
} }
else else
{ {
if (i > 0 && if (i > 0 &&
static_cast<ComboSegment *>(combos[i-1])->GetCombo() == iCombo && ToCombo(combos[i-1])->GetCombo() == iCombo &&
static_cast<ComboSegment *>(combos[i-1])->GetMissCombo() == iMiss) ToCombo(combos[i-1])->GetMissCombo() == iMiss)
combos.erase( combos.begin()+i, combos.begin()+i+1 ); combos.erase( combos.begin()+i, combos.begin()+i+1 );
else else
{ {
static_cast<ComboSegment *>(combos[i])->SetCombo(iCombo); ToCombo(combos[i])->SetCombo(iCombo);
static_cast<ComboSegment *>(combos[i])->SetMissCombo(iMiss); ToCombo(combos[i])->SetMissCombo(iMiss);
} }
} }
} }
@@ -418,21 +417,21 @@ void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
if( i == labels.size() || labels[i]->GetRow() != iRow ) if( i == labels.size() || labels[i]->GetRow() != iRow )
{ {
if (i == 0 || if (i == 0 ||
static_cast<LabelSegment *>(labels[i-1])->GetLabel() != sLabel ) ToLabel(labels[i-1])->GetLabel() != sLabel )
AddSegment( SEGMENT_LABEL, new LabelSegment(iRow, sLabel ) ); AddSegment( SEGMENT_LABEL, new LabelSegment(iRow, sLabel ) );
} }
else else
{ {
if (i > 0 && if (i > 0 &&
( static_cast<LabelSegment *>(labels[i-1])->GetLabel() == sLabel || ( ToLabel(labels[i-1])->GetLabel() == sLabel ||
sLabel == "" ) ) sLabel == "" ) )
labels.erase( labels.begin()+i, labels.begin()+i+1 ); labels.erase( labels.begin()+i, labels.begin()+i+1 );
else else
static_cast<LabelSegment *>(labels[i])->SetLabel(sLabel); ToLabel(labels[i])->SetLabel(sLabel);
} }
} }
void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned short usMode ) void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, SpeedSegment::BaseUnit unit )
{ {
unsigned i; unsigned i;
vector<TimingSegment *> &speeds = m_avpTimingSegments[SEGMENT_SPEED]; vector<TimingSegment *> &speeds = m_avpTimingSegments[SEGMENT_SPEED];
@@ -446,20 +445,20 @@ void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned
{ {
// the core mod itself matters the most for comparisons. // the core mod itself matters the most for comparisons.
if (i == 0 || if (i == 0 ||
static_cast<SpeedSegment *>(speeds[i-1])->GetRatio() != fPercent ) ToSpeed(speeds[i-1])->GetRatio() != fPercent )
AddSegment( SEGMENT_SPEED, new SpeedSegment(iRow, fPercent, fWait, usMode) ); AddSegment( SEGMENT_SPEED, new SpeedSegment(iRow, fPercent, fWait, unit) );
} }
else else
{ {
// The others aren't compared: only the mod itself matters. // The others aren't compared: only the mod itself matters.
if (i > 0 && if (i > 0 &&
static_cast<SpeedSegment *>(speeds[i-1])->GetRatio() == fPercent ) ToSpeed(speeds[i-1])->GetRatio() == fPercent )
speeds.erase( speeds.begin()+i, speeds.begin()+i+1 ); speeds.erase( speeds.begin()+i, speeds.begin()+i+1 );
else else
{ {
static_cast<SpeedSegment *>(speeds[i])->SetRatio(fPercent); ToSpeed(speeds[i])->SetRatio(fPercent);
static_cast<SpeedSegment *>(speeds[i])->SetLength(fWait); ToSpeed(speeds[i])->SetDelay(fWait);
static_cast<SpeedSegment *>(speeds[i])->SetUnit(usMode); ToSpeed(speeds[i])->SetUnit(unit);
} }
} }
} }
@@ -478,18 +477,18 @@ void TimingData::SetScrollAtRow( int iRow, float fPercent )
{ {
// the core mod itself matters the most for comparisons. // the core mod itself matters the most for comparisons.
if (i == 0 || if (i == 0 ||
static_cast<ScrollSegment *>(scrolls[i-1])->GetRatio() != fPercent ) ToScroll(scrolls[i-1])->GetRatio() != fPercent )
AddSegment( SEGMENT_SCROLL, new ScrollSegment(iRow, fPercent) ); AddSegment( SEGMENT_SCROLL, new ScrollSegment(iRow, fPercent) );
} }
else else
{ {
// The others aren't compared: only the mod itself matters. // The others aren't compared: only the mod itself matters.
if (i > 0 && if (i > 0 &&
static_cast<ScrollSegment *>(scrolls[i-1])->GetRatio() == fPercent ) ToScroll(scrolls[i-1])->GetRatio() == fPercent )
scrolls.erase( scrolls.begin()+i, scrolls.begin()+i+1 ); scrolls.erase( scrolls.begin()+i, scrolls.begin()+i+1 );
else else
{ {
static_cast<ScrollSegment *>(scrolls[i])->SetRatio(fPercent); ToScroll(scrolls[i])->SetRatio(fPercent);
} }
} }
} }
@@ -513,7 +512,7 @@ void TimingData::SetFakeAtRow( int iRow, float fNew )
{ {
if( valid ) if( valid )
{ {
static_cast<FakeSegment *>(fakes[i])->SetLength(fNew); ToFake(fakes[i])->SetLength(fNew);
} }
else else
fakes.erase( fakes.begin()+i, fakes.begin()+i+1 ); fakes.erase( fakes.begin()+i, fakes.begin()+i+1 );
@@ -524,7 +523,7 @@ void TimingData::SetSpeedPercentAtRow( int iRow, float fPercent )
{ {
SetSpeedAtRow( iRow, SetSpeedAtRow( iRow,
fPercent, fPercent,
GetSpeedSegmentAtRow( iRow )->GetLength(), GetSpeedSegmentAtRow( iRow )->GetDelay(),
GetSpeedSegmentAtRow( iRow )->GetUnit()); GetSpeedSegmentAtRow( iRow )->GetUnit());
} }
@@ -536,12 +535,12 @@ void TimingData::SetSpeedWaitAtRow( int iRow, float fWait )
GetSpeedSegmentAtRow( iRow )->GetUnit()); GetSpeedSegmentAtRow( iRow )->GetUnit());
} }
void TimingData::SetSpeedModeAtRow( int iRow, unsigned short usMode ) void TimingData::SetSpeedModeAtRow( int iRow, SpeedSegment::BaseUnit unit )
{ {
SetSpeedAtRow( iRow, SetSpeedAtRow( iRow,
GetSpeedSegmentAtRow( iRow )->GetRatio(), GetSpeedSegmentAtRow( iRow )->GetRatio(),
GetSpeedSegmentAtRow( iRow )->GetLength(), GetSpeedSegmentAtRow( iRow )->GetDelay(),
usMode ); unit );
} }
float TimingData::GetStopAtRow( int iRow ) const float TimingData::GetStopAtRow( int iRow ) const
@@ -549,7 +548,7 @@ float TimingData::GetStopAtRow( int iRow ) const
const vector<TimingSegment *> &stops = m_avpTimingSegments[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 = ToStop(stops[i]);
if( s->GetRow() == iRow ) if( s->GetRow() == iRow )
{ {
return s->GetPause(); return s->GetPause();
@@ -564,7 +563,7 @@ float TimingData::GetDelayAtRow( int iRow ) const
const vector<TimingSegment *> &stops = m_avpTimingSegments[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 = ToDelay(stops[i]);
if( s->GetRow() == iRow ) if( s->GetRow() == iRow )
{ {
return s->GetPause(); return s->GetPause();
@@ -577,21 +576,21 @@ int TimingData::GetComboAtRow( int iNoteRow ) const
{ {
const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO]; const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO];
const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow); const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow);
return static_cast<ComboSegment *>(c[index])->GetCombo(); return ToCombo(c[index])->GetCombo();
} }
int TimingData::GetMissComboAtRow(int iNoteRow) const int TimingData::GetMissComboAtRow(int iNoteRow) const
{ {
const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO]; const vector<TimingSegment *> &c = m_avpTimingSegments[SEGMENT_COMBO];
const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow); const int index = GetSegmentIndexAtRow(SEGMENT_COMBO, iNoteRow);
return static_cast<ComboSegment *>(c[index])->GetMissCombo(); return ToCombo(c[index])->GetMissCombo();
} }
RString TimingData::GetLabelAtRow( int iRow ) const RString TimingData::GetLabelAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &l = m_avpTimingSegments[SEGMENT_LABEL]; const vector<TimingSegment *> &l = m_avpTimingSegments[SEGMENT_LABEL];
const int index = GetSegmentIndexAtRow(SEGMENT_LABEL, iRow); const int index = GetSegmentIndexAtRow(SEGMENT_LABEL, iRow);
return static_cast<LabelSegment *>(l[index])->GetLabel(); return ToLabel(l[index])->GetLabel();
} }
float TimingData::GetWarpAtRow( int iWarpRow ) const float TimingData::GetWarpAtRow( int iWarpRow ) const
@@ -601,7 +600,7 @@ float TimingData::GetWarpAtRow( int iWarpRow ) const
{ {
if( warps[i]->GetRow() == iWarpRow ) if( warps[i]->GetRow() == iWarpRow )
{ {
return static_cast<WarpSegment *>(warps[i])->GetLength(); return ToWarp(warps[i])->GetLength();
} }
} }
return 0; return 0;
@@ -614,10 +613,10 @@ float TimingData::GetSpeedPercentAtRow( int iRow )
float TimingData::GetSpeedWaitAtRow( int iRow ) float TimingData::GetSpeedWaitAtRow( int iRow )
{ {
return GetSpeedSegmentAtRow( iRow )->GetLength(); return GetSpeedSegmentAtRow( iRow )->GetDelay();
} }
unsigned short TimingData::GetSpeedModeAtRow( int iRow ) SpeedSegment::BaseUnit TimingData::GetSpeedModeAtRow( int iRow )
{ {
return GetSpeedSegmentAtRow( iRow )->GetUnit(); return GetSpeedSegmentAtRow( iRow )->GetUnit();
} }
@@ -634,7 +633,7 @@ float TimingData::GetFakeAtRow( int iFakeRow ) const
{ {
if( fakes[i]->GetRow() == iFakeRow ) if( fakes[i]->GetRow() == iFakeRow )
{ {
return static_cast<FakeSegment *>(fakes[i])->GetLength(); return ToFake(fakes[i])->GetLength();
} }
} }
return 0; return 0;
@@ -647,7 +646,7 @@ void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float f
vector<TimingSegment *> &bpms = m_avpTimingSegments[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 = ToBPM(bpms[i]);
const int iStartIndexThisSegment = bs->GetRow(); const int iStartIndexThisSegment = bs->GetRow();
const bool bIsLastBPMSegment = i == bpms.size()-1; const bool bIsLastBPMSegment = i == bpms.size()-1;
const int iStartIndexNextSegment = bIsLastBPMSegment ? INT_MAX : bpms[i+1]->GetRow(); const int iStartIndexNextSegment = bIsLastBPMSegment ? INT_MAX : bpms[i+1]->GetRow();
@@ -690,7 +689,7 @@ float TimingData::GetBPMAtRow( int iNoteRow ) const
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;
return static_cast<BPMSegment *>(bpms[i])->GetBPM(); return ToBPM(bpms[i])->GetBPM();
} }
bool TimingData::IsWarpAtRow( int iNoteRow ) const bool TimingData::IsWarpAtRow( int iNoteRow ) const
@@ -700,7 +699,7 @@ bool TimingData::IsWarpAtRow( int iNoteRow ) const
return false; return false;
int i = GetSegmentIndexAtRow( SEGMENT_WARP, iNoteRow ); int i = GetSegmentIndexAtRow( SEGMENT_WARP, iNoteRow );
const WarpSegment *s = static_cast<WarpSegment *>(warps[i]); const WarpSegment *s = ToWarp(warps[i]);
float beatRow = NoteRowToBeat(iNoteRow); float beatRow = NoteRowToBeat(iNoteRow);
if( s->GetBeat() <= beatRow && beatRow < (s->GetBeat() + s->GetLength() ) ) if( s->GetBeat() <= beatRow && beatRow < (s->GetBeat() + s->GetLength() ) )
{ {
@@ -725,7 +724,7 @@ bool TimingData::IsFakeAtRow( int iNoteRow ) const
return false; return false;
int i = GetSegmentIndexAtRow( SEGMENT_FAKE, iNoteRow ); int i = GetSegmentIndexAtRow( SEGMENT_FAKE, iNoteRow );
const FakeSegment *s = static_cast<FakeSegment *>(fakes[i]); const FakeSegment *s = ToFake(fakes[i]);
float beatRow = NoteRowToBeat(iNoteRow); float beatRow = NoteRowToBeat(iNoteRow);
if( s->GetBeat() <= beatRow && beatRow < ( s->GetBeat() + s->GetLength() ) ) if( s->GetBeat() <= beatRow && beatRow < ( s->GetBeat() + s->GetLength() ) )
{ {
@@ -774,7 +773,7 @@ int TimingData::GetTickcountAtRow( int iRow ) const
{ {
const vector<TimingSegment *> &ticks = m_avpTimingSegments[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 ToTickcount(ticks[index])->GetTicks();
} }
bool TimingData::DoesLabelExist( RString sLabel ) const bool TimingData::DoesLabelExist( RString sLabel ) const
@@ -782,7 +781,7 @@ bool TimingData::DoesLabelExist( RString sLabel ) const
const vector<TimingSegment *> &labels = m_avpTimingSegments[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 (ToLabel(labels[i])->GetLabel() == sLabel)
return true; return true;
} }
return false; return false;
@@ -878,13 +877,13 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
bIsWarping = false; bIsWarping = false;
break; break;
case FOUND_BPM_CHANGE: case FOUND_BPM_CHANGE:
fBPS = static_cast<BPMSegment *>(*itBPMS)->GetBPS(); fBPS = ToBPM(*itBPMS)->GetBPS();
itBPMS ++; itBPMS ++;
break; break;
case FOUND_DELAY: case FOUND_DELAY:
case FOUND_STOP_DELAY: case FOUND_STOP_DELAY:
{ {
const DelaySegment *ss = static_cast<DelaySegment *>(*itDS); const DelaySegment *ss = ToDelay(*itDS);
fTimeToNextEvent = ss->GetPause(); fTimeToNextEvent = ss->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent; fNextEventTime = fLastTime + fTimeToNextEvent;
if ( fElapsedTime < fNextEventTime ) if ( fElapsedTime < fNextEventTime )
@@ -902,7 +901,7 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
} }
case FOUND_STOP: case FOUND_STOP:
{ {
const StopSegment *ss = static_cast<StopSegment *>(*itSS); const StopSegment *ss = ToStop(*itSS);
fTimeToNextEvent = ss->GetPause(); fTimeToNextEvent = ss->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent; fNextEventTime = fLastTime + fTimeToNextEvent;
if ( fElapsedTime < fNextEventTime ) if ( fElapsedTime < fNextEventTime )
@@ -920,7 +919,7 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
case FOUND_WARP: case FOUND_WARP:
{ {
bIsWarping = true; bIsWarping = true;
const WarpSegment *ws = static_cast<WarpSegment *>(*itWS); const WarpSegment *ws = ToWarp(*itWS);
float fWarpSum = ws->GetLength() + ws->GetBeat(); float fWarpSum = ws->GetLength() + ws->GetBeat();
if( fWarpSum > fWarpDestination ) if( fWarpSum > fWarpDestination )
{ {
@@ -1007,17 +1006,17 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
bIsWarping = false; bIsWarping = false;
break; break;
case FOUND_BPM_CHANGE: case FOUND_BPM_CHANGE:
fBPS = static_cast<BPMSegment *>(*itBPMS)->GetBPS(); fBPS = ToBPM(*itBPMS)->GetBPS();
itBPMS ++; itBPMS ++;
break; break;
case FOUND_STOP: case FOUND_STOP:
fTimeToNextEvent = static_cast<StopSegment *>(*itSS)->GetPause(); fTimeToNextEvent = ToStop(*itSS)->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent; fNextEventTime = fLastTime + fTimeToNextEvent;
fLastTime = fNextEventTime; fLastTime = fNextEventTime;
itSS ++; itSS ++;
break; break;
case FOUND_DELAY: case FOUND_DELAY:
fTimeToNextEvent = static_cast<DelaySegment *>(*itDS)->GetPause(); fTimeToNextEvent = ToDelay(*itDS)->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent; fNextEventTime = fLastTime + fTimeToNextEvent;
fLastTime = fNextEventTime; fLastTime = fNextEventTime;
itDS ++; itDS ++;
@@ -1027,7 +1026,7 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
case FOUND_WARP: case FOUND_WARP:
{ {
bIsWarping = true; bIsWarping = true;
WarpSegment *ws = static_cast<WarpSegment *>(*itWS); WarpSegment *ws = ToWarp(*itWS);
float fWarpSum = ws->GetLength() + ws->GetBeat(); float fWarpSum = ws->GetLength() + ws->GetBeat();
if( fWarpSum > fWarpDestination ) if( fWarpSum > fWarpDestination )
{ {
@@ -1053,9 +1052,9 @@ float TimingData::GetDisplayedBeat( float fBeat ) const
{ {
if( scrolls[i+1]->GetBeat() > fBeat ) if( scrolls[i+1]->GetBeat() > fBeat )
break; break;
fOutBeat += (scrolls[i+1]->GetBeat() - scrolls[i]->GetBeat()) * static_cast<ScrollSegment *>(scrolls[i])->GetRatio(); fOutBeat += (scrolls[i+1]->GetBeat() - scrolls[i]->GetBeat()) * ToScroll(scrolls[i])->GetRatio();
} }
fOutBeat += (fBeat - scrolls[i]->GetBeat()) * static_cast<ScrollSegment *>(scrolls[i])->GetRatio(); fOutBeat += (fBeat - scrolls[i]->GetBeat()) * ToScroll(scrolls[i])->GetRatio();
return fOutBeat; return fOutBeat;
} }
@@ -1086,7 +1085,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
// 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++ )
{ {
BPMSegment *bpm = static_cast<BPMSegment *>(bpms[i]); BPMSegment *bpm = ToBPM(bpms[i]);
const int iSegStart = bpm->GetRow(); const int iSegStart = bpm->GetRow();
if( iSegStart <= iStartIndex ) if( iSegStart <= iStartIndex )
continue; continue;
@@ -1175,7 +1174,7 @@ float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds
const int index = GetSegmentIndexAtBeat( SEGMENT_SPEED, fSongBeat ); const int index = GetSegmentIndexAtBeat( SEGMENT_SPEED, fSongBeat );
const SpeedSegment *seg = static_cast<SpeedSegment *>(speeds[index]); const SpeedSegment *seg = ToSpeed(speeds[index]);
float fStartBeat = seg->GetBeat(); float fStartBeat = seg->GetBeat();
float fStartTime = GetElapsedTimeFromBeat( fStartBeat ) - GetDelayAtBeat( fStartBeat ); float fStartTime = GetElapsedTimeFromBeat( fStartBeat ) - GetDelayAtBeat( fStartBeat );
float fEndTime; float fEndTime;
@@ -1183,25 +1182,25 @@ float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds
if( seg->GetUnit() == 1 ) // seconds if( seg->GetUnit() == 1 ) // seconds
{ {
fEndTime = fStartTime + seg->GetLength(); fEndTime = fStartTime + seg->GetDelay();
} }
else else
{ {
fEndTime = GetElapsedTimeFromBeat( fStartBeat + seg->GetLength() ) fEndTime = GetElapsedTimeFromBeat( fStartBeat + seg->GetDelay() )
- GetDelayAtBeat( fStartBeat + seg->GetLength() ); - GetDelayAtBeat( fStartBeat + seg->GetDelay() );
} }
SpeedSegment *first = static_cast<SpeedSegment *>(speeds[0]); SpeedSegment *first = ToSpeed(speeds[0]);
if( ( index == 0 && first->GetLength() > 0.0 ) && fCurTime < fStartTime ) if( ( index == 0 && first->GetDelay() > 0.0 ) && fCurTime < fStartTime )
{ {
return 1.0f; return 1.0f;
} }
else if( fEndTime >= fCurTime && ( index > 0 || first->GetLength() > 0.0 ) ) else if( fEndTime >= fCurTime && ( index > 0 || first->GetDelay() > 0.0 ) )
{ {
const float fPriorSpeed = (index == 0 ? const float fPriorSpeed = (index == 0 ?
1 : 1 :
static_cast<SpeedSegment *>(speeds[index - 1])->GetRatio() ); ToSpeed(speeds[index - 1])->GetRatio() );
float fTimeUsed = fCurTime - fStartTime; float fTimeUsed = fCurTime - fStartTime;
float fDuration = fEndTime - fStartTime; float fDuration = fEndTime - fStartTime;
float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration; float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration;
@@ -1304,14 +1303,14 @@ bool TimingData::HasSpeedChanges() const
{ {
const vector<TimingSegment *> &speeds = m_avpTimingSegments[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); ToSpeed(speeds[0])->GetRatio() != 1);
} }
bool TimingData::HasScrollChanges() const bool TimingData::HasScrollChanges() const
{ {
const vector<TimingSegment *> &scrolls = m_avpTimingSegments[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); ToScroll(scrolls[0])->GetRatio() != 1);
} }
void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const
@@ -1320,7 +1319,7 @@ void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, i
const vector<TimingSegment *> &tSigs = m_avpTimingSegments[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 = ToTimeSignature(tSigs[i]);
int iSegmentEndRow = (i + 1 == tSigs.size()) ? INT_MAX : curSig->GetRow(); int iSegmentEndRow = (i + 1 == tSigs.size()) ? INT_MAX : curSig->GetRow();
int iRowsPerMeasureThisSegment = curSig->GetNoteRowsPerMeasure(); int iRowsPerMeasureThisSegment = curSig->GetNoteRowsPerMeasure();
@@ -1426,7 +1425,7 @@ public:
vector<TimingSegment *> &bpms = p->m_avpTimingSegments[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 = ToBPM(bpms[i]);
const float fBPM = seg->GetBPM(); const float fBPM = seg->GetBPM();
vBPMs.push_back( fBPM ); vBPMs.push_back( fBPM );
} }
+64 -22
View File
@@ -10,6 +10,36 @@ struct lua_State;
/** @brief Compare a TimingData segment's properties with one another. */ /** @brief Compare a TimingData segment's properties with one another. */
#define COMPARE(x) if(this->x!=other.x) return false; #define COMPARE(x) if(this->x!=other.x) return false;
/* convenience functions to handle static casting */
template<class T> T* ToDerived( TimingSegment *t, TimingSegmentType tst )
{
ASSERT( t->GetType() == tst ); // type checking
return static_cast<T*>( t );
}
#define TimingSegmentToXWithName(Seg, SegName, SegType) \
inline Seg* To##SegName( TimingSegment *t ) { return ToDerived<Seg>(t, SegType); }
#define TimingSegmentToX(Seg, SegType) \
TimingSegmentToXWithName(Seg##Segment, Seg, SEGMENT_##SegType)
/* ToBPM(TimingSegment*), ToTimeSignature(TimingSegment*), etc. */
TimingSegmentToX( BPM, BPM );
TimingSegmentToX( Stop, STOP );
TimingSegmentToX( Delay, DELAY );
TimingSegmentToX( TimeSignature, TIME_SIG );
TimingSegmentToX( Warp, WARP );
TimingSegmentToX( Label, LABEL );
TimingSegmentToX( Tickcount, TICKCOUNT );
TimingSegmentToX( Combo, COMBO );
TimingSegmentToX( Speed, SPEED );
TimingSegmentToX( Scroll, SCROLL );
TimingSegmentToX( Fake, FAKE );
#undef TimingSegmentToXWithName
#undef TimingSegmentToX
/** /**
* @brief Holds data for translating beats<->seconds. * @brief Holds data for translating beats<->seconds.
*/ */
@@ -87,6 +117,7 @@ public:
* @return the segment in question. * @return the segment in question.
*/ */
TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst ); TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst );
/** /**
* @brief Retrieve the TimingSegment at the given beat. * @brief Retrieve the TimingSegment at the given beat.
* @param fBeat the beat that has a TimingSegment. * @param fBeat the beat that has a TimingSegment.
@@ -98,34 +129,45 @@ public:
return GetSegmentAtRow( BeatToNoteRow(fBeat), tst ); return GetSegmentAtRow( BeatToNoteRow(fBeat), tst );
} }
void SetTimingSegmentAtRow( TimingSegment *seg, int iNoteRow );
/* XXX: convenience shortcuts. We should get rid of these later. */ /* XXX: convenience shortcuts. We should get rid of these later. */
#define GetSegmentWithName(Seg, SegType) \ #define GetAndSetSegmentWithName(Seg, SegName, SegType) \
Seg* Get##Seg##AtRow( int iNoteRow ) \ Seg* Get##Seg##AtRow( int iNoteRow ) \
{ \ { \
TimingSegment *t = GetSegmentAtRow( iNoteRow, SegType ); \ TimingSegment *t = GetSegmentAtRow( iNoteRow, SegType ); \
return static_cast<Seg*>( t ); \ return To##SegName( t ); \
} \ } \
Seg* Get##Seg##AtBeat( float fBeat ) \ Seg* Get##Seg##AtBeat( float fBeat ) \
{ \ { \
TimingSegment *t = GetSegmentAtBeat( fBeat, SegType ); \ TimingSegment *t = GetSegmentAtBeat( fBeat, SegType ); \
return static_cast<Seg*>( t ); \ return To##SegName( t ); \
} \
void Set##SegName##AtRow( Seg &seg, int iNoteRow ) \
{ \
SetTimingSegmentAtRow( &seg, iNoteRow ); \
} }
// (TimeSignature,TIME_SIG) -> (TimeSignatureSegment,SEGMENT_TIME_SIG) // (TimeSignature,TIME_SIG) -> (TimeSignatureSegment,SEGMENT_TIME_SIG)
#define GetSegment(Seg, SegType ) \ #define GetAndSetSegment(Seg, SegType ) \
GetSegmentWithName( Seg##Segment, SEGMENT_##SegType ) GetAndSetSegmentWithName( Seg##Segment, Seg, SEGMENT_##SegType )
GetAndSetSegment( BPM, BPM );
GetAndSetSegment( Stop, STOP );
GetAndSetSegment( Delay, DELAY );
GetAndSetSegment( Warp, WARP );
GetAndSetSegment( Label, LABEL );
GetAndSetSegment( Tickcount, TICKCOUNT );
GetAndSetSegment( Combo, COMBO );
GetAndSetSegment( Speed, SPEED );
GetAndSetSegment( Scroll, SCROLL );
GetAndSetSegment( Fake, FAKE );
GetAndSetSegment( TimeSignature, TIME_SIG );
#undef GetAndSetSegmentWithName
#undef GetAndSetSegment
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.
@@ -443,13 +485,13 @@ public:
* @param iNoteRow the row in question. * @param iNoteRow the row in question.
* @return the mode. * @return the mode.
*/ */
unsigned short GetSpeedModeAtRow( int iNoteRow ); SpeedSegment::BaseUnit GetSpeedModeAtRow( int iNoteRow );
/** /**
* @brief Retrieve the Speed's mode at the given beat. * @brief Retrieve the Speed's mode at the given beat.
* @param fBeat the beat in question. * @param fBeat the beat in question.
* @return the mode. * @return the mode.
*/ */
unsigned short GetSpeedModeAtBeat( float fBeat ) { return GetSpeedModeAtRow( BeatToNoteRow(fBeat) ); } SpeedSegment::BaseUnit GetSpeedModeAtBeat( float fBeat ) { return GetSpeedModeAtRow( BeatToNoteRow(fBeat) ); }
/** /**
* @brief Set the row to have the new Speed. * @brief Set the row to have the new Speed.
* @param iNoteRow the row to have the new Speed. * @param iNoteRow the row to have the new Speed.
@@ -457,7 +499,7 @@ public:
* @param fWait the wait. * @param fWait the wait.
* @param usMode the mode. * @param usMode the mode.
*/ */
void SetSpeedAtRow( int iNoteRow, float fPercent, float fWait, unsigned short usMode ); void SetSpeedAtRow( int iNoteRow, float fPercent, float fWait, SpeedSegment::BaseUnit unit );
/** /**
* @brief Set the beat to have the new Speed. * @brief Set the beat to have the new Speed.
* @param fBeat the beat to have the new Speed. * @param fBeat the beat to have the new Speed.
@@ -465,7 +507,7 @@ public:
* @param fWait the wait. * @param fWait the wait.
* @param usMode the mode. * @param usMode the mode.
*/ */
void SetSpeedAtBeat( float fBeat, float fPercent, float fWait, unsigned short usMode ) { SetSpeedAtRow( BeatToNoteRow(fBeat), fPercent, fWait, usMode ); } void SetSpeedAtBeat( float fBeat, float fPercent, float fWait, SpeedSegment::BaseUnit unit ) { SetSpeedAtRow( BeatToNoteRow(fBeat), fPercent, fWait, unit ); }
/** /**
* @brief Set the row to have the new Speed percent. * @brief Set the row to have the new Speed percent.
* @param iNoteRow the row to have the new Speed percent. * @param iNoteRow the row to have the new Speed percent.
@@ -495,13 +537,13 @@ public:
* @param iNoteRow the row to have the new Speed mode. * @param iNoteRow the row to have the new Speed mode.
* @param usMode the mode. * @param usMode the mode.
*/ */
void SetSpeedModeAtRow( int iNoteRow, unsigned short usMode ); void SetSpeedModeAtRow( int iNoteRow, SpeedSegment::BaseUnit unit );
/** /**
* @brief Set the beat to have the new Speed mode. * @brief Set the beat to have the new Speed mode.
* @param fBeat the beat to have the new Speed mode. * @param fBeat the beat to have the new Speed mode.
* @param usMode the mode. * @param usMode the mode.
*/ */
void SetSpeedModeAtBeat( float fBeat, unsigned short usMode ) { SetSpeedModeAtRow( BeatToNoteRow(fBeat), usMode); } void SetSpeedModeAtBeat( float fBeat, SpeedSegment::BaseUnit unit ) { SetSpeedModeAtRow( BeatToNoteRow(fBeat), unit); }
float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const; float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const;
+51 -266
View File
@@ -19,45 +19,16 @@ XToString( TimingSegmentType );
#define LTCOMPARE(x) if(this->x < other.x) return true; if(this->x > other.x) return false; #define LTCOMPARE(x) if(this->x < other.x) return true; if(this->x > other.x) return false;
TimingSegment::~TimingSegment() {}
void TimingSegment::SetRow(const int s)
{
this->startingRow = s;
}
void TimingSegment::SetBeat(const float s)
{
SetRow(BeatToNoteRow(s));
}
int TimingSegment::GetRow() const
{
return this->startingRow;
}
float TimingSegment::GetBeat() const
{
return NoteRowToBeat(GetRow());
}
void TimingSegment::Scale( int start, int length, int newLength ) void TimingSegment::Scale( int start, int length, int newLength )
{ {
SetRow( ScalePosition( start, length, newLength, this->GetRow() ) ); SetRow( ScalePosition( start, length, newLength, this->GetRow() ) );
} }
RString FakeSegment::ToString(int dec) const
/* ======================================================
Here comes the actual timing segments implementation!! */
float FakeSegment::GetLength() const
{ {
return this->lengthBeats; RString str = "%.0" + IntToString(dec)
} + "f=%.0" + IntToString(dec) + "f";
return ssprintf(str.c_str(), GetBeat(), GetLength());
void FakeSegment::SetLength(const float b)
{
this->lengthBeats = b;
} }
void FakeSegment::Scale( int start, int length, int newLength ) void FakeSegment::Scale( int start, int length, int newLength )
@@ -70,24 +41,11 @@ void FakeSegment::Scale( int start, int length, int newLength )
TimingSegment::Scale( start, length, newLength ); TimingSegment::Scale( start, length, newLength );
} }
bool FakeSegment::operator<( const FakeSegment &other ) const RString WarpSegment::ToString(int dec) const
{ {
LTCOMPARE(GetRow()); RString str = "%.0" + IntToString(dec)
LTCOMPARE(GetLength()); + "f=%.0" + IntToString(dec) + "f";
return false; return ssprintf(str.c_str(), GetBeat(), GetLength());
}
float WarpSegment::GetLength() const
{
return this->lengthBeats;
}
void WarpSegment::SetLength(const float b)
{
this->lengthBeats = b;
} }
void WarpSegment::Scale( int start, int length, int newLength ) void WarpSegment::Scale( int start, int length, int newLength )
@@ -101,180 +59,48 @@ void WarpSegment::Scale( int start, int length, int newLength )
TimingSegment::Scale( start, length, newLength ); TimingSegment::Scale( start, length, newLength );
} }
bool WarpSegment::operator<( const WarpSegment &other ) const RString TickcountSegment::ToString(int dec) const
{ {
LTCOMPARE(GetRow()); const RString str = "%.0" + IntToString(dec) + "f=%i";
LTCOMPARE(GetLength()); return ssprintf(str.c_str(), GetBeat(), GetTicks());
return false; }
RString ComboSegment::ToString(int dec) const
{
RString str = "%.0" + IntToString(dec) + "f=%i";
if (GetCombo() == GetMissCombo())
{
return ssprintf(str.c_str(), GetBeat(), GetCombo());
}
str += "=%i";
return ssprintf(str.c_str(), GetBeat(), GetCombo(), GetMissCombo());
} }
RString LabelSegment::ToString(int dec) const
int TickcountSegment::GetTicks() const
{ {
return this->ticks; const RString str = "%.0" + IntToString(dec) + "f=%s";
return ssprintf(str.c_str(), GetBeat(), GetLabel().c_str());
} }
void TickcountSegment::SetTicks(const int i) RString BPMSegment::ToString(int dec) const
{ {
this->ticks = i; const RString str = "%.0" + IntToString(dec)
+ "f=%.0" + IntToString(dec) + "f";
return ssprintf(str.c_str(), GetBeat(), GetBPM());
} }
bool TickcountSegment::operator<( const TickcountSegment &other ) const RString TimeSignatureSegment::ToString(int dec) const
{ {
LTCOMPARE(GetRow()); const RString str = "%.0" + IntToString(dec) + "f=%i=%i";
LTCOMPARE(GetTicks()); return ssprintf(str.c_str(), GetBeat(), GetNum(), GetDen());
return false;
} }
RString SpeedSegment::ToString(int dec) const
int ComboSegment::GetCombo() const
{ {
return this->combo; const RString str = "%.0" + IntToString(dec)
} + "f=%.0" + IntToString(dec) + "f=%.0"
+ IntToString(dec) + "f=%u";
void ComboSegment::SetCombo(const int i) return ssprintf(str.c_str(), GetBeat(), GetRatio(),
{ GetDelay(), GetUnit());
this->combo = i;
}
int ComboSegment::GetMissCombo() const
{
return this->missCombo;
}
void ComboSegment::SetMissCombo(const int i)
{
this->missCombo = i;
}
bool ComboSegment::operator<( const ComboSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetCombo());
LTCOMPARE(GetMissCombo());
return false;
}
RString LabelSegment::GetLabel() const
{
return this->label;
}
void LabelSegment::SetLabel(const RString l)
{
this->label = l;
}
bool LabelSegment::operator<( const LabelSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetLabel());
return false;
}
float BPMSegment::GetBPM() const
{
return this->bps * 60.0f;
}
void BPMSegment::SetBPM(const float bpm)
{
this->bps = bpm / 60.0f;
}
float BPMSegment::GetBPS() const
{
return this->bps;
}
void BPMSegment::SetBPS(const float newBPS)
{
this->bps = newBPS;
}
bool BPMSegment::operator<( const BPMSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetBPS());
return false;
}
int TimeSignatureSegment::GetNum() const
{
return this->numerator;
}
void TimeSignatureSegment::SetNum(const int i)
{
this->numerator = i;
}
int TimeSignatureSegment::GetDen() const
{
return this->denominator;
}
void TimeSignatureSegment::SetDen(const int i)
{
this->denominator = i;
}
int TimeSignatureSegment::GetNoteRowsPerMeasure() const
{
return BeatToNoteRow(1) * 4 * numerator / denominator;
}
bool TimeSignatureSegment::operator<( const TimeSignatureSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetNum());
LTCOMPARE(GetDen());
return false;
}
float SpeedSegment::GetRatio() const
{
return this->ratio;
}
void SpeedSegment::SetRatio(const float i)
{
this->ratio = i;
}
float SpeedSegment::GetLength() const
{
return this->length;
}
void SpeedSegment::SetLength(const float i)
{
this->length = i;
}
unsigned short SpeedSegment::GetUnit() const
{
return this->unit;
}
void SpeedSegment::SetUnit(const unsigned short i)
{
this->unit = i;
}
void SpeedSegment::SetUnit(const int i)
{
this->unit = static_cast<unsigned short>(i);
} }
void SpeedSegment::Scale( int start, int oldLength, int newLength ) void SpeedSegment::Scale( int start, int oldLength, int newLength )
@@ -283,7 +109,7 @@ void SpeedSegment::Scale( int start, int oldLength, int newLength )
{ {
// XXX: this function is duplicated, there should be a better way // XXX: this function is duplicated, there should be a better way
float startBeat = GetBeat(); float startBeat = GetBeat();
float endBeat = startBeat + GetLength(); float endBeat = startBeat + GetDelay();
float newStartBeat = ScalePosition(NoteRowToBeat(start), float newStartBeat = ScalePosition(NoteRowToBeat(start),
NoteRowToBeat(oldLength), NoteRowToBeat(oldLength),
NoteRowToBeat(newLength), NoteRowToBeat(newLength),
@@ -292,73 +118,32 @@ void SpeedSegment::Scale( int start, int oldLength, int newLength )
NoteRowToBeat(oldLength), NoteRowToBeat(oldLength),
NoteRowToBeat(newLength), NoteRowToBeat(newLength),
endBeat); endBeat);
SetLength( newEndBeat - newStartBeat ); SetDelay( newEndBeat - newStartBeat );
} }
TimingSegment::Scale( start, oldLength, newLength ); TimingSegment::Scale( start, oldLength, newLength );
} }
bool SpeedSegment::operator<( const SpeedSegment &other ) const RString ScrollSegment::ToString(int dec) const
{ {
LTCOMPARE(GetRow()); const RString str = "%.0" + IntToString(dec)
LTCOMPARE(GetRatio()); + "f=%.0" + IntToString(dec) + "f";
LTCOMPARE(GetLength()); return ssprintf(str.c_str(), GetBeat(), GetRatio());
LTCOMPARE(GetUnit());
return false;
} }
float ScrollSegment::GetRatio() const RString StopSegment::ToString(int dec) const
{ {
return this->ratio; const RString str = "%.0" + IntToString(dec)
+ "f=%.0" + IntToString(dec) + "f";
return ssprintf(str.c_str(), GetBeat(), GetPause());
} }
void ScrollSegment::SetRatio(const float i) RString DelaySegment::ToString(int dec) const
{ {
this->ratio = i; const RString str = "%.0" + IntToString(dec)
+ "f=%.0" + IntToString(dec) + "f";
return ssprintf(str.c_str(), GetBeat(), GetPause());
} }
bool ScrollSegment::operator<( const ScrollSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetRatio());
return false;
}
float StopSegment::GetPause() const
{
return this->pauseSeconds;
}
void StopSegment::SetPause(const float i)
{
this->pauseSeconds = i;
}
bool StopSegment::operator<( const StopSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetPause());
return false;
}
float DelaySegment::GetPause() const
{
return this->pauseSeconds;
}
void DelaySegment::SetPause(const float i)
{
this->pauseSeconds = i;
}
bool DelaySegment::operator<( const DelaySegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetPause());
return false;
}
#undef LTCOMPARE
/** /**
* @file * @file
* @author Jason Felds (c) 2011 * @author Jason Felds (c) 2011
+216 -754
View File
File diff suppressed because it is too large Load Diff