vijender reddy
2010-Apr-05  10:31 UTC
[Speex-dev] Regarding problem with encoding / decoding
Hi, Tank you for your reply. I have tried the sample programs given the manual and done encoding and decoding a wave file. That is working fine. I have already read the manual and API reference. But this problem did not occured with the wave file encoding/decoding. While capturing the data from MIC and encoding/decoding is giving this problem. Thanks and Regards, Vijender Reddy, ----- Original Message ----- From: Jean-Marc Valin <jean-marc.valin at usherbrooke.ca> Date: Thursday, April 1, 2010 3:41 pm Subject: Re: [Speex-dev] Regarding problem with encoding / decoding To: vijender reddy <vijender at adrin.res.in> Cc: speex-dev at xiph.org> Start from the sample encoder/decoder in the manual. > > Jean-Marc > > On 2010-04-01 05:12, vijender reddy wrote: > > Hi, > > > > I am new to speex library. I am doing project in VC++. My project > details are, > > I have to capture voice from mic and encode it then decode and play. > > I am capturing the voice and storing in a buffer from there i am > reading frame by frame ( 160 bytes) . These bytes i am converting to > short int then calling speex_encode-int(). The output buffer i am > passing to doder speex_decode_int() function. with out encode and > decoding the program working perfectly i am able listen the voice. > > > > After decoding if i play the data in the buffer. I am not able to > listen the voice , noise is dominating the voice. I am hearing like > the voice itself merged with noise. I used denoising and ADC functions > but no use. Please help me.. > > > > > > Thanks and Regards, > > Vijender Reddy, > > > > _______________________________________________ > > Speex-dev mailing list > > Speex-dev at xiph.org > > http://lists.xiph.org/mailman/listinfo/speex-dev > > > >
vijender reddy
2010-Apr-20  05:20 UTC
[Speex-dev] Regarding problem with encoding / decoding
Hi,
I got the following problem with speex. Could you help me to resolve the 
following issue.
Description: I am taking speech input from MIC storing in a buffer after that i
will encode by using speex then decoding and sending to output(speakers).
it is small demo project of speech encoding/decoding in VC++.
I am reading the data from buffer in the following way where data is short[]
type and buffer is char[].
        for(int j=0;j < 160;j++)
	     data[j]= (buffer[i+j]<<8)^0x8000;
        speex_encode_int(state, data, &bits);
	  nbBytes = speex_bits_write(&bits, cbits, 200);
            outbuffer[k]= (char) nbBytes;  // Storing length of encoded data
first in outbuffer
            int writ= k+nbBytes,m=0;
        	for(k=k+1;k<= writ; k++)        // storing the encoded data in
outbuffer
		   outbuffer[k]= cbits[m++];
 I am repeatedly doing until the input buffer is over. The encoded data is
storing in outbuffer[].
In decoding:
I am reading first byte stored in size variable then reading the data.
             
            psize = buffer[i];     //size of the encoded data frame
		
		j=0;
		for(int k=i+1; k <= i+psize;k++)
			cbits[j++]= buffer[k];           //Reading encoded data
     speex_bits_read_from(&bits, cbits, psize);
		/*Decode the frame*/
          speex_decode_int(state, &bits, data);
         for(k=0;k< 160; k++)
              outbuffer[m++]= data[k];    //Storing the decoded frame in char
outbuffer[]
After completion of all encoded data. If i play the outbuffer
i am getting full noise. I am hearing voice with very low sound, noise is
dominating the speech.
I didn't talk also i am hearing lot of noise from speakers after decoding. 
I used following preprocess functions also but no use.
int noise_sup=2; // from 2 to 40 and -ve numbers also no use
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS,
&noise_sup);
int noise= 1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS,
&noise);
int denoise=1;
speex_preprocess_ctl(preprocess_state, SPEEX_PREPROCESS_SET_DENOISE,
&denoise);
int agc=1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_AGC,&agc);
speex_preprocess_run(preprocess_state,data);
            
Please help me. 
Thanks and Regards,
Vijender Reddy,
Sci/Engr-SC,
Advaced Data processing Research Institute,
#203,Akber Road,Manovikas nagar,
Secunderabad-500009,A.P.,India.
Ph. no: (040) 27781232
Please ignore this mail if it is duplicate
Hi,
I got the following problem with speex. Could you please help me to resolve the 
following issue.
Description: I am taking speech input from MIC storing in a buffer after that i
will encode by using speex then decoding and sending to output(speakers).
it is small demo project of speech encoding/decoding in VC++.
I am reading the data from buffer in the following way where data is short[]
type and buffer is char[].
        for(int j=0;j < 160;j++)
             data[j]= (buffer[i+j]<<8)^0x8000;
        speex_encode_int(state, data, &bits);
          nbBytes = speex_bits_write(&bits, cbits, 200);
            outbuffer[k]= (char) nbBytes;  // Storing length of encoded data
first in outbuffer
            int writ= k+nbBytes,m=0;
         for(k=k+1;k<= writ; k++)        // storing the encoded data in
outbuffer
                   outbuffer[k]= cbits[m++];
 I am repeatedly doing until the input buffer is over. The encoded data is
storing in outbuffer[].
In decoding:
I am reading first byte stored in size variable then reading the data.
            
            psize = buffer[i];     //size of the encoded data frame
        
         j=0;
         for(int k=i+1; k <= i+psize;k++)
                 cbits[j++]= buffer[k];           //Reading encoded data
     speex_bits_read_from(&bits, cbits, psize);
         /*Decode the frame*/
          speex_decode_int(state, &bits, data);
         for(k=0;k< 160; k++)
              outbuffer[m++]= data[k];    //Storing the decoded frame in char
outbuffer[]
After completion of all encoded data. If i play the outbuffer
i am getting full noise. I am hearing voice with very low sound, noise is
dominating the speech.
I didn't talk also i am hearing lot of noise from speakers after decoding. 
I used following preprocess functions also but no use.
int noise_sup=2; // from 2 to 40 and -ve numbers also no use
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS,
&noise_sup);
int noise= 1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_NOISE_SUPPRESS,
&noise);
int denoise=1;
speex_preprocess_ctl(preprocess_state, SPEEX_PREPROCESS_SET_DENOISE,
&denoise);
int agc=1;
speex_preprocess_ctl(preprocess_state,SPEEX_PREPROCESS_SET_AGC,&agc);
speex_preprocess_run(preprocess_state,data);
           
Please help me. 
Thanks & regards,
Vijender