Mercurial > hg > aimc
annotate src/CAR.cpp @ 487:d56da20c09ae carfac_cpp
Implemented all but g0 initialisation in CAR class
author | Ulf.Hammarqvist@gmail.com |
---|---|
date | Sat, 07 Apr 2012 09:35:10 +0000 |
parents | c6bd1d58e72e |
children | af4bc33b2e1c |
rev | line source |
---|---|
Ulf@477 | 1 #include "CAR.h" |
Ulf@484 | 2 #include "CARFAC_common.h" |
Ulf@487 | 3 #include "CARFAC.h" |
Ulf@486 | 4 #include <cmath> |
Ulf@477 | 5 |
Ulf@486 | 6 CAR_coefficients::CAR_coefficients(CAR_parameters* car_params, float fs, |
Ulf@484 | 7 FloatArray pole_freqs){ |
Ulf@486 | 8 |
Ulf@486 | 9 float f = pow(car_params->zero_ratio_, 2) + 1; |
Ulf@486 | 10 |
Ulf@487 | 11 // dirty FloatArray initialisation. Redo this later |
Ulf@487 | 12 r1_coeffs_= pole_freqs; |
Ulf@487 | 13 a0_coeffs_= pole_freqs; |
Ulf@487 | 14 c0_coeffs_= pole_freqs; |
Ulf@487 | 15 h_coeffs_= pole_freqs; |
Ulf@487 | 16 g0_coeffs_= pole_freqs; |
Ulf@487 | 17 zr_coeffs_= pole_freqs; |
Ulf@487 | 18 |
Ulf@486 | 19 FloatArray theta = pole_freqs; |
Ulf@486 | 20 |
Ulf@487 | 21 float min_zeta_mod; |
Ulf@487 | 22 float x; |
Ulf@487 | 23 float ff = car_params->high_f_damping_compression_; |
Ulf@487 | 24 |
Ulf@487 | 25 // temp loop until we get eigen in |
Ulf@486 | 26 for(float i=0; i<theta.size(); i++){ |
Ulf@486 | 27 theta[i] *= (2*kPi*fs); // scalar mult. |
Ulf@487 | 28 c0_coeffs_[i] = sin(theta[i]); |
Ulf@487 | 29 a0_coeffs_[i] = cos(theta[i]); |
Ulf@487 | 30 |
Ulf@487 | 31 x = theta[i]/kPi; |
Ulf@487 | 32 zr_coeffs_[i] = kPi * (x - ff * x*x*x); |
Ulf@487 | 33 |
Ulf@487 | 34 min_zeta_mod = (car_params->min_zeta_ + 0.25 * |
Ulf@487 | 35 (CARFAC::ERB_Hz(pole_freqs[i])/pole_freqs[i]-car_params->min_zeta_)); |
Ulf@487 | 36 |
Ulf@487 | 37 r1_coeffs_[i] = 1-zr_coeffs_[i]*min_zeta_mod; |
Ulf@487 | 38 |
Ulf@487 | 39 h_coeffs_[i] = c0_coeffs_[i] * f; |
Ulf@486 | 40 } |
Ulf@486 | 41 |
Ulf@487 | 42 // g0_coeffs_[i] = ... TODO: restructure this! |
Ulf@486 | 43 |
Ulf@477 | 44 } |
Ulf@477 | 45 |
Ulf@484 | 46 CAR_coefficients::~CAR_coefficients(){ |
Ulf@483 | 47 // TODO Auto-generated destructor stub |
Ulf@477 | 48 } |