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