Microsoft DirectX 8.1 (Visual Basic)

Step 1: Create the DirectX Objects

The first step is to create the DirectX8 object, which is then used to create DirectMusicLoader8 and DirectMusicPerformance8.

The variables for these objects are declared as follows:

Private dx As DirectX8
Private dml As DirectMusicLoader8
Private dmp As DirectMusicPerformance8

In addition, the following global object variables are declared for later use:

Private dmSeg As DirectMusicSegment8
Private dmSegState As DirectMusicSegmentState8
Private dmPath As DirectMusicAudioPath8

The first three objects are created in the Form_Load procedure. If any errors occur, they are ignored until after each creation method has been tried. If any error occurred, a single message box is displayed and the application terminates.

Private Sub Form_Load()
  
  Dim dmA As DMUS_AUDIOPARAMS
  MediaPath = FindMediaDir("tuta.wav")
 
  On Local Error Resume Next
 
  Set dx = New DirectX8
  Set dml = dx.DirectMusicLoaderCreate
  Set dmp = dx.DirectMusicPerformanceCreate

The Form_Load procedure is continued in the next topic, Step 2: Initialize the Audio Environment