Microsoft DirectX 8.1 (C++) |
The simplest way to create an audiopath is by passing a flag to IDirectMusicPerformance8::InitAudio. The tutorial sample passes the DMUS_APATH_DYNAMIC_STEREO flag, causing InitAudio to set up a default audiopath that supports stereo sounds:
g_pPerformance->InitAudio(
NULL, // IDirectMusic interface not needed.
NULL, // IDirectSound interface not needed.
NULL, // Window handle.
DMUS_APATH_DYNAMIC_STEREO, // Default audiopath type.
64, // Number of performance channels.
DMUS_AUDIOF_ALL, // Features on synthesizer.
NULL // Audio parameters; use defaults.
);
The default audiopath is suitable for sounds that do not have to be located in space, such as background music or narration. However, if an application implements 3-D sound effects, it will play each sound source on its own audiopath, so that 3-D parameters can be set individually.
The sample creates one such audiopath as follows:
IDirectMusicAudioPath8* p3DAudioPath = NULL;
g_pPerformance->CreateStandardAudioPath(
DMUS_APATH_DYNAMIC_3D, // Path type.
64, // Number of performance channels.
TRUE, // Activate now.
&p3DAudioPath // Pointer that receives audiopath.
);
A segment can now be played on this audiopath as follows:
g_pPerformance->PlaySegmentEx(
g_pSegment, // Segment to play.
NULL, // Used for songs; not implemented.
NULL, // For transitions.
0, // Flags.
0, // Start time; 0 is immediate.
NULL, // Pointer that receives segment state.
NULL, // Object to stop.
p3DAudioPath // Audiopath.
);