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: c@225: // PeakPicking.h: interface for the PeakPicking class. c@225: // c@225: ////////////////////////////////////////////////////////////////////// c@225: c@225: #ifndef PEAKPICKING_H c@225: #define 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: { c@225: unsigned int pre; c@225: unsigned int post; mathieu@321: mathieu@321: PPWinThresh(unsigned int x, unsigned 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: { c@225: unsigned int length; //Detection FunctionLength mathieu@321: double tau; // time resolution of the detection function c@225: unsigned int alpha; //alpha-norm parameter c@225: double cutoff;//low-pass Filter cutoff freq c@225: unsigned int LPOrd; // low-pass Filter order c@225: double* LPACoeffs; //low pass Filter den coefficients c@225: double* LPBCoeffs; //low pass Filter num coefficients c@237: PPWinThresh WinT;//window size in frames for adaptive thresholding [pre post]: c@225: QFitThresh QuadThresh; mathieu@321: 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(); c@225: c@225: void process( double* src, unsigned int len, vector &onsets ); c@225: c@225: c@225: private: c@225: void initialise( PPickParams Config ); c@225: void deInitialise(); c@225: int quadEval( vector &src, vector &idx ); c@225: c@225: DFProcConfig m_DFProcessingParams; c@225: c@225: unsigned int m_DFLength ; c@225: double Qfilta ; c@225: double Qfiltb; c@225: double Qfiltc; c@225: c@225: c@225: double* m_workBuffer; c@225: c@225: DFProcess* m_DFSmoothing; c@225: }; c@225: c@225: #endif