Loading a sound
The most common way to get audio data is to read it from an audio file. However, as we have seen before, there are many different audio file formats, and reading the audio data out of them is usually a non-trivial task. This is particularly true with compressed audio file formats, which require decoding the audio data using some algorithm, before we can use it in our application. In general, it is usually better to use an audio engine, or an external library, to read the contents of an audio file.
For educational purposes, we will be reading the audio data from a WAV file. We will, however, work under the assumption that the WAV file we read from is in the canonical form (that is, it contains only a format and a data subchunk, in that order) and that the audio data is stored without any compression. Under these conditions, we know where all of the data is stored, and can simply index into the file to read it. That is certainly not the case for every WAV file, which would require...