Platform SDK: DirectX

Tutorial 1: Playing a Sound

[Visual Basic]

The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.

[C++]

This tutorial shows how to create a simple DirectSound application that will play a wave file of any size.

The functions for opening, reading, and closing wave files are in Wavread.cpp, a module that is found with the DSShow3D tool application in the DirectX SDK. In order to implement the techniques shown in the tutorial, you must add Wavread.cpp and Wavread.h to your project and link to Winmm.lib. You must also add Debug.c and Debug.h from the same sample directory, or else edit the calls to the ASSERT macro in Wavread.cpp to call the standard assert function.

The method calls in this tutorial are made through the macros defined in Dsound.h, which are valid for both C and C++.

The tutorial is broken down into the following steps: