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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 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 "webrtc/modules/audio_processing/agc2/gain_controller2.h"
12
13 #include "webrtc/base/atomicops.h"
14 #include "webrtc/base/checks.h"
15 #include "webrtc/modules/audio_processing/audio_buffer.h"
16 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
17
18 namespace webrtc {
19
20 namespace {
21
22 constexpr float kGain = 0.5f;
23
24 } // namespace
25
26 int GainController2::instance_count_ = 0;
27
28 GainController2::GainController2(int sample_rate_hz)
29 : sample_rate_hz_(sample_rate_hz),
30 data_dumper_(new ApmDataDumper(
31 rtc::AtomicOps::Increment(&instance_count_))),
32 digital_gain_applier_(),
33 gain_(kGain) {
34 RTC_DCHECK(sample_rate_hz_ == AudioProcessing::kSampleRate8kHz ||
35 sample_rate_hz_ == AudioProcessing::kSampleRate16kHz ||
36 sample_rate_hz_ == AudioProcessing::kSampleRate32kHz ||
37 sample_rate_hz_ == AudioProcessing::kSampleRate48kHz);
38 data_dumper_->InitiateNewSetOfRecordings();
39 data_dumper_->DumpRaw("gain_", 1, &gain_);
40 }
41
42 GainController2::~GainController2() = default;
43
44 void GainController2::Process(AudioBuffer* audio) {
45 for (size_t k = 0; k < audio->num_channels(); ++k) {
46 auto channel_view = rtc::ArrayView<float>(
47 audio->channels_f()[k], audio->num_frames());
48 digital_gain_applier_.Process(gain_, channel_view);
49 }
50 }
51
52 bool GainController2::Validate(
53 const AudioProcessing::Config::GainController2& config) {
54 return true;
55 }
56
57 std::string GainController2::ToString(
58 const AudioProcessing::Config::GainController2& config) {
59 std::stringstream ss;
60 ss << "{"
61 << "enabled: " << (config.enabled ? "true" : "false") << "}";
62 return ss.str();
63 }
64
65 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698