blob: 838861db798de4b77247470cc4d3c9a93298c596 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.orgb9d7d932012-01-25 19:21:13 +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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_
12#define MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Alejandro Luebsfa639f02016-02-09 11:24:32 -080014#include <stddef.h>
15
Mirko Bonadei71207422017-09-15 13:58:09 +020016#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000017
18typedef struct NsxHandleT NsxHandle;
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*
Bjorn Volcker9345e862015-06-10 21:43:36 +020025 * This function creates an instance of the fixed point Noise Suppression.
niklase@google.com470e71d2011-07-07 08:21:25 +000026 */
Bjorn Volcker9345e862015-06-10 21:43:36 +020027NsxHandle* WebRtcNsx_Create();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29/*
30 * This function frees the dynamic memory of a specified Noise Suppression
31 * instance.
32 *
33 * Input:
34 * - nsxInst : Pointer to NS instance that should be freed
niklase@google.com470e71d2011-07-07 08:21:25 +000035 */
Bjorn Volckerf6a99e62015-04-10 07:56:57 +020036void WebRtcNsx_Free(NsxHandle* nsxInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38/*
39 * This function initializes a NS instance
40 *
41 * Input:
42 * - nsxInst : Instance that should be initialized
43 * - fs : sampling frequency
44 *
45 * Output:
46 * - nsxInst : Initialized instance
47 *
48 * Return value : 0 - Ok
49 * -1 - Error
50 */
pbos@webrtc.orgb7192b82013-04-10 07:50:54 +000051int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53/*
54 * This changes the aggressiveness of the noise suppression method.
55 *
56 * Input:
57 * - nsxInst : Instance that should be initialized
58 * - mode : 0: Mild, 1: Medium , 2: Aggressive
59 *
60 * Output:
61 * - nsxInst : Initialized instance
62 *
63 * Return value : 0 - Ok
64 * -1 - Error
65 */
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000066int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
68/*
69 * This functions does noise suppression for the inserted speech frame. The
70 * input and output signals should always be 10ms (80 or 160 samples).
71 *
72 * Input
73 * - nsxInst : NSx instance. Needs to be initiated before call.
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000074 * - speechFrame : Pointer to speech frame buffer for each band
75 * - num_bands : Number of bands
niklase@google.com470e71d2011-07-07 08:21:25 +000076 *
77 * Output:
78 * - nsxInst : Updated NSx instance
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000079 * - outFrame : Pointer to output frame for each band
niklase@google.com470e71d2011-07-07 08:21:25 +000080 */
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000081void WebRtcNsx_Process(NsxHandle* nsxInst,
82 const short* const* speechFrame,
83 int num_bands,
84 short* const* outFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000085
Alejandro Luebsfa639f02016-02-09 11:24:32 -080086/* Returns a pointer to the noise estimate per frequency bin. The number of
87 * frequency bins can be provided using WebRtcNsx_num_freq().
88 *
89 * Input
90 * - nsxInst : NSx instance. Needs to be initiated before call.
Alejandro Luebs3b149962016-04-01 13:54:36 -070091 * - q_noise : Q value of the noise estimate, which is the number of
92 * bits that it needs to be right-shifted to be
93 * normalized.
Alejandro Luebsfa639f02016-02-09 11:24:32 -080094 *
95 * Return value : Pointer to the noise estimate per frequency bin.
96 * Returns NULL if the input is a NULL pointer or an
97 * uninitialized instance.
98 */
Alejandro Luebs3b149962016-04-01 13:54:36 -070099const uint32_t* WebRtcNsx_noise_estimate(const NsxHandle* nsxInst,
100 int* q_noise);
Alejandro Luebsfa639f02016-02-09 11:24:32 -0800101
102/* Returns the number of frequency bins, which is the length of the noise
103 * estimate for example.
104 *
105 * Return value : Number of frequency bins.
106 */
107size_t WebRtcNsx_num_freq();
108
niklase@google.com470e71d2011-07-07 08:21:25 +0000109#ifdef __cplusplus
110}
111#endif
112
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200113#endif // MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_