niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | b9d7d93 | 2012-01-25 19:21:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Alejandro Luebs | fa639f0 | 2016-02-09 11:24:32 -0800 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 16 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
| 18 | typedef struct NsxHandleT NsxHandle; |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | /* |
Bjorn Volcker | 9345e86 | 2015-06-10 21:43:36 +0200 | [diff] [blame] | 25 | * This function creates an instance of the fixed point Noise Suppression. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | */ |
Bjorn Volcker | 9345e86 | 2015-06-10 21:43:36 +0200 | [diff] [blame] | 27 | NsxHandle* WebRtcNsx_Create(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
| 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | */ |
Bjorn Volcker | f6a99e6 | 2015-04-10 07:56:57 +0200 | [diff] [blame] | 36 | void WebRtcNsx_Free(NsxHandle* nsxInst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
| 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.org | b7192b8 | 2013-04-10 07:50:54 +0000 | [diff] [blame] | 51 | int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
| 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.org | af57de0 | 2011-10-05 23:36:01 +0000 | [diff] [blame] | 66 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
| 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.org | c5ebbd9 | 2014-12-10 19:30:57 +0000 | [diff] [blame] | 74 | * - speechFrame : Pointer to speech frame buffer for each band |
| 75 | * - num_bands : Number of bands |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | * |
| 77 | * Output: |
| 78 | * - nsxInst : Updated NSx instance |
aluebs@webrtc.org | c5ebbd9 | 2014-12-10 19:30:57 +0000 | [diff] [blame] | 79 | * - outFrame : Pointer to output frame for each band |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | */ |
aluebs@webrtc.org | c5ebbd9 | 2014-12-10 19:30:57 +0000 | [diff] [blame] | 81 | void WebRtcNsx_Process(NsxHandle* nsxInst, |
| 82 | const short* const* speechFrame, |
| 83 | int num_bands, |
| 84 | short* const* outFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
Alejandro Luebs | fa639f0 | 2016-02-09 11:24:32 -0800 | [diff] [blame] | 86 | /* 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 Luebs | 3b14996 | 2016-04-01 13:54:36 -0700 | [diff] [blame] | 91 | * - 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 Luebs | fa639f0 | 2016-02-09 11:24:32 -0800 | [diff] [blame] | 94 | * |
| 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 Luebs | 3b14996 | 2016-04-01 13:54:36 -0700 | [diff] [blame] | 99 | const uint32_t* WebRtcNsx_noise_estimate(const NsxHandle* nsxInst, |
| 100 | int* q_noise); |
Alejandro Luebs | fa639f0 | 2016-02-09 11:24:32 -0800 | [diff] [blame] | 101 | |
| 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 | */ |
| 107 | size_t WebRtcNsx_num_freq(); |
| 108 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | #ifdef __cplusplus |
| 110 | } |
| 111 | #endif |
| 112 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 113 | #endif // MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_X_H_ |