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