blob: 972784e5817380fce0c0b7b129f1d0ac6f5737d0 [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>
Niels Möllera12c42a2018-07-25 16:05:48 +020015#include <stdint.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17typedef struct NsxHandleT NsxHandle;
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
Bjorn Volcker9345e862015-06-10 21:43:36 +020024 * This function creates an instance of the fixed point Noise Suppression.
niklase@google.com470e71d2011-07-07 08:21:25 +000025 */
Mirko Bonadeid7573562018-03-19 16:23:48 +010026NsxHandle* WebRtcNsx_Create(void);
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28/*
29 * This function frees the dynamic memory of a specified Noise Suppression
30 * instance.
31 *
32 * Input:
33 * - nsxInst : Pointer to NS instance that should be freed
niklase@google.com470e71d2011-07-07 08:21:25 +000034 */
Bjorn Volckerf6a99e62015-04-10 07:56:57 +020035void WebRtcNsx_Free(NsxHandle* nsxInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37/*
38 * This function initializes a NS instance
39 *
40 * Input:
41 * - nsxInst : Instance that should be initialized
42 * - fs : sampling frequency
43 *
44 * Output:
45 * - nsxInst : Initialized instance
46 *
47 * Return value : 0 - Ok
48 * -1 - Error
49 */
pbos@webrtc.orgb7192b82013-04-10 07:50:54 +000050int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000051
52/*
53 * This changes the aggressiveness of the noise suppression method.
54 *
55 * Input:
56 * - nsxInst : Instance that should be initialized
57 * - mode : 0: Mild, 1: Medium , 2: Aggressive
58 *
59 * Output:
60 * - nsxInst : Initialized instance
61 *
62 * Return value : 0 - Ok
63 * -1 - Error
64 */
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000065int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000066
67/*
68 * This functions does noise suppression for the inserted speech frame. The
69 * input and output signals should always be 10ms (80 or 160 samples).
70 *
71 * Input
72 * - nsxInst : NSx instance. Needs to be initiated before call.
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000073 * - speechFrame : Pointer to speech frame buffer for each band
74 * - num_bands : Number of bands
niklase@google.com470e71d2011-07-07 08:21:25 +000075 *
76 * Output:
77 * - nsxInst : Updated NSx instance
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000078 * - outFrame : Pointer to output frame for each band
niklase@google.com470e71d2011-07-07 08:21:25 +000079 */
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000080void WebRtcNsx_Process(NsxHandle* nsxInst,
81 const short* const* speechFrame,
82 int num_bands,
83 short* const* outFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000084
Alejandro Luebsfa639f02016-02-09 11:24:32 -080085/* Returns a pointer to the noise estimate per frequency bin. The number of
86 * frequency bins can be provided using WebRtcNsx_num_freq().
87 *
88 * Input
89 * - nsxInst : NSx instance. Needs to be initiated before call.
Alejandro Luebs3b149962016-04-01 13:54:36 -070090 * - q_noise : Q value of the noise estimate, which is the number of
91 * bits that it needs to be right-shifted to be
92 * normalized.
Alejandro Luebsfa639f02016-02-09 11:24:32 -080093 *
94 * Return value : Pointer to the noise estimate per frequency bin.
95 * Returns NULL if the input is a NULL pointer or an
96 * uninitialized instance.
97 */
Alejandro Luebs3b149962016-04-01 13:54:36 -070098const uint32_t* WebRtcNsx_noise_estimate(const NsxHandle* nsxInst,
99 int* q_noise);
Alejandro Luebsfa639f02016-02-09 11:24:32 -0800100
101/* Returns the number of frequency bins, which is the length of the noise
102 * estimate for example.
103 *
104 * Return value : Number of frequency bins.
105 */
Mirko Bonadeid7573562018-03-19 16:23:48 +0100106size_t WebRtcNsx_num_freq(void);
Alejandro Luebsfa639f02016-02-09 11:24:32 -0800107
niklase@google.com470e71d2011-07-07 08:21:25 +0000108#ifdef __cplusplus
109}
110#endif
111
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200112#endif // MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_