annotate dsp/onsets/PeakPicking.h @ 495:1bea13b8f951

Style fixes in constant-Q: avoid unsigned, reuse our Window class, fix comments
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 31 May 2019 18:25:31 +0100
parents 701233f8ed41
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
mathieu@321 9 Modifications:
mathieu@321 10
mathieu@321 11 - delta threshold
mathieu@321 12 Description: add delta threshold used as offset in the smoothed
mathieu@321 13 detection function
mathieu@321 14 Author: Mathieu Barthet
mathieu@321 15 Date: June 2010
mathieu@321 16
c@309 17 This program is free software; you can redistribute it and/or
c@309 18 modify it under the terms of the GNU General Public License as
c@309 19 published by the Free Software Foundation; either version 2 of the
c@309 20 License, or (at your option) any later version. See the file
c@309 21 COPYING included with this distribution for more information.
c@225 22 */
c@225 23
cannam@489 24 #ifndef QM_DSP_PEAKPICKING_H
cannam@489 25 #define QM_DSP_PEAKPICKING_H
c@225 26
c@241 27 #include "maths/MathUtilities.h"
c@241 28 #include "maths/MathAliases.h"
c@225 29 #include "dsp/signalconditioning/DFProcess.h"
c@225 30
c@225 31
c@237 32 struct PPWinThresh
c@225 33 {
c@225 34 unsigned int pre;
c@225 35 unsigned int post;
mathieu@321 36
mathieu@321 37 PPWinThresh(unsigned int x, unsigned int y) :
mathieu@321 38 pre(x),
mathieu@321 39 post(y)
mathieu@321 40 {
mathieu@321 41 }
c@225 42 };
c@225 43
c@225 44 struct QFitThresh
c@225 45 {
c@225 46 double a;
c@225 47 double b;
c@225 48 double c;
mathieu@321 49
mathieu@321 50 QFitThresh(double x, double y, double z) :
mathieu@321 51 a(x),
mathieu@321 52 b(y),
mathieu@321 53 c(z)
mathieu@321 54 {
mathieu@321 55 }
c@225 56 };
c@225 57
c@225 58 struct PPickParams
c@225 59 {
c@225 60 unsigned int length; //Detection FunctionLength
mathieu@321 61 double tau; // time resolution of the detection function
c@225 62 unsigned int alpha; //alpha-norm parameter
c@225 63 double cutoff;//low-pass Filter cutoff freq
c@225 64 unsigned int LPOrd; // low-pass Filter order
c@225 65 double* LPACoeffs; //low pass Filter den coefficients
c@225 66 double* LPBCoeffs; //low pass Filter num coefficients
c@237 67 PPWinThresh WinT;//window size in frames for adaptive thresholding [pre post]:
c@225 68 QFitThresh QuadThresh;
mathieu@321 69 float delta; //delta threshold used as an offset when computing the smoothed detection function
mathieu@321 70
mathieu@321 71 PPickParams() :
mathieu@321 72 length(0),
mathieu@321 73 tau(0),
mathieu@321 74 alpha(0),
mathieu@321 75 cutoff(0),
mathieu@321 76 LPOrd(0),
mathieu@321 77 LPACoeffs(NULL),
mathieu@321 78 LPBCoeffs(NULL),
mathieu@321 79 WinT(0,0),
mathieu@321 80 QuadThresh(0,0,0),
mathieu@321 81 delta(0)
mathieu@321 82 {
mathieu@321 83 }
c@225 84 };
c@225 85
c@225 86 class PeakPicking
c@225 87 {
c@225 88 public:
c@225 89 PeakPicking( PPickParams Config );
c@225 90 virtual ~PeakPicking();
cannam@483 91
cannam@487 92 void process( double* src, unsigned int len, std::vector<int> &onsets );
c@225 93
c@225 94 private:
c@225 95 void initialise( PPickParams Config );
c@225 96 void deInitialise();
cannam@487 97 int quadEval( std::vector<double> &src, std::vector<int> &idx );
cannam@483 98
c@225 99 DFProcConfig m_DFProcessingParams;
c@225 100
c@225 101 unsigned int m_DFLength ;
c@225 102 double Qfilta ;
c@225 103 double Qfiltb;
c@225 104 double Qfiltc;
c@225 105
c@225 106 double* m_workBuffer;
cannam@483 107
cannam@483 108 DFProcess* m_DFSmoothing;
c@225 109 };
c@225 110
c@225 111 #endif