blob: 88544159a41922f9428854e67cb65c6beaab0f78 [file] [log] [blame]
aleloi5f099802016-08-25 00:45:31 -07001/*
2 * Copyright (c) 2016 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/audio_processing/include/audio_processing.h"
aleloi5f099802016-08-25 00:45:31 -070012
Artem Titov59bbd652019-08-02 11:31:37 +020013#include "rtc_base/strings/string_builder.h"
Per Åhgrenfcbe4072019-09-15 00:27:58 +020014#include "rtc_base/system/arch.h"
Artem Titov59bbd652019-08-02 11:31:37 +020015
aleloi5f099802016-08-25 00:45:31 -070016namespace webrtc {
Artem Titov59bbd652019-08-02 11:31:37 +020017namespace {
18
19std::string NoiseSuppressionLevelToString(
20 const AudioProcessing::Config::NoiseSuppression::Level& level) {
21 switch (level) {
22 case AudioProcessing::Config::NoiseSuppression::Level::kLow:
23 return "Low";
24 case AudioProcessing::Config::NoiseSuppression::Level::kModerate:
25 return "Moderate";
26 case AudioProcessing::Config::NoiseSuppression::Level::kHigh:
27 return "High";
28 case AudioProcessing::Config::NoiseSuppression::Level::kVeryHigh:
29 return "VeryHigh";
30 }
31}
32
33std::string GainController1ModeToString(
34 const AudioProcessing::Config::GainController1::Mode& mode) {
35 switch (mode) {
36 case AudioProcessing::Config::GainController1::Mode::kAdaptiveAnalog:
37 return "AdaptiveAnalog";
38 case AudioProcessing::Config::GainController1::Mode::kAdaptiveDigital:
39 return "AdaptiveDigital";
40 case AudioProcessing::Config::GainController1::Mode::kFixedDigital:
41 return "FixedDigital";
42 }
43}
44
45std::string GainController2LevelEstimatorToString(
46 const AudioProcessing::Config::GainController2::LevelEstimator& level) {
47 switch (level) {
48 case AudioProcessing::Config::GainController2::LevelEstimator::kRms:
49 return "Rms";
50 case AudioProcessing::Config::GainController2::LevelEstimator::kPeak:
51 return "Peak";
52 }
53}
54
Per Åhgrenfcbe4072019-09-15 00:27:58 +020055int GetDefaultMaxInternalRate() {
56#ifdef WEBRTC_ARCH_ARM_FAMILY
57 return 32000;
58#else
59 return 48000;
60#endif
61}
62
Artem Titov59bbd652019-08-02 11:31:37 +020063} // namespace
aleloi5f099802016-08-25 00:45:31 -070064
Sam Zackrisson4b6ba7c2020-03-12 12:45:21 +010065constexpr int AudioProcessing::kNativeSampleRatesHz[];
66
Alex Loiko73ec0192018-05-15 10:52:28 +020067void CustomProcessing::SetRuntimeSetting(
68 AudioProcessing::RuntimeSetting setting) {}
69
Per Åhgrenfcbe4072019-09-15 00:27:58 +020070AudioProcessing::Config::Pipeline::Pipeline()
71 : maximum_internal_processing_rate(GetDefaultMaxInternalRate()) {}
72
Artem Titov59bbd652019-08-02 11:31:37 +020073std::string AudioProcessing::Config::ToString() const {
74 char buf[1024];
75 rtc::SimpleStringBuilder builder(buf);
76 builder << "AudioProcessing::Config{ "
Jonas Olssonb2b20312020-01-14 12:11:31 +010077 "pipeline: {"
78 "maximum_internal_processing_rate: "
Sam Zackrisson72cc71c2019-10-21 12:54:02 +020079 << pipeline.maximum_internal_processing_rate
Jonas Olssonb2b20312020-01-14 12:11:31 +010080 << ", multi_channel_render: " << pipeline.multi_channel_render
81 << ", "
82 ", multi_channel_capture: "
83 << pipeline.multi_channel_capture
Per Åhgrene14cb992019-11-27 09:34:22 +010084 << "}, "
Jonas Olssonb2b20312020-01-14 12:11:31 +010085 "pre_amplifier: { enabled: "
86 << pre_amplifier.enabled
Artem Titov59bbd652019-08-02 11:31:37 +020087 << ", fixed_gain_factor: " << pre_amplifier.fixed_gain_factor
88 << " }, high_pass_filter: { enabled: " << high_pass_filter.enabled
89 << " }, echo_canceller: { enabled: " << echo_canceller.enabled
90 << ", mobile_mode: " << echo_canceller.mobile_mode
Per Åhgrended86c12019-12-09 20:47:39 +010091 << ", enforce_high_pass_filtering: "
92 << echo_canceller.enforce_high_pass_filtering
Artem Titov59bbd652019-08-02 11:31:37 +020093 << " }, noise_suppression: { enabled: " << noise_suppression.enabled
94 << ", level: "
95 << NoiseSuppressionLevelToString(noise_suppression.level)
Per Åhgrenc0734712020-01-02 15:15:36 +010096 << " }, transient_suppression: { enabled: "
97 << transient_suppression.enabled
Artem Titov59bbd652019-08-02 11:31:37 +020098 << " }, voice_detection: { enabled: " << voice_detection.enabled
99 << " }, gain_controller1: { enabled: " << gain_controller1.enabled
100 << ", mode: " << GainController1ModeToString(gain_controller1.mode)
101 << ", target_level_dbfs: " << gain_controller1.target_level_dbfs
102 << ", compression_gain_db: " << gain_controller1.compression_gain_db
103 << ", enable_limiter: " << gain_controller1.enable_limiter
104 << ", analog_level_minimum: " << gain_controller1.analog_level_minimum
105 << ", analog_level_maximum: " << gain_controller1.analog_level_maximum
106 << " }, gain_controller2: { enabled: " << gain_controller2.enabled
107 << ", fixed_digital: { gain_db: "
108 << gain_controller2.fixed_digital.gain_db
109 << " }, adaptive_digital: { enabled: "
110 << gain_controller2.adaptive_digital.enabled << ", level_estimator: "
111 << GainController2LevelEstimatorToString(
112 gain_controller2.adaptive_digital.level_estimator)
113 << ", use_saturation_protector: "
114 << gain_controller2.adaptive_digital.use_saturation_protector
115 << ", extra_saturation_margin_db: "
116 << gain_controller2.adaptive_digital.extra_saturation_margin_db
117 << " } }, residual_echo_detector: { enabled: "
118 << residual_echo_detector.enabled
119 << " }, level_estimation: { enabled: " << level_estimation.enabled
120 << " } }";
121 return builder.str();
122}
123
aleloi5f099802016-08-25 00:45:31 -0700124} // namespace webrtc