Microsoft DirectX 9.0

Audio Path Sample

The Audio Path sample demonstrates how different sounds can be played on an audiopath, and how the parameters of all sounds are affected by changes made on the audiopath.

Path

Source: (SDK root)\Samples\C++\DirectMusic\AudioPath

Executable: (SDK root)\Samples\C++\DirectMusic\Bin

User's Guide

Click Lullaby, Snore, and Mumble to play different sounds. Adjust the 3-D position of the sounds by using the sliders. Click Rude Awakening to play a different sound and stop all other sounds.

Programming Notes

This sample is very similar in form to the Play Audio Sample. The Audio Path sample differs by showing some of the various uses of an audiopath.

On WM_INITDIALOG, the OnInitDialog function does the following:

  1. Calls IDirectMusicPerformance8::CreateStandardAudioPath, passing in DMUS_APATH_DYNAMIC_3D to create a 3-D audiopath. The created IDirectMusicAudioPath8 interface is pointed to by g_p3DAudiopath.
  2. Uses the CMusicManager framework class to create CMusicSegment objects from a list of files.
  3. Gets the IDirectSound3DListener8 interface from the audiopath.
  4. Calls IDirectSound3DListener8::SetRolloffFactor to change the rate at which the amplitude of sounds diminishes over distance.

When the 3-D position slider is changed, the SetPosition function does the following:

  1. Calls IDirectMusicAudioPath8::GetObjectInPath to retrieve the IDirectSound3DBuffer8 interface.
  2. Calls IDirectSound3DBuffer8::SetPosition to set the position of the buffer.
  3. Releases the buffer.

When a segment is played, the PlaySegment function does one of the following:

See Also