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