Mercurial > hg > aimc
view src/CAR.cpp @ 496:5a5fc3a6051b carfac_cpp
* SUGGESTED re-factor of the FIR_coeffs calls (old code remains in commented out form for easy comparison).
* Minor changes to CARFAC and IHC corresponding to MATLAB refactoring
author | Ulf.Hammarqvist@gmail.com |
---|---|
date | Mon, 09 Apr 2012 09:43:02 +0000 |
parents | 24828350536a |
children | 83cd5bbf2a3e |
line wrap: on
line source
#include "CAR.h" #include "CARFAC_common.h" #include "CARFAC.h" #include <cmath> CAR_coefficients::CAR_coefficients(CAR_parameters* car_params, float fs, FloatArray pole_freqs){ float f = pow(car_params->zero_ratio_, 2) + 1; // TODO: dirty FloatArray initialization. r1_coeffs_= pole_freqs; a0_coeffs_= pole_freqs; c0_coeffs_= pole_freqs; h_coeffs_= pole_freqs; g0_coeffs_= pole_freqs; zr_coeffs_= pole_freqs; FloatArray theta = pole_freqs; float min_zeta_mod; float x; float ff = car_params->high_f_damping_compression_; // TODO: temp loop until we get eigen in (or we just leave it like this) for(float i=0; i<pole_freqs.size(); i++){ theta[i] *= (2*kPi*fs); // scalar mult. c0_coeffs_[i] = sin(theta[i]); a0_coeffs_[i] = cos(theta[i]); x = theta[i]/kPi; zr_coeffs_[i] = kPi * (x - ff * x*x*x); min_zeta_mod = (car_params->min_zeta_ + 0.25 * (CARFAC::ERB_Hz( pole_freqs[i], car_params->erb_break_freq_, car_params->erb_q_) / pole_freqs[i] - car_params->min_zeta_)); r1_coeffs_[i] = 1-zr_coeffs_[i]*min_zeta_mod; h_coeffs_[i] = c0_coeffs_[i] * f; //TODO: g0_coeffs_ calculated here for now. Let's talk about this, need // to see the whole picture of what makes sense. // Related: I believe CAR, IHC and AGC classes would be beneficial! float tmp = 1 - 2*r1_coeffs_[i]*a0_coeffs_[i] + r1_coeffs_[i]*r1_coeffs_[i]; g0_coeffs_[i] = tmp / ( tmp + h_coeffs_[i]*r1_coeffs_[i]*c0_coeffs_[i]); } } CAR_coefficients::~CAR_coefficients(){ // TODO Auto-generated destructor stub }