I'm so confused about fread and fwrite. In lab 4 " Volume", how can I know the number of samples in the input wav file? i=I need to use fread(buffer , size , qty , file operator ). So how can I know the count of samples?
1 Answer
Assuming the size to fread is 1 char, aka 1 byte, the qty argument to fread is the number of bytes to read per sample. The program does not need to be told the number of samples needed. Each one is independently sampled in, acted upon, and written out.
The lab setup gives the sample size, aka the qty: Your program should then read the rest of the data from the WAV file, one 16-bit (2-byte) sample at a time.