00001 /* Copyright (C) 2003 Epic Games 00002 Written by Jean-Marc Valin 00003 00004 File: speex_preprocess.h 00005 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions are 00009 met: 00010 00011 1. Redistributions of source code must retain the above copyright notice, 00012 this list of conditions and the following disclaimer. 00013 00014 2. Redistributions in binary form must reproduce the above copyright 00015 notice, this list of conditions and the following disclaimer in the 00016 documentation and/or other materials provided with the distribution. 00017 00018 3. The name of the author may not be used to endorse or promote products 00019 derived from this software without specific prior written permission. 00020 00021 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00022 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00023 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00027 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00028 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00029 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00030 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 struct drft_lookup; 00040 00041 typedef struct SpeexPreprocessState { 00042 int frame_size; 00043 int ps_size; 00044 int sampling_rate; 00046 /* parameters */ 00047 int denoise_enabled; 00048 int agc_enabled; 00049 float agc_level; 00050 int vad_enabled; 00051 00052 float *frame; 00053 float *ps; 00054 float *gain2; 00055 float *window; 00056 float *noise; 00057 float *old_ps; 00058 float *gain; 00059 float *prior; 00060 float *post; 00062 float *S; 00063 float *Smin; 00064 float *Stmp; 00065 float *update_prob; 00067 float *zeta; 00068 float Zpeak; 00069 float Zlast; 00070 00071 float *loudness_weight; 00073 float *echo_noise; 00074 00075 float *noise_bands; 00076 float *noise_bands2; 00077 int noise_bandsN; 00078 float *speech_bands; 00079 float *speech_bands2; 00080 int speech_bandsN; 00081 00082 float *inbuf; 00083 float *outbuf; 00085 float speech_prob; 00086 int last_speech; 00087 float loudness; 00088 float loudness2; 00089 int nb_adapt; 00090 int nb_loudness_adapt; 00091 int consec_noise; 00092 int nb_preprocess; 00093 struct drft_lookup *fft_lookup; 00095 } SpeexPreprocessState; 00096 00098 SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); 00099 00101 void speex_preprocess_state_destroy(SpeexPreprocessState *st); 00102 00104 int speex_preprocess(SpeexPreprocessState *st, float *x, float *noise); 00105 00107 void speex_preprocess_estimate_update(SpeexPreprocessState *st, float *x, float *noise); 00108 00110 int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); 00111 00112 00113 00114 #define SPEEX_PREPROCESS_SET_DENOISE 0 00115 #define SPEEX_PREPROCESS_GET_DENOISE 1 00116 00117 #define SPEEX_PREPROCESS_SET_AGC 2 00118 #define SPEEX_PREPROCESS_GET_AGC 3 00119 00120 #define SPEEX_PREPROCESS_SET_VAD 4 00121 #define SPEEX_PREPROCESS_GET_VAD 5 00122 00123 #define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 00124 #define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 00125 00126 #ifdef __cplusplus 00127 } 00128 #endif