Reply by chen...@hotmail.com January 9, 20072007-01-09
You can also try the following program. It worked well for me

...

FILE *src;

char f_scr_name[50];

short FileHead, FileTail;
short In_buffer[120]; // 120 words or 240 bytes

long Flen; // File Length
long Frame_Number; // Frame Number

long i;
strcpy(f_scr_name,"yourprograme.wav");

if((src=fopen(f_scr_name,"rb"))==NULL)
{
printf("can't open file !\n");
exit(0);
}
fseek(src, 0L, SEEK_END ) ;
Flen = ftell(src)-0x2c;
Frame_Number = Flen / 240; // Frame Numbers(240 bytes/frame)
rewind(src) ;
fread(&FileHead,1,0x2c,src); // 44 bytes head

for(i=0;i {
fread(&In_buffer,2,120,src);

// your program here
...
}

...

fclose(src);

...
If you want the last frame which maybe less than 240 bytes, you can also add this kind of program into the original program.
for(;!feof(src);)
{
fread(&filetail,2,1,src);
}

- zhixin
hi all
>I am working on a project on audio compression using code excited
>linear prediction (CELP) techniques. My aim is to design a basic
>working CELP codec using visual c++ under windows.
>i have some problem reading data chunk from riff format file using vc++
>whene i try to read a block of 240 byte only 60 byte are read and the
>rest of buffer is zero i try different commandes (_read,fread...)it
>give me the same fault.
>Can someone help me by refering some relavent documents explaing the
>how to do this correctly or a sample program in vc++ I will be highly
>obliged.
>thanks.
>yaso
Reply by Jeff Brower January 8, 20072007-01-08
Yaso-

> I am working on a project on audio compression using code excited
> linear prediction (CELP) techniques. My aim is to design a basic
> working CELP codec using visual c++ under windows.
> i have some problem reading data chunk from riff format file using vc++
> whene i try to read a block of 240 byte only 60 byte are read and the
> rest of buffer is zero i try different commandes (_read,fread...)it
> give me the same fault.
> Can someone help me by refering some relavent documents explaing the
> how to do this correctly or a sample program in vc++ I will be highly
> obliged.

I don't know if this helps or not, but here is some info on typical .wav file format:

http://www.signalogic.com/index.pl?page=ms_waveform

Suggest to verify first that you can read the header (44 bytes) correctly in your C/C++ program. Then you should be
able to read the next 240 bytes (which would be 120 samples for 16-bit format .wav file).

-Jeff
Reply by yaso21101975 January 8, 20072007-01-08
hi all
I am working on a project on audio compression using code excited
linear prediction (CELP) techniques. My aim is to design a basic
working CELP codec using visual c++ under windows.
i have some problem reading data chunk from riff format file using vc++
whene i try to read a block of 240 byte only 60 byte are read and the
rest of buffer is zero i try different commandes (_read,fread...)it
give me the same fault.
Can someone help me by refering some relavent documents explaing the
how to do this correctly or a sample program in vc++ I will be highly
obliged.
thanks.
yaso