qm-dsp
1.8
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 QM DSP Library 00005 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file 2005-2006 Christian Landone. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef TEMPOTRACK_H 00017 #define TEMPOTRACK_H 00018 00019 00020 #include <stdio.h> 00021 #include <vector> 00022 00023 #include "dsp/signalconditioning/DFProcess.h" 00024 #include "maths/Correlation.h" 00025 #include "dsp/signalconditioning/Framer.h" 00026 00027 00028 00029 using std::vector; 00030 00031 struct WinThresh 00032 { 00033 unsigned int pre; 00034 unsigned int post; 00035 }; 00036 00037 struct TTParams 00038 { 00039 unsigned int winLength; //Analysis window length 00040 unsigned int lagLength; //Lag & Stride size 00041 unsigned int alpha; //alpha-norm parameter 00042 unsigned int LPOrd; // low-pass Filter order 00043 double* LPACoeffs; //low pass Filter den coefficients 00044 double* LPBCoeffs; //low pass Filter num coefficients 00045 WinThresh WinT;//window size in frames for adaptive thresholding [pre post]: 00046 }; 00047 00048 00049 class TempoTrack 00050 { 00051 public: 00052 TempoTrack( TTParams Params ); 00053 virtual ~TempoTrack(); 00054 00055 vector<int> process( vector <double> DF, vector <double> *tempoReturn = 0); 00056 00057 00058 private: 00059 void initialise( TTParams Params ); 00060 void deInitialise(); 00061 00062 int beatPredict( unsigned int FSP, double alignment, double period, unsigned int step); 00063 int phaseMM( double* DF, double* weighting, unsigned int winLength, double period ); 00064 void createPhaseExtractor( double* Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat ); 00065 int findMeter( double* ACF, unsigned int len, double period ); 00066 void constDetect( double* periodP, int currentIdx, int* flag ); 00067 void stepDetect( double* periodP, double* periodG, int currentIdx, int* flag ); 00068 void createCombFilter( double* Filter, unsigned int winLength, unsigned int TSig, double beatLag ); 00069 double tempoMM( double* ACF, double* weight, int sig ); 00070 00071 unsigned int m_dataLength; 00072 unsigned int m_winLength; 00073 unsigned int m_lagLength; 00074 00075 double m_rayparam; 00076 double m_sigma; 00077 double m_DFWVNnorm; 00078 00079 vector<int> m_beats; // Vector of detected beats 00080 00081 double m_lockedTempo; 00082 00083 double* m_tempoScratch; 00084 double* m_smoothRCF; // Smoothed Output of Comb Filterbank (m_tempoScratch) 00085 00086 // Processing Buffers 00087 double* m_rawDFFrame; // Original Detection Function Analysis Frame 00088 double* m_smoothDFFrame; // Smoothed Detection Function Analysis Frame 00089 double* m_frameACF; // AutoCorrelation of Smoothed Detection Function 00090 00091 //Low Pass Coefficients for DF Smoothing 00092 double* m_ACoeffs; 00093 double* m_BCoeffs; 00094 00095 // Objetcs/operators declaration 00096 Framer m_DFFramer; 00097 DFProcess* m_DFConditioning; 00098 Correlation m_correlator; 00099 // Config structure for DFProcess 00100 DFProcConfig m_DFPParams; 00101 00102 // also want to smooth m_tempoScratch 00103 DFProcess* m_RCFConditioning; 00104 // Config structure for RCFProcess 00105 DFProcConfig m_RCFPParams; 00106 00107 00108 00109 }; 00110 00111 #endif