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 #ifndef MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_
12 #define MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_
13 
14 #include <memory>
15 #include <string>
16 
17 #include "modules/audio_processing/include/audio_processing.h"
18 #include "rtc_base/constructormagic.h"
19 
20 namespace webrtc {
21 
22 class ApmDataDumper;
23 class AudioBuffer;
24 
25 // Gain Controller 2 aims to automatically adjust levels by acting on the
26 // microphone gain and/or applying digital gain.
27 //
28 // Temporarily implements a fixed gain mode with hard-clipping.
29 class GainController2 {
30  public:
31   GainController2();
32   ~GainController2();
33 
34   void Initialize(int sample_rate_hz);
35   void Process(AudioBuffer* audio);
36 
37   void ApplyConfig(const AudioProcessing::Config::GainController2& config);
38   static bool Validate(const AudioProcessing::Config::GainController2& config);
39   static std::string ToString(
40       const AudioProcessing::Config::GainController2& config);
41 
42  private:
43   static int instance_count_;
44   std::unique_ptr<ApmDataDumper> data_dumper_;
45   int sample_rate_hz_;
46   float fixed_gain_;
47 
48   RTC_DISALLOW_COPY_AND_ASSIGN(GainController2);
49 };
50 
51 }  // namespace webrtc
52 
53 #endif  // MODULES_AUDIO_PROCESSING_AGC2_GAIN_CONTROLLER2_H_
54