niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 <stdlib.h> |
| 12 | #include <string.h> |
| 13 | |
| 14 | #include "noise_suppression.h" |
| 15 | #include "ns_core.h" |
| 16 | #include "defines.h" |
| 17 | |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 18 | int 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | return 0; |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 23 | } else { |
| 24 | return -1; |
| 25 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
| 27 | } |
| 28 | |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 29 | int WebRtcNs_Free(NsHandle* NS_inst) { |
| 30 | free(NS_inst); |
| 31 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 35 | int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) { |
| 36 | return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | } |
| 38 | |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 39 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) { |
| 40 | return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | |
kma@webrtc.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 44 | int 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | } |
bjornv@webrtc.org | 08329f4 | 2012-07-12 21:00:43 +0000 | [diff] [blame^] | 49 | |
| 50 | float 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 | } |