WAVE Soundfile Format

  1. The WAVE file format is a subset of Microsoft's RIFF specification for the storage of multimedia files. In this week, we are going to explore the format of WAVE files and the meaning of each header field.
  2. Utilize the C++ program we developed in last week, record a 10-second WAV file (e.g., you may count one to ten). Try to record some meaningful voices, instead of simply "la la la ...".
  3. Observe the filesize of this generated WAV file. It is larger than the memory buffer which you stored audio data. We know these extra bytes consist of the "header" of a WAV file. Understanding the meaning of these header fields is crucial to handle international standards, such as network protocols and multimedia data.
  4. Question 1: According to the above observation, in your opinion, what is the size of the header in a WAV file?
  5. Question 2: Read the article "Microsoft WAVE PCM soundfile format". According to the article, what should be the size of WAV file header?
  6. Task 1: Use the "utility" which you developed to dump a binary file in hexadecimal digits, inspect the header of your WAV file. Discuss with your partner for how to interpret each field.
  7. Question 3: Find out whether integers (such as ChunkSize, BitsPerSample) are represented in big-endian or little-endian.
  8. Task 2: Write a program which takes a filename from argv[1]. Read the file (assume it is a WAV file). Display the header fields in human-readable format, for example: The contents of the data chunk will simply be dumped as what you did in an earlier exercise.
  9. Task 3: Use the following two files to verify that your program can display header fields correctly:
    1. Beethovens_5th_Symphony.wav (1.1MB)
    2. riff-18.wav (220KB)
  10. Task 4: Write a program to read a WAV file. Swap the first half and the last half of the data chunk, and write it back to another WAV file. Note that the header should not be changed; only the data chunk is different. Play the modified WAV file to verify that you've done this task successfully.
  11. Task 5: Write a program to read a WAV file, and generate a new WAV file by duplicating its data chunk. The file size will be larger (approximately doubled). As a matter of fact, the size should be equal to the double size of the data chunk, plus the size of the header. Try to identify the fields in the header which must be updated, calculate the new value, and compare your result with your partner.
  12. Task 6: Modify your recording program so that the sampling rate is reduced (from 22050Hz) to 8000Hz, and each sample is saved in 8 bits instead of 16 bits. Compare the file size and voice quality with the original sampling rate (8kHz vs. 22.05kHz or 44.1kHz) and bit depth (8 bits vs. 16 bits).