annotate trunk/src/Modules/BMM/ModulePZFC.h @ 319:566a8543a6f1

Created wiki page through web user interface.
author tomwalters@google.com
date Wed, 19 May 2010 15:28:10 +0000
parents 30dde71d0230
children e7bcaf1e87d5
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@318 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@318 7 // you may not use this file except in compliance with the License.
tomwalters@318 8 // You may obtain a copy of the License at
tomwalters@268 9 //
tomwalters@318 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@268 11 //
tomwalters@318 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@318 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@318 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@318 15 // See the License for the specific language governing permissions and
tomwalters@318 16 // limitations under the License.
tomwalters@268 17
tomwalters@280 18 /*! \file
tomwalters@280 19 * \brief Dick Lyon's Pole-Zero Filter Cascade - implemented in C++ by Tom
tomwalters@280 20 * Walters from the AIM-MAT module based on Dick Lyon's code.
tomwalters@280 21 *
tomwalters@280 22 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@280 23 * \date created 2008/02/05
tomwalters@296 24 * \version \$Id$
tomwalters@280 25 */
tomwalters@280 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@280 40 explicit ModulePZFC(Parameters *pParam);
tomwalters@268 41 virtual ~ModulePZFC();
tomwalters@268 42
tomwalters@280 43 /*! \brief Process a buffer
tomwalters@280 44 */
tomwalters@268 45 virtual void Process(const SignalBank &input);
tomwalters@268 46
tomwalters@275 47 private:
tomwalters@280 48 /*! \brief Reset all internal state variables to their initial values
tomwalters@280 49 */
tomwalters@280 50 virtual void ResetInternal();
tomwalters@268 51
tomwalters@280 52 /*! \brief Prepare the module
tomwalters@280 53 * \param input Input SignalBank
tomwalters@280 54 * \param output true on success false on failure
tomwalters@280 55 */
tomwalters@268 56 virtual bool InitializeInternal(const SignalBank &input);
tomwalters@268 57
tomwalters@280 58 /*! \brief Set the filterbank parameters according to a fit matrix from Unoki
tomwalters@280 59 * and Lyon's fitting routine
tomwalters@280 60 */
tomwalters@268 61 bool SetPZBankCoeffsERBFitted();
tomwalters@268 62
tomwalters@280 63 /*! \brief Sets the general filterbank coefficients
tomwalters@280 64 */
tomwalters@268 65 bool SetPZBankCoeffs();
tomwalters@268 66
tomwalters@280 67 /*! \brief Automatic Gain Control
tomwalters@280 68 */
tomwalters@268 69 void AGCDampStep();
tomwalters@268 70
tomwalters@280 71 /*! \brief Detector function - halfwave rectification etc. Used internally,
tomwalters@280 72 * but not applied to the output.
tomwalters@280 73 */
tomwalters@268 74 float DetectFun(float fIN);
tomwalters@268 75
tomwalters@280 76 /*! \brief Minimum
tomwalters@280 77 */
tomwalters@268 78 inline float Minimum(float a, float b);
tomwalters@268 79
tomwalters@268 80 int channel_count_;
tomwalters@268 81 int buffer_length_;
tomwalters@268 82 int agc_stage_count_;
tomwalters@268 83 float sample_rate_;
tomwalters@268 84 float last_input_;
tomwalters@268 85
tomwalters@268 86 // Parameters
tomwalters@268 87 // User-settable scalars
tomwalters@268 88 float pole_damping_;
tomwalters@268 89 float zero_damping_;
tomwalters@268 90 float zero_factor_;
tomwalters@268 91 float step_factor_;
tomwalters@268 92 float bandwidth_over_cf_;
tomwalters@268 93 float min_bandwidth_hz_;
tomwalters@268 94 float agc_factor_;
tomwalters@268 95 float cf_max_;
tomwalters@268 96 float cf_min_;
tomwalters@268 97 float mindamp_;
tomwalters@268 98 float maxdamp_;
tomwalters@268 99 bool do_agc_step_;
tomwalters@268 100
tomwalters@268 101 // Internal Buffers
tomwalters@268 102 // Initialised once
tomwalters@268 103 vector<float> pole_dampings_;
tomwalters@268 104 vector<float> agc_epsilons_;
tomwalters@268 105 vector<float> agc_gains_;
tomwalters@268 106 vector<float> pole_frequencies_;
tomwalters@268 107 vector<float> za0_;
tomwalters@268 108 vector<float> za1_;
tomwalters@268 109 vector<float> za2_;
tomwalters@268 110 vector<float> rmin_;
tomwalters@268 111 vector<float> rmax_;
tomwalters@268 112 vector<float> xmin_;
tomwalters@268 113 vector<float> xmax_;
tomwalters@268 114
tomwalters@268 115 // Modified by algorithm at each time step
tomwalters@268 116 vector<float> detect_;
tomwalters@268 117 vector<vector<float> > agc_state_;
tomwalters@268 118 vector<float> state_1_;
tomwalters@268 119 vector<float> state_2_;
tomwalters@268 120 vector<float> previous_out_;
tomwalters@268 121 vector<float> pole_damps_mod_;
tomwalters@268 122 vector<float> inputs_;
tomwalters@268 123 };
tomwalters@268 124 }
tomwalters@268 125
tomwalters@268 126 #endif // _AIMC_MODULES_BMM_PZFC_H_