blob: 6684b8286b7a3ba3508e4b114421fbafd58d7152 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 <stdlib.h>
12#include <string.h>
13
14#include "noise_suppression.h"
15#include "ns_core.h"
16#include "defines.h"
17
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000018int WebRtcNs_Create(NsHandle** NS_inst) {
19 *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
20 if (*NS_inst != NULL) {
21 (*(NSinst_t**)NS_inst)->initFlag = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000022 return 0;
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000023 } else {
24 return -1;
25 }
niklase@google.com470e71d2011-07-07 08:21:25 +000026
27}
28
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000029int WebRtcNs_Free(NsHandle* NS_inst) {
30 free(NS_inst);
31 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000032}
33
34
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000035int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) {
36 return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000037}
38
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000039int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
40 return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000041}
42
43
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000044int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H,
45 short* outframe, short* outframe_H) {
46 return WebRtcNs_ProcessCore(
47 (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
niklase@google.com470e71d2011-07-07 08:21:25 +000048}
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000049
50float WebRtcNs_prior_speech_probability(NsHandle* handle) {
51 NSinst_t* self = (NSinst_t*) handle;
52 if (handle == NULL) {
53 return -1;
54 }
55 if (self->initFlag == 0) {
56 return -1;
57 }
58 return self->priorSpeechProb;
59}