gain_controller2.h 1.9 KB

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