niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 04:47:31 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 13 | |
kwiberg | 88788ad | 2016-02-19 15:04:49 | [diff] [blame] | 14 | #include <memory> |
Alejandro Luebs | fa639f0 | 2016-02-09 19:24:32 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 17 | #include "modules/audio_processing/include/audio_processing.h" |
| 18 | #include "rtc_base/constructormagic.h" |
| 19 | #include "rtc_base/criticalsection.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 | [diff] [blame] | 22 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 23 | class AudioBuffer; |
| 24 | |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 25 | class NoiseSuppressionImpl : public NoiseSuppression { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 26 | public: |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 27 | explicit NoiseSuppressionImpl(rtc::CriticalSection* crit); |
| 28 | ~NoiseSuppressionImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 29 | |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 30 | // TODO(peah): Fold into ctor, once public API is removed. |
Peter Kasting | 6955870 | 2016-01-13 00:26:35 | [diff] [blame] | 31 | void Initialize(size_t channels, int sample_rate_hz); |
solenberg | 29e2f93 | 2015-12-16 09:18:15 | [diff] [blame] | 32 | void AnalyzeCaptureAudio(AudioBuffer* audio); |
| 33 | void ProcessCaptureAudio(AudioBuffer* audio); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 34 | |
| 35 | // NoiseSuppression implementation. |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 36 | int Enable(bool enable) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 | [diff] [blame] | 37 | bool is_enabled() const override; |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 38 | int set_level(Level level) override; |
Minyue | 13b96ba | 2015-10-02 22:39:14 | [diff] [blame] | 39 | Level level() const override; |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 40 | float speech_probability() const override; |
Alejandro Luebs | fa639f0 | 2016-02-09 19:24:32 | [diff] [blame] | 41 | std::vector<float> NoiseEstimate() override; |
Alex Luebs | 57ae829 | 2016-03-09 15:24:34 | [diff] [blame] | 42 | static size_t num_noise_bins(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 43 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 44 | private: |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 45 | class Suppressor; |
peah | df3efa8 | 2015-11-28 20:35:15 | [diff] [blame] | 46 | rtc::CriticalSection* const crit_; |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 47 | bool enabled_ RTC_GUARDED_BY(crit_) = false; |
| 48 | Level level_ RTC_GUARDED_BY(crit_) = kModerate; |
| 49 | size_t channels_ RTC_GUARDED_BY(crit_) = 0; |
| 50 | int sample_rate_hz_ RTC_GUARDED_BY(crit_) = 0; |
| 51 | std::vector<std::unique_ptr<Suppressor>> suppressors_ RTC_GUARDED_BY(crit_); |
solenberg | 5e465c3 | 2015-12-08 21:22:33 | [diff] [blame] | 52 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(NoiseSuppressionImpl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 53 | }; |
| 54 | } // namespace webrtc |
| 55 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 56 | #endif // MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ |