annotate dsp/onsets/DetectionFunction.h @ 227:f06672e8db10

* Make it possible to provide the detection function with frequency domain inputs (i.e. phase vocoder already run)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 15 May 2006 11:21:47 +0000
parents 49844bc8a895
children da277e8b5244
rev   line source
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 DETECTIONFUNCTION_H
c@225 12 #define DETECTIONFUNCTION_H
c@225 13
c@225 14 #include "dsp/maths/MathUtilities.h"
c@225 15 #include "dsp/maths/MathAliases.h"
c@225 16 #include "dsp/phasevocoder/PhaseVocoder.h"
c@225 17 #include "base/Window.h"
c@225 18
c@225 19 #define DF_HFC (1)
c@225 20 #define DF_SPECDIFF (2)
c@225 21 #define DF_PHASEDEV (3)
c@225 22 #define DF_COMPLEXSD (4)
c@225 23
c@225 24 struct DFConfig{
c@225 25 double stepSecs; // DF step in seconds
c@225 26 unsigned int stepSize; // DF step in samples
c@225 27 unsigned int frameLength; // DF analysis window - usually 2*step
c@225 28 int DFType; // type of detection function ( see defines )
c@225 29 };
c@225 30
c@225 31 class DetectionFunction
c@225 32 {
c@225 33 public:
c@225 34 double* getSpectrumMagnitude();
c@225 35 DetectionFunction( DFConfig Config );
c@225 36 virtual ~DetectionFunction();
c@225 37 double process( double* TDomain );
c@227 38 double process( double* magnitudes, double* phases );
c@225 39
c@225 40 private:
c@227 41 double runDF();
c@227 42
c@225 43 double HFC( unsigned int length, double* src);
c@225 44 double specDiff( unsigned int length, double* src);
c@225 45 double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase);
c@225 46 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
c@225 47
c@225 48 private:
c@225 49 void initialise( DFConfig Config );
c@225 50 void deInitialise();
c@225 51
c@225 52 int m_DFType;
c@225 53 unsigned int m_dataLength;
c@225 54 unsigned int m_halfLength;
c@225 55
c@227 56 double* m_magHistory;
c@227 57 double* m_phaseHistory;
c@227 58 double* m_phaseHistoryOld;
c@225 59
c@225 60 double* m_DFWindowedFrame; // Array for windowed analysis frame
c@225 61 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
c@225 62 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
c@225 63
c@225 64 Window<double> *m_window;
c@227 65 PhaseVocoder* m_phaseVoc; // Phase Vocoder
c@225 66 };
c@225 67
c@225 68 #endif