agc.h (1600B)
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 11 #ifndef MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 12 #define MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 13 14 #include <cstdint> 15 #include <memory> 16 17 #include "api/array_view.h" 18 #include "modules/audio_processing/vad/voice_activity_detector.h" 19 20 namespace webrtc { 21 22 class LoudnessHistogram; 23 24 class Agc { 25 public: 26 Agc(); 27 virtual ~Agc(); 28 29 // `audio` must be mono; in a multi-channel stream, provide the first (usually 30 // left) channel. 31 virtual void Process(ArrayView<const int16_t> audio); 32 33 // Retrieves the difference between the target RMS level and the current 34 // signal RMS level in dB. Returns true if an update is available and false 35 // otherwise, in which case `error` should be ignored and no action taken. 36 virtual bool GetRmsErrorDb(int* error); 37 virtual void Reset(); 38 39 virtual int set_target_level_dbfs(int level); 40 virtual int target_level_dbfs() const; 41 virtual float voice_probability() const; 42 43 private: 44 double target_level_loudness_; 45 int target_level_dbfs_; 46 std::unique_ptr<LoudnessHistogram> histogram_; 47 std::unique_ptr<LoudnessHistogram> inactive_histogram_; 48 VoiceActivityDetector vad_; 49 }; 50 51 } // namespace webrtc 52 53 #endif // MODULES_AUDIO_PROCESSING_AGC_AGC_H_