blob: 8018118b60065f3cb422907f1011f5504b641cc9 [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
Henrik Kjellander9b72af92015-11-11 20:16:11 +010011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Peter Kastingdce40cf2015-08-24 14:52:23 -070014#include <stddef.h>
15
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000016#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
18typedef struct NsHandleT NsHandle;
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 floating point Noise Suppression.
niklase@google.com470e71d2011-07-07 08:21:25 +000026 */
Bjorn Volcker9345e862015-06-10 21:43:36 +020027NsHandle* WebRtcNs_Create();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29/*
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000030 * This function frees the dynamic memory of a specified noise suppression
niklase@google.com470e71d2011-07-07 08:21:25 +000031 * instance.
32 *
33 * Input:
34 * - NS_inst : 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 WebRtcNs_Free(NsHandle* NS_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38/*
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000039 * This function initializes a NS instance and has to be called before any other
40 * processing is made.
niklase@google.com470e71d2011-07-07 08:21:25 +000041 *
42 * Input:
43 * - NS_inst : Instance that should be initialized
44 * - fs : sampling frequency
45 *
46 * Output:
47 * - NS_inst : Initialized instance
48 *
49 * Return value : 0 - Ok
50 * -1 - Error
51 */
aluebs@webrtc.org50883772014-09-26 14:33:08 +000052int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000053
54/*
55 * This changes the aggressiveness of the noise suppression method.
56 *
57 * Input:
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000058 * - NS_inst : Noise suppression instance.
niklase@google.com470e71d2011-07-07 08:21:25 +000059 * - mode : 0: Mild, 1: Medium , 2: Aggressive
60 *
61 * Output:
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000062 * - NS_inst : Updated instance.
niklase@google.com470e71d2011-07-07 08:21:25 +000063 *
64 * Return value : 0 - Ok
65 * -1 - Error
66 */
kma@webrtc.orgaf57de02011-10-05 23:36:01 +000067int WebRtcNs_set_policy(NsHandle* NS_inst, int mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000068
aluebs@webrtc.orgfda2c2e2014-09-18 09:54:06 +000069/*
70 * This functions estimates the background noise for the inserted speech frame.
71 * The input and output signals should always be 10ms (80 or 160 samples).
72 *
73 * Input
74 * - NS_inst : Noise suppression instance.
75 * - spframe : Pointer to speech frame buffer for L band
76 *
77 * Output:
78 * - NS_inst : Updated NS instance
aluebs@webrtc.orgfda2c2e2014-09-18 09:54:06 +000079 */
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000080void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe);
niklase@google.com470e71d2011-07-07 08:21:25 +000081
82/*
83 * This functions does Noise Suppression for the inserted speech frame. The
84 * input and output signals should always be 10ms (80 or 160 samples).
85 *
86 * Input
bjornv@webrtc.org08329f42012-07-12 21:00:43 +000087 * - NS_inst : Noise suppression instance.
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000088 * - spframe : Pointer to speech frame buffer for each band
89 * - num_bands : Number of bands
niklase@google.com470e71d2011-07-07 08:21:25 +000090 *
91 * Output:
92 * - NS_inst : Updated NS instance
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000093 * - outframe : Pointer to output frame for each band
niklase@google.com470e71d2011-07-07 08:21:25 +000094 */
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000095void WebRtcNs_Process(NsHandle* NS_inst,
96 const float* const* spframe,
Peter Kastingdce40cf2015-08-24 14:52:23 -070097 size_t num_bands,
aluebs@webrtc.orgc5ebbd92014-12-10 19:30:57 +000098 float* const* outframe);
niklase@google.com470e71d2011-07-07 08:21:25 +000099
bjornv@webrtc.org08329f42012-07-12 21:00:43 +0000100/* Returns the internally used prior speech probability of the current frame.
101 * There is a frequency bin based one as well, with which this should not be
102 * confused.
103 *
104 * Input
105 * - handle : Noise suppression instance.
106 *
107 * Return value : Prior speech probability in interval [0.0, 1.0].
108 * -1 - NULL pointer or uninitialized instance.
109 */
110float WebRtcNs_prior_speech_probability(NsHandle* handle);
111
niklase@google.com470e71d2011-07-07 08:21:25 +0000112#ifdef __cplusplus
113}
114#endif
115
Henrik Kjellander9b72af92015-11-11 20:16:11 +0100116#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_