[Speex-dev] Speex Decoding Issue

Mauricio Cirelli mauricio.cirelli at quantatec.com.br
Tue Jun 24 11:22:56 PDT 2014

Dear Speex community,

I am having problems to get the Speex Decoding API to work properly in our project.

I am working in an embedded project with a very limited RAM and Flash memory and would like to use Speex encoded files to save memory while having good voice sounds in our speakers.
I have developed a Windows-based tool to convert WAV files to Speex files in packets of 160 bytes (we are using only the narrowband mode). Those packets are written into a C file which we compile and embed in our custom hardware (ARM-based microcontroller). I am attaching one of such C source files with speex encoded bytes for reference, which consists of 61 encoded packets. I am also attaching the original WAV file.

In our application, we are trying to decode the embedded list of packets and playback using the microcontroller DA converter. Here I paste the function which handles this task:

  SpeexBits bits;
  void *dec_state;
  int idx = 0;
  // 160 decoded "samples"
  short output_frame[SPEEX_NB_FRAME_SIZE];

  // Getting the timer period from the Sample Rate of the original WAV file
  float periodSec = 1.0f / (float) pstAudioBuffer->u.spx->dwSampleRate;
  unsigned int periodMicroSec = (unsigned int) (periodSec * 1000000.0f);

  // Initialization
  dec_state = speex_decoder_init(&speex_nb_mode);

  // Configures the output timer to generate IRQs every <periodMicroSec> microseconds

  // Configures the DAC for audio playback

  // Playback loop, for each packet in the List
  for(idx = 0; idx < pstAudioBuffer->u.spx->dwTotalChunks; idx++)
    speex_bits_read_from(&bits, pstAudioBuffer->u.spx->pstChunkList[idx]->pbyBuffer, pstAudioBuffer->u.spx->pstChunkList[idx]->dwChunkSize);
    while(speex_decode_int(dec_state, &bits, output_frame) != -1);
    // Sends each decoded sample to the DAC at the specified TIMER IRQ period
    pstAudioDriverInterface->write_buffer(output_frame, sizeof(output_frame));

  // Freeing memory

Everything I get is a very noise "hiss" output. When we playback a RAW PCM file or a WAV file in our hardware, it is perfectly clear and sounds good. However, due to hardware limitations, we cannot proceed with raw WAV files.

Any help would be very appreciated.

Thanks in advance.

[Descrição: Mauricio Cirelli]

AVISO LEGAL: As informações contidas nesta mensagem e nos arquivos anexados são para uso restrito, sendo seu sigilo protegido por lei, não havendo ainda garantia legal quanto à integridade de seu conteúdo. Caso não seja o destinatário, por favor, desconsidere essa mensagem. O uso indevido dessas informações será tratado conforme as normas da empresa e a legislação em vigor.

LEGAL ADVICE: The information in this e-mail and in the attached files are confidential and may be legally privileged. There is no legal guarantee as regards the reliability of said information. If you are not the intended recipient please disregard the content thereof. The unduly use of this information is subject to the rules of the company and the legislation in force.

P Economize papel, só imprima em caso de real necessidade, a natureza agradece.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20140624/a9ed061d/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 9784 bytes
Desc: image001.jpg
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20140624/a9ed061d/attachment-0001.jpg 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: youGotMail_spx.c
Url: http://lists.xiph.org/pipermail/speex-dev/attachments/20140624/a9ed061d/attachment-0001.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: youGotmail.wav
Type: audio/wav
Size: 9946 bytes
Desc: youGotmail.wav
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20140624/a9ed061d/attachment-0001.bin 

More information about the Speex-dev mailing list