noise_suppression.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include "noise_suppression.h"
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include "signal_processing_library.h"
  14. #include "defines.h"
  15. #include "ns_core.h"
  16. int WebRtcNs_Create(NsHandle** NS_inst) {
  17. *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
  18. if (*NS_inst != NULL) {
  19. (*(NSinst_t**)NS_inst)->initFlag = 0;
  20. return 0;
  21. }
  22. else {
  23. return -1;
  24. }
  25. }
  26. int WebRtcNs_Free(NsHandle* NS_inst) {
  27. free(NS_inst);
  28. return 0;
  29. }
  30. int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
  31. return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
  32. }
  33. int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
  34. return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
  35. }
  36. int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H,
  37. short* outframe, short* outframe_H) {
  38. return WebRtcNs_ProcessCore(
  39. (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
  40. }
  41. float WebRtcNs_prior_speech_probability(NsHandle* handle) {
  42. NSinst_t* self = (NSinst_t*) handle;
  43. if (handle == NULL) {
  44. return -1;
  45. }
  46. if (self->initFlag == 0) {
  47. return -1;
  48. }
  49. return self->priorSpeechProb;
  50. }