annotate dsp/signalconditioning/Filter.cpp @ 96:88f3cfcff55f

A threshold (delta) is added in the peak picking parameters structure (PPickParams). It is used as an offset when computing the smoothed detection function. A constructor for the structure PPickParams is also added to set the parameters to 0 when a structure instance is created. Hence programmes using the peak picking parameter structure and which do not set the delta parameter (e.g. QM Vamp note onset detector) won't be affected by the modifications. Functions modified: - dsp/onsets/PeakPicking.cpp - dsp/onsets/PeakPicking.h - dsp/signalconditioning/DFProcess.cpp - dsp/signalconditioning/DFProcess.h
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Mon, 20 Jun 2011 19:01:48 +0100
parents e5907ae6de17
children ca658c7215a9
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 QM DSP Library
cannam@0 5
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@84 7 This file 2005-2006 Christian Landone.
Chris@84 8
Chris@84 9 This program is free software; you can redistribute it and/or
Chris@84 10 modify it under the terms of the GNU General Public License as
Chris@84 11 published by the Free Software Foundation; either version 2 of the
Chris@84 12 License, or (at your option) any later version. See the file
Chris@84 13 COPYING included with this distribution for more information.
cannam@0 14 */
cannam@0 15
cannam@0 16 #include "Filter.h"
cannam@0 17
cannam@0 18 //////////////////////////////////////////////////////////////////////
cannam@0 19 // Construction/Destruction
cannam@0 20 //////////////////////////////////////////////////////////////////////
cannam@0 21
cannam@0 22 Filter::Filter( FilterConfig Config )
cannam@0 23 {
cannam@0 24 m_ord = 0;
cannam@0 25 m_outBuffer = NULL;
cannam@0 26 m_inBuffer = NULL;
cannam@0 27
cannam@0 28 initialise( Config );
cannam@0 29 }
cannam@0 30
cannam@0 31 Filter::~Filter()
cannam@0 32 {
cannam@0 33 deInitialise();
cannam@0 34 }
cannam@0 35
cannam@0 36 void Filter::initialise( FilterConfig Config )
cannam@0 37 {
cannam@0 38 m_ord = Config.ord;
cannam@0 39 m_ACoeffs = Config.ACoeffs;
cannam@0 40 m_BCoeffs = Config.BCoeffs;
cannam@0 41
cannam@0 42 m_inBuffer = new double[ m_ord + 1 ];
cannam@0 43 m_outBuffer = new double[ m_ord + 1 ];
cannam@0 44
cannam@0 45 reset();
cannam@0 46 }
cannam@0 47
cannam@0 48 void Filter::deInitialise()
cannam@0 49 {
cannam@0 50 delete[] m_inBuffer;
cannam@0 51 delete[] m_outBuffer;
cannam@0 52 }
cannam@0 53
cannam@0 54 void Filter::reset()
cannam@0 55 {
cannam@0 56 for( unsigned int i = 0; i < m_ord+1; i++ ){ m_inBuffer[ i ] = 0.0; }
cannam@0 57 for(unsigned int i = 0; i < m_ord+1; i++ ){ m_outBuffer[ i ] = 0.0; }
cannam@0 58 }
cannam@0 59
cannam@0 60 void Filter::process( double *src, double *dst, unsigned int length )
cannam@0 61 {
cannam@0 62 unsigned int SP,i,j;
cannam@0 63
cannam@0 64 double xin,xout;
cannam@0 65
cannam@0 66 for (SP=0;SP<length;SP++)
cannam@0 67 {
cannam@0 68 xin=src[SP];
cannam@0 69 /* move buffer */
cannam@0 70 for ( i = 0; i < m_ord; i++) {m_inBuffer[ m_ord - i ]=m_inBuffer[ m_ord - i - 1 ];}
cannam@0 71 m_inBuffer[0]=xin;
cannam@0 72
cannam@0 73 xout=0.0;
cannam@0 74 for (j=0;j< m_ord + 1; j++)
cannam@0 75 xout = xout + m_BCoeffs[ j ] * m_inBuffer[ j ];
cannam@0 76 for (j = 0; j < m_ord; j++)
cannam@0 77 xout= xout - m_ACoeffs[ j + 1 ] * m_outBuffer[ j ];
cannam@0 78
cannam@0 79 dst[ SP ] = xout;
cannam@0 80 for ( i = 0; i < m_ord - 1; i++ ) { m_outBuffer[ m_ord - i - 1 ] = m_outBuffer[ m_ord - i - 2 ];}
cannam@0 81 m_outBuffer[0]=xout;
cannam@0 82
cannam@0 83 } /* end of SP loop */
cannam@0 84 }
cannam@0 85
cannam@0 86
cannam@0 87