annotate trunk/src/Modules/BMM/ModulePZFC.h @ 275:ce2bab04f155

- Imported file input using libsndfile from old AIM-C and updated to the new API - Modified the Module base class to propogate Reset() calls down the module chain. - This required changing all Reset() functions in subclasses to ResetInternal() - Removed some unneeded imports from the Gaussians test
author tomwalters
date Tue, 16 Feb 2010 18:00:16 +0000
parents e14c70d1b171
children e55d0c225a57
rev   line source
tomwalters@268 1 // Copyright 2008-2010, University of Cambridge
tomwalters@268 2 //
tomwalters@268 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268 4 // http://www.acousticscale.org/AIMC
tomwalters@268 5 //
tomwalters@268 6 // This program is free software: you can redistribute it and/or modify
tomwalters@268 7 // it under the terms of the GNU General Public License as published by
tomwalters@268 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@268 9 // (at your option) any later version.
tomwalters@268 10 //
tomwalters@268 11 // This program is distributed in the hope that it will be useful,
tomwalters@268 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268 14 // GNU General Public License for more details.
tomwalters@268 15 //
tomwalters@268 16 // You should have received a copy of the GNU General Public License
tomwalters@268 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@268 18
tomwalters@268 19 //! \file
tomwalters@268 20 //! \brief Dick Lyon's Pole-Zero Filter Cascade - implemented in C++ by Tom
tomwalters@268 21 //! Walters from the AIM-MAT module based on Dick Lyon's code.
tomwalters@268 22 //!
tomwalters@268 23 //! \author Thomas Walters <tom@acousticscale.org>
tomwalters@268 24 //! \date created 2008/02/05
tomwalters@268 25 //! \version \$Id: ModulePZFC.h 2 2010-02-02 12:59:50Z tcw $
tomwalters@268 26 //!
tomwalters@268 27 #ifndef _AIMC_MODULES_BMM_PZFC_H_
tomwalters@268 28 #define _AIMC_MODULES_BMM_PZFC_H_
tomwalters@268 29
tomwalters@268 30 #include <vector>
tomwalters@268 31
tomwalters@268 32 #include "Support/Module.h"
tomwalters@268 33 #include "Support/Parameters.h"
tomwalters@268 34 #include "Support/SignalBank.h"
tomwalters@268 35
tomwalters@268 36 namespace aimc {
tomwalters@268 37 using std::vector;
tomwalters@268 38 class ModulePZFC : public Module {
tomwalters@268 39 public:
tomwalters@268 40 ModulePZFC(Parameters *pParam);
tomwalters@268 41 virtual ~ModulePZFC();
tomwalters@268 42
tomwalters@268 43 //! \brief Process a buffer
tomwalters@268 44 virtual void Process(const SignalBank &input);
tomwalters@268 45
tomwalters@275 46 private:
tomwalters@275 47 //! \brief Reset all internal state variables to their initial values
tomwalters@275 48 virtual void ResetInternal();
tomwalters@268 49
tomwalters@268 50 //! \brief Prepare the module
tomwalters@268 51 //! \param input Input SignalBank
tomwalters@268 52 //! \param output true on success false on failure
tomwalters@268 53 virtual bool InitializeInternal(const SignalBank &input);
tomwalters@268 54
tomwalters@268 55 //! \brief Set the filterbank parameters according to a fit matrix from Unoki
tomwalters@268 56 //! and Lyon's fitting routine
tomwalters@268 57 bool SetPZBankCoeffsERBFitted();
tomwalters@268 58
tomwalters@268 59 //! \brief Sets the general filterbank coefficients
tomwalters@268 60 bool SetPZBankCoeffs();
tomwalters@268 61
tomwalters@268 62 //! \brief Automatic Gain Control
tomwalters@268 63 void AGCDampStep();
tomwalters@268 64
tomwalters@268 65 //! \brief Detector function - halfwave rectification etc. Used internally,
tomwalters@268 66 //! but not applied to the output.
tomwalters@268 67 float DetectFun(float fIN);
tomwalters@268 68
tomwalters@268 69 //! \brief Minimum
tomwalters@268 70 inline float Minimum(float a, float b);
tomwalters@268 71
tomwalters@268 72 int channel_count_;
tomwalters@268 73 int buffer_length_;
tomwalters@268 74 int agc_stage_count_;
tomwalters@268 75 float sample_rate_;
tomwalters@268 76 float last_input_;
tomwalters@268 77
tomwalters@268 78 // Parameters
tomwalters@268 79 // User-settable scalars
tomwalters@268 80 float pole_damping_;
tomwalters@268 81 float zero_damping_;
tomwalters@268 82 float zero_factor_;
tomwalters@268 83 float step_factor_;
tomwalters@268 84 float bandwidth_over_cf_;
tomwalters@268 85 float min_bandwidth_hz_;
tomwalters@268 86 float agc_factor_;
tomwalters@268 87 float cf_max_;
tomwalters@268 88 float cf_min_;
tomwalters@268 89 float mindamp_;
tomwalters@268 90 float maxdamp_;
tomwalters@268 91 bool do_agc_step_;
tomwalters@268 92
tomwalters@268 93 // Internal Buffers
tomwalters@268 94 // Initialised once
tomwalters@268 95 vector<float> pole_dampings_;
tomwalters@268 96 vector<float> agc_epsilons_;
tomwalters@268 97 vector<float> agc_gains_;
tomwalters@268 98 vector<float> pole_frequencies_;
tomwalters@268 99 vector<float> za0_;
tomwalters@268 100 vector<float> za1_;
tomwalters@268 101 vector<float> za2_;
tomwalters@268 102 vector<float> rmin_;
tomwalters@268 103 vector<float> rmax_;
tomwalters@268 104 vector<float> xmin_;
tomwalters@268 105 vector<float> xmax_;
tomwalters@268 106
tomwalters@268 107 // Modified by algorithm at each time step
tomwalters@268 108 vector<float> detect_;
tomwalters@268 109 vector<vector<float> > agc_state_;
tomwalters@268 110 vector<float> state_1_;
tomwalters@268 111 vector<float> state_2_;
tomwalters@268 112 vector<float> previous_out_;
tomwalters@268 113 vector<float> pole_damps_mod_;
tomwalters@268 114 vector<float> inputs_;
tomwalters@268 115 };
tomwalters@268 116 }
tomwalters@268 117
tomwalters@268 118 #endif // _AIMC_MODULES_BMM_PZFC_H_