blob: 0796a5b1ee7cee8beaa822984658e1e503aa0111 [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
kma@webrtc.org0221b782012-09-08 00:09:26 +000011#include "noise_suppression.h"
12
niklase@google.com470e71d2011-07-07 08:21:25 +000013#include <stdlib.h>
14#include <string.h>
15
kma@webrtc.org0221b782012-09-08 00:09:26 +000016#include "common_audio/signal_processing/include/signal_processing_library.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017#include "defines.h"
kma@webrtc.org0221b782012-09-08 00:09:26 +000018#include "ns_core.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000020int 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;
niklase@google.com470e71d2011-07-07 08:21:25 +000024 return 0;
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000025 } else {
26 return -1;
27 }
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29}
30
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000031int WebRtcNs_Free(NsHandle* NS_inst) {
32 free(NS_inst);
33 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000034}
35
36
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000037int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) {
38 return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000039}
40
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000041int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
42 return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000043}
44
45
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000046int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H,
47 short* outframe, short* outframe_H) {
48 return WebRtcNs_ProcessCore(
49 (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
niklase@google.com470e71d2011-07-07 08:21:25 +000050}
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000051
52float WebRtcNs_prior_speech_probability(NsHandle* handle) {
53 NSinst_t* self = (NSinst_t*) handle;
54 if (handle == NULL) {
55 return -1;
56 }
57 if (self->initFlag == 0) {
58 return -1;
59 }
60 return self->priorSpeechProb;
61}