SLIDE 6
- 3. Manipulating WAV files
10
Reading a WAV file [2/2]
◮ You can then read the audio file yourself:
⊲ Mono:
Sample1 Sample2 Sample3 Sample4
1 or 2 bytes
⊲ Stereo:
Sample1 left Sample2 left Sample2 right Sample1 right
1 or 2 bytes
◮ Don’t forget to close the file when you are finished!
- 3. Manipulating WAV files
11
Playing a WAV file
◮ You must first open the audio device and declare which kind of WAV file you are going to give:
#include "audio.h" int aud_writeinit(int sample_rate, int sample_size, int channels);
⊲ Pass the sample rate, sample size, number of channels that the audio device should expect ⊲ Attention: you cannot pass any value and expect the audio device to like it. If you pass “strange” values, the device will select something close for you. . .
◮ The function returns a file descriptor
⊲ Just write your samples into it! ⊲ And don’t forget to close it when you are finished. . .