I have Dev-C++ as an IDE and MinGW as the compiler, and I am running C programs on the IDE. I have this project where I have to write raw PCM data (unsigned 8-bit i.e bytes of PCM) as an array. I have figured out the reading part but when I view the output on the screen the starting bytes are missing and the remaining integers just display fine. Where did the bytes at the beginning go? Why cant I see the entire data?? I am using the fread() function to read the data and it returns the number of values read by it. The return value is also fine, nothing absurd and upto my expectations. Any reason why this is happening?
The code below is very specific and is tailored to my wav file. I have used MATLAB to read the header. Is there any problem in the code??
#include<stdio.h>
#include<stdlib.h>
int main()
{FILE *fp;
fp=fopen("AE.wav", "rb");
unsigned char samples[4576];
fseek ( fp , 46 , SEEK_SET );
int nr = fread(samples, sizeof(char), 4576, fp);
int i;
for(i=0;i<4576;i++)
{
printf("%d",(int)samples[i]);
printf("\n");
}
printf("No. of samples read= %d", nr);
fclose(fp);
return 0;
}