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: #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@225: #include "dsp/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; c@225: 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@225: vector process( vector DF ); c@225: vector process( double* DF, unsigned int length ); 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@225: double* 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: c@225: // Config structure for DFProcess c@225: DFProcConfig m_DFPParams; c@225: }; c@225: c@225: #endif