Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: webrtc/modules/audio_processing/agc2/gain_controller2.cc

Issue 2848593002: AGC2 as a new APM sub-module operating with hard-coded gain. (Closed)
Patch Set: unneeded DCHECK removed Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d0b1b39b7f2883b86a7bbdb1f7c1fc238418af79
--- /dev/null
+++ b/webrtc/modules/audio_processing/agc2/gain_controller2.cc
@@ -0,0 +1,65 @@
+/*
+ * 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/atomicops.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 {
+
+namespace {
+
+constexpr float kGain = 0.5f;
+
+} // namespace
+
+int GainController2::instance_count_ = 0;
+
+GainController2::GainController2(int sample_rate_hz)
+ : sample_rate_hz_(sample_rate_hz),
+ data_dumper_(new ApmDataDumper(
+ rtc::AtomicOps::Increment(&instance_count_))),
+ digital_gain_applier_(),
+ gain_(kGain) {
+ 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("gain_", 1, &gain_);
+}
+
+GainController2::~GainController2() = default;
+
+void GainController2::Process(AudioBuffer* audio) {
+ for (size_t k = 0; k < audio->num_channels(); ++k) {
+ auto channel_view = rtc::ArrayView<float>(
+ audio->channels_f()[k], audio->num_frames());
+ digital_gain_applier_.Process(gain_, channel_view);
+ }
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698