Share via


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:

  • If the Lullaby button was clicked, the segment is played on the audiopath as the primary segment.
  • If Snore or Mumble was clicked, a secondary segment is played.
  • If Rude Awakening was clicked, all sounds on the audiopath are stopped because the audiopath is passed to IDirectMusicPerformance8::PlaySegmentEx as the pFrom parameter. The alarm sound is then played as a new primary segment.

See Also

© 2004 Microsoft Corporation. All rights reserved.