Dear Community,
I have got it to work now.
However, sound is very noisy. It seems that it is overflowing my DAC.
We use a 10-bit DAC and it seems that Speex is decoding values to a 16-bit PCM
buffer.
Looking at the decoded buffer, I can see values very close 0 (some negative
ones, some positive ones, but very close to 0).
Is there any proper way to rescale decoded samples from 16-bit to 8-bit (or
10-bit at most)?
Thank you!
[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.
De: Mauricio Cirelli
Enviada em: ter?a-feira, 24 de junho de 2014 15:23
Para: 'speex-dev at xiph.org'
Assunto: Speex Decoding Issue
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
speex_bits_init(&bits);
dec_state = speex_decoder_init(&speex_nb_mode);
// Configures the output timer to generate IRQs every <periodMicroSec>
microseconds
pstAudioDriverInterface->configure_output_timer(periodMicroSec);
// Configures the DAC for audio playback
pstAudioDriverInterface->configure_dac(pstAudioBuffer->u.spx->dwSampleRate);
// Playback loop, for each packet in the List
for(idx = 0; idx < pstAudioBuffer->u.spx->dwTotalChunks; idx++)
{
speex_bits_reset(&bits);
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
speex_bits_destroy(&bits);
speex_decoder_destroy(dec_state);
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/20140625/41e7e9a5/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/20140625/41e7e9a5/attachment-0001.jpg