annotate trunk/src/Modules/BMM/ModulePZFC.h @ 304:e4f704f67ca6

-Typo in file path
author tomwalters
date Wed, 24 Feb 2010 15:18:00 +0000
parents fe5ce00a64f5
children 30dde71d0230
rev   line source
tomwalters@282 1 // Copyright 2008-2010, Thomas Walters
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@280 19 /*! \file
tomwalters@280 20 * \brief Dick Lyon's Pole-Zero Filter Cascade - implemented in C++ by Tom
tomwalters@280 21 * Walters from the AIM-MAT module based on Dick Lyon's code.
tomwalters@280 22 *
tomwalters@280 23 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@280 24 * \date created 2008/02/05
tomwalters@296 25 * \version \$Id$
tomwalters@280 26 */
tomwalters@280 27
tomwalters@268 28 #ifndef _AIMC_MODULES_BMM_PZFC_H_
tomwalters@268 29 #define _AIMC_MODULES_BMM_PZFC_H_
tomwalters@268 30
tomwalters@268 31 #include <vector>
tomwalters@268 32
tomwalters@268 33 #include "Support/Module.h"
tomwalters@268 34 #include "Support/Parameters.h"
tomwalters@268 35 #include "Support/SignalBank.h"
tomwalters@268 36
tomwalters@268 37 namespace aimc {
tomwalters@268 38 using std::vector;
tomwalters@268 39 class ModulePZFC : public Module {
tomwalters@268 40 public:
tomwalters@280 41 explicit ModulePZFC(Parameters *pParam);
tomwalters@268 42 virtual ~ModulePZFC();
tomwalters@268 43
tomwalters@280 44 /*! \brief Process a buffer
tomwalters@280 45 */
tomwalters@268 46 virtual void Process(const SignalBank &input);
tomwalters@268 47
tomwalters@275 48 private:
tomwalters@280 49 /*! \brief Reset all internal state variables to their initial values
tomwalters@280 50 */
tomwalters@280 51 virtual void ResetInternal();
tomwalters@268 52
tomwalters@280 53 /*! \brief Prepare the module
tomwalters@280 54 * \param input Input SignalBank
tomwalters@280 55 * \param output true on success false on failure
tomwalters@280 56 */
tomwalters@268 57 virtual bool InitializeInternal(const SignalBank &input);
tomwalters@268 58
tomwalters@280 59 /*! \brief Set the filterbank parameters according to a fit matrix from Unoki
tomwalters@280 60 * and Lyon's fitting routine
tomwalters@280 61 */
tomwalters@268 62 bool SetPZBankCoeffsERBFitted();
tomwalters@268 63
tomwalters@280 64 /*! \brief Sets the general filterbank coefficients
tomwalters@280 65 */
tomwalters@268 66 bool SetPZBankCoeffs();
tomwalters@268 67
tomwalters@280 68 /*! \brief Automatic Gain Control
tomwalters@280 69 */
tomwalters@268 70 void AGCDampStep();
tomwalters@268 71
tomwalters@280 72 /*! \brief Detector function - halfwave rectification etc. Used internally,
tomwalters@280 73 * but not applied to the output.
tomwalters@280 74 */
tomwalters@268 75 float DetectFun(float fIN);
tomwalters@268 76
tomwalters@280 77 /*! \brief Minimum
tomwalters@280 78 */
tomwalters@268 79 inline float Minimum(float a, float b);
tomwalters@268 80
tomwalters@268 81 int channel_count_;
tomwalters@268 82 int buffer_length_;
tomwalters@268 83 int agc_stage_count_;
tomwalters@268 84 float sample_rate_;
tomwalters@268 85 float last_input_;
tomwalters@268 86
tomwalters@268 87 // Parameters
tomwalters@268 88 // User-settable scalars
tomwalters@268 89 float pole_damping_;
tomwalters@268 90 float zero_damping_;
tomwalters@268 91 float zero_factor_;
tomwalters@268 92 float step_factor_;
tomwalters@268 93 float bandwidth_over_cf_;
tomwalters@268 94 float min_bandwidth_hz_;
tomwalters@268 95 float agc_factor_;
tomwalters@268 96 float cf_max_;
tomwalters@268 97 float cf_min_;
tomwalters@268 98 float mindamp_;
tomwalters@268 99 float maxdamp_;
tomwalters@268 100 bool do_agc_step_;
tomwalters@268 101
tomwalters@268 102 // Internal Buffers
tomwalters@268 103 // Initialised once
tomwalters@268 104 vector<float> pole_dampings_;
tomwalters@268 105 vector<float> agc_epsilons_;
tomwalters@268 106 vector<float> agc_gains_;
tomwalters@268 107 vector<float> pole_frequencies_;
tomwalters@268 108 vector<float> za0_;
tomwalters@268 109 vector<float> za1_;
tomwalters@268 110 vector<float> za2_;
tomwalters@268 111 vector<float> rmin_;
tomwalters@268 112 vector<float> rmax_;
tomwalters@268 113 vector<float> xmin_;
tomwalters@268 114 vector<float> xmax_;
tomwalters@268 115
tomwalters@268 116 // Modified by algorithm at each time step
tomwalters@268 117 vector<float> detect_;
tomwalters@268 118 vector<vector<float> > agc_state_;
tomwalters@268 119 vector<float> state_1_;
tomwalters@268 120 vector<float> state_2_;
tomwalters@268 121 vector<float> previous_out_;
tomwalters@268 122 vector<float> pole_damps_mod_;
tomwalters@268 123 vector<float> inputs_;
tomwalters@268 124 };
tomwalters@268 125 }
tomwalters@268 126
tomwalters@268 127 #endif // _AIMC_MODULES_BMM_PZFC_H_