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@309: This file 2005-2006 Christian Landone. mathieu@321: mathieu@321: This program is free software; you can redistribute it and/or mathieu@321: modify it under the terms of the GNU General Public License as mathieu@321: published by the Free Software Foundation; either version 2 of the mathieu@321: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@225: */ c@225: c@225: #ifndef TEMPOTRACK_H c@225: #define TEMPOTRACK_H c@225: c@225: c@225: #include c@225: #include c@225: c@225: #include "dsp/signalconditioning/DFProcess.h" c@241: #include "maths/Correlation.h" c@225: #include "dsp/signalconditioning/Framer.h" c@225: c@225: c@225: c@225: using std::vector; c@225: c@225: struct WinThresh c@225: { c@225: unsigned int pre; mathieu@321: unsigned int post; c@225: }; c@225: c@225: struct TTParams c@225: { c@225: unsigned int winLength; //Analysis window length c@225: unsigned int lagLength; //Lag & Stride size c@225: unsigned int alpha; //alpha-norm parameter c@225: unsigned int LPOrd; // low-pass Filter order c@225: double* LPACoeffs; //low pass Filter den coefficients c@225: double* LPBCoeffs; //low pass Filter num coefficients c@225: WinThresh WinT;//window size in frames for adaptive thresholding [pre post]: c@225: }; c@225: c@225: c@225: class TempoTrack c@225: { c@225: public: c@225: TempoTrack( TTParams Params ); c@225: virtual ~TempoTrack(); c@225: c@231: vector process( vector DF, vector *tempoReturn = 0); c@225: c@225: c@225: private: c@225: void initialise( TTParams Params ); c@225: void deInitialise(); c@225: c@225: int beatPredict( unsigned int FSP, double alignment, double period, unsigned int step); c@225: int phaseMM( double* DF, double* weighting, unsigned int winLength, double period ); c@225: void createPhaseExtractor( double* Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat ); c@225: int findMeter( double* ACF, unsigned int len, double period ); c@225: void constDetect( double* periodP, int currentIdx, int* flag ); c@225: void stepDetect( double* periodP, double* periodG, int currentIdx, int* flag ); c@225: void createCombFilter( double* Filter, unsigned int winLength, unsigned int TSig, double beatLag ); c@225: double tempoMM( double* ACF, double* weight, int sig ); c@225: c@225: unsigned int m_dataLength; c@225: unsigned int m_winLength; c@225: unsigned int m_lagLength; c@225: c@225: double m_rayparam; c@225: double m_sigma; c@225: double m_DFWVNnorm; c@225: c@225: vector m_beats; // Vector of detected beats c@225: c@231: double m_lockedTempo; c@231: c@225: double* m_tempoScratch; c@264: double* m_smoothRCF; // Smoothed Output of Comb Filterbank (m_tempoScratch) c@225: c@225: // Processing Buffers c@225: double* m_rawDFFrame; // Original Detection Function Analysis Frame c@225: double* m_smoothDFFrame; // Smoothed Detection Function Analysis Frame c@225: double* m_frameACF; // AutoCorrelation of Smoothed Detection Function c@225: c@225: //Low Pass Coefficients for DF Smoothing c@225: double* m_ACoeffs; c@225: double* m_BCoeffs; c@225: c@225: // Objetcs/operators declaration c@225: Framer m_DFFramer; c@225: DFProcess* m_DFConditioning; c@225: Correlation m_correlator; c@225: // Config structure for DFProcess c@225: DFProcConfig m_DFPParams; c@264: c@264: // also want to smooth m_tempoScratch c@264: DFProcess* m_RCFConditioning; c@264: // Config structure for RCFProcess c@264: DFProcConfig m_RCFPParams; c@264: c@264: c@264: c@225: }; c@225: c@225: #endif