1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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 "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
12
13 #include <stdlib.h>
14
15 #include "webrtc/common_audio/signal_processing/include/real_fft.h"
16 #include "webrtc/modules/audio_processing/ns/nsx_core.h"
17 #include "webrtc/modules/audio_processing/ns/nsx_defines.h"
18
WebRtcNsx_Create()19 NsxHandle* WebRtcNsx_Create() {
20 NoiseSuppressionFixedC* self = malloc(sizeof(NoiseSuppressionFixedC));
21 WebRtcSpl_Init();
22 self->real_fft = NULL;
23 self->initFlag = 0;
24 return (NsxHandle*)self;
25 }
26
WebRtcNsx_Free(NsxHandle * nsxInst)27 void WebRtcNsx_Free(NsxHandle* nsxInst) {
28 WebRtcSpl_FreeRealFFT(((NoiseSuppressionFixedC*)nsxInst)->real_fft);
29 free(nsxInst);
30 }
31
WebRtcNsx_Init(NsxHandle * nsxInst,uint32_t fs)32 int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) {
33 return WebRtcNsx_InitCore((NoiseSuppressionFixedC*)nsxInst, fs);
34 }
35
WebRtcNsx_set_policy(NsxHandle * nsxInst,int mode)36 int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) {
37 return WebRtcNsx_set_policy_core((NoiseSuppressionFixedC*)nsxInst, mode);
38 }
39
WebRtcNsx_Process(NsxHandle * nsxInst,const short * const * speechFrame,int num_bands,short * const * outFrame)40 void WebRtcNsx_Process(NsxHandle* nsxInst,
41 const short* const* speechFrame,
42 int num_bands,
43 short* const* outFrame) {
44 WebRtcNsx_ProcessCore((NoiseSuppressionFixedC*)nsxInst, speechFrame,
45 num_bands, outFrame);
46 }
47