You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

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