2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-25 19:21:13 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "typedefs.h" // NOLINT(build/include)
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
typedef struct NsHandleT NsHandle;
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
2015-06-10 21:43:36 +02:00
|
|
|
* This function creates an instance of the floating point Noise Suppression.
|
2011-07-07 08:21:25 +00:00
|
|
|
*/
|
2015-06-10 21:43:36 +02:00
|
|
|
NsHandle* WebRtcNs_Create();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/*
|
2012-07-12 21:00:43 +00:00
|
|
|
* This function frees the dynamic memory of a specified noise suppression
|
2011-07-07 08:21:25 +00:00
|
|
|
* instance.
|
|
|
|
|
*
|
|
|
|
|
* Input:
|
|
|
|
|
* - NS_inst : Pointer to NS instance that should be freed
|
|
|
|
|
*/
|
2015-04-10 07:56:57 +02:00
|
|
|
void WebRtcNs_Free(NsHandle* NS_inst);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/*
|
2012-07-12 21:00:43 +00:00
|
|
|
* This function initializes a NS instance and has to be called before any other
|
|
|
|
|
* processing is made.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Input:
|
|
|
|
|
* - NS_inst : Instance that should be initialized
|
|
|
|
|
* - fs : sampling frequency
|
|
|
|
|
*
|
|
|
|
|
* Output:
|
|
|
|
|
* - NS_inst : Initialized instance
|
|
|
|
|
*
|
|
|
|
|
* Return value : 0 - Ok
|
|
|
|
|
* -1 - Error
|
|
|
|
|
*/
|
Revert 7297 "Remove the different block lengths in ns_core"
> Remove the different block lengths in ns_core
>
> This CL has bit-exact output.
>
> What it does:
> * Remove the blockLen10Ms, as it is hardcoded to be equal to blockLen.
> * This makes outLen to be always zero, so it can be removed too.
> * It also avoids the need to have an outBuf, because it is not used, so it is also removed
> * Replaced blockLen10Ms by blockLen everywhere, since they were hardcoded to be equal.
> * We don't need to check if outLen is zero, because it always is, so it was removed.
> * Of course, the outBuf needs no initial set or copying around, because it is not used.
>
> BUG=webrtc:3811
> R=bjornv@webrtc.org, kwiberg@webrtc.org
>
> Review URL: https://webrtc-codereview.appspot.com/30539004
TBR=aluebs@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/26629004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7306 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-09-26 14:33:08 +00:00
|
|
|
int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This changes the aggressiveness of the noise suppression method.
|
|
|
|
|
*
|
|
|
|
|
* Input:
|
2012-07-12 21:00:43 +00:00
|
|
|
* - NS_inst : Noise suppression instance.
|
2011-07-07 08:21:25 +00:00
|
|
|
* - mode : 0: Mild, 1: Medium , 2: Aggressive
|
|
|
|
|
*
|
|
|
|
|
* Output:
|
2012-07-12 21:00:43 +00:00
|
|
|
* - NS_inst : Updated instance.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Return value : 0 - Ok
|
|
|
|
|
* -1 - Error
|
|
|
|
|
*/
|
2011-10-05 23:36:01 +00:00
|
|
|
int WebRtcNs_set_policy(NsHandle* NS_inst, int mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-09-18 09:54:06 +00:00
|
|
|
/*
|
|
|
|
|
* This functions estimates the background noise for the inserted speech frame.
|
|
|
|
|
* The input and output signals should always be 10ms (80 or 160 samples).
|
|
|
|
|
*
|
|
|
|
|
* Input
|
|
|
|
|
* - NS_inst : Noise suppression instance.
|
|
|
|
|
* - spframe : Pointer to speech frame buffer for L band
|
|
|
|
|
*
|
|
|
|
|
* Output:
|
|
|
|
|
* - NS_inst : Updated NS instance
|
|
|
|
|
*/
|
2014-12-10 19:30:57 +00:00
|
|
|
void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This functions does Noise Suppression for the inserted speech frame. The
|
|
|
|
|
* input and output signals should always be 10ms (80 or 160 samples).
|
|
|
|
|
*
|
|
|
|
|
* Input
|
2012-07-12 21:00:43 +00:00
|
|
|
* - NS_inst : Noise suppression instance.
|
2014-12-10 19:30:57 +00:00
|
|
|
* - spframe : Pointer to speech frame buffer for each band
|
|
|
|
|
* - num_bands : Number of bands
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Output:
|
|
|
|
|
* - NS_inst : Updated NS instance
|
2014-12-10 19:30:57 +00:00
|
|
|
* - outframe : Pointer to output frame for each band
|
2011-07-07 08:21:25 +00:00
|
|
|
*/
|
2014-12-10 19:30:57 +00:00
|
|
|
void WebRtcNs_Process(NsHandle* NS_inst,
|
|
|
|
|
const float* const* spframe,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t num_bands,
|
2014-12-10 19:30:57 +00:00
|
|
|
float* const* outframe);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-07-12 21:00:43 +00:00
|
|
|
/* Returns the internally used prior speech probability of the current frame.
|
|
|
|
|
* There is a frequency bin based one as well, with which this should not be
|
|
|
|
|
* confused.
|
|
|
|
|
*
|
|
|
|
|
* Input
|
|
|
|
|
* - handle : Noise suppression instance.
|
|
|
|
|
*
|
|
|
|
|
* Return value : Prior speech probability in interval [0.0, 1.0].
|
|
|
|
|
* -1 - NULL pointer or uninitialized instance.
|
|
|
|
|
*/
|
|
|
|
|
float WebRtcNs_prior_speech_probability(NsHandle* handle);
|
|
|
|
|
|
2016-02-09 11:24:32 -08:00
|
|
|
/* Returns a pointer to the noise estimate per frequency bin. The number of
|
|
|
|
|
* frequency bins can be provided using WebRtcNs_num_freq().
|
|
|
|
|
*
|
|
|
|
|
* Input
|
|
|
|
|
* - handle : Noise suppression instance.
|
|
|
|
|
*
|
|
|
|
|
* Return value : Pointer to the noise estimate per frequency bin.
|
|
|
|
|
* Returns NULL if the input is a NULL pointer or an
|
|
|
|
|
* uninitialized instance.
|
|
|
|
|
*/
|
|
|
|
|
const float* WebRtcNs_noise_estimate(const NsHandle* handle);
|
|
|
|
|
|
|
|
|
|
/* Returns the number of frequency bins, which is the length of the noise
|
|
|
|
|
* estimate for example.
|
|
|
|
|
*
|
|
|
|
|
* Return value : Number of frequency bins.
|
|
|
|
|
*/
|
|
|
|
|
size_t WebRtcNs_num_freq();
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_NS_NOISE_SUPPRESSION_H_
|