Per Ã…hgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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/ns/suppression_params.h" |
| 12 | |
| 13 | #include "rtc_base/checks.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | SuppressionParams::SuppressionParams( |
| 18 | NsConfig::SuppressionLevel suppression_level) { |
| 19 | switch (suppression_level) { |
| 20 | case NsConfig::SuppressionLevel::k6dB: |
| 21 | over_subtraction_factor = 1.f; |
| 22 | // 6 dB attenuation. |
| 23 | minimum_attenuating_gain = 0.5f; |
| 24 | use_attenuation_adjustment = false; |
| 25 | break; |
| 26 | case NsConfig::SuppressionLevel::k12dB: |
| 27 | over_subtraction_factor = 1.f; |
| 28 | // 12 dB attenuation. |
| 29 | minimum_attenuating_gain = 0.25f; |
| 30 | use_attenuation_adjustment = true; |
| 31 | break; |
| 32 | case NsConfig::SuppressionLevel::k18dB: |
| 33 | over_subtraction_factor = 1.1f; |
| 34 | // 18 dB attenuation. |
| 35 | minimum_attenuating_gain = 0.125f; |
| 36 | use_attenuation_adjustment = true; |
| 37 | break; |
| 38 | case NsConfig::SuppressionLevel::k21dB: |
| 39 | over_subtraction_factor = 1.25f; |
| 40 | // 20.9 dB attenuation. |
| 41 | minimum_attenuating_gain = 0.09f; |
| 42 | use_attenuation_adjustment = true; |
| 43 | break; |
| 44 | default: |
| 45 | RTC_NOTREACHED(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | } // namespace webrtc |