• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_GAIN_CONTROLLER2_H_
12 #define MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
13 
14 #include <memory>
15 #include <string>
16 
17 #include "modules/audio_processing/agc2/adaptive_agc.h"
18 #include "modules/audio_processing/agc2/gain_applier.h"
19 #include "modules/audio_processing/agc2/limiter.h"
20 #include "modules/audio_processing/include/audio_processing.h"
21 #include "rtc_base/constructor_magic.h"
22 
23 namespace webrtc {
24 
25 class ApmDataDumper;
26 class AudioBuffer;
27 
28 // Gain Controller 2 aims to automatically adjust levels by acting on the
29 // microphone gain and/or applying digital gain.
30 class GainController2 {
31  public:
32   GainController2();
33   ~GainController2();
34 
35   void Initialize(int sample_rate_hz);
36   void Process(AudioBuffer* audio);
37   void NotifyAnalogLevel(int level);
38 
39   void ApplyConfig(const AudioProcessing::Config::GainController2& config);
40   static bool Validate(const AudioProcessing::Config::GainController2& config);
41   static std::string ToString(
42       const AudioProcessing::Config::GainController2& config);
43 
44  private:
45   static int instance_count_;
46   std::unique_ptr<ApmDataDumper> data_dumper_;
47   AudioProcessing::Config::GainController2 config_;
48   GainApplier gain_applier_;
49   std::unique_ptr<AdaptiveAgc> adaptive_agc_;
50   Limiter limiter_;
51   int analog_level_ = -1;
52 
53   RTC_DISALLOW_COPY_AND_ASSIGN(GainController2);
54 };
55 
56 }  // namespace webrtc
57 
58 #endif  // MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
59