Use references rather than pointers.
This commit is contained in:
@@ -209,8 +209,7 @@ void AdjustSync::AutosyncTempo()
|
|||||||
{
|
{
|
||||||
float fSlope = 0.0f;
|
float fSlope = 0.0f;
|
||||||
float fIntercept = 0.0f;
|
float fIntercept = 0.0f;
|
||||||
if( !CalcLeastSquares( s_vAutosyncTempoData,
|
if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, s_fAverageError ) )
|
||||||
&fSlope, &fIntercept, &s_fAverageError ) )
|
|
||||||
{
|
{
|
||||||
s_vAutosyncTempoData.clear();
|
s_vAutosyncTempoData.clear();
|
||||||
return;
|
return;
|
||||||
@@ -230,8 +229,7 @@ void AdjustSync::AutosyncTempo()
|
|||||||
fSlope, fIntercept, ERROR_TOO_HIGH );
|
fSlope, fIntercept, ERROR_TOO_HIGH );
|
||||||
s_iStepsFiltered -= s_vAutosyncTempoData.size();
|
s_iStepsFiltered -= s_vAutosyncTempoData.size();
|
||||||
|
|
||||||
if( !CalcLeastSquares( s_vAutosyncTempoData,
|
if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, fFilteredError ) )
|
||||||
&fSlope, &fIntercept, &fFilteredError ) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fIntercept;
|
GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fIntercept;
|
||||||
|
|||||||
@@ -1000,10 +1000,8 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample )
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
||||||
float *pfSlope, float *pfIntercept, float *pfError )
|
float &pfSlope, float &pfIntercept, float &pfError )
|
||||||
{
|
{
|
||||||
ASSERT( pfSlope != NULL );
|
|
||||||
ASSERT( pfIntercept != NULL );
|
|
||||||
int iNumSamples = vCoordinates.size();
|
int iNumSamples = vCoordinates.size();
|
||||||
float fNumSamples = static_cast<float>(iNumSamples);
|
float fNumSamples = static_cast<float>(iNumSamples);
|
||||||
if( iNumSamples == 0 )
|
if( iNumSamples == 0 )
|
||||||
@@ -1019,17 +1017,17 @@ bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
|||||||
fSumY += vCoordinates[i].second;
|
fSumY += vCoordinates[i].second;
|
||||||
}
|
}
|
||||||
float fDenominator = fNumSamples * fSumXX - fSumX * fSumX;
|
float fDenominator = fNumSamples * fSumXX - fSumX * fSumX;
|
||||||
*pfSlope = (fNumSamples * fSumXY - fSumX * fSumY) / fDenominator;
|
pfSlope = (fNumSamples * fSumXY - fSumX * fSumY) / fDenominator;
|
||||||
*pfIntercept = (fSumXX * fSumY - fSumX * fSumXY) / fDenominator;
|
pfIntercept = (fSumXX * fSumY - fSumX * fSumXY) / fDenominator;
|
||||||
|
|
||||||
*pfError = 0.0f;
|
pfError = 0.0f;
|
||||||
for( int i = 0; i < iNumSamples; ++i )
|
for( int i = 0; i < iNumSamples; ++i )
|
||||||
{
|
{
|
||||||
float fOneError = (vCoordinates[i].second - (*pfIntercept + *pfSlope * vCoordinates[i].first));
|
float fOneError = (vCoordinates[i].second - (pfIntercept + pfSlope * vCoordinates[i].first));
|
||||||
*pfError += fOneError * fOneError;
|
pfError += fOneError * fOneError;
|
||||||
}
|
}
|
||||||
*pfError /= fNumSamples;
|
pfError /= fNumSamples;
|
||||||
*pfError = sqrtf( *pfError );
|
pfError = sqrtf( pfError );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample = false
|
|||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
bool CalcLeastSquares( const vector< pair<float, float> > &vCoordinates,
|
||||||
float *p_fSlope, float *p_fIntercept, float *p_fError );
|
float &p_fSlope, float &p_fIntercept, float &p_fError );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method throws away any points that are more than fCutoff away from
|
* This method throws away any points that are more than fCutoff away from
|
||||||
|
|||||||
Reference in New Issue
Block a user