annotate 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
rev   line source
Ulf@538 1 #include "CARFAC.h"
Ulf@538 2 #include "CAR.h"
Ulf@538 3 #include "IHC.h"
Ulf@538 4 #include "AGC.h"
Ulf@538 5
Ulf@545 6 #include "CARFAC_common.h"
Ulf@538 7
Ulf@544 8 CARFAC::CARFAC(int fs = kDefaultFs,
Ulf@544 9 CAR_parameters* car_params = new CAR_parameters(),
Ulf@544 10 IHC_parameters* ihc_params = new IHC_parameters(),
Ulf@544 11 AGC_parameters* agc_params = new AGC_parameters(),
Ulf@544 12 float erb_break_freq = kDefaultErbBreakFreq,
Ulf@545 13 float erb_q = kDefaultErbQ) : n_ears_(0) {
Ulf@538 14
Ulf@545 15 // Design is to take ownership. Preferences? Make copies, call by value, etc?
Ulf@544 16 car_params_ = car_params;
Ulf@544 17 ihc_params_ = ihc_params;
Ulf@544 18 agc_params_ = agc_params;
Ulf@538 19
Ulf@545 20 float pole_hz = car_params->first_pole_theta_* fs / (2*kPi);
Ulf@545 21 while (pole_hz > car_params->min_pole_hz_){
Ulf@545 22 pole_freqs_.push_back(pole_hz); // STL specific
Ulf@545 23 pole_hz = pole_hz - car_params->erb_per_step_ *
Ulf@545 24 ERB_Hz(pole_hz, erb_break_freq, erb_q);
Ulf@545 25 }
Ulf@545 26 n_ch_ = pole_freqs_.size(); // STL specific
Ulf@538 27
Ulf@545 28 // replace with feeding this (as const ref) instead? Saves storing doubly
Ulf@545 29 car_coeffs_ = new CAR_coefficients(car_params_, fs_, pole_freqs_);
Ulf@545 30 ihc_coeffs_ = new IHC_coefficients(ihc_params_, fs_, n_ch_);
Ulf@545 31 agc_coeffs_ = new AGC_coefficients(agc_params_, fs_, n_ch_);
Ulf@542 32
Ulf@545 33 // move this into AGC_coefficients constructor instead
Ulf@545 34 agc_coeffs_->detect_scale_ = agc_params_->detect_scale_ /
Ulf@545 35 (ihc_coeffs_->saturation_output_ *
Ulf@545 36 agc_coeffs_->agc_gain_);
Ulf@545 37 }
Ulf@545 38
Ulf@545 39 //move this somewhere else?
Ulf@545 40 float CARFAC::ERB_Hz(float cf_hz, float erb_break_freq, float erb_q){
Ulf@545 41 return (erb_break_freq + cf_hz) / erb_q;
Ulf@538 42 }
Ulf@538 43
Ulf@538 44 CARFAC::~CARFAC() {
Ulf@544 45 delete car_coeffs_;
Ulf@544 46 delete ihc_coeffs_;
Ulf@544 47 delete agc_coeffs_;
Ulf@539 48
Ulf@544 49 //delete car_params_;
Ulf@544 50 //delete ihc_params_;
Ulf@544 51 //delete agc_params_;
Ulf@538 52 }