[Speex-dev] Win CE playback error
ohjames
ohjames at singnet.com.sg
Tue Feb 22 17:37:23 PST 2005
Hi,
I have a module sampling raw PCM data on Win CE as 10ms time slice (160 bytes), mono, 8000HZ, 16 bits per sample.
Does anyone know what is the mflops for using fixed point on a Win CE compared to using floating point?
Looking at the manual,
"In practice, frame_size will correspond to 20 ms when using 8, 16, or 32 kHz sampling
rate."
for a 8 kHz sampling, the framesize should be 320 right?
But when i use
speex_encoder_ctl(enc_state,SPEEX_GET_FRAME_SIZE,&frame_size)
The framesize i got is 160.
I am trying to encode the data which is contained as an unsigned char buffer[160] as mode 2 of 5,950 bps and stored as the same data type as unsigned char array after encoding
I have managed to link the libspeex_armce.lib file successfully but have gotten garbage on playback.
I am not sure if i have done it correctly.
Below are snippets of the coding.
Any help is appreciated.
//assuming data is stored as unsigned char buffer[160];
//Trying to use Fixed Point
#define FIXED_POINT
//initialization
SpeexBits bits;
speex_bits_init(&bits);
void *enc_state;
enc_state = speex_encoder_init(&speex_nb_mode);
void *dec_state;
dec_state = speex_decoder_init(&speex_nb_mode);
int i;
int x;
x = 5950; //set the bit-rate
speex_encoder_ctl(enc_state,SPEEX_SET_BITRATE,&x);
x = 8000; //set the sampling rate
speex_encoder_ctl(enc_state,SPEEX_SET_SAMPLING_RATE,&x);
x = 2; //set the quality
speex_encoder_ctl(enc_state,SPEEX_SET_QUALITY,&x);
x = 3; //set the complexity
speex_encoder_ctl(enc_state,SPEEX_SET_COMPLEXITY,&x);
speex_bits_reset(&bits);
//to convert my unsigned char buffer array to short for encoding
short TempEncode [160];
for (i=0; i<160; i++);
{
TempEncode[i] = buffer[i];
}
speex_encode_int(enc_state, TempEncode, &bits);
char encode[200];
int nbBytes = speex_bits_write(&bits, encode, 200);
speex_encoder_destroy(enc_state);
speex_bits_reset(&bits);
speex_bits_read_from(&bits, encode, nbBytes);
short TempDecode[160];
speex_decode_int(dec_state, &bits, TempDecode);
//Declare an unsigned char buffer2
// Convert from short back to unsigned char for playback
unsigned char buffer2[160];
for (i=0; i<160; i++);
{
buffer2[i] = TempDecode[i];
}
speex_bits_destroy(&bits);
speex_decoder_destroy(dec_state);
More information about the Speex-dev
mailing list