annotate src/Modules/BMM/ModulePZFC.h @ 0:582cbe817f2c

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