[speex-dev] About reducing noise..

Ali Naqi ali at uraan.com
Mon Feb 23 21:42:33 PST 2004



Hello, 
 
When I decode a recoded sound encoded by speex, it has too much noise.
The noise is "slightly" reduced if I set the quality to 10. How do I get
rid of this noise? The code is as follows.
 
 
For encoding .
 
state = speex_encoder_init ( &speex_nb_mode );
 
tmp = 7;
speex_encoder_ctl ( state, SPEEX_SET_MODE, &tmp);
 
// set quality
tmp = 10;
speex_encoder_ctl ( state, SPEEX_SET_QUALITY, &tmp);
 
// initialize bits
speex_bits_init(&bits);
 
 
while( 1 )
{
      // read FRAME_SIZE bytes from buffer
      // convert to short
      for ( int i = 0; i < FRAME_SIZE; i++)
            in[i] = out_buffer[i];
 
      speex_bits_reset(&bits);
 
      // encode
      speex_encode ( state, in, &bits);
 
      // copy bits to an array of chars 
      nbBytes = speex_bits_write ( &bits, cbits, 200);
 
      // copy these cbits into a buffer
      CopyBuffer(pBuffer + dwLength, cbits, nbBytes);
      dwLength += nbBytes;
}
 
// uninitialize
 
For decoding .
 
SpeexBits bits;
int i, tmp;
 
state = speex_decoder_init(&speex_nb_mode);
tmp =1;
speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
 
speex_bits_init(&bits);
char temp[10];
long sizeToRead = 4;
while(1)
{
      int ret = ReadFile(file,temp, sizeToRead , &bytesRead,NULL);
      if( bytesRead == 0 )
{
            break;
      }
      nbBytes = atoi(temp);
      totalBytesRead += bytesRead;
 
      ret = ReadFile(file, cbits, nbBytes, &bytesRead, NULL);
      totalBytesRead += bytesRead;
      speex_bits_read_from(&bits, cbits, nbBytes);
      speex_decode(state, &bits, out);
      for( i=0; i <FRAME_SIZE; i++)
            buf[i] = (char)out[i];
      // write to file
WriteFile(file2, buf, FRAME_SIZE, &bytesWritten, NULL);
      totalBytesWritten+= bytesWritten;
}
 
I am using wave api for capturing and playing back sound. 
 
Please guide me in this problem.
 
Regards,
Ali Naqi Shaheen, 
 

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Speex-dev mailing list