Mercurial > hg > aimc
changeset 683:66688b9f8853
Delete CARFAC::Run to tighten up the interface.
author | ronw@google.com |
---|---|
date | Wed, 29 May 2013 20:33:06 +0000 |
parents | 10dc41e4d2f2 |
children | 49af9a8d5a53 |
files | trunk/carfac/carfac.cc trunk/carfac/carfac.h trunk/carfac/carfac_common.h trunk/carfac/carfac_test.cc |
diffstat | 4 files changed, 13 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/carfac/carfac.cc Wed May 29 15:37:28 2013 +0000 +++ b/trunk/carfac/carfac.cc Wed May 29 20:33:06 2013 +0000 @@ -59,30 +59,6 @@ } } -void CARFAC::Run(const vector<vector<float>>& sound_data, - CARFACOutput* output) { - int n_audio_channels = sound_data.size(); - int32_t seg_len = 441; // We use a fixed segment length for now. - int32_t n_timepoints = sound_data[0].size(); - int32_t n_segs = ceil((n_timepoints * 1.0) / seg_len); - // These values store the start and endpoints for each segment - int32_t start; - int32_t length = seg_len; - // This section loops over the individual audio segments. - for (int32_t i = 0; i < n_segs; ++i) { - // For each segment we calculate the start point and the segment length. - start = i * seg_len; - if (i == n_segs - 1) { - // The last segment can be shorter than the rest. - length = n_timepoints - start; - } - // Once we've determined the start point and segment length, we run the - // CARFAC model on the current segment. - RunSegment(sound_data, start, - length, false, output); - } -} - void CARFAC::RunSegment(const vector<vector<float>>& sound_data, const int32_t start, const int32_t length, const bool open_loop, CARFACOutput* seg_output) { @@ -347,4 +323,4 @@ previous_stage_gain = agc_coeff.agc_gain; decim = agc_coeff.decim; } -} \ No newline at end of file +}
--- a/trunk/carfac/carfac.h Wed May 29 15:37:28 2013 +0000 +++ b/trunk/carfac/carfac.h Wed May 29 20:33:06 2013 +0000 @@ -60,10 +60,6 @@ // model. void Design(const int n_ears, const FPType fs, const CARParams& car_params, const IHCParams& ihc_params, const AGCParams& agc_params); - // The 'Run' method processes an entire file with the current model, using - // subsequent calls to the 'RunSegment' method - void Run(const std::vector<std::vector<float>>& sound_data, - CARFACOutput* seg_output); // The 'RunSegment' method processes individual sound segments void RunSegment(const std::vector<std::vector<float>>& sound_data, const int32_t start, const int32_t length, @@ -78,6 +74,7 @@ std::vector<AGCCoeffs>* agc_coeffs); void CrossCouple(); void CloseAGCLoop(); + int n_ears_; // This is the number of ears. FPType fs_; // This is our current sample rate. int n_ch_; // This is the number of channels in the CARFAC model. @@ -87,4 +84,4 @@ FloatArray pole_freqs_; }; -#endif // CARFAC_CARFAC_H \ No newline at end of file +#endif // CARFAC_CARFAC_H
--- a/trunk/carfac/carfac_common.h Wed May 29 15:37:28 2013 +0000 +++ b/trunk/carfac/carfac_common.h Wed May 29 20:33:06 2013 +0000 @@ -42,7 +42,7 @@ // point data is consistent. // // The functions 'ERBHz' and 'CARFACDetect' are defined here, and are used -// during the design stage of a CARFAC model. +// during the design stage of a CARFAC model. #ifndef CARFAC_CARFAC_COMMON_H #define CARFAC_CARFAC_COMMON_H @@ -75,6 +75,6 @@ // Function CARFACDetect // This returns the IHC detection nonilnearity function of the filter output // values. This is here because it is called both in design and run phases. -FloatArray CARFACDetect (const FloatArray& x); +FloatArray CARFACDetect(const FloatArray& x); -#endif // CARFAC_CARFAC_COMMON_H \ No newline at end of file +#endif // CARFAC_CARFAC_COMMON_H
--- a/trunk/carfac/carfac_test.cc Wed May 29 15:37:28 2013 +0000 +++ b/trunk/carfac/carfac_test.cc Wed May 29 20:33:06 2013 +0000 @@ -146,7 +146,9 @@ agc_params); CARFACOutput my_output; my_output.Init(n_ears, true, false, true, false, false); - mycf.Run(sound_data, &my_output); + const bool kOpenLoop = false; + const int length = sound_data[0].size(); + mycf.RunSegment(sound_data, 0, length, kOpenLoop, &my_output); filename = "cpp_nap_output_1_binaural_test.txt"; WriteNAPOutput(my_output, filename, 0); filename = "cpp_nap_output_2_binaural_test.txt"; @@ -199,7 +201,9 @@ agc_params); CARFACOutput my_output; my_output.Init(n_ears, true, false, true, false, false); - mycf.Run(sound_data, &my_output); + const bool kOpenLoop = false; + const int length = sound_data[0].size(); + mycf.RunSegment(sound_data, 0, length, kOpenLoop, &my_output); filename = "cpp_nap_output_1_long_test.txt"; WriteNAPOutput(my_output, filename, 0); filename = "cpp_nap_output_2_long_test.txt"; @@ -226,4 +230,4 @@ ASSERT_NEAR(cplusplus, matlab, kPrecisionLevel); } } -} \ No newline at end of file +}