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@309: This file 2005-2006 Christian Landone. c@309: mathieu@321: Modifications: mathieu@321: mathieu@321: - delta threshold mathieu@321: Description: add delta threshold used as offset in the smoothed mathieu@321: detection function mathieu@321: Author: Mathieu Barthet mathieu@321: Date: June 2010 mathieu@321: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@225: */ c@225: cannam@489: #ifndef QM_DSP_PEAKPICKING_H cannam@489: #define QM_DSP_PEAKPICKING_H c@225: c@241: #include "maths/MathUtilities.h" c@241: #include "maths/MathAliases.h" c@225: #include "dsp/signalconditioning/DFProcess.h" c@225: c@225: c@237: struct PPWinThresh c@225: { cannam@499: int pre; cannam@499: int post; mathieu@321: cannam@499: PPWinThresh(int x, int y) : mathieu@321: pre(x), mathieu@321: post(y) mathieu@321: { mathieu@321: } c@225: }; c@225: c@225: struct QFitThresh c@225: { c@225: double a; c@225: double b; c@225: double c; mathieu@321: mathieu@321: QFitThresh(double x, double y, double z) : mathieu@321: a(x), mathieu@321: b(y), mathieu@321: c(z) mathieu@321: { mathieu@321: } c@225: }; c@225: c@225: struct PPickParams c@225: { cannam@499: int length; // detection function length mathieu@321: double tau; // time resolution of the detection function cannam@499: int alpha; // alpha-norm parameter cannam@499: double cutoff;// low-pass filter cutoff freq cannam@499: int LPOrd; // low-pass filter order cannam@499: double* LPACoeffs; // low-pass filter denominator coefficients cannam@499: double* LPBCoeffs; // low-pass filter numerator coefficients cannam@499: PPWinThresh WinT;// window size in frames for adaptive thresholding [pre post]: c@225: QFitThresh QuadThresh; cannam@499: float delta; // delta threshold used as an offset when computing the smoothed detection function mathieu@321: mathieu@321: PPickParams() : mathieu@321: length(0), mathieu@321: tau(0), mathieu@321: alpha(0), mathieu@321: cutoff(0), mathieu@321: LPOrd(0), mathieu@321: LPACoeffs(NULL), mathieu@321: LPBCoeffs(NULL), mathieu@321: WinT(0,0), mathieu@321: QuadThresh(0,0,0), mathieu@321: delta(0) mathieu@321: { mathieu@321: } c@225: }; c@225: c@225: class PeakPicking c@225: { c@225: public: c@225: PeakPicking( PPickParams Config ); c@225: virtual ~PeakPicking(); cannam@483: cannam@499: void process( double* src, int len, std::vector &onsets ); c@225: c@225: private: c@225: void initialise( PPickParams Config ); c@225: void deInitialise(); cannam@487: int quadEval( std::vector &src, std::vector &idx ); cannam@483: c@225: DFProcConfig m_DFProcessingParams; c@225: cannam@499: int m_DFLength ; c@225: double Qfilta ; c@225: double Qfiltb; c@225: double Qfiltc; c@225: c@225: double* m_workBuffer; cannam@483: cannam@483: DFProcess* m_DFSmoothing; c@225: }; c@225: c@225: #endif