annotate trunk/carfac/agc_params.h @ 684:49af9a8d5a53

Initial translation of SAI code to C++. This only implements the simple (as opposed to the layered) SAI, as implemented in SAI_Run.m.
author ronw@google.com
date Fri, 31 May 2013 21:46:48 +0000
parents 10dc41e4d2f2
children
rev   line source
alexbrandmeyer@620 1 //
alexbrandmeyer@620 2 // agc_params.h
alexbrandmeyer@620 3 // CARFAC Open Source C++ Library
alexbrandmeyer@620 4 //
alexbrandmeyer@620 5 // Created by Alex Brandmeyer on 5/10/13.
alexbrandmeyer@620 6 //
alexbrandmeyer@620 7 // This C++ file is part of an implementation of Lyon's cochlear model:
alexbrandmeyer@620 8 // "Cascade of Asymmetric Resonators with Fast-Acting Compression"
alexbrandmeyer@620 9 // to supplement Lyon's upcoming book "Human and Machine Hearing"
alexbrandmeyer@620 10 //
alexbrandmeyer@620 11 // Licensed under the Apache License, Version 2.0 (the "License");
alexbrandmeyer@620 12 // you may not use this file except in compliance with the License.
alexbrandmeyer@620 13 // You may obtain a copy of the License at
alexbrandmeyer@620 14 //
alexbrandmeyer@620 15 // http://www.apache.org/licenses/LICENSE-2.0
alexbrandmeyer@620 16 //
alexbrandmeyer@620 17 // Unless required by applicable law or agreed to in writing, software
alexbrandmeyer@620 18 // distributed under the License is distributed on an "AS IS" BASIS,
alexbrandmeyer@620 19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
alexbrandmeyer@620 20 // See the License for the specific language governing permissions and
alexbrandmeyer@620 21 // limitations under the License.
alexbrandmeyer@620 22
alexbrandmeyer@682 23 #ifndef CARFAC_AGC_PARAMS_H
alexbrandmeyer@682 24 #define CARFAC_AGC_PARAMS_H
alexbrandmeyer@620 25
alexbrandmeyer@682 26 #include <vector>
alexbrandmeyer@620 27 #include "carfac_common.h"
alexbrandmeyer@620 28
alexbrandmeyer@621 29 struct AGCParams {
alexbrandmeyer@679 30 AGCParams() {
alexbrandmeyer@682 31 n_stages = 4;
alexbrandmeyer@682 32 agc_stage_gain = 2.0;
alexbrandmeyer@682 33 time_constants.resize(n_stages);
alexbrandmeyer@682 34 agc1_scales.resize(n_stages);
alexbrandmeyer@682 35 agc2_scales.resize(n_stages);
alexbrandmeyer@682 36 agc1_scales[0] = 1.0;
alexbrandmeyer@682 37 agc2_scales[0] = 1.65;
alexbrandmeyer@682 38 time_constants[0] = 0.002;
alexbrandmeyer@682 39 for (int i = 1; i < n_stages; ++i) {
alexbrandmeyer@682 40 agc1_scales[i] = agc1_scales[i - 1] * sqrt(2.0);
alexbrandmeyer@682 41 agc2_scales[i] = agc2_scales[i - 1] * sqrt(2.0);
alexbrandmeyer@682 42 time_constants[i] = time_constants[i - 1] * 4.0;
alexbrandmeyer@679 43 }
alexbrandmeyer@682 44 decimation = {8, 2, 2, 2};
alexbrandmeyer@682 45 agc_mix_coeff = 0.5;
alexbrandmeyer@679 46 }
alexbrandmeyer@682 47 int n_stages;
alexbrandmeyer@682 48 FPType agc_stage_gain;
alexbrandmeyer@682 49 FPType agc_mix_coeff;
alexbrandmeyer@682 50 std::vector<FPType> time_constants;
alexbrandmeyer@682 51 std::vector<int> decimation;
alexbrandmeyer@682 52 std::vector<FPType> agc1_scales;
alexbrandmeyer@682 53 std::vector<FPType> agc2_scales;
alexbrandmeyer@620 54 };
alexbrandmeyer@620 55
alexbrandmeyer@682 56 #endif // CARFAC_AGC_PARAMS_H