annotate dsp/onsets/DetectionFunction.h @ 489:701233f8ed41

Make include-guards consistent
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 31 May 2019 16:48:37 +0100
parents fdaa63607c15
children af5b7ef02aa7
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
cannam@489 16 #ifndef QM_DSP_DETECTIONFUNCTION_H
cannam@489 17 #define QM_DSP_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@356 32 unsigned int frameLength; // DF analysis window - usually 2*step. Must be even!
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@344 46
c@344 47 /**
c@344 48 * Process a single time-domain frame of audio, provided as
c@344 49 * frameLength samples.
c@344 50 */
c@344 51 double processTimeDomain(const double* samples);
c@344 52
c@344 53 /**
c@344 54 * Process a single frequency-domain frame, provided as
c@344 55 * frameLength/2+1 real and imaginary component values.
c@344 56 */
c@344 57 double processFrequencyDomain(const double* reals, const double* imags);
c@225 58
c@225 59 private:
c@239 60 void whiten();
c@227 61 double runDF();
c@227 62
c@225 63 double HFC( unsigned int length, double* src);
c@225 64 double specDiff( unsigned int length, double* src);
c@239 65 double phaseDev(unsigned int length, double *srcPhase);
c@225 66 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
c@239 67 double broadband(unsigned int length, double *srcMagnitude);
cannam@483 68
c@225 69 private:
c@225 70 void initialise( DFConfig Config );
c@225 71 void deInitialise();
c@225 72
c@225 73 int m_DFType;
c@225 74 unsigned int m_dataLength;
c@225 75 unsigned int m_halfLength;
c@238 76 unsigned int m_stepSize;
c@237 77 double m_dbRise;
c@239 78 bool m_whiten;
c@239 79 double m_whitenRelaxCoeff;
c@239 80 double m_whitenFloor;
c@225 81
c@227 82 double* m_magHistory;
c@227 83 double* m_phaseHistory;
c@227 84 double* m_phaseHistoryOld;
c@239 85 double* m_magPeaks;
c@225 86
c@344 87 double* m_windowed; // Array for windowed analysis frame
c@225 88 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
c@225 89 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
c@340 90 double* m_unwrapped; // Unwrapped phase of analysis frame
c@225 91
c@225 92 Window<double> *m_window;
cannam@483 93 PhaseVocoder* m_phaseVoc; // Phase Vocoder
c@225 94 };
c@225 95
c@225 96 #endif