annotate dsp/tempotracking/TempoTrack.h @ 73:dcb555b90924

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author cannam
date Fri, 05 Jun 2009 15:12:39 +0000
parents 38bf09927942
children e5907ae6de17
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
cannam@0 52
cannam@0 53 private:
cannam@0 54 void initialise( TTParams Params );
cannam@0 55 void deInitialise();
cannam@0 56
cannam@0 57 int beatPredict( unsigned int FSP, double alignment, double period, unsigned int step);
cannam@0 58 int phaseMM( double* DF, double* weighting, unsigned int winLength, double period );
cannam@0 59 void createPhaseExtractor( double* Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat );
cannam@0 60 int findMeter( double* ACF, unsigned int len, double period );
cannam@0 61 void constDetect( double* periodP, int currentIdx, int* flag );
cannam@0 62 void stepDetect( double* periodP, double* periodG, int currentIdx, int* flag );
cannam@0 63 void createCombFilter( double* Filter, unsigned int winLength, unsigned int TSig, double beatLag );
cannam@0 64 double tempoMM( double* ACF, double* weight, int sig );
cannam@0 65
cannam@0 66 unsigned int m_dataLength;
cannam@0 67 unsigned int m_winLength;
cannam@0 68 unsigned int m_lagLength;
cannam@0 69
cannam@0 70 double m_rayparam;
cannam@0 71 double m_sigma;
cannam@0 72 double m_DFWVNnorm;
cannam@0 73
cannam@0 74 vector<int> m_beats; // Vector of detected beats
cannam@0 75
cannam@6 76 double m_lockedTempo;
cannam@6 77
cannam@0 78 double* m_tempoScratch;
cannam@39 79 double* m_smoothRCF; // Smoothed Output of Comb Filterbank (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 // Config structure for DFProcess
cannam@0 95 DFProcConfig m_DFPParams;
cannam@39 96
cannam@39 97 // also want to smooth m_tempoScratch
cannam@39 98 DFProcess* m_RCFConditioning;
cannam@39 99 // Config structure for RCFProcess
cannam@39 100 DFProcConfig m_RCFPParams;
cannam@39 101
cannam@39 102
cannam@39 103
cannam@0 104 };
cannam@0 105
cannam@0 106 #endif