Index: webrtc/modules/audio_processing/agc2/gain_controller2.cc |
diff --git a/webrtc/modules/audio_processing/agc2/gain_controller2.cc b/webrtc/modules/audio_processing/agc2/gain_controller2.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0edaeab97aec2ccc027eb33cc240707e77207eb3 |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/agc2/gain_controller2.cc |
@@ -0,0 +1,56 @@ |
+/* |
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include "webrtc/modules/audio_processing/agc2/gain_controller2.h" |
+ |
+#include "webrtc/base/checks.h" |
+#include "webrtc/modules/audio_processing/audio_buffer.h" |
+#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" |
+ |
+namespace webrtc { |
+ |
+int GainController2::instance_count_ = 0; |
+ |
+GainController2::GainController2(int sample_rate_hz) |
+ : data_dumper_(new ApmDataDumper(instance_count_)), |
+ gain_applier_(data_dumper_.get()), |
+ hard_coded_gain_(0.9f) { |
+ RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz || |
+ sample_rate_hz == AudioProcessing::kSampleRate16kHz || |
+ sample_rate_hz == AudioProcessing::kSampleRate32kHz || |
+ sample_rate_hz == AudioProcessing::kSampleRate48kHz); |
+ data_dumper_->InitiateNewSetOfRecordings(); |
+ data_dumper_->DumpRaw("agc2_hard_coded_gain", 1, &hard_coded_gain_); |
+ gain_applier_.Initialize(sample_rate_hz); |
+ ++instance_count_; |
peah-webrtc
2017/05/16 13:06:57
This increement needs to be atomic as APM can be i
AleBzk
2017/05/18 08:31:37
Thanks, great to learn this.
Then the same change
peah-webrtc
2017/05/18 10:51:18
Good point :-) I guess the reason for that not bei
|
+} |
+ |
+GainController2::~GainController2() = default; |
+ |
+void GainController2::Process(AudioBuffer* audio) { |
+ RTC_DCHECK_LT(0, audio->num_channels()); |
+ int num_saturations = gain_applier_.Process(hard_coded_gain_, audio); |
+ data_dumper_->DumpRaw("agc2_num_saturations", 1, &num_saturations); |
+} |
+ |
+bool GainController2::Validate( |
+ const AudioProcessing::Config::GainController2& config) { |
+ return true; |
+} |
+ |
+std::string GainController2::ToString( |
+ const AudioProcessing::Config::GainController2& config) { |
+ std::stringstream ss; |
+ ss << "{" |
+ << "enabled: " << (config.enabled ? "true" : "false") << "}"; |
+ return ss.str(); |
+} |
+ |
+} // namespace webrtc |