Mercurial > hg > aimc
comparison branches/carfac_cpp/src/CARFAC.cpp @ 545:e63fbe19b255
stubbed some more, and tidying
author | Ulf.Hammarqvist@gmail.com |
---|---|
date | Sat, 31 Mar 2012 17:24:08 +0000 |
parents | c666e8e0696a |
children | e5ae2ed4249c |
comparison
equal
deleted
inserted
replaced
544:c666e8e0696a | 545:e63fbe19b255 |
---|---|
1 #include "CARFAC.h" | 1 #include "CARFAC.h" |
2 #include "CAR.h" | 2 #include "CAR.h" |
3 #include "IHC.h" | 3 #include "IHC.h" |
4 #include "AGC.h" | 4 #include "AGC.h" |
5 | 5 |
6 #include "CARFAC_common_typedefs.h" | 6 #include "CARFAC_common.h" |
7 | 7 |
8 CARFAC::CARFAC(int fs = kDefaultFs, | 8 CARFAC::CARFAC(int fs = kDefaultFs, |
9 CAR_parameters* car_params = new CAR_parameters(), | 9 CAR_parameters* car_params = new CAR_parameters(), |
10 IHC_parameters* ihc_params = new IHC_parameters(), | 10 IHC_parameters* ihc_params = new IHC_parameters(), |
11 AGC_parameters* agc_params = new AGC_parameters(), | 11 AGC_parameters* agc_params = new AGC_parameters(), |
12 float erb_break_freq = kDefaultErbBreakFreq, | 12 float erb_break_freq = kDefaultErbBreakFreq, |
13 float erb_q = kDefaultErbQ){ | 13 float erb_q = kDefaultErbQ) : n_ears_(0) { |
14 | 14 |
15 // for now, design is to take ownership. Preferences? Make copies, call by value, etc? | 15 // Design is to take ownership. Preferences? Make copies, call by value, etc? |
16 car_params_ = car_params; | 16 car_params_ = car_params; |
17 ihc_params_ = ihc_params; | 17 ihc_params_ = ihc_params; |
18 agc_params_ = agc_params; | 18 agc_params_ = agc_params; |
19 | 19 |
20 FloatArray pole_freqs; //TODO: do it | 20 float pole_hz = car_params->first_pole_theta_* fs / (2*kPi); |
21 car_coeffs_ = new CAR_coefficients(car_params_, fs, pole_freqs); | 21 while (pole_hz > car_params->min_pole_hz_){ |
22 pole_freqs_.push_back(pole_hz); // STL specific | |
23 pole_hz = pole_hz - car_params->erb_per_step_ * | |
24 ERB_Hz(pole_hz, erb_break_freq, erb_q); | |
25 } | |
26 n_ch_ = pole_freqs_.size(); // STL specific | |
22 | 27 |
23 int n_ch = 10; // TODO: do the design loops | 28 // replace with feeding this (as const ref) instead? Saves storing doubly |
24 agc_coeffs_ = new AGC_coefficients(agc_params_, fs, n_ch); | 29 car_coeffs_ = new CAR_coefficients(car_params_, fs_, pole_freqs_); |
30 ihc_coeffs_ = new IHC_coefficients(ihc_params_, fs_, n_ch_); | |
31 agc_coeffs_ = new AGC_coefficients(agc_params_, fs_, n_ch_); | |
25 | 32 |
26 ihc_coeffs_ = new IHC_coefficients(ihc_params_, fs, n_ch); | 33 // move this into AGC_coefficients constructor instead |
34 agc_coeffs_->detect_scale_ = agc_params_->detect_scale_ / | |
35 (ihc_coeffs_->saturation_output_ * | |
36 agc_coeffs_->agc_gain_); | |
37 } | |
38 | |
39 //move this somewhere else? | |
40 float CARFAC::ERB_Hz(float cf_hz, float erb_break_freq, float erb_q){ | |
41 return (erb_break_freq + cf_hz) / erb_q; | |
27 } | 42 } |
28 | 43 |
29 CARFAC::~CARFAC() { | 44 CARFAC::~CARFAC() { |
30 delete car_coeffs_; | 45 delete car_coeffs_; |
31 delete ihc_coeffs_; | 46 delete ihc_coeffs_; |