Mercurial > hg > aimc
diff carfac/agc_params.cc @ 626:586b0677aae8
Fourth revision of Alex Brandmeyer's C++ implementation. Fixed more style issues, changed AGC structures to vectors, replaced FloatArray2d with vector<FloatArray>, implemented first tests using GTest to verify coefficients and monaural output against Matlab values (stored in aimc/carfac/test_data/). To run tests, change the path stored in carfac_test.h in TEST_SRC_DIR. Added CARFAC_GenerateTestData to the Matlab branch, fixed stage indexing in CARFAC_Cross_Couple.m to reflect changes in AGCCoeffs and AGCState structs.
author | alexbrandmeyer |
---|---|
date | Wed, 22 May 2013 21:30:02 +0000 |
parents | 3786bc6e5155 |
children | 27f2d9b76075 |
line wrap: on
line diff
--- a/carfac/agc_params.cc Tue May 21 21:48:34 2013 +0000 +++ b/carfac/agc_params.cc Wed May 22 21:30:02 2013 +0000 @@ -26,30 +26,23 @@ // Lyon's book 'Human and Machine Hearing' AGCParams::AGCParams() { n_stages_ = 4; - agc_stage_gain_ = 2; + agc_stage_gain_ = 2.0; + std::vector<FPType> base_values = {1.0, 1.4, 2.0, 2.8}; + FPType agc1_factor = 1.0; FPType agc2_factor = 1.65; - std::vector<FPType> stage_values = {1.0, 1.4, 2.0, 2.8}; time_constants_.resize(n_stages_); agc1_scales_.resize(n_stages_); agc2_scales_.resize(n_stages_); for (int i = 0; i < n_stages_; ++i) { - time_constants_(i) = pow(4, i) * 0.002; - agc1_scales_(i) = stage_values.at(i); - agc2_scales_(i) = stage_values.at(i) * agc2_factor; + time_constants_[i] = pow(4, i) * 0.002; + // TODO (alexbrandmeyer): check with Dick Lyon about best way to initialize. + // Tests on AGC values fail the equality test with Matlab when using the + // geometric method for initializing the AGC scales. + // agc1_scales_[i] = agc1_factor * pow(2.0, i/2.0); + // agc2_scales_[i] = agc2_factor * pow(2.0, i/2.0); + agc1_scales_[i] = agc1_factor * base_values[i]; + agc2_scales_[i] = agc2_factor * base_values[i]; } decimation_ = {8, 2, 2, 2}; agc_mix_coeff_ = 0.5; -} - -// The overloaded constructor allows for use of different AGC parameters. -AGCParams::AGCParams(int n_stages, FPType agc_stage_gain, FPType agc_mix_coeff, - FloatArray time_constants, std::vector<int> decimation, - FloatArray agc1_scales, FloatArray agc2_scales) { - n_stages_ = n_stages; - agc_stage_gain_ = agc_stage_gain; - agc_mix_coeff_ = agc_mix_coeff; - time_constants_ = time_constants; - decimation_ = decimation; - agc1_scales_ = agc1_scales; - agc2_scales_ = agc2_scales; -} +} \ No newline at end of file