pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC_AGC_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AGC_AGC_H_ |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 13 | |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/audio_processing/vad/voice_activity_detector.h" |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
peah | bbe4233 | 2016-06-08 06:42:02 -0700 | [diff] [blame] | 20 | class LoudnessHistogram; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 21 | |
| 22 | class Agc { |
| 23 | public: |
| 24 | Agc(); |
| 25 | virtual ~Agc(); |
| 26 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 27 | // |audio| must be mono; in a multi-channel stream, provide the first (usually |
| 28 | // left) channel. |
Jonas Olsson | 645b027 | 2018-02-15 15:16:27 +0100 | [diff] [blame] | 29 | virtual void Process(const int16_t* audio, size_t length, int sample_rate_hz); |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 30 | |
| 31 | // Retrieves the difference between the target RMS level and the current |
| 32 | // signal RMS level in dB. Returns true if an update is available and false |
| 33 | // otherwise, in which case |error| should be ignored and no action taken. |
| 34 | virtual bool GetRmsErrorDb(int* error); |
| 35 | virtual void Reset(); |
| 36 | |
| 37 | virtual int set_target_level_dbfs(int level); |
kwiberg | 8cf8898 | 2016-08-26 14:50:38 -0700 | [diff] [blame] | 38 | virtual int target_level_dbfs() const; |
| 39 | virtual float voice_probability() const; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 40 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 41 | private: |
| 42 | double target_level_loudness_; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 43 | int target_level_dbfs_; |
peah | bbe4233 | 2016-06-08 06:42:02 -0700 | [diff] [blame] | 44 | std::unique_ptr<LoudnessHistogram> histogram_; |
| 45 | std::unique_ptr<LoudnessHistogram> inactive_histogram_; |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 46 | VoiceActivityDetector vad_; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace webrtc |
| 50 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 51 | #endif // MODULES_AUDIO_PROCESSING_AGC_AGC_H_ |