I am puzzled by the lab volume in week 4. The few questions I have in particular are:
How does the code below know to skip the first 44 bytes of header when it begins multiplying the bytes by factor?
In the while loop, what is the condition or increment that allows the loop to run properly. For example, earlier we would say while x < y x++. Where is the x++ equivalent here, why will the loop run differently on the second and third pass than it does in the first pass.
Lastly, I absolutely can't wrap my mind around the input arguments in fread and fwrite even after going over the manual documentation. What do they mean? Any help welcome.
// TODO: Copy header from input file to output file
uint8_t header[HEADER_SIZE];
fread(header, HEADER_SIZE, 1, input);
fwrite(header, HEADER_SIZE, 1, output);
// TODO: Read samples from input file and write updated data to output file
int16_t buffer;
while (fread(&buffer, sizeof(int16_t), 1, input))
{
buffer *= factor;
fwrite(&buffer, sizeof(int16_t), 1, output);
}