<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2722" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=4>Mon,</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>Here is an additional post that came to me
regarding your trouble. In the meantime, I will take your latest comments
and see what more feedback we can get. I don't know what it is, and I
haven't taken the time in the last few months to try again to get Speex going
inside C++, but something about it has been much more difficult for me to grasp
than both mmio and Ogg Vorbis.</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>(That's not a criticism! I appreciate all the
"free" efforts involved.)</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>Steve</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV>steve,<BR><BR>your speex decoding code looks ok, only you have to be sure
that you have<BR>the spx file encoded correctly as well. the point is the
problem could also<BR>be caused by the source file being read and if you are at
all reading it<BR>correctly.<BR><BR>what i'll probably do here is:<BR><BR>1.
check the encoding code to validate the integrity of the spx file<BR>2. check
the decoding code if the sizes are being read correctly.<BR><BR>the spx file
here shows a certain formatting structure where each item =<BR>size+data, so i
assume this is a variable bitrate (VBR) encoding where item<BR>sizes could be of
any value. to make it easier you can also do CBR, where<BR>your speex data are
encoded on a constant bitrate. this will make debugging<BR>easier for
starters until you know what the problem is.<BR><BR>regards,<BR>ronald</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mowin.dev@gmail.com href="mailto:mowin.dev@gmail.com">Mo Win</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=speex-dev@xiph.org
href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=srussell@innernet.net
href="mailto:srussell@innernet.net">Steve Russell</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, October 17, 2005 10:31
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Speex-dev] Error Executing
sampledec in VC++</DIV>
<DIV><BR></DIV>Hi Steve, thanks for the advice. I placed the appropriate
functions outside the while statement but I still get this error at the while
loop:<BR><BR>First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005:
Access violation reading location 0x0000000c.<BR>Unhandled exception at
0x004010fa in SPXDEC.exe: 0xC0000005: Access violation reading location
0x0000000c.<BR><BR>It looks like the same error. I've attached the code
below<BR><BR>Thanks,<BR>Mon<BR><BR>Portion of the revised
code:<BR><BR><BR> decstate = speex_decoder_init
(&speex_nb_mode);<BR> // Set default options for
decoding:<BR> temp = 1;<BR>
speex_decoder_ctl(decstate, SPEEX_SET_ENH,
&temp);<BR><BR> // Initialize spxbits (structure
SpeexBits)<BR> speex_bits_init
(&spxbits);<BR><BR> while
(!(feof(fo))) // this is where the problem
starts<BR> {<BR>
fread (&nbBytes, sizeof(int), 1,
fo);<BR> fread (cbits, 1, nbBytes,
fo);<BR><BR> cout << "1"; //
just to see whether the loop
iterates<BR><BR>
speex_bits_read_from (&spxbits, cbits,
nbBytes);<BR> speex_decode
(decstate, &spxbits,
pcm);<BR><BR><BR> // Copy 1 frame
from float pcm to short spx<BR> for
(n=0; n<FRAME_SIZE;
n++)<BR> spx
[n] = pcm [n];<BR><BR> fwrite (spx,
sizeof(short), FRAME_SIZE, fs);<BR><BR>
}<BR> // end of loop<BR> //
Entire file has been read, decoded and saved<BR><BR>
speex_decoder_destroy (decstate);<BR> speex_bits_destroy
(&spxbits);<BR> fclose (fo);<BR>
fclose (fs);<BR> <BR> cout << "Finished
processing!\n";<BR>}<BR><BR>
<DIV><SPAN class=gmail_quote>On 10/18/05, <B class=gmail_sendername>Steve
Russell</B> <<A
href="mailto:srussell@innernet.net">srussell@innernet.net</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV><FONT face=Arial size=4>Mon,</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>Here is feedback that I got concerning the
access violation, i.e. the failure of the while loop below. Does this
solve the problem?</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>Steve</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV>My guess is that speex_decoder_init() should be outside the while()..
loop<BR>as speex_decoder_destroy() is also outside.</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px"><SPAN
class=q>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal">-----
Original Message ----- </DIV>
<DIV
style="BACKGROUND: rgb(228,228,228) 0% 50%; FONT: 10pt arial; font-size-adjust: none; font-stretch: normal; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial"><B>From:</B>
<A title=mowin.dev@gmail.com
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:mowin.dev@gmail.com" target=_blank>Mo Win</A> </DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>To:</B>
<A title=speex-dev@xiph.org
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:speex-dev@xiph.org" target=_blank>speex-dev@xiph.org</A>
</DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Sent:</B>
Monday, October 17, 2005 8:05 AM</DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Subject:</B>
[Speex-dev] Error Executing sampledec in VC++</DIV>
<DIV><BR></DIV></SPAN>
<DIV><SPAN class=q id=q_10700a0bc525377c_2>hey guys, I just compiled an
application similar to sampledec.c (for speex 1.1.10) and it was fine but
when I executed it, the app exited without doing anything. I'm using MS VC
6.0 and this was all I got -<SPAN style="FONT-WEIGHT: bold"> First-chance
exception in sampledec.exe : 0xC0000005: Access Violation. </SPAN>Has
anyone encountered this / does anyone know how to deal with it? by the
way, sampleenc executed perfectly... <BR><BR>When I removed the "while"
loop in sampledec, the program executed fine (I placed printf's to check
which lines were executed). I also tried running the loop only once
(erasing only the while statement and retaining the code within it) and it
worked fine again. Something seems to be happening during loop iteration
that causes the program to terminate abnormally.. any clues? thanks very
much for any tip..<BR><BR>In gratitude,<BR>Mon<BR><BR>(Below is my code.
it's almost exactly like sampleenc except I read a file stream instead of
stdin)<BR><BR>#include "speex/speex.h"<BR><BR>#include
<stdio.h><BR>#include <iostream.h><BR><BR>void main
()<BR>{<BR> <SPAN style="COLOR: rgb(153,255,153)">//
Definitions</SPAN><BR> #define FRAME_SIZE
160<BR> #define
FIXED_POINT<BR><BR> <SPAN
style="COLOR: rgb(153,255,153)"> // Variable
Declarations</SPAN><BR> FILE *fo,
*fs;<BR> short spx [FRAME_SIZE];<BR>
float pcm [FRAME_SIZE];<BR> char cbits
[200];<BR> int nbBytes, n,
temp;<BR><BR> void *decstate;<BR>
SpeexBits spxbits;<BR><BR><BR> <SPAN
style="COLOR: rgb(153,255,153)">// Program starts
here:</SPAN><BR> cout << "Starting
spxdec...\n";<BR> fo =
fopen("samp.spx","rb");<BR><BR> if (fo ==
NULL)<BR> cout <<
"Error!\n";<BR> else<BR>
cout << "Okay!\n";<BR><BR> fs =
fopen ("pcmfile", "wb");<BR><BR> if (fs ==
NULL)<BR> cout << "Error
creating file!\n";<BR> else<BR>
cout << "File
created!\n";<BR><BR><BR> while
(!(feof(fo)))<BR> {<BR> decstate =
speex_decoder_init (&speex_nb_mode);<BR><BR> // Set
default options for decoding:<BR> temp =
1;<BR> speex_decoder_ctl(decstate, SPEEX_SET_ENH,
&temp);<BR><BR><BR> // Initialize spxbits (structure
SpeexBits)<BR> speex_bits_init
(&spxbits);<BR><BR><BR> fread
(&nbBytes, sizeof(int), 1, fo);<BR>
fread (cbits, 1, nbBytes,
fo);<BR><BR> cout << "1"; //
just to see whether the loop iterates<BR><BR>
speex_bits_read_from (&spxbits, cbits,
nbBytes);<BR> speex_decode (decstate,
&spxbits, pcm);<BR><BR><BR> //
Copy 1 frame from float pcm to short spx<BR>
for (n=0; n<FRAME_SIZE; n++)<BR>
spx [n] = pcm
[n];<BR><BR> fwrite (spx,
sizeof(short), FRAME_SIZE, fs);<BR><BR>
}<BR> // end of loop<BR>
// Entire file has been read, decoded and saved<BR><BR>
speex_decoder_destroy (decstate);<BR> speex_bits_destroy
(&spxbits);<BR> fclose (fo);<BR>
fclose (fs);<BR> <BR> cout <<
"Finished processing!\n";<BR>}<BR><BR></SPAN></DIV><SPAN class=q>
<P></P>
<HR>
<P></P>_______________________________________________<BR>Speex-dev
mailing list<BR><A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:Speex-dev@xiph.org"
target=_blank>Speex-dev@xiph.org</A><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://lists.xiph.org/mailman/listinfo/speex-dev"
target=_blank>http://lists.xiph.org/mailman/listinfo/speex-dev</A><BR>
<P></P></SPAN></BLOCKQUOTE></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>