annotate trunk/src/Modules/BMM/ModuleGammatone.h @ 288:34993448961f

-Updated the Slaney IIR gammatone to use a cascase of four second-order filters as per the implementtion in Slaney's auditory toolbox. This is more numerically stable at high sample rates and low centre frequencies.
author tomwalters
date Sat, 20 Feb 2010 17:56:40 +0000
parents e55d0c225a57
children 30dde71d0230
rev   line source
tomwalters@276 1 // Copyright 2009-2010, Thomas Walters
tomwalters@276 2 //
tomwalters@276 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@276 4 // http://www.acousticscale.org/AIMC
tomwalters@276 5 //
tomwalters@276 6 // This program is free software: you can redistribute it and/or modify
tomwalters@276 7 // it under the terms of the GNU General Public License as published by
tomwalters@276 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@276 9 // (at your option) any later version.
tomwalters@276 10 //
tomwalters@276 11 // This program is distributed in the hope that it will be useful,
tomwalters@276 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@276 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@276 14 // GNU General Public License for more details.
tomwalters@276 15 //
tomwalters@276 16 // You should have received a copy of the GNU General Public License
tomwalters@276 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@276 18
tomwalters@276 19 /*! \file
tomwalters@276 20 * \brief Slaney's gammatone filterbank
tomwalters@276 21 *
tomwalters@276 22 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@276 23 * \date created 2009/11/13
tomwalters@276 24 * \version \$Id$
tomwalters@288 25 *
tomwalters@288 26 * This is the version of the IIR gammatone used in Slaney's Auditory toolbox.
tomwalters@288 27 * The original verison as described in Apple Tech. Report #35 has a problem
tomwalters@288 28 * with the high-order coefficients at low centre frequencies and high sample
tomwalters@288 29 * rates. Since it is important that AIM-C can deal with these cases (for
tomwalters@288 30 * example for the Gaussian features), I've reiplemeted Slaney's alternative
tomwalters@288 31 * version which uses a cascade of four second-order filters in place of the
tomwalters@288 32 * eighth-order filter.
tomwalters@276 33 */
tomwalters@280 34 #ifndef _AIMC_MODULES_BMM_GAMMATONE_H_
tomwalters@280 35 #define _AIMC_MODULES_BMM_GAMMATONE_H_
tomwalters@276 36
tomwalters@276 37 #include <vector>
tomwalters@276 38
tomwalters@277 39 #include "Support/Module.h"
tomwalters@277 40 #include "Support/Parameters.h"
tomwalters@277 41 #include "Support/SignalBank.h"
tomwalters@277 42
tomwalters@276 43 namespace aimc {
tomwalters@276 44 using std::vector;
tomwalters@276 45 class ModuleGammatone : public Module {
tomwalters@276 46 public:
tomwalters@280 47 explicit ModuleGammatone(Parameters *params);
tomwalters@276 48 virtual ~ModuleGammatone();
tomwalters@280 49 /*! \brief Process a buffer
tomwalters@280 50 */
tomwalters@276 51 virtual void Process(const SignalBank &input);
tomwalters@276 52
tomwalters@276 53 private:
tomwalters@276 54 virtual bool InitializeInternal(const SignalBank& input);
tomwalters@276 55 virtual void ResetInternal();
tomwalters@288 56
tomwalters@288 57 // Filter coefficients
tomwalters@288 58 vector<vector<double> > b1_;
tomwalters@288 59 vector<vector<double> > b2_;
tomwalters@288 60 vector<vector<double> > b3_;
tomwalters@288 61 vector<vector<double> > b4_;
tomwalters@288 62 vector<vector<double> > a_;
tomwalters@288 63
tomwalters@288 64 vector<vector<double> > state_1_;
tomwalters@288 65 vector<vector<double> > state_2_;
tomwalters@288 66 vector<vector<double> > state_3_;
tomwalters@288 67 vector<vector<double> > state_4_;
tomwalters@288 68
tomwalters@288 69 vector<double> centre_frequencies_;
tomwalters@276 70 int num_channels_;
tomwalters@288 71 double max_frequency_;
tomwalters@288 72 double min_frequency_;
tomwalters@276 73 };
tomwalters@280 74 } // namespace aimc
tomwalters@280 75 #endif // _AIMC_MODULES_BMM_GAMMATONE_H_