OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 size_t window_size = static_cast<size_t>(1) << RealFourier::FftOrder(freqs_); | 104 size_t window_size = static_cast<size_t>(1) << RealFourier::FftOrder(freqs_); |
105 std::vector<float> kbd_window(window_size); | 105 std::vector<float> kbd_window(window_size); |
106 WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size, | 106 WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size, |
107 kbd_window.data()); | 107 kbd_window.data()); |
108 render_mangler_.reset(new LappedTransform( | 108 render_mangler_.reset(new LappedTransform( |
109 num_render_channels_, num_render_channels_, chunk_length_, | 109 num_render_channels_, num_render_channels_, chunk_length_, |
110 kbd_window.data(), window_size, window_size / 2, this)); | 110 kbd_window.data(), window_size, window_size / 2, this)); |
111 } | 111 } |
112 | 112 |
113 void IntelligibilityEnhancer::SetCaptureNoiseEstimate( | 113 void IntelligibilityEnhancer::SetCaptureNoiseEstimate( |
114 std::vector<float> noise, int gain_db) { | 114 std::vector<float> noise, float gain) { |
115 RTC_DCHECK_EQ(noise.size(), num_noise_bins_); | 115 RTC_DCHECK_EQ(noise.size(), num_noise_bins_); |
116 const float gain = std::pow(10.f, gain_db / 20.f); | |
117 for (auto& bin : noise) { | 116 for (auto& bin : noise) { |
118 bin *= gain; | 117 bin *= gain; |
119 } | 118 } |
120 // Disregarding return value since buffer overflow is acceptable, because it | 119 // Disregarding return value since buffer overflow is acceptable, because it |
121 // is not critical to get each noise estimate. | 120 // is not critical to get each noise estimate. |
122 if (noise_estimation_queue_.Insert(&noise)) { | 121 if (noise_estimation_queue_.Insert(&noise)) { |
123 }; | 122 }; |
124 } | 123 } |
125 | 124 |
126 void IntelligibilityEnhancer::ProcessRenderAudio(float* const* audio, | 125 void IntelligibilityEnhancer::ProcessRenderAudio(float* const* audio, |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); | 343 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); |
345 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { | 344 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { |
346 chunks_since_voice_ = 0; | 345 chunks_since_voice_ = 0; |
347 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { | 346 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { |
348 ++chunks_since_voice_; | 347 ++chunks_since_voice_; |
349 } | 348 } |
350 return chunks_since_voice_ < kSpeechOffsetDelay; | 349 return chunks_since_voice_ < kSpeechOffsetDelay; |
351 } | 350 } |
352 | 351 |
353 } // namespace webrtc | 352 } // namespace webrtc |
OLD | NEW |