Microsoft DirectX 8.1 (C++) |
The wave file loaded in the previous step is now available to the performance through its IDirectMusicSegment8 interface.
Before a segment can be played, its band must be downloaded to the synthesizer. As long as you don't unload the band, this step has to be taken only once for each segment that uses a unique band.
The following code from the WinMain function in the sample downloads the band to the performance. Alternatively, it could be downloaded to an audiopath. As long as only a single synthesizer is in use, it doesn't matter which destination object you choose:
g_pSegment->Download( g_pPerformance );
To play the file, pass the segment interface to IDirectMusicPerformance8::PlaySegmentEx. This method offers many options for playback, but to play a segment immediately on the default audiopath, all the parameters except the first can be NULL or 0:
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.
NULL // Audiopath, if not default.
);
MessageBox( NULL, "Click OK to Exit.", "Play Audio", MB_OK );
Next: Step 4: Close Down