Vain, hopeless attempt to simplify GetBeatAndBPSFromElapsedTime. :)
This commit is contained in:
+12
-14
@@ -163,7 +163,8 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl
|
|||||||
|
|
||||||
// calculate the number of seconds in this segment
|
// calculate the number of seconds in this segment
|
||||||
float fSecondsInThisSegment = fBeatsInThisSegment / fBPS;
|
float fSecondsInThisSegment = fBeatsInThisSegment / fBPS;
|
||||||
for( int j=0; j<m_StopSegments.GetSize(); j++ ) // foreach freeze
|
int j;
|
||||||
|
for( j=0; j<m_StopSegments.GetSize(); j++ ) // foreach freeze
|
||||||
{
|
{
|
||||||
if( fStartBeatThisSegment <= m_StopSegments[j].m_fStartBeat && m_StopSegments[j].m_fStartBeat < fStartBeatNextSegment )
|
if( fStartBeatThisSegment <= m_StopSegments[j].m_fStartBeat && m_StopSegments[j].m_fStartBeat < fStartBeatNextSegment )
|
||||||
{
|
{
|
||||||
@@ -177,21 +178,24 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl
|
|||||||
{
|
{
|
||||||
// this BPMSegement is NOT the current segment
|
// this BPMSegement is NOT the current segment
|
||||||
fElapsedTime -= fSecondsInThisSegment;
|
fElapsedTime -= fSecondsInThisSegment;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// this BPMSegment IS the current segment
|
// this BPMSegment IS the current segment
|
||||||
|
|
||||||
float fBeatEstimate = fStartBeatThisSegment + fElapsedTime*fBPS;
|
float fBeatEstimate = fStartBeatThisSegment + fElapsedTime*fBPS;
|
||||||
|
|
||||||
for( int j=0; j<m_StopSegments.GetSize(); j++ ) // foreach freeze
|
for( j=0; j<m_StopSegments.GetSize(); j++ ) // foreach freeze
|
||||||
{
|
|
||||||
if( fStartBeatThisSegment <= m_StopSegments[j].m_fStartBeat && m_StopSegments[j].m_fStartBeat <= fStartBeatNextSegment )
|
|
||||||
{
|
{
|
||||||
|
if( fStartBeatThisSegment > m_StopSegments[j].m_fStartBeat ||
|
||||||
|
m_StopSegments[j].m_fStartBeat > fStartBeatNextSegment )
|
||||||
|
continue;
|
||||||
|
|
||||||
// this freeze lies within this BPMSegment
|
// this freeze lies within this BPMSegment
|
||||||
|
|
||||||
if( m_StopSegments[j].m_fStartBeat <= fBeatEstimate )
|
if( m_StopSegments[j].m_fStartBeat > fBeatEstimate )
|
||||||
{
|
break;
|
||||||
|
|
||||||
fElapsedTime -= m_StopSegments[j].m_fStopSeconds;
|
fElapsedTime -= m_StopSegments[j].m_fStopSeconds;
|
||||||
// re-estimate
|
// re-estimate
|
||||||
fBeatEstimate = fStartBeatThisSegment + fElapsedTime*fBPS;
|
fBeatEstimate = fStartBeatThisSegment + fElapsedTime*fBPS;
|
||||||
@@ -203,18 +207,12 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fBeatOut = fBeatEstimate;
|
fBeatOut = fBeatEstimate;
|
||||||
fBPSOut = fBPS;
|
fBPSOut = fBPS;
|
||||||
bFreezeOut = false;
|
bFreezeOut = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user