agc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2012 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_AGC_AGC_H_
  11. #define MODULES_AUDIO_PROCESSING_AGC_AGC_H_
  12. #include <memory>
  13. #include "modules/audio_processing/vad/voice_activity_detector.h"
  14. namespace webrtc {
  15. class LoudnessHistogram;
  16. class Agc {
  17. public:
  18. Agc();
  19. virtual ~Agc();
  20. // |audio| must be mono; in a multi-channel stream, provide the first (usually
  21. // left) channel.
  22. virtual void Process(const int16_t* audio, size_t length, int sample_rate_hz);
  23. // Retrieves the difference between the target RMS level and the current
  24. // signal RMS level in dB. Returns true if an update is available and false
  25. // otherwise, in which case |error| should be ignored and no action taken.
  26. virtual bool GetRmsErrorDb(int* error);
  27. virtual void Reset();
  28. virtual int set_target_level_dbfs(int level);
  29. virtual int target_level_dbfs() const;
  30. virtual float voice_probability() const;
  31. private:
  32. double target_level_loudness_;
  33. int target_level_dbfs_;
  34. std::unique_ptr<LoudnessHistogram> histogram_;
  35. std::unique_ptr<LoudnessHistogram> inactive_histogram_;
  36. VoiceActivityDetector vad_;
  37. };
  38. } // namespace webrtc
  39. #endif // MODULES_AUDIO_PROCESSING_AGC_AGC_H_