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