[warps] merge

This commit is contained in:
Thai Pangsakulyanont
2011-03-26 14:53:27 +07:00
+38 -36
View File
@@ -104,8 +104,6 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
out.m_WarpSegments.clear(); out.m_WarpSegments.clear();
out.m_vTimeSignatureSegments.clear(); out.m_vTimeSignatureSegments.clear();
vector<WarpSegment> arrayWarpsFromNegativeStops;
for( unsigned i=0; i<msd.GetNumValues(); i++ ) for( unsigned i=0; i<msd.GetNumValues(); i++ )
{ {
const MsdFile::value_t &sParams = msd.GetValue(i); const MsdFile::value_t &sParams = msd.GetValue(i);
@@ -174,6 +172,10 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
vector<RString> arrayFreezeExpressions; vector<RString> arrayFreezeExpressions;
split( sParams[1], ",", arrayFreezeExpressions ); split( sParams[1], ",", arrayFreezeExpressions );
// Prepare variables for negative stop conversion.
float negBeat = -1;
float negPause = 0;
for( unsigned f=0; f<arrayFreezeExpressions.size(); f++ ) for( unsigned f=0; f<arrayFreezeExpressions.size(); f++ )
{ {
vector<RString> arrayFreezeValues; vector<RString> arrayFreezeValues;
@@ -188,36 +190,46 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] ); const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] );
const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] ); const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] );
StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds );
// XXX: Remove Negatives Bug? // Process the prior stop.
new_seg.m_iStartRow = BeatToNoteRow(fFreezeBeat); if( negPause > 0 )
new_seg.m_fStopSeconds = fFreezeSeconds; {
BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat));
float fSecondsPerBeat = 60 / oldBPM.GetBPM();
float fSkipBeats = negPause / fSecondsPerBeat;
if( negBeat + fSkipBeats > fFreezeBeat )
fSkipBeats = fFreezeBeat - negBeat;
WarpSegment ws( BeatToNoteRow(negBeat), negBeat + fSkipBeats);
out.AddWarpSegment( ws );
negBeat = -1;
negPause = 0;
}
if( fFreezeSeconds < 0.0f ) if( fFreezeSeconds < 0.0f )
{ {
// Convert negative Stops into Warps. negBeat = fFreezeBeat;
negPause = -fFreezeSeconds;
// get BPM at current row: }
BPMSegment curBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(fFreezeBeat)); else if( fFreezeSeconds > 0.0f )
float fSecondsPerBeat = 60 / curBPM.GetBPM();
float fSkipBeats = fFreezeSeconds/fSecondsPerBeat;
WarpSegment wsTemp( BeatToNoteRow(fFreezeBeat), BeatToNoteRow(fFreezeBeat+fSkipBeats) );
arrayWarpsFromNegativeStops.push_back( wsTemp );
if( PREFSMAN->m_bQuirksMode )
{ {
// LOG->Trace( "Adding a negative freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); StopSegment ss( BeatToNoteRow(fFreezeBeat), fFreezeSeconds );
out.AddStopSegment( new_seg ); out.AddStopSegment( ss );
} }
else
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid stop at beat %f, length %f.", fFreezeBeat, fFreezeSeconds );
} }
else
// Process the prior stop if there was one.
if( negPause > 0 )
{ {
// LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat));
out.AddStopSegment( new_seg ); float fSecondsPerBeat = 60 / oldBPM.GetBPM();
} float fSkipBeats = negPause / fSecondsPerBeat;
WarpSegment ws( BeatToNoteRow(negBeat), negBeat + fSkipBeats);
out.AddWarpSegment( ws );
} }
} }
@@ -339,17 +351,7 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
} }
} }
} }
// Ensure all of the warps are handled right.
// do the same for Warps from Negative Stops.
/*
if(arrayWarpsFromNegativeStops.size() > 0)
{
for( unsigned j=0; j<arrayWarpsFromNegativeStops.size(); j++ )
{
out.AddWarpSegment( arrayWarpsFromNegativeStops[j] );
}
}
*/
sort(out.m_WarpSegments.begin(), out.m_WarpSegments.end()); sort(out.m_WarpSegments.begin(), out.m_WarpSegments.end());
} }
} }