Mercurial > hg > aimc
diff carfac/sai.cc @ 643:8b70f4cf00c7
Additional changes to C++ CARFAC on the basis of ronw's comments on r289. Moved CARFAC::Design to CARFAC::CARFAC and CARFAC::Reset(), moved carfac_common.h to common.h, CARFACDetect to carfac_util.h/cc, FloatArray and Float2dArray to ArrayX and ArrayXX, improved variable naming, made a start on improved commenting documentation.
author | alexbrandmeyer |
---|---|
date | Tue, 04 Jun 2013 18:30:22 +0000 |
parents | 20f64146c2ce |
children | 749b5aed61f6 |
line wrap: on
line diff
--- a/carfac/sai.cc Fri May 31 21:46:48 2013 +0000 +++ b/carfac/sai.cc Tue Jun 04 18:30:22 2013 +0000 @@ -35,8 +35,8 @@ .sin(); } -void SAI::RunSegment(const std::vector<FloatArray>& input, - Float2dArray* output_frame) { +void SAI::RunSegment(const std::vector<ArrayX>& input, + ArrayXX* output_frame) { assert(!input.empty() || input.size() <= params_.window_width && "Unexpected input size."); assert(input[0].size() == params_.n_ch && @@ -60,8 +60,8 @@ *output_frame = output_buffer_; } -void SAI::StabilizeSegment(const Float2dArray& input_buffer, - Float2dArray* output_buffer) const { +void SAI::StabilizeSegment(const ArrayXX& input_buffer, + ArrayXX* output_buffer) const { // Windows are always approximately 50% overlapped. float window_hop = params_.window_width / 2; int window_start = (input_buffer.cols() - params_.window_width) - @@ -72,14 +72,14 @@ for (int i = 0; i < params_.n_ch; ++i) { // TODO(ronw): Rename this here and in the Matlab code since the // input doesn't have to contain naps. - const FloatArray& nap_wave = input_buffer.row(i); + const ArrayX& nap_wave = input_buffer.row(i); // TODO(ronw): Smooth row. for (int w = 0; w < params_.n_window_pos; ++w) { int current_window_offset = w * window_hop; // Choose a trigger point. int trigger_time; - const FloatArray& trigger_window = + const ArrayX& trigger_window = nap_wave.segment(window_range_start + current_window_offset, params_.window_width); FPType peak_val = (trigger_window * window_).maxCoeff(&trigger_time);