[Speex-dev] Noise :-(

Michele "O-Zone" Pinassi liste at zerozone.it
Thu Sep 22 00:58:13 PDT 2005


Hi all,
i use speex preprocessor features in this way:

===================================
#define NN 160 /* 20msec di audio */
...
    int 	tbc=0,c,d,ret;
    spx_int16_t TEMP_Buffer[NN];
    char DLECODE;
    /* Inizializza il preprocessore Speex se non inizializzato */
    if(Modem->speex_pp_state == NULL) {
	Modem->speex_pp_state = speex_preprocess_state_init(NN,AUDIO_SAMPLERATE);
    }
    /* Modifica i parametri di Speex */
    c = Modem->denoise;
    speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_DENOISE, &c);
    c = Modem->agc;
    speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_AGC, &c);
    if(Modem->agc) {
	float t;
	t = Modem->agc_level * 3276;
	speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &t);
    }
    c = Modem->vox;
    speex_preprocess_ctl(Modem->speex_pp_state, SPEEX_PREPROCESS_SET_VAD, &c); 
    /* vai */
    for(c=0;c<Modem->buffer_size;c++) {
        if((Modem->buffer[c] == 0x10)&&(Modem->buffer[c+1] == 0x10)) { /* DLE */
	    c+=2;
	    DLECODE=Modem->buffer[c];
    	    LOG_Write(LOG_DEBUG,"[%s:%d] <DLE> %c on Line %d\n",__FILE__,__LINE__,DLECODE,Modem->id);
	} else {
	    /* I dati audio vengono convertiti da 8 bit unsigned a 16 bit signed */
	    TEMP_Buffer[tbc] = (spx_int16_t)((int)Modem->buffer[c] << 8) - 32640; 
	    if((Modem->agc == 0)&&(Modem->agc_level != 5)) { /* Se AGC disabilitato, usa l'agc_level come GAIN (5 == 0) */
		if(Modem->agc_level < 5) { /* Attenua */
		    TEMP_Buffer[tbc] = TEMP_Buffer[tbc] / ( 5 - Modem->agc_level);
		} else {
		    TEMP_Buffer[tbc] = TEMP_Buffer[tbc] * ((Modem->agc_level - 5) + 1);		
		}		    
	    }	    
	    tbc++;
	    if((tbc > NN)||(c == Modem->buffer_size)) {
    		ret = speex_preprocess(Modem->speex_pp_state, TEMP_Buffer, NULL); 
		if(ret > 0) {
		    Modem->trigger++;
		} else if(Modem->trigger > 0) {
		    Modem->trigger--;
		}
		if(Modem->is_onair) {
		    Modem->trigger = Modem->trigger_high;
		    /* Se siamo ON AIR, colleziona i dati audio VALIDI in un buffer separato */
		    for(d=0;d<tbc;d++) {
			Modem->audiobuffer[Modem->audio_count] = TEMP_Buffer[d];
			Modem->audio_count++; 
		    } 
		}
		tbc = 0;
		bzero(&TEMP_Buffer,NN);
	    } 
===============================================

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 ?

Thanks ! Oz

-- 
----
O-Zone ! No (C) 2005
WEB @ http://www.zerozone.it
HOBBY @ http://peggy.altervista.org
Call me with FWD: 692329
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20050922/c59ab93d/attachment.htm


More information about the Speex-dev mailing list