OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 DelayBuffer<float> delay_buffer(delay_samples); | 330 DelayBuffer<float> delay_buffer(delay_samples); |
331 CascadedBiQuadFilter x_hp_filter(kHighPassFilterCoefficients, 1); | 331 CascadedBiQuadFilter x_hp_filter(kHighPassFilterCoefficients, 1); |
332 CascadedBiQuadFilter y_hp_filter(kHighPassFilterCoefficients, 1); | 332 CascadedBiQuadFilter y_hp_filter(kHighPassFilterCoefficients, 1); |
333 | 333 |
334 SCOPED_TRACE(ProduceDebugText(delay_samples)); | 334 SCOPED_TRACE(ProduceDebugText(delay_samples)); |
335 for (size_t k = 0; k < kNumBlocksToProcess; ++k) { | 335 for (size_t k = 0; k < kNumBlocksToProcess; ++k) { |
336 RandomizeSampleVector(&random_generator, x[0]); | 336 RandomizeSampleVector(&random_generator, x[0]); |
337 delay_buffer.Delay(x[0], y); | 337 delay_buffer.Delay(x[0], y); |
338 | 338 |
339 RandomizeSampleVector(&random_generator, n); | 339 RandomizeSampleVector(&random_generator, n); |
340 const float kNoiseScaling = 1.f / 100.f; | 340 static constexpr float kNoiseScaling = 1.f / 100.f; |
341 std::transform( | 341 std::transform( |
342 y.begin(), y.end(), n.begin(), y.begin(), | 342 y.begin(), y.end(), n.begin(), y.begin(), |
343 [kNoiseScaling](float a, float b) { return a + b * kNoiseScaling; }); | 343 [](float a, float b) { return a + b * kNoiseScaling; }); |
344 | 344 |
345 x_hp_filter.Process(x[0]); | 345 x_hp_filter.Process(x[0]); |
346 y_hp_filter.Process(y); | 346 y_hp_filter.Process(y); |
347 | 347 |
348 render_buffer.Insert(x); | 348 render_buffer.Insert(x); |
349 render_signal_analyzer.Update(render_buffer, aec_state.FilterDelay()); | 349 render_signal_analyzer.Update(render_buffer, aec_state.FilterDelay()); |
350 | 350 |
351 filter.Filter(render_buffer, &S); | 351 filter.Filter(render_buffer, &S); |
352 fft.Ifft(S, &s_scratch); | 352 fft.Ifft(S, &s_scratch); |
353 std::transform(y.begin(), y.end(), s_scratch.begin() + kFftLengthBy2, | 353 std::transform(y.begin(), y.end(), s_scratch.begin() + kFftLengthBy2, |
(...skipping 16 matching lines...) Expand all Loading... |
370 } | 370 } |
371 // Verify that the filter is able to perform well. | 371 // Verify that the filter is able to perform well. |
372 EXPECT_LT(1000 * std::inner_product(e.begin(), e.end(), e.begin(), 0.f), | 372 EXPECT_LT(1000 * std::inner_product(e.begin(), e.end(), e.begin(), 0.f), |
373 std::inner_product(y.begin(), y.end(), y.begin(), 0.f)); | 373 std::inner_product(y.begin(), y.end(), y.begin(), 0.f)); |
374 ASSERT_TRUE(aec_state.FilterDelay()); | 374 ASSERT_TRUE(aec_state.FilterDelay()); |
375 EXPECT_EQ(delay_samples / kBlockSize, *aec_state.FilterDelay()); | 375 EXPECT_EQ(delay_samples / kBlockSize, *aec_state.FilterDelay()); |
376 } | 376 } |
377 } | 377 } |
378 } // namespace aec3 | 378 } // namespace aec3 |
379 } // namespace webrtc | 379 } // namespace webrtc |
OLD | NEW |