<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:12pt;font-family:Arial">
<p>Hi all,</p>
<p>i use speex preprocessor features in this way:</p>
<p></p>
<p>===================================</p>
<p>#define NN 160 /* 20msec di audio */</p>
<p>...</p>
<p> int         tbc=0,c,d,ret;</p>
<p> spx_int16_t TEMP_Buffer[NN];</p>
<p> char DLECODE;</p>
<p> /* Inizializza il preprocessore Speex se non inizializzato */</p>
<p> if(Modem->speex_pp_state == NULL) {</p>
<p>        Modem->speex_pp_state = speex_preprocess_state_init(NN,AUDIO_SAMPLERATE);</p>
<p> }</p>
<p> /* Modifica i parametri di Speex */</p>
<p> c = Modem->denoise;</p>
<p> speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_DENOISE, &c);</p>
<p> c = Modem->agc;</p>
<p> speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_AGC, &c);</p>
<p> if(Modem->agc) {</p>
<p>        float t;</p>
<p>        t = Modem->agc_level * 3276;</p>
<p>        speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &t);</p>
<p> }</p>
<p> c = Modem->vox;</p>
<p> speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_VAD, &c); </p>
<p> /* vai */</p>
<p> for(c=0;c<Modem->buffer_size;c++) {</p>
<p> if((Modem->buffer[c] == 0x10)&&(Modem->buffer[c+1] == 0x10)) { /* DLE */</p>
<p>         c+=2;</p>
<p>         DLECODE=Modem->buffer[c];</p>
<p>          LOG_Write(LOG_DEBUG,"[%s:%d] <DLE> %c on Line %d\n",__FILE__,__LINE__,DLECODE,Modem->id);</p>
<p>        } else {</p>
<p>         /* I dati audio vengono convertiti da 8 bit unsigned a 16 bit signed */</p>
<p>         TEMP_Buffer[tbc] = (spx_int16_t)((int)Modem->buffer[c] << 8) - 32640; </p>
<p>         if((Modem->agc == 0)&&(Modem->agc_level != 5)) { /* Se AGC disabilitato, usa l'agc_level come GAIN (5 == 0) */</p>
<p>                if(Modem->agc_level < 5) { /* Attenua */</p>
<p>                 TEMP_Buffer[tbc] = TEMP_Buffer[tbc] / ( 5 - Modem->agc_level);</p>
<p>                } else {</p>
<p>                 TEMP_Buffer[tbc] = TEMP_Buffer[tbc] * ((Modem->agc_level - 5) + 1);                </p>
<p>                }                 </p>
<p>         }         </p>
<p>         tbc++;</p>
<p>         if((tbc > NN)||(c == Modem->buffer_size)) {</p>
<p>                 ret = speex_preprocess(Modem->speex_pp_state, TEMP_Buffer, NULL); </p>
<p>                if(ret > 0) {</p>
<p>                 Modem->trigger++;</p>
<p>                } else if(Modem->trigger > 0) {</p>
<p>                 Modem->trigger--;</p>
<p>                }</p>
<p>                if(Modem->is_onair) {</p>
<p>                 Modem->trigger = Modem->trigger_high;</p>
<p>                 /* Se siamo ON AIR, colleziona i dati audio VALIDI in un buffer separato */</p>
<p>                 for(d=0;d<tbc;d++) {</p>
<p>                        Modem->audiobuffer[Modem->audio_count] = TEMP_Buffer[d];</p>
<p>                        Modem->audio_count++; </p>
<p>                 } </p>
<p>                }</p>
<p>                tbc = 0;</p>
<p>                bzero(&TEMP_Buffer,NN);</p>
<p>         } </p>
<p>===============================================</p>
<p></p>
<p>As you can image i use speex to clean and elaborate audio from a voice modem. All work correctly BUT i've a ugly "noise" in the output sound data. There's some hints that i've missed ?</p>
<p></p>
<p>Thanks ! Oz</p>
<p></p>
<p>-- </p>
<p>----</p>
<p>O-Zone ! No (C) 2005</p>
<p>WEB @ http://www.zerozone.it</p>
<p>HOBBY @ http://peggy.altervista.org</p>
<p>Call me with FWD: 692329</p>
<p></p>
</body></html>