blob: 414ca313bec0c821bbc91bbaf8ae2b6d006b9ade [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_
12#define MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg88788ad2016-02-19 07:04:49 -080014#include <memory>
Alejandro Luebsfa639f02016-02-09 11:24:32 -080015#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_processing/include/audio_processing.h"
Steve Anton10542f22019-01-11 09:11:00 -080018#include "rtc_base/constructor_magic.h"
19#include "rtc_base/critical_section.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
21namespace webrtc {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000022
niklase@google.com470e71d2011-07-07 08:21:25 +000023class AudioBuffer;
24
solenberg5e465c32015-12-08 13:22:33 -080025class NoiseSuppressionImpl : public NoiseSuppression {
niklase@google.com470e71d2011-07-07 08:21:25 +000026 public:
solenberg5e465c32015-12-08 13:22:33 -080027 explicit NoiseSuppressionImpl(rtc::CriticalSection* crit);
28 ~NoiseSuppressionImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000029
solenberg5e465c32015-12-08 13:22:33 -080030 // TODO(peah): Fold into ctor, once public API is removed.
Peter Kasting69558702016-01-12 16:26:35 -080031 void Initialize(size_t channels, int sample_rate_hz);
solenberg29e2f932015-12-16 01:18:15 -080032 void AnalyzeCaptureAudio(AudioBuffer* audio);
33 void ProcessCaptureAudio(AudioBuffer* audio);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
35 // NoiseSuppression implementation.
solenberg5e465c32015-12-08 13:22:33 -080036 int Enable(bool enable) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000037 bool is_enabled() const override;
solenberg5e465c32015-12-08 13:22:33 -080038 int set_level(Level level) override;
Minyue13b96ba2015-10-03 00:39:14 +020039 Level level() const override;
solenberg5e465c32015-12-08 13:22:33 -080040 float speech_probability() const override;
Alejandro Luebsfa639f02016-02-09 11:24:32 -080041 std::vector<float> NoiseEstimate() override;
Alex Luebs57ae8292016-03-09 16:24:34 +010042 static size_t num_noise_bins();
niklase@google.com470e71d2011-07-07 08:21:25 +000043
niklase@google.com470e71d2011-07-07 08:21:25 +000044 private:
solenberg5e465c32015-12-08 13:22:33 -080045 class Suppressor;
peahdf3efa82015-11-28 12:35:15 -080046 rtc::CriticalSection* const crit_;
danilchap56359be2017-09-07 07:53:45 -070047 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_);
solenberg5e465c32015-12-08 13:22:33 -080052 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(NoiseSuppressionImpl);
niklase@google.com470e71d2011-07-07 08:21:25 +000053};
54} // namespace webrtc
55
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020056#endif // MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_