SVG of thorsten's editor track/bus list icons
[ardour2.git] / libs / qm-dsp / dsp / tempotracking / TempoTrack.h
blob12eb977cd529086fd10acd6a7717149fb379fdc7
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 /*
4 QM DSP Library
6 Centre for Digital Music, Queen Mary, University of London.
7 This file 2005-2006 Christian Landone.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
16 #ifndef TEMPOTRACK_H
17 #define TEMPOTRACK_H
20 #include <stdio.h>
21 #include <vector>
23 #include "dsp/signalconditioning/DFProcess.h"
24 #include "maths/Correlation.h"
25 #include "dsp/signalconditioning/Framer.h"
29 using std::vector;
31 struct WinThresh
33 unsigned int pre;
34 unsigned int post;
37 struct TTParams
39 unsigned int winLength; //Analysis window length
40 unsigned int lagLength; //Lag & Stride size
41 unsigned int alpha; //alpha-norm parameter
42 unsigned int LPOrd; // low-pass Filter order
43 double* LPACoeffs; //low pass Filter den coefficients
44 double* LPBCoeffs; //low pass Filter num coefficients
45 WinThresh WinT;//window size in frames for adaptive thresholding [pre post]:
49 class TempoTrack
51 public:
52 TempoTrack( TTParams Params );
53 virtual ~TempoTrack();
55 vector<int> process( vector <double> DF, vector <double> *tempoReturn = 0);
58 private:
59 void initialise( TTParams Params );
60 void deInitialise();
62 int beatPredict( unsigned int FSP, double alignment, double period, unsigned int step);
63 int phaseMM( double* DF, double* weighting, unsigned int winLength, double period );
64 void createPhaseExtractor( double* Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat );
65 int findMeter( double* ACF, unsigned int len, double period );
66 void constDetect( double* periodP, int currentIdx, int* flag );
67 void stepDetect( double* periodP, double* periodG, int currentIdx, int* flag );
68 void createCombFilter( double* Filter, unsigned int winLength, unsigned int TSig, double beatLag );
69 double tempoMM( double* ACF, double* weight, int sig );
71 unsigned int m_dataLength;
72 unsigned int m_winLength;
73 unsigned int m_lagLength;
75 double m_rayparam;
76 double m_sigma;
77 double m_DFWVNnorm;
79 vector<int> m_beats; // Vector of detected beats
81 double m_lockedTempo;
83 double* m_tempoScratch;
84 double* m_smoothRCF; // Smoothed Output of Comb Filterbank (m_tempoScratch)
86 // Processing Buffers
87 double* m_rawDFFrame; // Original Detection Function Analysis Frame
88 double* m_smoothDFFrame; // Smoothed Detection Function Analysis Frame
89 double* m_frameACF; // AutoCorrelation of Smoothed Detection Function
91 //Low Pass Coefficients for DF Smoothing
92 double* m_ACoeffs;
93 double* m_BCoeffs;
95 // Objetcs/operators declaration
96 Framer m_DFFramer;
97 DFProcess* m_DFConditioning;
98 Correlation m_correlator;
99 // Config structure for DFProcess
100 DFProcConfig m_DFPParams;
102 // also want to smooth m_tempoScratch
103 DFProcess* m_RCFConditioning;
104 // Config structure for RCFProcess
105 DFProcConfig m_RCFPParams;
111 #endif