ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 /* Copyright (C) 2003 Epic Games
TMBOY 47:9e361da97763 2 Written by Jean-Marc Valin */
TMBOY 47:9e361da97763 3 /**
TMBOY 47:9e361da97763 4 * @file speex_preprocess.h
TMBOY 47:9e361da97763 5 * @brief Speex preprocessor. The preprocess can do noise suppression,
TMBOY 47:9e361da97763 6 * residual echo suppression (after using the echo canceller), automatic
TMBOY 47:9e361da97763 7 * gain control (AGC) and voice activity detection (VAD).
TMBOY 47:9e361da97763 8 */
TMBOY 47:9e361da97763 9 /*
TMBOY 47:9e361da97763 10 Redistribution and use in source and binary forms, with or without
TMBOY 47:9e361da97763 11 modification, are permitted provided that the following conditions are
TMBOY 47:9e361da97763 12 met:
TMBOY 47:9e361da97763 13
TMBOY 47:9e361da97763 14 1. Redistributions of source code must retain the above copyright notice,
TMBOY 47:9e361da97763 15 this list of conditions and the following disclaimer.
TMBOY 47:9e361da97763 16
TMBOY 47:9e361da97763 17 2. Redistributions in binary form must reproduce the above copyright
TMBOY 47:9e361da97763 18 notice, this list of conditions and the following disclaimer in the
TMBOY 47:9e361da97763 19 documentation and/or other materials provided with the distribution.
TMBOY 47:9e361da97763 20
TMBOY 47:9e361da97763 21 3. The name of the author may not be used to endorse or promote products
TMBOY 47:9e361da97763 22 derived from this software without specific prior written permission.
TMBOY 47:9e361da97763 23
TMBOY 47:9e361da97763 24 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
TMBOY 47:9e361da97763 25 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
TMBOY 47:9e361da97763 26 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
TMBOY 47:9e361da97763 27 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
TMBOY 47:9e361da97763 28 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
TMBOY 47:9e361da97763 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
TMBOY 47:9e361da97763 30 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
TMBOY 47:9e361da97763 31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
TMBOY 47:9e361da97763 32 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
TMBOY 47:9e361da97763 33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
TMBOY 47:9e361da97763 34 POSSIBILITY OF SUCH DAMAGE.
TMBOY 47:9e361da97763 35 */
TMBOY 47:9e361da97763 36
TMBOY 47:9e361da97763 37 #ifndef SPEEX_PREPROCESS_H
TMBOY 47:9e361da97763 38 #define SPEEX_PREPROCESS_H
TMBOY 47:9e361da97763 39 /** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor
TMBOY 47:9e361da97763 40 * This is the Speex preprocessor. The preprocess can do noise suppression,
TMBOY 47:9e361da97763 41 * residual echo suppression (after using the echo canceller), automatic
TMBOY 47:9e361da97763 42 * gain control (AGC) and voice activity detection (VAD).
TMBOY 47:9e361da97763 43 * @{
TMBOY 47:9e361da97763 44 */
TMBOY 47:9e361da97763 45
TMBOY 47:9e361da97763 46 #include "speex/speex_types.h"
TMBOY 47:9e361da97763 47
TMBOY 47:9e361da97763 48 #ifdef __cplusplus
TMBOY 47:9e361da97763 49 extern "C" {
TMBOY 47:9e361da97763 50 #endif
TMBOY 47:9e361da97763 51
TMBOY 47:9e361da97763 52 /** State of the preprocessor (one per channel). Should never be accessed directly. */
TMBOY 47:9e361da97763 53 struct SpeexPreprocessState_;
TMBOY 47:9e361da97763 54
TMBOY 47:9e361da97763 55 /** State of the preprocessor (one per channel). Should never be accessed directly. */
TMBOY 47:9e361da97763 56 typedef struct SpeexPreprocessState_ SpeexPreprocessState;
TMBOY 47:9e361da97763 57
TMBOY 47:9e361da97763 58
TMBOY 47:9e361da97763 59 /** Creates a new preprocessing state. You MUST create one state per channel processed.
TMBOY 47:9e361da97763 60 * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be
TMBOY 47:9e361da97763 61 * the same value as that used for the echo canceller for residual echo cancellation to work.
TMBOY 47:9e361da97763 62 * @param sampling_rate Sampling rate used for the input.
TMBOY 47:9e361da97763 63 * @return Newly created preprocessor state
TMBOY 47:9e361da97763 64 */
TMBOY 47:9e361da97763 65 SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate);
TMBOY 47:9e361da97763 66
TMBOY 47:9e361da97763 67 /** Destroys a preprocessor state
TMBOY 47:9e361da97763 68 * @param st Preprocessor state to destroy
TMBOY 47:9e361da97763 69 */
TMBOY 47:9e361da97763 70 void speex_preprocess_state_destroy(SpeexPreprocessState *st);
TMBOY 47:9e361da97763 71
TMBOY 47:9e361da97763 72 /** Preprocess a frame
TMBOY 47:9e361da97763 73 * @param st Preprocessor state
TMBOY 47:9e361da97763 74 * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init().
TMBOY 47:9e361da97763 75 * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on.
TMBOY 47:9e361da97763 76 */
TMBOY 47:9e361da97763 77 int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x);
TMBOY 47:9e361da97763 78
TMBOY 47:9e361da97763 79 /** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/
TMBOY 47:9e361da97763 80 int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo);
TMBOY 47:9e361da97763 81
TMBOY 47:9e361da97763 82 /** Update preprocessor state, but do not compute the output
TMBOY 47:9e361da97763 83 * @param st Preprocessor state
TMBOY 47:9e361da97763 84 * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init().
TMBOY 47:9e361da97763 85 */
TMBOY 47:9e361da97763 86 void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x);
TMBOY 47:9e361da97763 87
TMBOY 47:9e361da97763 88 /** Used like the ioctl function to control the preprocessor parameters
TMBOY 47:9e361da97763 89 * @param st Preprocessor state
TMBOY 47:9e361da97763 90 * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros)
TMBOY 47:9e361da97763 91 * @param ptr Data exchanged to-from function
TMBOY 47:9e361da97763 92 * @return 0 if no error, -1 if request in unknown
TMBOY 47:9e361da97763 93 */
TMBOY 47:9e361da97763 94 int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr);
TMBOY 47:9e361da97763 95
TMBOY 47:9e361da97763 96
TMBOY 47:9e361da97763 97
TMBOY 47:9e361da97763 98 /** Set preprocessor denoiser state */
TMBOY 47:9e361da97763 99 #define SPEEX_PREPROCESS_SET_DENOISE 0
TMBOY 47:9e361da97763 100 /** Get preprocessor denoiser state */
TMBOY 47:9e361da97763 101 #define SPEEX_PREPROCESS_GET_DENOISE 1
TMBOY 47:9e361da97763 102
TMBOY 47:9e361da97763 103 /** Set preprocessor Automatic Gain Control state */
TMBOY 47:9e361da97763 104 #define SPEEX_PREPROCESS_SET_AGC 2
TMBOY 47:9e361da97763 105 /** Get preprocessor Automatic Gain Control state */
TMBOY 47:9e361da97763 106 #define SPEEX_PREPROCESS_GET_AGC 3
TMBOY 47:9e361da97763 107
TMBOY 47:9e361da97763 108 /** Set preprocessor Voice Activity Detection state */
TMBOY 47:9e361da97763 109 #define SPEEX_PREPROCESS_SET_VAD 4
TMBOY 47:9e361da97763 110 /** Get preprocessor Voice Activity Detection state */
TMBOY 47:9e361da97763 111 #define SPEEX_PREPROCESS_GET_VAD 5
TMBOY 47:9e361da97763 112
TMBOY 47:9e361da97763 113 /** Set preprocessor Automatic Gain Control level */
TMBOY 47:9e361da97763 114 #define SPEEX_PREPROCESS_SET_AGC_LEVEL 6
TMBOY 47:9e361da97763 115 /** Get preprocessor Automatic Gain Control level */
TMBOY 47:9e361da97763 116 #define SPEEX_PREPROCESS_GET_AGC_LEVEL 7
TMBOY 47:9e361da97763 117
TMBOY 47:9e361da97763 118 /** Set preprocessor dereverb state */
TMBOY 47:9e361da97763 119 #define SPEEX_PREPROCESS_SET_DEREVERB 8
TMBOY 47:9e361da97763 120 /** Get preprocessor dereverb state */
TMBOY 47:9e361da97763 121 #define SPEEX_PREPROCESS_GET_DEREVERB 9
TMBOY 47:9e361da97763 122
TMBOY 47:9e361da97763 123 /** Set preprocessor dereverb level */
TMBOY 47:9e361da97763 124 #define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10
TMBOY 47:9e361da97763 125 /** Get preprocessor dereverb level */
TMBOY 47:9e361da97763 126 #define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11
TMBOY 47:9e361da97763 127
TMBOY 47:9e361da97763 128 /** Set preprocessor dereverb decay */
TMBOY 47:9e361da97763 129 #define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12
TMBOY 47:9e361da97763 130 /** Get preprocessor dereverb decay */
TMBOY 47:9e361da97763 131 #define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13
TMBOY 47:9e361da97763 132
TMBOY 47:9e361da97763 133 /** Set probability required for the VAD to go from silence to voice */
TMBOY 47:9e361da97763 134 #define SPEEX_PREPROCESS_SET_PROB_START 14
TMBOY 47:9e361da97763 135 /** Get probability required for the VAD to go from silence to voice */
TMBOY 47:9e361da97763 136 #define SPEEX_PREPROCESS_GET_PROB_START 15
TMBOY 47:9e361da97763 137
TMBOY 47:9e361da97763 138 /** Set probability required for the VAD to stay in the voice state (integer percent) */
TMBOY 47:9e361da97763 139 #define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16
TMBOY 47:9e361da97763 140 /** Get probability required for the VAD to stay in the voice state (integer percent) */
TMBOY 47:9e361da97763 141 #define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17
TMBOY 47:9e361da97763 142
TMBOY 47:9e361da97763 143 /** Set maximum attenuation of the noise in dB (negative number) */
TMBOY 47:9e361da97763 144 #define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18
TMBOY 47:9e361da97763 145 /** Get maximum attenuation of the noise in dB (negative number) */
TMBOY 47:9e361da97763 146 #define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19
TMBOY 47:9e361da97763 147
TMBOY 47:9e361da97763 148 /** Set maximum attenuation of the residual echo in dB (negative number) */
TMBOY 47:9e361da97763 149 #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20
TMBOY 47:9e361da97763 150 /** Get maximum attenuation of the residual echo in dB (negative number) */
TMBOY 47:9e361da97763 151 #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21
TMBOY 47:9e361da97763 152
TMBOY 47:9e361da97763 153 /** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */
TMBOY 47:9e361da97763 154 #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22
TMBOY 47:9e361da97763 155 /** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */
TMBOY 47:9e361da97763 156 #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23
TMBOY 47:9e361da97763 157
TMBOY 47:9e361da97763 158 /** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */
TMBOY 47:9e361da97763 159 #define SPEEX_PREPROCESS_SET_ECHO_STATE 24
TMBOY 47:9e361da97763 160 /** Get the corresponding echo canceller state */
TMBOY 47:9e361da97763 161 #define SPEEX_PREPROCESS_GET_ECHO_STATE 25
TMBOY 47:9e361da97763 162
TMBOY 47:9e361da97763 163 /** Set maximal gain increase in dB/second (int32) */
TMBOY 47:9e361da97763 164 #define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26
TMBOY 47:9e361da97763 165
TMBOY 47:9e361da97763 166 /** Get maximal gain increase in dB/second (int32) */
TMBOY 47:9e361da97763 167 #define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27
TMBOY 47:9e361da97763 168
TMBOY 47:9e361da97763 169 /** Set maximal gain decrease in dB/second (int32) */
TMBOY 47:9e361da97763 170 #define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28
TMBOY 47:9e361da97763 171
TMBOY 47:9e361da97763 172 /** Get maximal gain decrease in dB/second (int32) */
TMBOY 47:9e361da97763 173 #define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29
TMBOY 47:9e361da97763 174
TMBOY 47:9e361da97763 175 /** Set maximal gain in dB (int32) */
TMBOY 47:9e361da97763 176 #define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30
TMBOY 47:9e361da97763 177
TMBOY 47:9e361da97763 178 /** Get maximal gain in dB (int32) */
TMBOY 47:9e361da97763 179 #define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31
TMBOY 47:9e361da97763 180
TMBOY 47:9e361da97763 181 #ifdef __cplusplus
TMBOY 47:9e361da97763 182 }
TMBOY 47:9e361da97763 183 #endif
TMBOY 47:9e361da97763 184
TMBOY 47:9e361da97763 185 /** @}*/
TMBOY 47:9e361da97763 186 #endif