qm-dsp  1.8
PeakPicking.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     QM DSP Library
00005 
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file 2005-2006 Christian Landone.
00008 
00009     Modifications:
00010 
00011     - delta threshold
00012     Description: add delta threshold used as offset in the smoothed
00013     detection function
00014     Author: Mathieu Barthet
00015     Date: June 2010
00016 
00017     This program is free software; you can redistribute it and/or
00018     modify it under the terms of the GNU General Public License as
00019     published by the Free Software Foundation; either version 2 of the
00020     License, or (at your option) any later version.  See the file
00021     COPYING included with this distribution for more information.
00022 */
00023 
00024 // PeakPicking.h: interface for the PeakPicking class.
00025 //
00027 
00028 #ifndef PEAKPICKING_H
00029 #define PEAKPICKING_H
00030 
00031 #include "maths/MathUtilities.h"
00032 #include "maths/MathAliases.h"
00033 #include "dsp/signalconditioning/DFProcess.h"
00034 
00035 
00036 struct PPWinThresh
00037 {
00038     unsigned int pre;
00039     unsigned int  post;
00040 
00041     PPWinThresh(unsigned int x, unsigned int y) :
00042         pre(x),
00043         post(y)
00044     {
00045     }
00046 };
00047 
00048 struct QFitThresh
00049 {
00050     double a;
00051     double b;
00052     double c;
00053 
00054     QFitThresh(double x, double y, double z) :
00055         a(x),
00056         b(y),
00057         c(z)
00058     {
00059     }
00060 };
00061 
00062 struct PPickParams
00063 {
00064     unsigned int length; //Detection FunctionLength
00065     double tau; // time resolution of the detection function
00066     unsigned int alpha; //alpha-norm parameter
00067     double cutoff;//low-pass Filter cutoff freq
00068     unsigned int LPOrd; // low-pass Filter order
00069     double* LPACoeffs; //low pass Filter den coefficients
00070     double* LPBCoeffs; //low pass Filter num coefficients
00071     PPWinThresh WinT;//window size in frames for adaptive thresholding [pre post]:
00072     QFitThresh QuadThresh;
00073     float delta; //delta threshold used as an offset when computing the smoothed detection function
00074 
00075     PPickParams() :
00076         length(0),
00077         tau(0),
00078         alpha(0),
00079         cutoff(0),
00080         LPOrd(0),
00081         LPACoeffs(NULL),
00082         LPBCoeffs(NULL),
00083         WinT(0,0),
00084         QuadThresh(0,0,0),
00085         delta(0)
00086     {
00087     }
00088 };
00089 
00090 class PeakPicking  
00091 {
00092 public:
00093     PeakPicking( PPickParams Config );
00094     virtual ~PeakPicking();
00095         
00096     void process( double* src, unsigned int len, vector<int> &onsets  );
00097 
00098 
00099 private:
00100     void initialise( PPickParams Config  );
00101     void deInitialise();
00102     int  quadEval( vector<double> &src, vector<int> &idx );
00103         
00104     DFProcConfig m_DFProcessingParams;
00105 
00106     unsigned int m_DFLength ;
00107     double Qfilta ;
00108     double Qfiltb;
00109     double Qfiltc;
00110 
00111 
00112     double* m_workBuffer;
00113         
00114     DFProcess*  m_DFSmoothing;
00115 };
00116 
00117 #endif