blob: a83c9b2a1d35940ac01cf82068f7109fa20dc9f3 [file] [log] [blame]
Sam Zackrisson23513132019-01-11 15:10:32 +01001/*
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/noise_suppression_proxy.h"
12
13namespace webrtc {
14NoiseSuppressionProxy::NoiseSuppressionProxy(AudioProcessing* apm,
15 NoiseSuppression* ns)
16 : apm_(apm), ns_(ns) {}
17
18NoiseSuppressionProxy::~NoiseSuppressionProxy() {}
19
20int NoiseSuppressionProxy::Enable(bool enable) {
21 AudioProcessing::Config config = apm_->GetConfig();
22 if (config.noise_suppression.enabled != enable) {
23 config.noise_suppression.enabled = enable;
24 apm_->ApplyConfig(config);
25 }
26 return AudioProcessing::kNoError;
27}
28
29bool NoiseSuppressionProxy::is_enabled() const {
30 return ns_->is_enabled();
31}
32
33int NoiseSuppressionProxy::set_level(Level level) {
34 AudioProcessing::Config config = apm_->GetConfig();
35 using NsConfig = AudioProcessing::Config::NoiseSuppression;
36 NsConfig::Level new_level;
37 switch (level) {
38 case NoiseSuppression::kLow:
39 new_level = NsConfig::kLow;
40 break;
41 case NoiseSuppression::kModerate:
42 new_level = NsConfig::kModerate;
43 break;
44 case NoiseSuppression::kHigh:
45 new_level = NsConfig::kHigh;
46 break;
47 case NoiseSuppression::kVeryHigh:
48 new_level = NsConfig::kVeryHigh;
49 break;
50 default:
51 RTC_NOTREACHED();
52 }
53 if (config.noise_suppression.level != new_level) {
54 config.noise_suppression.level = new_level;
55 apm_->ApplyConfig(config);
56 }
57 return AudioProcessing::kNoError;
58}
59
60NoiseSuppression::Level NoiseSuppressionProxy::level() const {
61 return ns_->level();
62}
63
64float NoiseSuppressionProxy::speech_probability() const {
65 return ns_->speech_probability();
66}
67
68std::vector<float> NoiseSuppressionProxy::NoiseEstimate() {
69 return ns_->NoiseEstimate();
70}
71} // namespace webrtc