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 14 matching lines...) Expand all Loading... |
25 size_t max_delay, | 25 size_t max_delay, |
26 std::array<float, kFftLengthBy2Plus1>* X2) { | 26 std::array<float, kFftLengthBy2Plus1>* X2) { |
27 X2->fill(0.f); | 27 X2->fill(0.f); |
28 for (size_t k = min_delay; k <= max_delay; ++k) { | 28 for (size_t k = min_delay; k <= max_delay; ++k) { |
29 std::transform(X2->begin(), X2->end(), render_buffer.Spectrum(k).begin(), | 29 std::transform(X2->begin(), X2->end(), render_buffer.Spectrum(k).begin(), |
30 X2->begin(), | 30 X2->begin(), |
31 [](float a, float b) { return std::max(a, b); }); | 31 [](float a, float b) { return std::max(a, b); }); |
32 } | 32 } |
33 | 33 |
34 // Apply soft noise gate of -78 dBFS. | 34 // Apply soft noise gate of -78 dBFS. |
35 constexpr float kNoiseGatePower = 27509.42f; | 35 const float kNoiseGatePower = 27509.42f; |
36 std::for_each(X2->begin(), X2->end(), [kNoiseGatePower](float& a) { | 36 std::for_each(X2->begin(), X2->end(), [kNoiseGatePower](float& a) { |
37 if (kNoiseGatePower > a) { | 37 if (kNoiseGatePower > a) { |
38 a = std::max(0.f, a - 0.3f * (kNoiseGatePower - a)); | 38 a = std::max(0.f, a - 0.3f * (kNoiseGatePower - a)); |
39 } | 39 } |
40 }); | 40 }); |
41 } | 41 } |
42 | 42 |
43 constexpr int kNoiseFloorCounterMax = 50; | 43 constexpr int kNoiseFloorCounterMax = 50; |
44 constexpr float kNoiseFloorMin = 10.f * 10.f * 128.f * 128.f; | 44 constexpr float kNoiseFloorMin = 10.f * 10.f * 128.f * 128.f; |
45 | 45 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } else { | 251 } else { |
252 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); | 252 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); |
253 } | 253 } |
254 | 254 |
255 // Add the power of the echo reverb to the residual echo power. | 255 // Add the power of the echo reverb to the residual echo power. |
256 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), | 256 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), |
257 std::plus<float>()); | 257 std::plus<float>()); |
258 } | 258 } |
259 | 259 |
260 } // namespace webrtc | 260 } // namespace webrtc |
OLD | NEW |