AudioPath
Description
The AudioPath 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\Multimedia\DirectMusic\AudioPath
Executable: (SDK root)\Samples\Multimedia\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 PlayAudio sample. The AudioPath differs by showing some of the various uses of an audiopath.
On WM_INITDIALOG, the OnInitDialog function does the following:
- Calls IDirectMusicPerformance8::CreateStandardAudioPath, passing in DMUS_APATH_DYNAMIC_3D to create a 3-D audiopath represented by the IDirectMusicAudioPath8 interface g_p3DAudiopath.
- Uses the CMusicManager framework class to create CMusicSegment objects from a list of files.
- Gets the IDirectSound3DListener8 interface from the audiopath.
- 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:
- Calls IDirectMusicAudioPath8::GetObjectInPath to retrieve the IDirectSound3DBuffer8 interface.
- Calls IDirectSound3DBuffer8::SetPosition to set the position of the buffer.
- 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