saza | 0bad15f | 2019-10-16 11:46:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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 | |
Per Åhgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_LEGACY_NOISE_SUPPRESSION_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_LEGACY_NOISE_SUPPRESSION_H_ |
saza | 0bad15f | 2019-10-16 11:46:11 +0200 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | class AudioBuffer; |
| 20 | |
| 21 | // The noise suppression (NS) component attempts to remove noise while |
| 22 | // retaining speech. Recommended to be enabled on the client-side. |
| 23 | class NoiseSuppression { |
| 24 | public: |
| 25 | // Determines the aggressiveness of the suppression. Increasing the level |
| 26 | // will reduce the noise level at the expense of a higher speech distortion. |
| 27 | enum class Level { kLow, kModerate, kHigh, kVeryHigh }; |
| 28 | |
| 29 | NoiseSuppression(size_t channels, int sample_rate_hz, Level level); |
| 30 | ~NoiseSuppression(); |
| 31 | |
| 32 | NoiseSuppression(NoiseSuppression&) = delete; |
| 33 | NoiseSuppression& operator=(NoiseSuppression&) = delete; |
| 34 | |
| 35 | void AnalyzeCaptureAudio(AudioBuffer* audio); |
| 36 | void ProcessCaptureAudio(AudioBuffer* audio); |
| 37 | |
| 38 | // LEGACY: Returns the internally computed prior speech probability of current |
| 39 | // frame averaged over output channels. This is not supported in fixed point, |
| 40 | // for which |kUnsupportedFunctionError| is returned. |
| 41 | float speech_probability() const; |
| 42 | |
| 43 | // LEGACY: Returns the size of the noise vector returned by NoiseEstimate(). |
| 44 | static size_t num_noise_bins(); |
| 45 | |
| 46 | // LEGACY: Returns the noise estimate per frequency bin averaged over all |
| 47 | // channels. |
| 48 | std::vector<float> NoiseEstimate(); |
| 49 | |
| 50 | private: |
| 51 | class Suppressor; |
| 52 | |
| 53 | std::vector<std::unique_ptr<Suppressor>> suppressors_; |
| 54 | }; |
| 55 | } // namespace webrtc |
| 56 | |
Per Åhgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 57 | #endif // MODULES_AUDIO_PROCESSING_LEGACY_NOISE_SUPPRESSION_H_ |