1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6 Centre for Digital Music, Queen Mary, University of London.
7 This file 2005-2006 Christian Landone.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
18 //////////////////////////////////////////////////////////////////////
19 // Construction/Destruction
20 //////////////////////////////////////////////////////////////////////
22 Filter::Filter( FilterConfig Config )
36 void Filter::initialise( FilterConfig Config )
39 m_ACoeffs = Config.ACoeffs;
40 m_BCoeffs = Config.BCoeffs;
42 m_inBuffer = new double[ m_ord + 1 ];
43 m_outBuffer = new double[ m_ord + 1 ];
48 void Filter::deInitialise()
56 for( unsigned int i = 0; i < m_ord+1; i++ ){ m_inBuffer[ i ] = 0.0; }
57 for(unsigned int i = 0; i < m_ord+1; i++ ){ m_outBuffer[ i ] = 0.0; }
60 void Filter::process( double *src, double *dst, unsigned int length )
66 for (SP=0;SP<length;SP++)
70 for ( i = 0; i < m_ord; i++) {m_inBuffer[ m_ord - i ]=m_inBuffer[ m_ord - i - 1 ];}
74 for (j=0;j< m_ord + 1; j++)
75 xout = xout + m_BCoeffs[ j ] * m_inBuffer[ j ];
76 for (j = 0; j < m_ord; j++)
77 xout= xout - m_ACoeffs[ j + 1 ] * m_outBuffer[ j ];
80 for ( i = 0; i < m_ord - 1; i++ ) { m_outBuffer[ m_ord - i - 1 ] = m_outBuffer[ m_ord - i - 2 ];}
83 } /* end of SP loop */