1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "modules/audio_processing/aec3/suppression_gain.h"
12
13 #include <math.h>
14 #include <stddef.h>
15 #include <algorithm>
16 #include <numeric>
17
18 #include "modules/audio_processing/aec3/moving_average.h"
19 #include "modules/audio_processing/aec3/vector_math.h"
20 #include "modules/audio_processing/logging/apm_data_dumper.h"
21 #include "rtc_base/atomicops.h"
22 #include "rtc_base/checks.h"
23
24 namespace webrtc {
25 namespace {
26
27 // Adjust the gains according to the presence of known external filters.
AdjustForExternalFilters(std::array<float,kFftLengthBy2Plus1> * gain)28 void AdjustForExternalFilters(std::array<float, kFftLengthBy2Plus1>* gain) {
29 // Limit the low frequency gains to avoid the impact of the high-pass filter
30 // on the lower-frequency gain influencing the overall achieved gain.
31 (*gain)[0] = (*gain)[1] = std::min((*gain)[1], (*gain)[2]);
32
33 // Limit the high frequency gains to avoid the impact of the anti-aliasing
34 // filter on the upper-frequency gains influencing the overall achieved
35 // gain. TODO(peah): Update this when new anti-aliasing filters are
36 // implemented.
37 constexpr size_t kAntiAliasingImpactLimit = (64 * 2000) / 8000;
38 const float min_upper_gain = (*gain)[kAntiAliasingImpactLimit];
39 std::for_each(
40 gain->begin() + kAntiAliasingImpactLimit, gain->end() - 1,
41 [min_upper_gain](float& a) { a = std::min(a, min_upper_gain); });
42 (*gain)[kFftLengthBy2] = (*gain)[kFftLengthBy2Minus1];
43 }
44
45 // Scales the echo according to assessed audibility at the other end.
WeightEchoForAudibility(const EchoCanceller3Config & config,rtc::ArrayView<const float> echo,rtc::ArrayView<float> weighted_echo)46 void WeightEchoForAudibility(const EchoCanceller3Config& config,
47 rtc::ArrayView<const float> echo,
48 rtc::ArrayView<float> weighted_echo) {
49 RTC_DCHECK_EQ(kFftLengthBy2Plus1, echo.size());
50 RTC_DCHECK_EQ(kFftLengthBy2Plus1, weighted_echo.size());
51
52 auto weigh = [](float threshold, float normalizer, size_t begin, size_t end,
53 rtc::ArrayView<const float> echo,
54 rtc::ArrayView<float> weighted_echo) {
55 for (size_t k = begin; k < end; ++k) {
56 if (echo[k] < threshold) {
57 float tmp = (threshold - echo[k]) * normalizer;
58 weighted_echo[k] = echo[k] * std::max(0.f, 1.f - tmp * tmp);
59 } else {
60 weighted_echo[k] = echo[k];
61 }
62 }
63 };
64
65 float threshold = config.echo_audibility.floor_power *
66 config.echo_audibility.audibility_threshold_lf;
67 float normalizer = 1.f / (threshold - config.echo_audibility.floor_power);
68 weigh(threshold, normalizer, 0, 3, echo, weighted_echo);
69
70 threshold = config.echo_audibility.floor_power *
71 config.echo_audibility.audibility_threshold_mf;
72 normalizer = 1.f / (threshold - config.echo_audibility.floor_power);
73 weigh(threshold, normalizer, 3, 7, echo, weighted_echo);
74
75 threshold = config.echo_audibility.floor_power *
76 config.echo_audibility.audibility_threshold_hf;
77 normalizer = 1.f / (threshold - config.echo_audibility.floor_power);
78 weigh(threshold, normalizer, 7, kFftLengthBy2Plus1, echo, weighted_echo);
79 }
80
81 // TODO(peah): Make adaptive to take the actual filter error into account.
82 constexpr size_t kUpperAccurateBandPlus1 = 29;
83
84 // Limits the gain in the frequencies for which the adaptive filter has not
85 // converged. Currently, these frequencies are not hardcoded to the frequencies
86 // which are typically not excited by speech.
87 // TODO(peah): Make adaptive to take the actual filter error into account.
AdjustNonConvergedFrequencies(std::array<float,kFftLengthBy2Plus1> * gain)88 void AdjustNonConvergedFrequencies(
89 std::array<float, kFftLengthBy2Plus1>* gain) {
90 constexpr float oneByBandsInSum =
91 1 / static_cast<float>(kUpperAccurateBandPlus1 - 20);
92 const float hf_gain_bound =
93 std::accumulate(gain->begin() + 20,
94 gain->begin() + kUpperAccurateBandPlus1, 0.f) *
95 oneByBandsInSum;
96
97 std::for_each(gain->begin() + kUpperAccurateBandPlus1, gain->end(),
98 [hf_gain_bound](float& a) { a = std::min(a, hf_gain_bound); });
99 }
100
101 } // namespace
102
103 int SuppressionGain::instance_count_ = 0;
104
UpperBandsGain(const std::array<float,kFftLengthBy2Plus1> & echo_spectrum,const std::array<float,kFftLengthBy2Plus1> & comfort_noise_spectrum,const absl::optional<int> & narrow_peak_band,bool saturated_echo,const std::vector<std::vector<float>> & render,const std::array<float,kFftLengthBy2Plus1> & low_band_gain) const105 float SuppressionGain::UpperBandsGain(
106 const std::array<float, kFftLengthBy2Plus1>& echo_spectrum,
107 const std::array<float, kFftLengthBy2Plus1>& comfort_noise_spectrum,
108 const absl::optional<int>& narrow_peak_band,
109 bool saturated_echo,
110 const std::vector<std::vector<float>>& render,
111 const std::array<float, kFftLengthBy2Plus1>& low_band_gain) const {
112 RTC_DCHECK_LT(0, render.size());
113 if (render.size() == 1) {
114 return 1.f;
115 }
116
117 if (narrow_peak_band &&
118 (*narrow_peak_band > static_cast<int>(kFftLengthBy2Plus1 - 10))) {
119 return 0.001f;
120 }
121
122 constexpr size_t kLowBandGainLimit = kFftLengthBy2 / 2;
123 const float gain_below_8_khz = *std::min_element(
124 low_band_gain.begin() + kLowBandGainLimit, low_band_gain.end());
125
126 // Always attenuate the upper bands when there is saturated echo.
127 if (saturated_echo) {
128 return std::min(0.001f, gain_below_8_khz);
129 }
130
131 // Compute the upper and lower band energies.
132 const auto sum_of_squares = [](float a, float b) { return a + b * b; };
133 const float low_band_energy =
134 std::accumulate(render[0].begin(), render[0].end(), 0.f, sum_of_squares);
135 float high_band_energy = 0.f;
136 for (size_t k = 1; k < render.size(); ++k) {
137 const float energy = std::accumulate(render[k].begin(), render[k].end(),
138 0.f, sum_of_squares);
139 high_band_energy = std::max(high_band_energy, energy);
140 }
141
142 // If there is more power in the lower frequencies than the upper frequencies,
143 // or if the power in upper frequencies is low, do not bound the gain in the
144 // upper bands.
145 float anti_howling_gain;
146 constexpr float kThreshold = kBlockSize * 10.f * 10.f / 4.f;
147 if (high_band_energy < std::max(low_band_energy, kThreshold)) {
148 anti_howling_gain = 1.f;
149 } else {
150 // In all other cases, bound the gain for upper frequencies.
151 RTC_DCHECK_LE(low_band_energy, high_band_energy);
152 RTC_DCHECK_NE(0.f, high_band_energy);
153 anti_howling_gain = 0.01f * sqrtf(low_band_energy / high_band_energy);
154 }
155
156 // Bound the upper gain during significant echo activity.
157 auto low_frequency_energy = [](rtc::ArrayView<const float> spectrum) {
158 RTC_DCHECK_LE(16, spectrum.size());
159 return std::accumulate(spectrum.begin() + 1, spectrum.begin() + 16, 0.f);
160 };
161 const float echo_sum = low_frequency_energy(echo_spectrum);
162 const float noise_sum = low_frequency_energy(comfort_noise_spectrum);
163 const auto& cfg = config_.suppressor.high_bands_suppression;
164 float gain_bound = 1.f;
165 if (echo_sum > cfg.enr_threshold * noise_sum &&
166 !dominant_nearend_detector_.IsNearendState()) {
167 gain_bound = cfg.max_gain_during_echo;
168 }
169
170 // Choose the gain as the minimum of the lower and upper gains.
171 return std::min(std::min(gain_below_8_khz, anti_howling_gain), gain_bound);
172 }
173
174 // Computes the gain to reduce the echo to a non audible level.
GainToNoAudibleEcho(const std::array<float,kFftLengthBy2Plus1> & nearend,const std::array<float,kFftLengthBy2Plus1> & echo,const std::array<float,kFftLengthBy2Plus1> & masker,const std::array<float,kFftLengthBy2Plus1> & min_gain,const std::array<float,kFftLengthBy2Plus1> & max_gain,std::array<float,kFftLengthBy2Plus1> * gain) const175 void SuppressionGain::GainToNoAudibleEcho(
176 const std::array<float, kFftLengthBy2Plus1>& nearend,
177 const std::array<float, kFftLengthBy2Plus1>& echo,
178 const std::array<float, kFftLengthBy2Plus1>& masker,
179 const std::array<float, kFftLengthBy2Plus1>& min_gain,
180 const std::array<float, kFftLengthBy2Plus1>& max_gain,
181 std::array<float, kFftLengthBy2Plus1>* gain) const {
182 const auto& p = dominant_nearend_detector_.IsNearendState() ? nearend_params_
183 : normal_params_;
184 for (size_t k = 0; k < gain->size(); ++k) {
185 float enr = echo[k] / (nearend[k] + 1.f); // Echo-to-nearend ratio.
186 float emr = echo[k] / (masker[k] + 1.f); // Echo-to-masker (noise) ratio.
187 float g = 1.0f;
188 if (enr > p.enr_transparent_[k] && emr > p.emr_transparent_[k]) {
189 g = (p.enr_suppress_[k] - enr) /
190 (p.enr_suppress_[k] - p.enr_transparent_[k]);
191 g = std::max(g, p.emr_transparent_[k] / emr);
192 }
193 (*gain)[k] = std::max(std::min(g, max_gain[k]), min_gain[k]);
194 }
195 }
196
197 // Compute the minimum gain as the attenuating gain to put the signal just
198 // above the zero sample values.
GetMinGain(rtc::ArrayView<const float> suppressor_input,rtc::ArrayView<const float> weighted_residual_echo,bool low_noise_render,bool saturated_echo,rtc::ArrayView<float> min_gain) const199 void SuppressionGain::GetMinGain(
200 rtc::ArrayView<const float> suppressor_input,
201 rtc::ArrayView<const float> weighted_residual_echo,
202 bool low_noise_render,
203 bool saturated_echo,
204 rtc::ArrayView<float> min_gain) const {
205 if (!saturated_echo) {
206 const float min_echo_power =
207 low_noise_render ? config_.echo_audibility.low_render_limit
208 : config_.echo_audibility.normal_render_limit;
209
210 for (size_t k = 0; k < suppressor_input.size(); ++k) {
211 const float denom =
212 std::min(suppressor_input[k], weighted_residual_echo[k]);
213 min_gain[k] = denom > 0.f ? min_echo_power / denom : 1.f;
214 min_gain[k] = std::min(min_gain[k], 1.f);
215 }
216 for (size_t k = 0; k < 6; ++k) {
217 const auto& dec = dominant_nearend_detector_.IsNearendState()
218 ? nearend_params_.max_dec_factor_lf
219 : normal_params_.max_dec_factor_lf;
220
221 // Make sure the gains of the low frequencies do not decrease too
222 // quickly after strong nearend.
223 if (last_nearend_[k] > last_echo_[k]) {
224 min_gain[k] = std::max(min_gain[k], last_gain_[k] * dec);
225 min_gain[k] = std::min(min_gain[k], 1.f);
226 }
227 }
228 } else {
229 std::fill(min_gain.begin(), min_gain.end(), 0.f);
230 }
231 }
232
233 // Compute the maximum gain by limiting the gain increase from the previous
234 // gain.
GetMaxGain(rtc::ArrayView<float> max_gain) const235 void SuppressionGain::GetMaxGain(rtc::ArrayView<float> max_gain) const {
236 const auto& inc = dominant_nearend_detector_.IsNearendState()
237 ? nearend_params_.max_inc_factor
238 : normal_params_.max_inc_factor;
239 const auto& floor = config_.suppressor.floor_first_increase;
240 for (size_t k = 0; k < max_gain.size(); ++k) {
241 max_gain[k] = std::min(std::max(last_gain_[k] * inc, floor), 1.f);
242 }
243 }
244
245 // TODO(peah): Add further optimizations, in particular for the divisions.
LowerBandGain(bool low_noise_render,const AecState & aec_state,const std::array<float,kFftLengthBy2Plus1> & suppressor_input,const std::array<float,kFftLengthBy2Plus1> & nearend,const std::array<float,kFftLengthBy2Plus1> & residual_echo,const std::array<float,kFftLengthBy2Plus1> & comfort_noise,std::array<float,kFftLengthBy2Plus1> * gain)246 void SuppressionGain::LowerBandGain(
247 bool low_noise_render,
248 const AecState& aec_state,
249 const std::array<float, kFftLengthBy2Plus1>& suppressor_input,
250 const std::array<float, kFftLengthBy2Plus1>& nearend,
251 const std::array<float, kFftLengthBy2Plus1>& residual_echo,
252 const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
253 std::array<float, kFftLengthBy2Plus1>* gain) {
254 const bool saturated_echo = aec_state.SaturatedEcho();
255
256 // Weight echo power in terms of audibility. // Precompute 1/weighted echo
257 // (note that when the echo is zero, the precomputed value is never used).
258 std::array<float, kFftLengthBy2Plus1> weighted_residual_echo;
259 WeightEchoForAudibility(config_, residual_echo, weighted_residual_echo);
260
261 std::array<float, kFftLengthBy2Plus1> min_gain;
262 GetMinGain(suppressor_input, weighted_residual_echo, low_noise_render,
263 saturated_echo, min_gain);
264
265 std::array<float, kFftLengthBy2Plus1> max_gain;
266 GetMaxGain(max_gain);
267
268 GainToNoAudibleEcho(nearend, weighted_residual_echo, comfort_noise,
269 min_gain, max_gain, gain);
270 AdjustForExternalFilters(gain);
271
272 // Adjust the gain for frequencies which have not yet converged.
273 AdjustNonConvergedFrequencies(gain);
274
275 // Store data required for the gain computation of the next block.
276 std::copy(nearend.begin(), nearend.end(), last_nearend_.begin());
277 std::copy(weighted_residual_echo.begin(), weighted_residual_echo.end(),
278 last_echo_.begin());
279 std::copy(gain->begin(), gain->end(), last_gain_.begin());
280 aec3::VectorMath(optimization_).Sqrt(*gain);
281
282 // Debug outputs for the purpose of development and analysis.
283 data_dumper_->DumpRaw("aec3_suppressor_min_gain", min_gain);
284 data_dumper_->DumpRaw("aec3_suppressor_max_gain", max_gain);
285 data_dumper_->DumpRaw("aec3_dominant_nearend",
286 dominant_nearend_detector_.IsNearendState());
287 }
288
SuppressionGain(const EchoCanceller3Config & config,Aec3Optimization optimization,int sample_rate_hz)289 SuppressionGain::SuppressionGain(const EchoCanceller3Config& config,
290 Aec3Optimization optimization,
291 int sample_rate_hz)
292 : data_dumper_(
293 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
294 optimization_(optimization),
295 config_(config),
296 state_change_duration_blocks_(
297 static_cast<int>(config_.filter.config_change_duration_blocks)),
298 moving_average_(kFftLengthBy2Plus1,
299 config.suppressor.nearend_average_blocks),
300 nearend_params_(config_.suppressor.nearend_tuning),
301 normal_params_(config_.suppressor.normal_tuning),
302 dominant_nearend_detector_(
303 config_.suppressor.dominant_nearend_detection) {
304 RTC_DCHECK_LT(0, state_change_duration_blocks_);
305 one_by_state_change_duration_blocks_ = 1.f / state_change_duration_blocks_;
306 last_gain_.fill(1.f);
307 last_nearend_.fill(0.f);
308 last_echo_.fill(0.f);
309 }
310
311 SuppressionGain::~SuppressionGain() = default;
312
GetGain(const std::array<float,kFftLengthBy2Plus1> & suppressor_input_spectrum,const std::array<float,kFftLengthBy2Plus1> & nearend_spectrum,const std::array<float,kFftLengthBy2Plus1> & echo_spectrum,const std::array<float,kFftLengthBy2Plus1> & residual_echo_spectrum,const std::array<float,kFftLengthBy2Plus1> & comfort_noise_spectrum,const FftData & linear_aec_fft,const FftData & capture_fft,const RenderSignalAnalyzer & render_signal_analyzer,const AecState & aec_state,const std::vector<std::vector<float>> & render,float * high_bands_gain,std::array<float,kFftLengthBy2Plus1> * low_band_gain)313 void SuppressionGain::GetGain(
314 const std::array<float, kFftLengthBy2Plus1>& suppressor_input_spectrum,
315 const std::array<float, kFftLengthBy2Plus1>& nearend_spectrum,
316 const std::array<float, kFftLengthBy2Plus1>& echo_spectrum,
317 const std::array<float, kFftLengthBy2Plus1>& residual_echo_spectrum,
318 const std::array<float, kFftLengthBy2Plus1>& comfort_noise_spectrum,
319 const FftData& linear_aec_fft,
320 const FftData& capture_fft,
321 const RenderSignalAnalyzer& render_signal_analyzer,
322 const AecState& aec_state,
323 const std::vector<std::vector<float>>& render,
324 float* high_bands_gain,
325 std::array<float, kFftLengthBy2Plus1>* low_band_gain) {
326 RTC_DCHECK(high_bands_gain);
327 RTC_DCHECK(low_band_gain);
328 const auto& cfg = config_.suppressor;
329
330 if (cfg.enforce_transparent) {
331 low_band_gain->fill(1.f);
332 *high_bands_gain = cfg.enforce_empty_higher_bands ? 0.f : 1.f;
333 return;
334 }
335
336 std::array<float, kFftLengthBy2Plus1> nearend_average;
337 moving_average_.Average(nearend_spectrum, nearend_average);
338
339 // Update the state selection.
340 dominant_nearend_detector_.Update(nearend_spectrum, residual_echo_spectrum,
341 comfort_noise_spectrum, initial_state_);
342
343 // Compute gain for the lower band.
344 bool low_noise_render = low_render_detector_.Detect(render);
345 LowerBandGain(low_noise_render, aec_state, suppressor_input_spectrum,
346 nearend_average, residual_echo_spectrum, comfort_noise_spectrum,
347 low_band_gain);
348
349 // Limit the gain of the lower bands during start up and after resets.
350 const float gain_upper_bound = aec_state.SuppressionGainLimit();
351 if (gain_upper_bound < 1.f) {
352 for (size_t k = 0; k < low_band_gain->size(); ++k) {
353 (*low_band_gain)[k] = std::min((*low_band_gain)[k], gain_upper_bound);
354 }
355 }
356
357 // Compute the gain for the upper bands.
358 const absl::optional<int> narrow_peak_band =
359 render_signal_analyzer.NarrowPeakBand();
360
361 *high_bands_gain =
362 UpperBandsGain(echo_spectrum, comfort_noise_spectrum, narrow_peak_band,
363 aec_state.SaturatedEcho(), render, *low_band_gain);
364 if (cfg.enforce_empty_higher_bands) {
365 *high_bands_gain = 0.f;
366 }
367 }
368
SetInitialState(bool state)369 void SuppressionGain::SetInitialState(bool state) {
370 initial_state_ = state;
371 if (state) {
372 initial_state_change_counter_ = state_change_duration_blocks_;
373 } else {
374 initial_state_change_counter_ = 0;
375 }
376 }
377
378 // Detects when the render signal can be considered to have low power and
379 // consist of stationary noise.
Detect(const std::vector<std::vector<float>> & render)380 bool SuppressionGain::LowNoiseRenderDetector::Detect(
381 const std::vector<std::vector<float>>& render) {
382 float x2_sum = 0.f;
383 float x2_max = 0.f;
384 for (auto x_k : render[0]) {
385 const float x2 = x_k * x_k;
386 x2_sum += x2;
387 x2_max = std::max(x2_max, x2);
388 }
389
390 constexpr float kThreshold = 50.f * 50.f * 64.f;
391 const bool low_noise_render =
392 average_power_ < kThreshold && x2_max < 3 * average_power_;
393 average_power_ = average_power_ * 0.9f + x2_sum * 0.1f;
394 return low_noise_render;
395 }
396
DominantNearendDetector(const EchoCanceller3Config::Suppressor::DominantNearendDetection config)397 SuppressionGain::DominantNearendDetector::DominantNearendDetector(
398 const EchoCanceller3Config::Suppressor::DominantNearendDetection config)
399 : enr_threshold_(config.enr_threshold),
400 enr_exit_threshold_(config.enr_exit_threshold),
401 snr_threshold_(config.snr_threshold),
402 hold_duration_(config.hold_duration),
403 trigger_threshold_(config.trigger_threshold),
404 use_during_initial_phase_(config.use_during_initial_phase) {}
405
Update(rtc::ArrayView<const float> nearend_spectrum,rtc::ArrayView<const float> residual_echo_spectrum,rtc::ArrayView<const float> comfort_noise_spectrum,bool initial_state)406 void SuppressionGain::DominantNearendDetector::Update(
407 rtc::ArrayView<const float> nearend_spectrum,
408 rtc::ArrayView<const float> residual_echo_spectrum,
409 rtc::ArrayView<const float> comfort_noise_spectrum,
410 bool initial_state) {
411 auto low_frequency_energy = [](rtc::ArrayView<const float> spectrum) {
412 RTC_DCHECK_LE(16, spectrum.size());
413 return std::accumulate(spectrum.begin() + 1, spectrum.begin() + 16, 0.f);
414 };
415 const float ne_sum = low_frequency_energy(nearend_spectrum);
416 const float echo_sum = low_frequency_energy(residual_echo_spectrum);
417 const float noise_sum = low_frequency_energy(comfort_noise_spectrum);
418
419 // Detect strong active nearend if the nearend is sufficiently stronger than
420 // the echo and the nearend noise.
421 if ((!initial_state || use_during_initial_phase_) &&
422 ne_sum > enr_threshold_ * echo_sum &&
423 ne_sum > snr_threshold_ * noise_sum) {
424 if (++trigger_counter_ >= trigger_threshold_) {
425 // After a period of strong active nearend activity, flag nearend mode.
426 hold_counter_ = hold_duration_;
427 trigger_counter_ = trigger_threshold_;
428 }
429 } else {
430 // Forget previously detected strong active nearend activity.
431 trigger_counter_ = std::max(0, trigger_counter_ - 1);
432 }
433
434 // Exit nearend-state early at strong echo.
435 if (ne_sum < enr_exit_threshold_ * echo_sum &&
436 echo_sum > snr_threshold_ * noise_sum) {
437 hold_counter_ = 0;
438 }
439
440 // Remain in any nearend mode for a certain duration.
441 hold_counter_ = std::max(0, hold_counter_ - 1);
442 nearend_state_ = hold_counter_ > 0;
443 }
444
GainParameters(const EchoCanceller3Config::Suppressor::Tuning & tuning)445 SuppressionGain::GainParameters::GainParameters(
446 const EchoCanceller3Config::Suppressor::Tuning& tuning)
447 : max_inc_factor(tuning.max_inc_factor),
448 max_dec_factor_lf(tuning.max_dec_factor_lf) {
449 // Compute per-band masking thresholds.
450 constexpr size_t kLastLfBand = 5;
451 constexpr size_t kFirstHfBand = 8;
452 RTC_DCHECK_LT(kLastLfBand, kFirstHfBand);
453 auto& lf = tuning.mask_lf;
454 auto& hf = tuning.mask_hf;
455 RTC_DCHECK_LT(lf.enr_transparent, lf.enr_suppress);
456 RTC_DCHECK_LT(hf.enr_transparent, hf.enr_suppress);
457 for (size_t k = 0; k < kFftLengthBy2Plus1; k++) {
458 float a;
459 if (k <= kLastLfBand) {
460 a = 0.f;
461 } else if (k < kFirstHfBand) {
462 a = (k - kLastLfBand) / static_cast<float>(kFirstHfBand - kLastLfBand);
463 } else {
464 a = 1.f;
465 }
466 enr_transparent_[k] = (1 - a) * lf.enr_transparent + a * hf.enr_transparent;
467 enr_suppress_[k] = (1 - a) * lf.enr_suppress + a * hf.enr_suppress;
468 emr_transparent_[k] = (1 - a) * lf.emr_transparent + a * hf.emr_transparent;
469 }
470 }
471
472 } // namespace webrtc
473