blob: 11706870f435e20628a7812b4f0517a0bbf2f1d2 [file] [log] [blame]
alessiob3ec96df2017-05-22 06:57:06 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_
12#define MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_
alessiob3ec96df2017-05-22 06:57:06 -070013
14#include <memory>
15#include <string>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_processing/include/audio_processing.h"
18#include "rtc_base/constructormagic.h"
alessiob3ec96df2017-05-22 06:57:06 -070019
20namespace webrtc {
21
22class ApmDataDumper;
23class AudioBuffer;
24
25// Gain Controller 2 aims to automatically adjust levels by acting on the
26// microphone gain and/or applying digital gain.
27//
Alessio Bazzica270f7b52017-10-13 11:05:17 +020028// Temporarily implements a fixed gain mode with hard-clipping.
alessiob3ec96df2017-05-22 06:57:06 -070029class GainController2 {
30 public:
Alessio Bazzica270f7b52017-10-13 11:05:17 +020031 GainController2();
alessiob3ec96df2017-05-22 06:57:06 -070032 ~GainController2();
33
Alessio Bazzica270f7b52017-10-13 11:05:17 +020034 void Initialize(int sample_rate_hz);
alessiob3ec96df2017-05-22 06:57:06 -070035 void Process(AudioBuffer* audio);
36
Alessio Bazzica270f7b52017-10-13 11:05:17 +020037 void ApplyConfig(const AudioProcessing::Config::GainController2& config);
alessiob3ec96df2017-05-22 06:57:06 -070038 static bool Validate(const AudioProcessing::Config::GainController2& config);
39 static std::string ToString(
40 const AudioProcessing::Config::GainController2& config);
41
42 private:
alessiob3ec96df2017-05-22 06:57:06 -070043 static int instance_count_;
Alessio Bazzica270f7b52017-10-13 11:05:17 +020044 std::unique_ptr<ApmDataDumper> data_dumper_;
45 int sample_rate_hz_;
46 float fixed_gain_;
47
alessiob3ec96df2017-05-22 06:57:06 -070048 RTC_DISALLOW_COPY_AND_ASSIGN(GainController2);
49};
50
51} // namespace webrtc
52
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020053#endif // MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_