Microsoft DirectX 8.1 (Visual Basic)

Step 2: Initialize the Audio Environment

Still in the Form_Load procedure, the sample application sets the search directory so the loader knows where to find the sound files:

  dml.SetSearchDirectory MediaPath

Next it initializes the performance. The DMUS_AUDIOPARAMS type is left blank, causing the performance to be initialized with default parameters. No default audiopath is requested.

  dmp.InitAudio Me.hWnd, DMUS_AUDIOF_ALL, dmA

If any errors have occurred in creating or initializing the objects, they are handled now:

  If Err.Number <> 0 Then
    MsgBox "Could not initialize DirectMusic." & vbCrLf & _
    "This sample will exit.", vbOKOnly Or vbInformation, _
    "Exiting..."
    Unload Me
    Exit Sub
  End If

The Form_Load procedure is concluded in the next topic, Step 3: Create the Audiopath