Handle adding a duplicate BPM segment in a well-defined way: overwrite
the old one, don't put duplicate segments in the BPM list.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "TimingData.h"
|
#include "TimingData.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
TimingData::TimingData()
|
TimingData::TimingData()
|
||||||
{
|
{
|
||||||
@@ -43,6 +44,16 @@ void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const
|
|||||||
|
|
||||||
void TimingData::AddBPMSegment( const BPMSegment &seg )
|
void TimingData::AddBPMSegment( const BPMSegment &seg )
|
||||||
{
|
{
|
||||||
|
/* If we already have a BPM segment at this beat, replace it. */
|
||||||
|
for( unsigned i=0; i<m_BPMSegments.size(); i++ )
|
||||||
|
if( fabsf(m_BPMSegments[i].m_fStartBeat-seg.m_fStartBeat) < 0.0001 )
|
||||||
|
{
|
||||||
|
LOG->Trace( "Replaced BPM segment at %f (%f BPM) with %f BPM",
|
||||||
|
m_BPMSegments[i].m_fStartBeat, m_BPMSegments[i].m_fBPM, seg.m_fBPM );
|
||||||
|
m_BPMSegments[i] = seg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_BPMSegments.push_back( seg );
|
m_BPMSegments.push_back( seg );
|
||||||
SortBPMSegmentsArray( m_BPMSegments );
|
SortBPMSegmentsArray( m_BPMSegments );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user