blob: 075ab88c1c6abc3ef35c0a5cdb983b0311ba2da8 [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
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000011#include "webrtc/modules/audio_processing/ns/include/noise_suppression.h"
kma@webrtc.org0221b782012-09-08 00:09:26 +000012
niklase@google.com470e71d2011-07-07 08:21:25 +000013#include <stdlib.h>
14#include <string.h>
15
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000016#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"
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
pbos@webrtc.orgb7192b82013-04-10 07:50:54 +000037int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000038 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
kwiberg@webrtc.org12cd4432014-06-10 11:13:09 +000046int WebRtcNs_Process(NsHandle* NS_inst, float* spframe, float* spframe_H,
47 float* outframe, float* outframe_H) {
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000048 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}