annotate dsp/onsets/DetectionFunction.h @ 340:c99d83236f0d

Do actual phase unwrapping in the phase vocoder!
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 02 Oct 2013 15:05:34 +0100
parents d5014ab8b0e5
children 2020c73dc997
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@309 7 This file 2005-2006 Christian Landone.
c@309 8
c@309 9 This program is free software; you can redistribute it and/or
c@309 10 modify it under the terms of the GNU General Public License as
c@309 11 published by the Free Software Foundation; either version 2 of the
c@309 12 License, or (at your option) any later version. See the file
c@309 13 COPYING included with this distribution for more information.
c@225 14 */
c@225 15
c@225 16 #ifndef DETECTIONFUNCTION_H
c@225 17 #define DETECTIONFUNCTION_H
c@225 18
c@241 19 #include "maths/MathUtilities.h"
c@241 20 #include "maths/MathAliases.h"
c@225 21 #include "dsp/phasevocoder/PhaseVocoder.h"
c@225 22 #include "base/Window.h"
c@225 23
c@225 24 #define DF_HFC (1)
c@225 25 #define DF_SPECDIFF (2)
c@225 26 #define DF_PHASEDEV (3)
c@225 27 #define DF_COMPLEXSD (4)
c@237 28 #define DF_BROADBAND (5)
c@225 29
c@225 30 struct DFConfig{
c@225 31 unsigned int stepSize; // DF step in samples
c@225 32 unsigned int frameLength; // DF analysis window - usually 2*step
c@225 33 int DFType; // type of detection function ( see defines )
c@237 34 double dbRise; // only used for broadband df (and required for it)
c@239 35 bool adaptiveWhitening; // perform adaptive whitening
c@239 36 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
c@239 37 double whiteningFloor; // if < 0, a sensible default will be used
c@225 38 };
c@225 39
c@225 40 class DetectionFunction
c@225 41 {
c@225 42 public:
c@225 43 double* getSpectrumMagnitude();
c@225 44 DetectionFunction( DFConfig Config );
c@225 45 virtual ~DetectionFunction();
c@280 46 double process( const double* TDomain );
c@280 47 double process( const double* magnitudes, const double* phases );
c@225 48
c@225 49 private:
c@239 50 void whiten();
c@227 51 double runDF();
c@227 52
c@225 53 double HFC( unsigned int length, double* src);
c@225 54 double specDiff( unsigned int length, double* src);
c@239 55 double phaseDev(unsigned int length, double *srcPhase);
c@225 56 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
c@239 57 double broadband(unsigned int length, double *srcMagnitude);
c@225 58
c@225 59 private:
c@225 60 void initialise( DFConfig Config );
c@225 61 void deInitialise();
c@225 62
c@225 63 int m_DFType;
c@225 64 unsigned int m_dataLength;
c@225 65 unsigned int m_halfLength;
c@238 66 unsigned int m_stepSize;
c@237 67 double m_dbRise;
c@239 68 bool m_whiten;
c@239 69 double m_whitenRelaxCoeff;
c@239 70 double m_whitenFloor;
c@225 71
c@227 72 double* m_magHistory;
c@227 73 double* m_phaseHistory;
c@227 74 double* m_phaseHistoryOld;
c@239 75 double* m_magPeaks;
c@225 76
c@225 77 double* m_DFWindowedFrame; // Array for windowed analysis frame
c@225 78 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
c@225 79 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
c@340 80 double* m_unwrapped; // Unwrapped phase of analysis frame
c@225 81
c@225 82 Window<double> *m_window;
c@227 83 PhaseVocoder* m_phaseVoc; // Phase Vocoder
c@225 84 };
c@225 85
c@225 86 #endif