Microsoft DirectX 9.0 |
WAV files are in the Resource Interchange File Format (RIFF), which consists of a variable number of named chunks containing either header information (for example, the format of sound samples) or data (the samples themselves). The Win32 API supplies functions for opening and closing RIFF files, seeking to chunks, and so on. The names of these functions all start with "mmio".
To store WAV sounds in an executable, import your WAV files as resources and give them string names. Note that the CWaveFile Sample Class expects these resources to be of type "WAVE" or "WAV", and expects to find them in the executable module rather than a DLL.
The DirectSound API does not include methods for loading sound data. However, the Dsutil.cpp file used by many of the SDK sample applications implements several classes that can be used to create sound buffers from files, resources, or a memory location.
The basic steps involved in using the sample classes to initialize DirectSound and to create and load buffers are as follows:
Note that the actual reading of data is done by a CWaveFile object that is a protected member of the CSound or CStreamingSound object. You do not normally need to use the CWaveFile class directly; however, you can refer to the implementation of this class for information on how to parse WAV data.
See Also