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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_
13 
14 #include "webrtc/typedefs.h"
15 
16 typedef struct NsxHandleT NsxHandle;
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /*
23  * This function creates an instance of the fixed point Noise Suppression.
24  */
25 NsxHandle* WebRtcNsx_Create();
26 
27 /*
28  * This function frees the dynamic memory of a specified Noise Suppression
29  * instance.
30  *
31  * Input:
32  *      - nsxInst       : Pointer to NS instance that should be freed
33  */
34 void WebRtcNsx_Free(NsxHandle* nsxInst);
35 
36 /*
37  * This function initializes a NS instance
38  *
39  * Input:
40  *      - nsxInst       : Instance that should be initialized
41  *      - fs            : sampling frequency
42  *
43  * Output:
44  *      - nsxInst       : Initialized instance
45  *
46  * Return value         :  0 - Ok
47  *                        -1 - Error
48  */
49 int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs);
50 
51 /*
52  * This changes the aggressiveness of the noise suppression method.
53  *
54  * Input:
55  *      - nsxInst       : Instance that should be initialized
56  *      - mode          : 0: Mild, 1: Medium , 2: Aggressive
57  *
58  * Output:
59  *      - nsxInst       : Initialized instance
60  *
61  * Return value         :  0 - Ok
62  *                        -1 - Error
63  */
64 int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode);
65 
66 /*
67  * This functions does noise suppression for the inserted speech frame. The
68  * input and output signals should always be 10ms (80 or 160 samples).
69  *
70  * Input
71  *      - nsxInst       : NSx instance. Needs to be initiated before call.
72  *      - speechFrame   : Pointer to speech frame buffer for each band
73  *      - num_bands     : Number of bands
74  *
75  * Output:
76  *      - nsxInst       : Updated NSx instance
77  *      - outFrame      : Pointer to output frame for each band
78  */
79 void WebRtcNsx_Process(NsxHandle* nsxInst,
80                        const short* const* speechFrame,
81                        int num_bands,
82                        short* const* outFrame);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_
89