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