Microsoft DirectX 8.1 (Visual Basic)

Using Wave Data

DirectSound buffers play only waveform audio data, which consists of digital samples of the sound at a fixed sampling rate. The representation of an analog signal by a sequence of numbers is known as pulse code modulation (PCM).

Wave data is usually stored in files or resources in Resource Interchange File Format (RIFF). The data includes a description of the wave format, including parameters such as the sampling rate and number of output channels.

The particular format of a sound can be described by a WAVEFORMATEX type.

Note   The WAVEFORMATEX type in the DirectX for Visual Basic type library is not identical to the WAVEFORMATEX structure declared in Mmreg.h and used in the format chunk of a wave file or resource. For information on how to read a format chunk and copy the relevant data into a DirectX WAVEFORMATEX type, see Reading Wave Files.

When you are creating a static buffer by using DirectSound8.CreateSoundBufferFromFile or DirectSound8.CreateSoundBufferFromResource, you do not specify a buffer format, because the format of the created buffer always matches the format of the data. You do, however, have to specify the format of any buffer created by using DirectSound8.CreateSoundBuffer, and this format must match the format of the data you intend to play in the buffer.

DirectSound does not support compressed wave formats. Applications should use the audio compression manager (ACM) functions, provided with the Win32 APIs in the Platform SDK, to convert compressed audio to PCM format before writing the data to a sound buffer. Alternatively, use the DirectMusic loader, which automatically enlists the help of ACM when loading compressed waves for playback through the DirectMusic performance.

More information on waves is included in the following topics: