In https://webrtc-review.googlesource.com/c/src/+/1560 we moved WebRTC from src/webrtc to src/ (in order to preserve an healthy git history). This CL takes care of fixing header guards, #include paths, etc... NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true TBR=tommi@webrtc.org Bug: chromium:611808 Change-Id: Iea91618212bee0af16aa3f05071eab8f93706578 Reviewed-on: https://webrtc-review.googlesource.com/1561 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Henrik Kjellander <kjellander@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#19846}
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
/*
|
|
* 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 "modules/audio_processing/agc2/gain_controller2.h"
|
|
|
|
#include "modules/audio_processing/audio_buffer.h"
|
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
|
#include "rtc_base/atomicops.h"
|
|
#include "rtc_base/checks.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
|