Mercurial > hg > aimc
comparison 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 |
comparison
equal
deleted
inserted
replaced
486:c6bd1d58e72e | 487:d56da20c09ae |
---|---|
1 #include "CAR.h" | 1 #include "CAR.h" |
2 #include "CARFAC_common.h" | 2 #include "CARFAC_common.h" |
3 #include "CARFAC.h" | |
3 #include <cmath> | 4 #include <cmath> |
4 | 5 |
5 CAR_coefficients::CAR_coefficients(CAR_parameters* car_params, float fs, | 6 CAR_coefficients::CAR_coefficients(CAR_parameters* car_params, float fs, |
6 FloatArray pole_freqs){ | 7 FloatArray pole_freqs){ |
7 | 8 |
8 // initialisation of the FloatArray coefficients, if needed. | |
9 | |
10 float f = pow(car_params->zero_ratio_, 2) + 1; | 9 float f = pow(car_params->zero_ratio_, 2) + 1; |
11 | 10 |
11 // dirty FloatArray initialisation. Redo this later | |
12 r1_coeffs_= pole_freqs; | |
13 a0_coeffs_= pole_freqs; | |
14 c0_coeffs_= pole_freqs; | |
15 h_coeffs_= pole_freqs; | |
16 g0_coeffs_= pole_freqs; | |
17 zr_coeffs_= pole_freqs; | |
18 | |
12 FloatArray theta = pole_freqs; | 19 FloatArray theta = pole_freqs; |
13 FloatArray c0 = pole_freqs; | |
14 FloatArray a0 = pole_freqs; | |
15 | 20 |
16 // temp until we get eigen in | 21 float min_zeta_mod; |
22 float x; | |
23 float ff = car_params->high_f_damping_compression_; | |
24 | |
25 // temp loop until we get eigen in | |
17 for(float i=0; i<theta.size(); i++){ | 26 for(float i=0; i<theta.size(); i++){ |
18 theta[i] *= (2*kPi*fs); // scalar mult. | 27 theta[i] *= (2*kPi*fs); // scalar mult. |
19 c0[i] = sin(theta[i]); | 28 c0_coeffs_[i] = sin(theta[i]); |
20 a0[i] = cos(theta[i]); | 29 a0_coeffs_[i] = cos(theta[i]); |
30 | |
31 x = theta[i]/kPi; | |
32 zr_coeffs_[i] = kPi * (x - ff * x*x*x); | |
33 | |
34 min_zeta_mod = (car_params->min_zeta_ + 0.25 * | |
35 (CARFAC::ERB_Hz(pole_freqs[i])/pole_freqs[i]-car_params->min_zeta_)); | |
36 | |
37 r1_coeffs_[i] = 1-zr_coeffs_[i]*min_zeta_mod; | |
38 | |
39 h_coeffs_[i] = c0_coeffs_[i] * f; | |
21 } | 40 } |
22 | 41 |
23 // etc | 42 // g0_coeffs_[i] = ... TODO: restructure this! |
24 | 43 |
25 } | 44 } |
26 | 45 |
27 CAR_coefficients::~CAR_coefficients(){ | 46 CAR_coefficients::~CAR_coefficients(){ |
28 // TODO Auto-generated destructor stub | 47 // TODO Auto-generated destructor stub |