blob: 30e16e490bc242e2801168db40775abe8add43f1 [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 {
Alessio Bazzica0c83e152020-10-14 12:49:54 +020074 char buf[2048];
Artem Titov59bbd652019-08-02 11:31:37 +020075 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
Alessio Bazzica0c83e152020-10-14 12:49:54 +020081 << ", multi_channel_capture: " << pipeline.multi_channel_capture
82 << "}, pre_amplifier: { enabled: " << pre_amplifier.enabled
Artem Titov59bbd652019-08-02 11:31:37 +020083 << ", fixed_gain_factor: " << pre_amplifier.fixed_gain_factor
84 << " }, high_pass_filter: { enabled: " << high_pass_filter.enabled
85 << " }, echo_canceller: { enabled: " << echo_canceller.enabled
86 << ", mobile_mode: " << echo_canceller.mobile_mode
Per Åhgrended86c12019-12-09 20:47:39 +010087 << ", enforce_high_pass_filtering: "
88 << echo_canceller.enforce_high_pass_filtering
Artem Titov59bbd652019-08-02 11:31:37 +020089 << " }, noise_suppression: { enabled: " << noise_suppression.enabled
90 << ", level: "
91 << NoiseSuppressionLevelToString(noise_suppression.level)
Per Åhgrenc0734712020-01-02 15:15:36 +010092 << " }, transient_suppression: { enabled: "
93 << transient_suppression.enabled
Artem Titov59bbd652019-08-02 11:31:37 +020094 << " }, voice_detection: { enabled: " << voice_detection.enabled
95 << " }, gain_controller1: { enabled: " << gain_controller1.enabled
96 << ", mode: " << GainController1ModeToString(gain_controller1.mode)
97 << ", target_level_dbfs: " << gain_controller1.target_level_dbfs
98 << ", compression_gain_db: " << gain_controller1.compression_gain_db
99 << ", enable_limiter: " << gain_controller1.enable_limiter
100 << ", analog_level_minimum: " << gain_controller1.analog_level_minimum
101 << ", analog_level_maximum: " << gain_controller1.analog_level_maximum
102 << " }, gain_controller2: { enabled: " << gain_controller2.enabled
103 << ", fixed_digital: { gain_db: "
104 << gain_controller2.fixed_digital.gain_db
Alessio Bazzica0c83e152020-10-14 12:49:54 +0200105 << "}, adaptive_digital: { enabled: "
106 << gain_controller2.adaptive_digital.enabled
107 << ", level_estimator: { type: "
Artem Titov59bbd652019-08-02 11:31:37 +0200108 << GainController2LevelEstimatorToString(
109 gain_controller2.adaptive_digital.level_estimator)
Alessio Bazzica0c83e152020-10-14 12:49:54 +0200110 << ", adjacent_speech_frames_threshold: "
111 << gain_controller2.adaptive_digital
112 .level_estimator_adjacent_speech_frames_threshold
113 << ", initial_saturation_margin_db: "
114 << gain_controller2.adaptive_digital.initial_saturation_margin_db
Artem Titov59bbd652019-08-02 11:31:37 +0200115 << ", extra_saturation_margin_db: "
116 << gain_controller2.adaptive_digital.extra_saturation_margin_db
Alessio Bazzica0c83e152020-10-14 12:49:54 +0200117 << "}, gain_applier: { adjacent_speech_frames_threshold: "
118 << gain_controller2.adaptive_digital
119 .gain_applier_adjacent_speech_frames_threshold
120 << ", max_gain_change_db_per_second: "
121 << gain_controller2.adaptive_digital.max_gain_change_db_per_second
122 << ", max_output_noise_level_dbfs: "
123 << gain_controller2.adaptive_digital.max_output_noise_level_dbfs
Artem Titov59bbd652019-08-02 11:31:37 +0200124 << " } }, residual_echo_detector: { enabled: "
125 << residual_echo_detector.enabled
126 << " }, level_estimation: { enabled: " << level_estimation.enabled
Alessio Bazzica0c83e152020-10-14 12:49:54 +0200127 << " }}}";
Artem Titov59bbd652019-08-02 11:31:37 +0200128 return builder.str();
129}
130
aleloi5f099802016-08-25 00:45:31 -0700131} // namespace webrtc