Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 int GainController2::instance_count_ = 0; | |
| 21 | |
| 22 GainController2::GainController2(int sample_rate_hz) | |
| 23 : sample_rate_hz_(sample_rate_hz), | |
| 24 data_dumper_(new ApmDataDumper( | |
| 25 rtc::AtomicOps::Increment(&instance_count_))), | |
| 26 digital_gain_applier_(), | |
| 27 hard_coded_digital_gain_(0.9f) { | |
| 28 RTC_DCHECK(sample_rate_hz_ == AudioProcessing::kSampleRate8kHz || | |
| 29 sample_rate_hz_ == AudioProcessing::kSampleRate16kHz || | |
| 30 sample_rate_hz_ == AudioProcessing::kSampleRate32kHz || | |
| 31 sample_rate_hz_ == AudioProcessing::kSampleRate48kHz); | |
| 32 data_dumper_->InitiateNewSetOfRecordings(); | |
| 33 data_dumper_->DumpRaw("hard_coded_digital_gain_", 1, | |
| 34 &hard_coded_digital_gain_); | |
| 35 } | |
| 36 | |
| 37 GainController2::~GainController2() = default; | |
| 38 | |
| 39 void GainController2::Process(AudioBuffer* audio) { | |
| 40 RTC_DCHECK_LT(0, audio->num_channels()); | |
| 41 digital_gain_applier_.Process(hard_coded_digital_gain_, audio); | |
|
peah-webrtc
2017/05/18 10:51:19
As commented on elsewhere. AudioBuffer is handy to
AleBzk
2017/05/18 12:06:22
Done.
| |
| 42 } | |
| 43 | |
| 44 bool GainController2::Validate( | |
| 45 const AudioProcessing::Config::GainController2& config) { | |
| 46 return true; | |
| 47 } | |
| 48 | |
| 49 std::string GainController2::ToString( | |
| 50 const AudioProcessing::Config::GainController2& config) { | |
| 51 std::stringstream ss; | |
| 52 ss << "{" | |
| 53 << "enabled: " << (config.enabled ? "true" : "false") << "}"; | |
| 54 return ss.str(); | |
| 55 } | |
| 56 | |
| 57 } // namespace webrtc | |
| OLD | NEW |