annotate dsp/tempotracking/TempoTrack.h @ 16:2e3f5d2d62c1

* Move dsp/maths to maths ; bring PCA and HMM across from Soundbite
author cannam
date Wed, 09 Jan 2008 10:31:29 +0000
parents a9bf0cfe9383
children 200677638f5b
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 QM DSP Library
cannam@0 5
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
cannam@0 7 This file copyright 2005-2006 Christian Landone.
cannam@0 8 All rights reserved.
cannam@0 9 */
cannam@0 10
cannam@0 11 #ifndef TEMPOTRACK_H
cannam@0 12 #define TEMPOTRACK_H
cannam@0 13
cannam@0 14
cannam@0 15 #include <stdio.h>
cannam@0 16 #include <vector>
cannam@0 17
cannam@0 18 #include "dsp/signalconditioning/DFProcess.h"
cannam@16 19 #include "maths/Correlation.h"
cannam@0 20 #include "dsp/signalconditioning/Framer.h"
cannam@0 21
cannam@0 22
cannam@0 23
cannam@0 24 using std::vector;
cannam@0 25
cannam@0 26 struct WinThresh
cannam@0 27 {
cannam@0 28 unsigned int pre;
cannam@0 29 unsigned int post;
cannam@0 30 };
cannam@0 31
cannam@0 32 struct TTParams
cannam@0 33 {
cannam@0 34 unsigned int winLength; //Analysis window length
cannam@0 35 unsigned int lagLength; //Lag & Stride size
cannam@0 36 unsigned int alpha; //alpha-norm parameter
cannam@0 37 unsigned int LPOrd; // low-pass Filter order
cannam@0 38 double* LPACoeffs; //low pass Filter den coefficients
cannam@0 39 double* LPBCoeffs; //low pass Filter num coefficients
cannam@0 40 WinThresh WinT;//window size in frames for adaptive thresholding [pre post]:
cannam@0 41 };
cannam@0 42
cannam@0 43
cannam@0 44 class TempoTrack
cannam@0 45 {
cannam@0 46 public:
cannam@0 47 TempoTrack( TTParams Params );
cannam@0 48 virtual ~TempoTrack();
cannam@0 49
cannam@6 50 vector<int> process( vector <double> DF, vector <double> *tempoReturn = 0);
cannam@0 51 vector<int> process( double* DF, unsigned int length );
cannam@0 52
cannam@0 53
cannam@0 54 private:
cannam@0 55 void initialise( TTParams Params );
cannam@0 56 void deInitialise();
cannam@0 57
cannam@0 58 int beatPredict( unsigned int FSP, double alignment, double period, unsigned int step);
cannam@0 59 int phaseMM( double* DF, double* weighting, unsigned int winLength, double period );
cannam@0 60 void createPhaseExtractor( double* Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat );
cannam@0 61 int findMeter( double* ACF, unsigned int len, double period );
cannam@0 62 void constDetect( double* periodP, int currentIdx, int* flag );
cannam@0 63 void stepDetect( double* periodP, double* periodG, int currentIdx, int* flag );
cannam@0 64 void createCombFilter( double* Filter, unsigned int winLength, unsigned int TSig, double beatLag );
cannam@0 65 double tempoMM( double* ACF, double* weight, int sig );
cannam@0 66
cannam@0 67 unsigned int m_dataLength;
cannam@0 68 unsigned int m_winLength;
cannam@0 69 unsigned int m_lagLength;
cannam@0 70
cannam@0 71 double m_rayparam;
cannam@0 72 double m_sigma;
cannam@0 73 double m_DFWVNnorm;
cannam@0 74
cannam@0 75 vector<int> m_beats; // Vector of detected beats
cannam@0 76
cannam@6 77 double m_lockedTempo;
cannam@6 78
cannam@0 79 double* m_tempoScratch;
cannam@0 80
cannam@0 81 // Processing Buffers
cannam@0 82 double* m_rawDFFrame; // Original Detection Function Analysis Frame
cannam@0 83 double* m_smoothDFFrame; // Smoothed Detection Function Analysis Frame
cannam@0 84 double* m_frameACF; // AutoCorrelation of Smoothed Detection Function
cannam@0 85
cannam@0 86 //Low Pass Coefficients for DF Smoothing
cannam@0 87 double* m_ACoeffs;
cannam@0 88 double* m_BCoeffs;
cannam@0 89
cannam@0 90 // Objetcs/operators declaration
cannam@0 91 Framer m_DFFramer;
cannam@0 92 DFProcess* m_DFConditioning;
cannam@0 93 Correlation m_correlator;
cannam@0 94
cannam@0 95 // Config structure for DFProcess
cannam@0 96 DFProcConfig m_DFPParams;
cannam@0 97 };
cannam@0 98
cannam@0 99 #endif