noise_suppression.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_
  11. #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_
  12. #include "typedefs.h"
  13. typedef struct NsHandleT NsHandle;
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*
  18. * This function creates an instance to the noise suppression structure
  19. *
  20. * Input:
  21. * - NS_inst : Pointer to noise suppression instance that should be
  22. * created
  23. *
  24. * Output:
  25. * - NS_inst : Pointer to created noise suppression instance
  26. *
  27. * Return value : 0 - Ok
  28. * -1 - Error
  29. */
  30. int WebRtcNs_Create(NsHandle** NS_inst);
  31. /*
  32. * This function frees the dynamic memory of a specified noise suppression
  33. * instance.
  34. *
  35. * Input:
  36. * - NS_inst : Pointer to NS instance that should be freed
  37. *
  38. * Return value : 0 - Ok
  39. * -1 - Error
  40. */
  41. int WebRtcNs_Free(NsHandle* NS_inst);
  42. /*
  43. * This function initializes a NS instance and has to be called before any other
  44. * processing is made.
  45. *
  46. * Input:
  47. * - NS_inst : Instance that should be initialized
  48. * - fs : sampling frequency
  49. *
  50. * Output:
  51. * - NS_inst : Initialized instance
  52. *
  53. * Return value : 0 - Ok
  54. * -1 - Error
  55. */
  56. int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs);
  57. /*
  58. * This changes the aggressiveness of the noise suppression method.
  59. *
  60. * Input:
  61. * - NS_inst : Noise suppression instance.
  62. * - mode : 0: Mild, 1: Medium , 2: Aggressive
  63. *
  64. * Output:
  65. * - NS_inst : Updated instance.
  66. *
  67. * Return value : 0 - Ok
  68. * -1 - Error
  69. */
  70. int WebRtcNs_set_policy(NsHandle* NS_inst, int mode);
  71. /*
  72. * This functions does Noise Suppression for the inserted speech frame. The
  73. * input and output signals should always be 10ms (80 or 160 samples).
  74. *
  75. * Input
  76. * - NS_inst : Noise suppression instance.
  77. * - spframe : Pointer to speech frame buffer for L band
  78. * - spframe_H : Pointer to speech frame buffer for H band
  79. * - fs : sampling frequency
  80. *
  81. * Output:
  82. * - NS_inst : Updated NS instance
  83. * - outframe : Pointer to output frame for L band
  84. * - outframe_H : Pointer to output frame for H band
  85. *
  86. * Return value : 0 - OK
  87. * -1 - Error
  88. */
  89. int WebRtcNs_Process(NsHandle* NS_inst,
  90. short* spframe,
  91. short* spframe_H,
  92. short* outframe,
  93. short* outframe_H);
  94. /* Returns the internally used prior speech probability of the current frame.
  95. * There is a frequency bin based one as well, with which this should not be
  96. * confused.
  97. *
  98. * Input
  99. * - handle : Noise suppression instance.
  100. *
  101. * Return value : Prior speech probability in interval [0.0, 1.0].
  102. * -1 - NULL pointer or uninitialized instance.
  103. */
  104. float WebRtcNs_prior_speech_probability(NsHandle* handle);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_