Microsoft DirectX 8.1 (Visual Basic)

Step 7: Stop the Sound

The following procedure stops the sound in response to input. Because no repetitions are set for any of the sample segments, they also stop automatically when they reach the end.

Private Sub cmdStop_Click()
  If dmSeg Is Nothing Then Exit Sub
  dmp.StopEx dmSeg, 0, 0
  mlOffset = 0
End Sub

The call to DirectMusicPerformance8.StopEx takes the segment as an argument; it might also take the segment state obtained in the previous step, or the audiopath. The second parameter orders an immediate stop, and the third specifies no flags. The flags could request that the music not stop until an appropriate boundary occurs, such as the end of a measure, but such a request would be ignored for wave files.

Next: Step 8: Set Audiopath Parameters