[speex-dev] [revised PATCH] Decoding .spx with 1.0 on ppc produces noise!
Ben Stanley
bds02 at uow.edu.au
Thu Apr 17 15:45:20 PDT 2003
Hi,
The previous native-endian patch that I sent is the simplest way to get
sound working through the sound card. However, it will stuff up the
writing of correct .wav files.
If you want correct .wav files, use the one attached here instead.
Ben.
<p>
--- speex-1.0/src/speexdec.c Fri Mar 21 08:52:39 2003
+++ speex-1.0-works/src/speexdec.c Thu Apr 17 10:42:46 2003
@@ -136,7 +136,7 @@
exit(1);
}
- format=AFMT_S16_LE;
+ format=AFMT_S16_NE;
if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)
{
perror("SNDCTL_DSP_SETFMT");
@@ -360,6 +360,7 @@
int option_index = 0;
char *inFile, *outFile;
FILE *fin, *fout=NULL;
+ int wav_format=0;
short out[MAX_FRAME_SIZE];
float output[MAX_FRAME_SIZE];
int frame_size=0;
@@ -492,6 +493,9 @@
outFile=argv[optind+1];
else
outFile = "";
+ wav_format = strlen(outFile)>=4 && (
+ strcmp(outFile+strlen(outFile)-4,".wav")==0
+ || strcmp(inFile+strlen(inFile)-4,".WAV")==0 );
/*Open input file*/
if (strcmp(inFile, "-")==0)
{
@@ -611,8 +615,13 @@
output[i]=-32000.0;
}
/*Convert to short and save to output file*/
- for (i=0;i<frame_size*channels;i++)
- out[i]=(short)le_short((short)floor(.5+output[i]));
+ if (wav_format) {
+ for (i=0;i<frame_size*channels;i++)
+ out[i]=(short)le_short((short)floor(.5+output[i]));
+ } else {
+ for (i=0;i<frame_size*channels;i++)
+ out[i]=(short)floor(.5+output[i]);
+ }
#if defined WIN32 || defined _WIN32
if (strlen(outFile)==0)
WIN_Play_Samples (out, sizeof(short) * frame_size*channels);
@@ -631,7 +640,7 @@
}
- if (strcmp(outFile+strlen(outFile)-4,".wav")==0 || strcmp(inFile+strlen(inFile)-4,".WAV")==0)
+ if (wav_format)
{
if (fseek(fout,4,SEEK_SET)==0)
{
<p>--- >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