blob: 0015e3857d1b612ed6e0f9af065857276f7fb4e1 [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
aluebs@webrtc.org50883772014-09-26 14:33:08 +000037int WebRtcNs_Init(NsHandle* NS_inst, uint32_t 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
aluebs@webrtc.orgfda2c2e2014-09-18 09:54:06 +000045int WebRtcNs_Analyze(NsHandle* NS_inst, float* spframe) {
46 return WebRtcNs_AnalyzeCore((NSinst_t*) NS_inst, spframe);
47}
niklase@google.com470e71d2011-07-07 08:21:25 +000048
kwiberg@webrtc.org12cd4432014-06-10 11:13:09 +000049int WebRtcNs_Process(NsHandle* NS_inst, float* spframe, float* spframe_H,
50 float* outframe, float* outframe_H) {
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000051 return WebRtcNs_ProcessCore(
52 (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
niklase@google.com470e71d2011-07-07 08:21:25 +000053}
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000054
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}