WAVE Soundfile Format
- 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.
- 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 ...".
- 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.
- Question 1: According to the above observation, in your opinion,
what is the size of the header in a WAV file?
- Question 2: Read the article "Microsoft WAVE PCM soundfile
format". According to the article, what should be the size of WAV file
header?
- 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.
- Question 3: Find out whether integers (such as ChunkSize,
BitsPerSample) are represented in big-endian or little-endian.
- 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:
- ChunkID: RIFF
- ChunkSize: 220538 (0x00035d7a)
- Format: WAVE
- SubChunk1ID: fmt
The contents of the data chunk will simply be dumped as what you did in
an
earlier
exercise.
- Task 3: Use the following two files to verify that your program can display
header fields correctly:
- Beethovens_5th_Symphony.wav
(1.1MB)
- riff-18.wav (220KB)
- 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.
- Pass your C program to your partner.
- Ask him/her to test with these files:
- Beethovens_5th_Symphony.wav
(1.1MB)
- riff-18.wav (220KB)
- ncnu.wav (81KB)
- 11k
u-law (152KB)
- First, play the original file.
- Then, use your program to swap the contents.
- Final, play the generated WAV file to hear the voice.
- 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.
- 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).