Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc

Issue 1913603002: Compensate for the compression gain in the IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Naming Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 size_t window_size = static_cast<size_t>(1) << RealFourier::FftOrder(freqs_); 102 size_t window_size = static_cast<size_t>(1) << RealFourier::FftOrder(freqs_);
103 std::vector<float> kbd_window(window_size); 103 std::vector<float> kbd_window(window_size);
104 WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size, 104 WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size,
105 kbd_window.data()); 105 kbd_window.data());
106 render_mangler_.reset(new LappedTransform( 106 render_mangler_.reset(new LappedTransform(
107 num_render_channels_, num_render_channels_, chunk_length_, 107 num_render_channels_, num_render_channels_, chunk_length_,
108 kbd_window.data(), window_size, window_size / 2, this)); 108 kbd_window.data(), window_size, window_size / 2, this));
109 } 109 }
110 110
111 void IntelligibilityEnhancer::SetCaptureNoiseEstimate( 111 void IntelligibilityEnhancer::SetCaptureNoiseEstimate(
112 std::vector<float> noise) { 112 std::vector<float> noise, int gain_db) {
113 RTC_DCHECK_EQ(noise.size(), num_noise_bins_); 113 RTC_DCHECK_EQ(noise.size(), num_noise_bins_);
114 const float gain = std::pow(10.f, gain_db / 20.f);
115 for (auto& bin : noise) {
116 bin *= gain;
117 }
114 // Disregarding return value since buffer overflow is acceptable, because it 118 // Disregarding return value since buffer overflow is acceptable, because it
115 // is not critical to get each noise estimate. 119 // is not critical to get each noise estimate.
116 if (noise_estimation_queue_.Insert(&noise)) { 120 if (noise_estimation_queue_.Insert(&noise)) {
117 }; 121 };
118 } 122 }
119 123
120 void IntelligibilityEnhancer::ProcessRenderAudio(float* const* audio, 124 void IntelligibilityEnhancer::ProcessRenderAudio(float* const* audio,
121 int sample_rate_hz, 125 int sample_rate_hz,
122 size_t num_channels) { 126 size_t num_channels) {
123 RTC_CHECK_EQ(sample_rate_hz_, sample_rate_hz); 127 RTC_CHECK_EQ(sample_rate_hz_, sample_rate_hz);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); 342 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_);
339 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { 343 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) {
340 chunks_since_voice_ = 0; 344 chunks_since_voice_ = 0;
341 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { 345 } else if (chunks_since_voice_ < kSpeechOffsetDelay) {
342 ++chunks_since_voice_; 346 ++chunks_since_voice_;
343 } 347 }
344 return chunks_since_voice_ < kSpeechOffsetDelay; 348 return chunks_since_voice_ < kSpeechOffsetDelay;
345 } 349 }
346 350
347 } // namespace webrtc 351 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698