[warps] merge
This commit is contained in:
+36
-34
@@ -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?
|
|
||||||
new_seg.m_iStartRow = BeatToNoteRow(fFreezeBeat);
|
|
||||||
new_seg.m_fStopSeconds = fFreezeSeconds;
|
|
||||||
|
|
||||||
if(fFreezeSeconds < 0.0f)
|
// Process the prior stop.
|
||||||
|
if( negPause > 0 )
|
||||||
{
|
{
|
||||||
// Convert negative Stops into Warps.
|
BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat));
|
||||||
|
float fSecondsPerBeat = 60 / oldBPM.GetBPM();
|
||||||
|
float fSkipBeats = negPause / fSecondsPerBeat;
|
||||||
|
|
||||||
// get BPM at current row:
|
if( negBeat + fSkipBeats > fFreezeBeat )
|
||||||
BPMSegment curBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(fFreezeBeat));
|
fSkipBeats = fFreezeBeat - negBeat;
|
||||||
float fSecondsPerBeat = 60 / curBPM.GetBPM();
|
|
||||||
float fSkipBeats = fFreezeSeconds/fSecondsPerBeat;
|
|
||||||
|
|
||||||
WarpSegment wsTemp( BeatToNoteRow(fFreezeBeat), BeatToNoteRow(fFreezeBeat+fSkipBeats) );
|
WarpSegment ws( BeatToNoteRow(negBeat), negBeat + fSkipBeats);
|
||||||
arrayWarpsFromNegativeStops.push_back( wsTemp );
|
out.AddWarpSegment( ws );
|
||||||
|
|
||||||
if( PREFSMAN->m_bQuirksMode )
|
negBeat = -1;
|
||||||
|
negPause = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fFreezeSeconds < 0.0f )
|
||||||
{
|
{
|
||||||
// LOG->Trace( "Adding a negative freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
|
negBeat = fFreezeBeat;
|
||||||
out.AddStopSegment( new_seg );
|
negPause = -fFreezeSeconds;
|
||||||
}
|
}
|
||||||
else
|
else if( fFreezeSeconds > 0.0f )
|
||||||
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid stop at beat %f, length %f.", fFreezeBeat, fFreezeSeconds );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// LOG->Trace( "Adding a 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the prior stop if there was one.
|
||||||
|
if( negPause > 0 )
|
||||||
|
{
|
||||||
|
BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat));
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user