annotate dsp/onsets/DetectionFunction.h @ 0:d7116e3183f8

* Queen Mary C++ DSP library
author cannam
date Wed, 05 Apr 2006 17:35:59 +0000
parents
children c539af5259da
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 DETECTIONFUNCTION_H
cannam@0 12 #define DETECTIONFUNCTION_H
cannam@0 13
cannam@0 14 #include "dsp/maths/MathUtilities.h"
cannam@0 15 #include "dsp/maths/MathAliases.h"
cannam@0 16 #include "dsp/phasevocoder/PhaseVocoder.h"
cannam@0 17 #include "base/Window.h"
cannam@0 18
cannam@0 19 #define DF_HFC (1)
cannam@0 20 #define DF_SPECDIFF (2)
cannam@0 21 #define DF_PHASEDEV (3)
cannam@0 22 #define DF_COMPLEXSD (4)
cannam@0 23
cannam@0 24 struct DFConfig{
cannam@0 25 double stepSecs; // DF step in seconds
cannam@0 26 unsigned int stepSize; // DF step in samples
cannam@0 27 unsigned int frameLength; // DF analysis window - usually 2*step
cannam@0 28 int DFType; // type of detection function ( see defines )
cannam@0 29 };
cannam@0 30
cannam@0 31 class DetectionFunction
cannam@0 32 {
cannam@0 33 public:
cannam@0 34 double* getSpectrumMagnitude();
cannam@0 35 DetectionFunction( DFConfig Config );
cannam@0 36 virtual ~DetectionFunction();
cannam@0 37 double process( double* TDomain );
cannam@0 38
cannam@0 39 private:
cannam@0 40 double HFC( unsigned int length, double* src);
cannam@0 41 double specDiff( unsigned int length, double* src);
cannam@0 42 double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase);
cannam@0 43 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
cannam@0 44
cannam@0 45 private:
cannam@0 46 void initialise( DFConfig Config );
cannam@0 47 void deInitialise();
cannam@0 48
cannam@0 49 int m_DFType;
cannam@0 50 unsigned int m_dataLength;
cannam@0 51 unsigned int m_halfLength;
cannam@0 52
cannam@0 53 double* magHistory;
cannam@0 54 double* phaseHistory;
cannam@0 55 double* phaseHistoryOld;
cannam@0 56
cannam@0 57 double* m_DFWindowedFrame; // Array for windowed analysis frame
cannam@0 58 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
cannam@0 59 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
cannam@0 60
cannam@0 61
cannam@0 62 vector < ComplexData > meas ;
cannam@0 63
cannam@0 64 ComplexData j;
cannam@0 65
cannam@0 66 Window<double> *m_window;
cannam@0 67
cannam@0 68 PhaseVocoder* m_phaseVoc; // Phase Vocoder
cannam@0 69
cannam@0 70 };
cannam@0 71
cannam@0 72 #endif