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
11#include "webrtc/modules/audio_processing/ns/include/noise_suppression.h"
12
13#include <stdlib.h>
14#include <string.h>
15
16#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
17#include "webrtc/modules/audio_processing/ns/defines.h"
18#include "webrtc/modules/audio_processing/ns/ns_core.h"
19
20int WebRtcNs_Create(NsHandle** NS_inst) {
21  *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
22  if (*NS_inst != NULL) {
23    (*(NSinst_t**)NS_inst)->initFlag = 0;
24    return 0;
25  } else {
26    return -1;
27  }
28
29}
30
31int WebRtcNs_Free(NsHandle* NS_inst) {
32  free(NS_inst);
33  return 0;
34}
35
36
37int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
38  return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
39}
40
41int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
42  return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
43}
44
45int WebRtcNs_Analyze(NsHandle* NS_inst, float* spframe) {
46  return WebRtcNs_AnalyzeCore((NSinst_t*) NS_inst, spframe);
47}
48
49int WebRtcNs_Process(NsHandle* NS_inst, float* spframe, float* spframe_H,
50                     float* outframe, float* outframe_H) {
51  return WebRtcNs_ProcessCore(
52      (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
53}
54
55float WebRtcNs_prior_speech_probability(NsHandle* handle) {
56  NSinst_t* self = (NSinst_t*) handle;
57  if (handle == NULL) {
58    return -1;
59  }
60  if (self->initFlag == 0) {
61    return -1;
62  }
63  return self->priorSpeechProb;
64}
65