annotate dsp/onsets/DetectionFunction.h @ 321:f1e6be2de9a5

A threshold (delta) is added in the peak picking parameters structure (PPickParams). It is used as an offset when computing the smoothed detection function. A constructor for the structure PPickParams is also added to set the parameters to 0 when a structure instance is created. Hence programmes using the peak picking parameter structure and which do not set the delta parameter (e.g. QM Vamp note onset detector) won't be affected by the modifications. Functions modified: - dsp/onsets/PeakPicking.cpp - dsp/onsets/PeakPicking.h - dsp/signalconditioning/DFProcess.cpp - dsp/signalconditioning/DFProcess.h
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Mon, 20 Jun 2011 19:01:48 +0100
parents d5014ab8b0e5
children f3c69325cca2
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@225 80
c@225 81 Window<double> *m_window;
c@227 82 PhaseVocoder* m_phaseVoc; // Phase Vocoder
c@225 83 };
c@225 84
c@225 85 #endif