adaptive_agc.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2018 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_AGC2_ADAPTIVE_AGC_H_
  11. #define MODULES_AUDIO_PROCESSING_AGC2_ADAPTIVE_AGC_H_
  12. #include "modules/audio_processing/agc2/adaptive_digital_gain_applier.h"
  13. #include "modules/audio_processing/agc2/adaptive_mode_level_estimator.h"
  14. #include "modules/audio_processing/agc2/noise_level_estimator.h"
  15. #include "modules/audio_processing/agc2/vad_with_level.h"
  16. #include "modules/audio_processing/include/audio_frame_view.h"
  17. #include "modules/audio_processing/include/audio_processing.h"
  18. namespace webrtc {
  19. class ApmDataDumper;
  20. // Adaptive digital gain controller.
  21. // TODO(crbug.com/webrtc/7494): Unify with `AdaptiveDigitalGainApplier`.
  22. class AdaptiveAgc {
  23. public:
  24. explicit AdaptiveAgc(ApmDataDumper* apm_data_dumper);
  25. // TODO(crbug.com/webrtc/7494): Remove ctor above.
  26. AdaptiveAgc(ApmDataDumper* apm_data_dumper,
  27. const AudioProcessing::Config::GainController2& config);
  28. ~AdaptiveAgc();
  29. // Analyzes `frame` and applies a digital adaptive gain to it. Takes into
  30. // account the envelope measured by the limiter.
  31. // TODO(crbug.com/webrtc/7494): Make the class depend on the limiter.
  32. void Process(AudioFrameView<float> frame, float limiter_envelope);
  33. void Reset();
  34. private:
  35. AdaptiveModeLevelEstimator speech_level_estimator_;
  36. VadLevelAnalyzer vad_;
  37. AdaptiveDigitalGainApplier gain_applier_;
  38. ApmDataDumper* const apm_data_dumper_;
  39. NoiseLevelEstimator noise_level_estimator_;
  40. };
  41. } // namespace webrtc
  42. #endif // MODULES_AUDIO_PROCESSING_AGC2_ADAPTIVE_AGC_H_