[speex-dev] Error in my code
Willie Engelbrecht
200211870 at webmail.co.za
Fri Nov 7 11:14:13 PST 2003
Hi
I apologise if the following message is inappropriate for
this list. However, I feel this is the only place where I
can get some help with my problem.
BOOL CALLBACK RecordProc(HRECORD hRecord, void *buffer,
DWORD length, DWORD user)
{
try
{
long sent = 0;
long inputOffset = 0;
long outputOffset = 0;
long nbBytes = 0;
char *outputBuffer = NULL;
outputBuffer = (char*)malloc(65535);
memset(speexBuffer, 0, 65536);
while (inputOffset < length)
{
(float*)buffer = (float*)buffer + (frameSize);
speex_bits_reset(&bits);
speex_encode(enc_state, (float*)buffer, &bits);
nbBytes = speex_bits_write(&bits, outputBuffer +
outputOffset, 65535);
inputOffset += frameSize;
outputOffset += nbBytes;
}
MainForm->memoOutput->Lines->Append("A buffer size
of '" + (String)length +
"' was compressed to '" + (String)outputOffset +
"'");
return true;
}
catch (Exception err)
{
MainForm->memoOutput->Lines->Append("Exceotion
thrown. Message: " + err.Message);
}
RecordProc is a callback function called every 250
milliseconds with recorded data stored in 'buffer' with
length 'length'. Data is in float format. Framesize is 640
(uwb mode). With each call, length has a size of about
32000 (hz). After 5 calls (ie: the sixth call), the program
crashes with the following messages in message boxes:
log: OVERFLOW error
sqrt: DOMAIN error
log: OVERFLOW error
log10: SING error
log: OVERFLOW error
log: OVERFLOW error
log: OVERFLOW error
log: OVERFLOW error
log: OVERFLOW error
And then an exception is thrown:
Exception: Access violation
<p>Output on memoOuput:
A buffer size of '26880' was compressed to '3780'
A buffer size of '30720' was compressed to '4320'
A buffer size of '30720' was compressed to '4320'
A buffer size of '30720' was compressed to '4320'
A buffer size of '30720' was compressed to '4320'
<p>The compiler returns me to the following line:
speex_encode(enc_state, (float*)buffer, &bits);
<p>This is how speex was initialised:
speex_bits_init(&bits);
enc_state = speex_encoder_init(&speex_uwb_mode);
peex_encoder_ctl(enc_state,SPEEX_GET_FRAME_SIZE,&frameSize);
long x = 32000;
speex_encoder_ctl(enc_state,SPEEX_SET_SAMPLING_RATE,&x);
<p>What am I doing wrong?
Compiler: Borland C++ Builder 6 Professional.
OS: Windows XP
Speex version: 1.01
Sound library: BASS 2.0
Thanks in advance for any help.
Willie
___________________________________________
Look Good, Feel Good www.healthiest.co.za
--- >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