diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index 16cbeaa1fe..fb7d1fb11d 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -306,6 +306,48 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam ) } } +void SMALoader::ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam ) +{ + vector vs1; + split( sParam, ",", vs1 ); + + FOREACH_CONST( RString, vs1, s1 ) + { + vector vs2; + split( *s1, "=", vs2 ); + + if( vs2[0] == 0 ) // First one always seems to have 2. + { + vs2.push_back(0); + } + + if( vs2.size() < 3 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with %i values.", (int)vs2.size() ); + continue; + } + + const float fBeat = RowToBeat( vs2[0], iRowsPerBeat ); + + SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] )); + + if( fBeat < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f.", fBeat ); + continue; + } + + if( seg.m_fWait < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, fWait %f.", fBeat, seg.m_fWait ); + continue; + } + + out.AddSpeedSegment( seg ); + } +} + + void SMALoader::LoadFromSMATokens( RString sStepsType, RString sDescription, diff --git a/src/NotesLoaderSMA.h b/src/NotesLoaderSMA.h index 1c40b462f2..af397205fb 100644 --- a/src/NotesLoaderSMA.h +++ b/src/NotesLoaderSMA.h @@ -47,6 +47,7 @@ namespace SMALoader void ProcessDelays( TimingData &out, const int iRowsPerBeat, const RString sParam ); void ProcessTickcounts( TimingData &out, const int iRowsPerBeat, const RString sParam ); void ProcessMultipliers( TimingData &out, const int iRowsPerBeat, const RString sParam ); + void ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam ); float RowToBeat( RString sLine, const int iRowsPerBeat ); }; diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index b576d26ca0..8003a20754 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -126,6 +126,48 @@ void SSCLoader::ProcessCombos( TimingData &out, const RString sParam ) } } +void SSCLoader::ProcessSpeeds( TimingData &out, const RString sParam ) +{ + vector vs1; + split( sParam, ",", vs1 ); + + FOREACH_CONST( RString, vs1, s1 ) + { + vector vs2; + split( *s1, "=", vs2 ); + + if( vs2[0] == 0 ) // First one always seems to have 2. + { + vs2.push_back(0); + } + + if( vs2.size() < 3 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with %i values.", (int)vs2.size() ); + continue; + } + + const float fBeat = StringToFloat( vs2[0] ); + + SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] )); + + if( fBeat < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f.", fBeat ); + continue; + } + + if( seg.m_fWait < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, fWait %f.", fBeat, seg.m_fWait ); + continue; + } + + out.AddSpeedSegment( seg ); + } +} + + bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCache ) { LOG->Trace( "Song::LoadFromSSCFile(%s)", sPath.c_str() ); diff --git a/src/NotesLoaderSSC.h b/src/NotesLoaderSSC.h index 7d185cc690..c78231677b 100644 --- a/src/NotesLoaderSSC.h +++ b/src/NotesLoaderSSC.h @@ -80,6 +80,7 @@ namespace SSCLoader void ProcessWarps( TimingData &, const RString ); void ProcessLabels( TimingData &, const RString ); void ProcessCombos( TimingData &, const RString ); + void ProcessSpeeds( TimingData &, const RString ); } #endif /** diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 3e7882741e..3d036c538c 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -76,6 +76,7 @@ struct TimingTagWriter { void Write( const int row, const float value ) { Write( row, ssprintf( "%.6f", value ) ); } void Write( const int row, const int value ) { Write( row, ssprintf( "%d", value ) ); } void Write( const int row, const int a, const int b ) { Write( row, ssprintf( "%d=%d", a, b ) ); } + void Write( const int row, const float a, const float b ) { Write( row, ssprintf( "%.6f=%.6f", a, b) ); } void Init( const RString sTag ) { m_sNext = "#" + sTag + ":"; } void Finish( ) { m_pvsLines->push_back( ( m_sNext != "," ? m_sNext : "" ) + ";" ); } @@ -131,6 +132,14 @@ static void GetTimingTags( vector &lines, TimingData timing, bool bIsSo w.Write( cs->m_iStartRow, cs->m_iCombo ); w.Finish(); + if( !bIsSong ) + { + w.Init( "SPEEDS" ); + FOREACH_CONST( SpeedSegment, timing.m_SpeedSegments, ss ) + w.Write( ss->m_iStartRow, ss->m_fPercent, ss->m_fWait ); + w.Finish(); + } + w.Init( "LABELS" ); FOREACH_CONST( LabelSegment, timing.m_LabelSegments, ls ) w.Write( ls->m_iStartRow, ls->m_sLabel.c_str() );