c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@225: This file copyright 2005-2006 Christian Landone. c@225: All rights reserved. c@225: */ c@225: c@225: #ifndef DETECTIONFUNCTION_H c@225: #define DETECTIONFUNCTION_H c@225: c@225: #include "dsp/maths/MathUtilities.h" c@225: #include "dsp/maths/MathAliases.h" c@225: #include "dsp/phasevocoder/PhaseVocoder.h" c@225: #include "base/Window.h" c@225: c@225: #define DF_HFC (1) c@225: #define DF_SPECDIFF (2) c@225: #define DF_PHASEDEV (3) c@225: #define DF_COMPLEXSD (4) c@225: c@225: struct DFConfig{ c@225: double stepSecs; // DF step in seconds c@225: unsigned int stepSize; // DF step in samples c@225: unsigned int frameLength; // DF analysis window - usually 2*step c@225: int DFType; // type of detection function ( see defines ) c@225: }; c@225: c@225: class DetectionFunction c@225: { c@225: public: c@225: double* getSpectrumMagnitude(); c@225: DetectionFunction( DFConfig Config ); c@225: virtual ~DetectionFunction(); c@225: double process( double* TDomain ); c@227: double process( double* magnitudes, double* phases ); c@225: c@225: private: c@227: double runDF(); c@227: c@225: double HFC( unsigned int length, double* src); c@225: double specDiff( unsigned int length, double* src); c@225: double phaseDev(unsigned int length, double *srcMagnitude, double *srcPhase); c@225: double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase); c@225: c@225: private: c@225: void initialise( DFConfig Config ); c@225: void deInitialise(); c@225: c@225: int m_DFType; c@225: unsigned int m_dataLength; c@225: unsigned int m_halfLength; c@225: c@227: double* m_magHistory; c@227: double* m_phaseHistory; c@227: double* m_phaseHistoryOld; c@225: c@225: double* m_DFWindowedFrame; // Array for windowed analysis frame c@225: double* m_magnitude; // Magnitude of analysis frame ( frequency domain ) c@225: double* m_thetaAngle;// Phase of analysis frame ( frequency domain ) c@225: c@225: Window *m_window; c@227: PhaseVocoder* m_phaseVoc; // Phase Vocoder c@225: }; c@225: c@225: #endif