c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@225: This file copyright 2005-2006 Christian Landone. c@225: All rights reserved. c@225: */ c@225: c@225: #include "TempoTrack.h" c@225: c@241: #include "maths/MathAliases.h" c@241: #include "maths/MathUtilities.h" c@225: c@231: #include c@231: c@225: c@225: ////////////////////////////////////////////////////////////////////// c@225: // Construction/Destruction c@225: ////////////////////////////////////////////////////////////////////// c@225: c@225: TempoTrack::TempoTrack( TTParams Params ) c@225: { c@225: m_tempoScratch = NULL; c@225: m_rawDFFrame = NULL; c@225: m_smoothDFFrame = NULL; c@225: m_frameACF = NULL; c@225: c@225: m_dataLength = 0; c@225: m_winLength = 0; c@225: m_lagLength = 0; c@225: c@225: m_rayparam = 0; c@225: m_sigma = 0; c@225: m_DFWVNnorm = 0; c@225: c@225: initialise( Params ); c@225: } c@225: c@225: TempoTrack::~TempoTrack() c@225: { c@225: deInitialise(); c@225: } c@225: c@225: void TempoTrack::initialise( TTParams Params ) c@225: { c@225: m_winLength = Params.winLength; c@225: m_lagLength = Params.lagLength; c@225: c@225: m_rayparam = 43.0; c@225: m_sigma = sqrt(3.9017); c@225: m_DFWVNnorm = exp( ( log( 2.0 ) / m_rayparam ) * ( m_winLength + 2 ) ); c@225: c@225: m_rawDFFrame = new double[ m_winLength ]; c@225: m_smoothDFFrame = new double[ m_winLength ]; c@225: m_frameACF = new double[ m_winLength ]; c@225: m_tempoScratch = new double[ m_lagLength ]; c@225: c@225: unsigned int winPre = Params.WinT.pre; c@225: unsigned int winPost = Params.WinT.post; c@225: c@225: m_DFFramer.configure( m_winLength, m_lagLength ); c@225: c@225: m_DFPParams.length = m_winLength; c@225: m_DFPParams.AlphaNormParam = Params.alpha; c@225: m_DFPParams.LPOrd = Params.LPOrd; c@225: m_DFPParams.LPACoeffs = Params.LPACoeffs; c@225: m_DFPParams.LPBCoeffs = Params.LPBCoeffs; c@225: m_DFPParams.winPre = Params.WinT.pre; c@225: m_DFPParams.winPost = Params.WinT.post; c@225: m_DFPParams.isMedianPositive = true; c@225: c@225: m_DFConditioning = new DFProcess( m_DFPParams ); c@225: c@225: } c@225: c@225: void TempoTrack::deInitialise() c@225: { c@225: delete [] m_rawDFFrame; c@225: c@225: delete [] m_smoothDFFrame; c@225: c@225: delete [] m_frameACF; c@225: c@225: delete [] m_tempoScratch; c@225: c@225: delete m_DFConditioning; c@225: } c@225: c@225: void TempoTrack::createCombFilter(double* Filter, unsigned int winLength, unsigned int TSig, double beatLag) c@225: { c@225: unsigned int i; c@225: c@225: if( beatLag == 0 ) c@225: { c@225: for( i = 0; i < winLength; i++ ) c@225: { c@225: Filter[ i ] = ( ( i + 1 ) / pow( m_rayparam, 2.0) ) * exp( ( -pow(( i + 1 ),2.0 ) / ( 2.0 * pow( m_rayparam, 2.0)))); c@225: } c@225: } c@225: else c@225: { c@225: m_sigma = beatLag/8; c@225: for( i = 0; i < winLength; i++ ) c@225: { c@225: double dlag = (double)(i+1) - beatLag; c@225: Filter[ i ] = exp(-0.5 * pow(( dlag / m_sigma), 2.0) ) / (sqrt( 2 * PI) * m_sigma); c@225: } c@225: } c@225: } c@225: c@225: double TempoTrack::tempoMM(double* ACF, double* weight, int tsig) c@225: { c@225: c@225: double period = 0; c@225: double maxValRCF = 0.0; c@225: unsigned int maxIndexRCF = 0; c@225: c@225: double* pdPeaks; c@225: c@225: unsigned int maxIndexTemp; c@225: double maxValTemp; c@225: unsigned int count; c@225: c@225: unsigned int numelem; c@225: int i, a, b; c@225: c@225: for( i = 0; i < m_lagLength; i++ ) c@225: m_tempoScratch[ i ] = 0.0; c@225: c@225: if( tsig == 0 ) c@225: { c@225: //if time sig is unknown, use metrically unbiased version of Filterbank c@225: numelem = 4; c@225: } c@225: else c@225: { c@225: numelem = tsig; c@225: } c@225: c@225: for(i=1;i maxValRCF) c@225: { c@225: maxValRCF = m_tempoScratch[ i ]; c@225: maxIndexRCF = i; c@225: } c@225: } c@231: c@231: double locked = 5168.f / maxIndexRCF; c@231: if (locked >= 30 && locked <= 180) { c@231: m_lockedTempo = locked; c@231: } c@231: c@225: if( tsig == 0 ) c@225: tsig = 4; c@225: c@225: c@225: if( tsig == 4 ) c@225: { c@225: pdPeaks = new double[ 4 ]; c@225: for( i = 0; i < 4; i++ ){ pdPeaks[ i ] = 0.0;} c@225: c@225: pdPeaks[ 0 ] = ( double )maxIndexRCF + 1; c@225: c@225: maxIndexTemp = 0; c@225: maxValTemp = 0.0; c@225: count = 0; c@225: c@225: for( i = (2 * maxIndexRCF + 1) - 1; i < (2 * maxIndexRCF + 1) + 2; i++ ) c@225: { c@225: if( ACF[ i ] > maxValTemp ) c@225: { c@225: maxValTemp = ACF[ i ]; c@225: maxIndexTemp = count; c@225: } c@225: count++; c@225: } c@225: pdPeaks[ 1 ] = (double)( maxIndexTemp + 1 + ( (2 * maxIndexRCF + 1 ) - 2 ) + 1 )/2; c@225: c@225: maxIndexTemp = 0; c@225: maxValTemp = 0.0; c@225: count = 0; c@225: c@225: for( i = (3 * maxIndexRCF + 2 ) - 2; i < (3 * maxIndexRCF + 2 ) + 3; i++ ) c@225: { c@225: if( ACF[ i ] > maxValTemp ) c@225: { c@225: maxValTemp = ACF[ i ]; c@225: maxIndexTemp = count; c@225: } c@225: count++; c@225: } c@225: pdPeaks[ 2 ] = (double)( maxIndexTemp + 1 + ( (3 * maxIndexRCF + 2) - 4 ) + 1 )/3; c@225: c@225: maxIndexTemp = 0; c@225: maxValTemp = 0.0; c@225: count = 0; c@225: c@225: for( i = ( 4 * maxIndexRCF + 3) - 3; i < ( 4 * maxIndexRCF + 3) + 4; i++ ) c@225: { c@225: if( ACF[ i ] > maxValTemp ) c@225: { c@225: maxValTemp = ACF[ i ]; c@225: maxIndexTemp = count; c@225: } c@225: count++; c@225: } c@225: pdPeaks[ 3 ] = (double)( maxIndexTemp + 1 + ( (4 * maxIndexRCF + 3) - 9 ) + 1 )/4 ; c@225: c@225: c@225: period = MathUtilities::mean( pdPeaks, 4 ); c@225: } c@225: else c@225: { c@225: pdPeaks = new double[ 3 ]; c@225: for( i = 0; i < 3; i++ ){ pdPeaks[ i ] = 0.0;} c@225: c@225: pdPeaks[ 0 ] = ( double )maxIndexRCF + 1; c@225: c@225: maxIndexTemp = 0; c@225: maxValTemp = 0.0; c@225: count = 0; c@225: c@225: for( i = (2 * maxIndexRCF + 1) - 1; i < (2 * maxIndexRCF + 1) + 2; i++ ) c@225: { c@225: if( ACF[ i ] > maxValTemp ) c@225: { c@225: maxValTemp = ACF[ i ]; c@225: maxIndexTemp = count; c@225: } c@225: count++; c@225: } c@225: pdPeaks[ 1 ] = (double)( maxIndexTemp + 1 + ( (2 * maxIndexRCF + 1 ) - 2 ) + 1 )/2; c@225: c@225: maxIndexTemp = 0; c@225: maxValTemp = 0.0; c@225: count = 0; c@225: c@225: for( i = (3 * maxIndexRCF + 2 ) - 2; i < (3 * maxIndexRCF + 2 ) + 3; i++ ) c@225: { c@225: if( ACF[ i ] > maxValTemp ) c@225: { c@225: maxValTemp = ACF[ i ]; c@225: maxIndexTemp = count; c@225: } c@225: count++; c@225: } c@225: pdPeaks[ 2 ] = (double)( maxIndexTemp + 1 + ( (3 * maxIndexRCF + 2) - 4 ) + 1 )/3; c@225: c@225: c@225: period = MathUtilities::mean( pdPeaks, 3 ); c@225: } c@225: c@225: delete [] pdPeaks; c@225: c@225: return period; c@225: } c@225: c@225: void TempoTrack::stepDetect( double* periodP, double* periodG, int currentIdx, int* flag ) c@225: { c@225: double stepthresh = 1 * 3.9017; c@225: c@225: if( *flag ) c@225: { c@225: if(abs(periodG[ currentIdx ] - periodP[ currentIdx ]) > stepthresh) c@225: { c@225: // do nuffin' c@225: } c@225: } c@225: else c@225: { c@225: if(fabs(periodG[ currentIdx ]-periodP[ currentIdx ]) > stepthresh) c@225: { c@225: *flag = 3; c@225: } c@225: } c@225: } c@225: c@225: void TempoTrack::constDetect( double* periodP, int currentIdx, int* flag ) c@225: { c@225: double constthresh = 2 * 3.9017; c@225: c@225: if( fabs( 2 * periodP[ currentIdx ] - periodP[ currentIdx - 1] - periodP[ currentIdx - 2] ) < constthresh) c@225: { c@225: *flag = 1; c@225: } c@225: else c@225: { c@225: *flag = 0; c@225: } c@225: } c@225: c@225: int TempoTrack::findMeter(double *ACF, unsigned int len, double period) c@225: { c@225: int i; c@225: int p = (int)MathUtilities::round( period ); c@225: int tsig; c@225: c@225: double Energy_3 = 0.0; c@225: double Energy_4 = 0.0; c@225: c@225: double temp3A = 0.0; c@225: double temp3B = 0.0; c@225: double temp4A = 0.0; c@225: double temp4B = 0.0; c@225: c@225: double* dbf = new double[ len ]; int t = 0; c@225: for( unsigned int u = 0; u < len; u++ ){ dbf[ u ] = 0.0; } c@225: c@225: if( (double)len < 6 * p + 2 ) c@225: { c@225: for( i = ( 3 * p - 2 ); i < ( 3 * p + 2 ) + 1; i++ ) c@225: { c@225: temp3A += ACF[ i ]; c@225: dbf[ t++ ] = ACF[ i ]; c@225: } c@225: c@225: for( i = ( 4 * p - 2 ); i < ( 4 * p + 2 ) + 1; i++ ) c@225: { c@225: temp4A += ACF[ i ]; c@225: } c@225: c@225: Energy_3 = temp3A; c@225: Energy_4 = temp4A; c@225: } c@225: else c@225: { c@225: for( i = ( 3 * p - 2 ); i < ( 3 * p + 2 ) + 1; i++ ) c@225: { c@225: temp3A += ACF[ i ]; c@225: } c@225: c@225: for( i = ( 4 * p - 2 ); i < ( 4 * p + 2 ) + 1; i++ ) c@225: { c@225: temp4A += ACF[ i ]; c@225: } c@225: c@225: for( i = ( 6 * p - 2 ); i < ( 6 * p + 2 ) + 1; i++ ) c@225: { c@225: temp3B += ACF[ i ]; c@225: } c@225: c@225: for( i = ( 2 * p - 2 ); i < ( 2 * p + 2 ) + 1; i++ ) c@225: { c@225: temp4B += ACF[ i ]; c@225: } c@225: c@225: Energy_3 = temp3A + temp3B; c@225: Energy_4 = temp4A + temp4B; c@225: } c@225: c@225: if (Energy_3 > Energy_4) c@225: { c@225: tsig = 3; c@225: } c@225: else c@225: { c@225: tsig = 4; c@225: } c@225: c@225: c@225: return tsig; c@225: } c@225: c@225: void TempoTrack::createPhaseExtractor(double *Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat) c@225: { c@225: int p = (int)MathUtilities::round( period ); c@225: int predictedOffset = 0; c@225: c@225: double* phaseScratch = new double[ p*2 ]; c@225: c@225: c@225: if( lastBeat != 0 ) c@225: { c@225: lastBeat = (int)MathUtilities::round((double)lastBeat );///(double)winLength); c@225: c@225: predictedOffset = lastBeat + p - fsp; c@225: c@225: if (predictedOffset < 0) c@225: { c@225: lastBeat = 0; c@225: } c@225: } c@225: c@225: if( lastBeat != 0 ) c@225: { c@225: int mu = p; c@225: double sigma = (double)p/4; c@225: double PhaseMin = 0.0; c@225: double PhaseMax = 0.0; c@225: unsigned int scratchLength = p*2; c@225: double temp = 0.0; c@225: c@225: for( int i = 0; i < scratchLength; i++ ) c@225: { c@225: phaseScratch[ i ] = exp( -0.5 * pow( ( i - mu ) / sigma, 2 ) ) / ( sqrt( 2*PI ) *sigma ); c@225: } c@225: c@225: MathUtilities::getFrameMinMax( phaseScratch, scratchLength, &PhaseMin, &PhaseMax ); c@225: c@225: for(int i = 0; i < scratchLength; i ++) c@225: { c@225: temp = phaseScratch[ i ]; c@225: phaseScratch[ i ] = (temp - PhaseMin)/PhaseMax; c@225: } c@225: c@225: unsigned int index = 0; c@225: for(int i = p - ( predictedOffset - 1); i < p + ( p - predictedOffset) + 1; i++) c@225: { c@225: Filter[ index++ ] = phaseScratch[ i ]; c@225: } c@225: } c@225: else c@225: { c@225: for( int i = 0; i < p; i ++) c@225: { c@225: Filter[ i ] = 1; c@225: } c@225: } c@225: c@225: delete [] phaseScratch; c@225: } c@225: c@225: int TempoTrack::phaseMM(double *DF, double *weighting, unsigned int winLength, double period) c@225: { c@225: int alignment = 0; c@225: int p = (int)MathUtilities::round( period ); c@225: c@225: double temp = 0.0; c@225: c@225: double* y = new double[ winLength ]; c@225: double* align = new double[ p ]; c@225: c@225: for( int i = 0; i < winLength; i++ ) c@225: { c@225: y[ i ] = (double)( -i + winLength )/(double)winLength; c@225: } c@225: c@225: for( int o = 0; o < p; o++ ) c@225: { c@225: temp = 0.0; c@225: for(int i = 1 + (o - 1); i< winLength; i += (p + 1)) c@225: { c@225: temp = temp + DF[ i ] * y[ i ]; c@225: } c@225: align[ o ] = temp * weighting[ o ]; c@225: } c@225: c@225: c@225: double valTemp = 0.0; c@225: for(int i = 0; i < p; i++) c@225: { c@225: if( align[ i ] > valTemp ) c@225: { c@225: valTemp = align[ i ]; c@225: alignment = i; c@225: } c@225: } c@225: c@225: delete [] y; c@225: delete [] align; c@225: c@225: return alignment; c@225: } c@225: c@225: int TempoTrack::beatPredict(unsigned int FSP0, double alignment, double period, unsigned int step ) c@225: { c@225: int beat = 0; c@225: c@225: int p = (int)MathUtilities::round( period ); c@225: int align = (int)MathUtilities::round( alignment ); c@225: int FSP = (int)MathUtilities::round( FSP0 ); c@225: c@225: int FEP = FSP + ( step ); c@225: c@225: beat = FSP + align; c@225: c@225: m_beats.push_back( beat ); c@225: c@225: while( beat + p < FEP ) c@225: { c@225: beat += p; c@225: c@225: m_beats.push_back( beat ); c@225: } c@225: c@225: return beat; c@225: } c@225: c@225: vector TempoTrack::process(double *DF, unsigned int length) c@225: { c@225: m_dataLength = length; c@225: c@225: double period = 0.0; c@225: int stepFlag = 0; c@225: int constFlag = 0; c@225: int FSP = 0; c@225: int tsig = 0; c@225: int lastBeat = 0; c@225: c@225: c@225: double* RW = new double[ m_lagLength ]; c@225: for( unsigned int clear = 0; clear < m_lagLength; clear++){ RW[ clear ] = 0.0;} c@225: c@225: double* GW = new double[ m_lagLength ]; c@225: for(unsigned int clear = 0; clear < m_lagLength; clear++){ GW[ clear ] = 0.0;} c@225: c@225: double* PW = new double[ m_lagLength ]; c@225: for(unsigned int clear = 0; clear < m_lagLength; clear++){ PW[ clear ] = 0.0;} c@225: c@225: m_DFFramer.setSource( DF, m_dataLength ); c@225: c@225: unsigned int TTFrames = m_DFFramer.getMaxNoFrames(); c@225: c@225: double* periodP = new double[ TTFrames ]; c@225: for(unsigned int clear = 0; clear < TTFrames; clear++){ periodP[ clear ] = 0.0;} c@225: c@225: double* periodG = new double[ TTFrames ]; c@225: for(unsigned int clear = 0; clear < TTFrames; clear++){ periodG[ clear ] = 0.0;} c@225: c@225: double* alignment = new double[ TTFrames ]; c@225: for(unsigned int clear = 0; clear < TTFrames; clear++){ alignment[ clear ] = 0.0;} c@225: c@225: m_beats.clear(); c@225: c@225: createCombFilter( RW, m_lagLength, 0, 0 ); c@225: c@225: int TTLoopIndex = 0; c@225: c@225: for( unsigned int i = 0; i < TTFrames; i++ ) c@225: { c@225: m_DFFramer.getFrame( m_rawDFFrame ); c@225: c@225: m_DFConditioning->process( m_rawDFFrame, m_smoothDFFrame ); c@225: c@225: m_correlator.doAutoUnBiased( m_smoothDFFrame, m_frameACF, m_winLength ); c@225: c@225: periodP[ TTLoopIndex ] = tempoMM( m_frameACF, RW, 0 ); c@225: c@225: if( GW[ 0 ] != 0 ) c@225: { c@225: periodG[ TTLoopIndex ] = tempoMM( m_frameACF, GW, tsig ); c@225: } c@225: else c@225: { c@225: periodG[ TTLoopIndex ] = 0.0; c@225: } c@225: c@225: stepDetect( periodP, periodG, TTLoopIndex, &stepFlag ); c@225: c@225: if( stepFlag == 1) c@225: { c@225: constDetect( periodP, TTLoopIndex, &constFlag ); c@225: stepFlag = 0; c@225: } c@225: else c@225: { c@225: stepFlag -= 1; c@225: } c@225: c@225: if( stepFlag < 0 ) c@225: { c@225: stepFlag = 0; c@225: } c@225: c@225: if( constFlag != 0) c@225: { c@225: tsig = findMeter( m_frameACF, m_winLength, periodP[ TTLoopIndex ] ); c@225: c@225: createCombFilter( GW, m_lagLength, tsig, periodP[ TTLoopIndex ] ); c@225: c@225: periodG[ TTLoopIndex ] = tempoMM( m_frameACF, GW, tsig ); c@225: c@225: period = periodG[ TTLoopIndex ]; c@225: c@225: createPhaseExtractor( PW, m_winLength, period, FSP, 0 ); c@225: c@225: constFlag = 0; c@225: c@225: } c@225: else c@225: { c@225: if( GW[ 0 ] != 0 ) c@225: { c@225: period = periodG[ TTLoopIndex ]; c@225: createPhaseExtractor( PW, m_winLength, period, FSP, lastBeat ); c@225: c@225: } c@225: else c@225: { c@225: period = periodP[ TTLoopIndex ]; c@225: createPhaseExtractor( PW, m_winLength, period, FSP, 0 ); c@225: } c@225: } c@225: c@225: alignment[ TTLoopIndex ] = phaseMM( m_rawDFFrame, PW, m_winLength, period ); c@225: c@225: lastBeat = beatPredict(FSP, alignment[ TTLoopIndex ], period, m_lagLength ); c@225: c@225: FSP += (m_lagLength); c@225: c@225: TTLoopIndex++; c@225: } c@225: c@225: c@225: delete [] periodP; c@225: delete [] periodG; c@225: delete [] alignment; c@225: c@225: delete [] RW; c@225: delete [] GW; c@225: delete [] PW; c@225: c@225: return m_beats; c@225: } c@225: c@225: c@225: c@225: c@225: c@231: vector TempoTrack::process( vector DF, c@231: vector *tempoReturn ) c@225: { c@225: m_dataLength = DF.size(); c@225: c@231: m_lockedTempo = 0.0; c@231: c@225: double period = 0.0; c@225: int stepFlag = 0; c@225: int constFlag = 0; c@225: int FSP = 0; c@225: int tsig = 0; c@225: int lastBeat = 0; c@225: c@225: vector causalDF; c@225: c@225: causalDF = DF; c@225: c@225: //Prepare Causal Extension DFData c@225: unsigned int DFCLength = m_dataLength + m_winLength; c@225: c@225: for( unsigned int j = 0; j < m_winLength; j++ ) c@225: { c@225: causalDF.push_back( 0 ); c@225: } c@225: c@225: c@225: double* RW = new double[ m_lagLength ]; c@225: for( unsigned int clear = 0; clear < m_lagLength; clear++){ RW[ clear ] = 0.0;} c@225: c@225: double* GW = new double[ m_lagLength ]; c@225: for(unsigned int clear = 0; clear < m_lagLength; clear++){ GW[ clear ] = 0.0;} c@225: c@225: double* PW = new double[ m_lagLength ]; c@225: for(unsigned clear = 0; clear < m_lagLength; clear++){ PW[ clear ] = 0.0;} c@225: c@225: m_DFFramer.setSource( &causalDF[0], m_dataLength ); c@225: c@225: unsigned int TTFrames = m_DFFramer.getMaxNoFrames(); c@225: c@225: double* periodP = new double[ TTFrames ]; c@225: for(unsigned clear = 0; clear < TTFrames; clear++){ periodP[ clear ] = 0.0;} c@225: c@225: double* periodG = new double[ TTFrames ]; c@225: for(unsigned clear = 0; clear < TTFrames; clear++){ periodG[ clear ] = 0.0;} c@225: c@225: double* alignment = new double[ TTFrames ]; c@225: for(unsigned clear = 0; clear < TTFrames; clear++){ alignment[ clear ] = 0.0;} c@225: c@225: m_beats.clear(); c@225: c@225: createCombFilter( RW, m_lagLength, 0, 0 ); c@225: c@225: int TTLoopIndex = 0; c@225: c@225: for( unsigned int i = 0; i < TTFrames; i++ ) c@225: { c@225: m_DFFramer.getFrame( m_rawDFFrame ); c@225: c@225: m_DFConditioning->process( m_rawDFFrame, m_smoothDFFrame ); c@225: c@225: m_correlator.doAutoUnBiased( m_smoothDFFrame, m_frameACF, m_winLength ); c@225: c@225: periodP[ TTLoopIndex ] = tempoMM( m_frameACF, RW, 0 ); c@225: c@225: if( GW[ 0 ] != 0 ) c@225: { c@225: periodG[ TTLoopIndex ] = tempoMM( m_frameACF, GW, tsig ); c@225: } c@225: else c@225: { c@225: periodG[ TTLoopIndex ] = 0.0; c@225: } c@225: c@225: stepDetect( periodP, periodG, TTLoopIndex, &stepFlag ); c@225: c@225: if( stepFlag == 1) c@225: { c@225: constDetect( periodP, TTLoopIndex, &constFlag ); c@225: stepFlag = 0; c@225: } c@225: else c@225: { c@225: stepFlag -= 1; c@225: } c@225: c@225: if( stepFlag < 0 ) c@225: { c@225: stepFlag = 0; c@225: } c@225: c@225: if( constFlag != 0) c@225: { c@225: tsig = findMeter( m_frameACF, m_winLength, periodP[ TTLoopIndex ] ); c@225: c@225: createCombFilter( GW, m_lagLength, tsig, periodP[ TTLoopIndex ] ); c@225: c@225: periodG[ TTLoopIndex ] = tempoMM( m_frameACF, GW, tsig ); c@225: c@225: period = periodG[ TTLoopIndex ]; c@225: c@225: createPhaseExtractor( PW, m_winLength, period, FSP, 0 ); c@225: c@225: constFlag = 0; c@225: c@225: } c@225: else c@225: { c@225: if( GW[ 0 ] != 0 ) c@225: { c@225: period = periodG[ TTLoopIndex ]; c@225: createPhaseExtractor( PW, m_winLength, period, FSP, lastBeat ); c@225: c@225: } c@225: else c@225: { c@225: period = periodP[ TTLoopIndex ]; c@225: createPhaseExtractor( PW, m_winLength, period, FSP, 0 ); c@225: } c@225: } c@225: c@225: alignment[ TTLoopIndex ] = phaseMM( m_rawDFFrame, PW, m_winLength, period ); c@225: c@225: lastBeat = beatPredict(FSP, alignment[ TTLoopIndex ], period, m_lagLength ); c@225: c@225: FSP += (m_lagLength); c@225: c@231: if (tempoReturn) tempoReturn->push_back(m_lockedTempo); c@231: c@225: TTLoopIndex++; c@225: } c@225: c@225: c@225: delete [] periodP; c@225: delete [] periodG; c@225: delete [] alignment; c@225: c@225: delete [] RW; c@225: delete [] GW; c@225: delete [] PW; c@225: c@225: return m_beats; c@225: }