annotate branches/carfac_cpp/src/CARFAC.cpp @ 695:2e3672df5698

Simple integration test between CARFAC and SAI. The interface between the two classes is pretty clunky because of the way CARFACOutput stores things. We should work on this, probably by rotating the outer two dimensions of CARFACOutput (i.e. store outputs in containers with sizes n_ears x n_samples x n_channels instead of n_samples x n_ears x n_channels).
author ronw@google.com
date Wed, 26 Jun 2013 23:35:47 +0000
parents d59c0d65624b
children
rev   line source
Ulf@546 1 #include <cmath>
Ulf@546 2
Ulf@538 3 #include "CARFAC.h"
Ulf@538 4 #include "CAR.h"
Ulf@538 5 #include "IHC.h"
Ulf@538 6 #include "AGC.h"
Ulf@564 7 #include "Ear.h"
Ulf@587 8 #include "unit_conversion.h"
Ulf@545 9 #include "CARFAC_common.h"
Ulf@538 10
Ulf@586 11 CARFAC::CARFAC(int fs,
Ulf@586 12 CAR_parameters* car_params,
Ulf@586 13 IHC_parameters* ihc_params,
Ulf@586 14 AGC_parameters* agc_params,
Ulf@586 15 int n_ears){
Ulf@538 16
Ulf@564 17 fs_ = fs;
Ulf@538 18
Ulf@545 19 float pole_hz = car_params->first_pole_theta_* fs / (2*kPi);
Ulf@545 20 while (pole_hz > car_params->min_pole_hz_){
Ulf@547 21 pole_freqs_.push_back(pole_hz); // TODO: STL specific
Ulf@545 22 pole_hz = pole_hz - car_params->erb_per_step_ *
Ulf@555 23 ERB_Hz(pole_hz, car_params->erb_break_freq_,
Ulf@555 24 car_params->erb_q_);
Ulf@545 25 }
Ulf@547 26 n_ch_ = pole_freqs_.size();
Ulf@546 27 max_channels_per_octave_ = log(2) / log(pole_freqs_[0]/pole_freqs_[1]);
Ulf@546 28
Ulf@564 29 n_ears_ = n_ears;
Ulf@586 30 Ear ear = Ear(car_params, ihc_params, agc_params, pole_freqs_, n_ch_, fs);
Ulf@586 31 ears_.assign(n_ears_, ear);
Ulf@545 32 }