Microsoft DirectX 8.1 (Visual Basic)

Step 3: Play the File

The file loaded in the previous step is now available to the performance as a DirectMusicSegment8 object.

Before a segment loaded from a MIDI file or a DirectMusic Producer segment file 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 sample application downloads the band to the default audiopath. Alternatively, it could be downloaded to the performance. As long as only a single synthesizer is in use, it doesn't matter which destination object you choose.

seg.Download dmp.GetDefaultAudioPath

To play the file, pass the segment object to DirectMusicPerformance8.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 0 or omitted, as in the following code from the sample application:

dmp.PlaySegmentEx seg, 0, 0

Next: Step 4: Close Down