Home | History | Annotate | Download | only in ns
      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/include/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 
     19 int WebRtcNsx_Create(NsxHandle** nsxInst) {
     20   NsxInst_t* self = malloc(sizeof(NsxInst_t));
     21   *nsxInst = (NsxHandle*)self;
     22 
     23   if (self != NULL) {
     24     WebRtcSpl_Init();
     25     self->real_fft = NULL;
     26     self->initFlag = 0;
     27     return 0;
     28   } else {
     29     return -1;
     30   }
     31 
     32 }
     33 
     34 int WebRtcNsx_Free(NsxHandle* nsxInst) {
     35   WebRtcSpl_FreeRealFFT(((NsxInst_t*)nsxInst)->real_fft);
     36   free(nsxInst);
     37   return 0;
     38 }
     39 
     40 int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) {
     41   return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
     42 }
     43 
     44 int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) {
     45   return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
     46 }
     47 
     48 int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame,
     49                       short* speechFrameHB, short* outFrame,
     50                       short* outFrameHB) {
     51   return WebRtcNsx_ProcessCore(
     52       (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB);
     53 }
     54