DirectX SDK

Step 2: Load the MIDI File

[C++]

This topic pertains only to DirectX for Visual Basic. See DirectMusic C/C++ Tutorials.

[Visual Basic]

To load a MIDI file, you need three things:

If your music files are not in the working directory of the application, call DirectMusicLoader.SetSearchDirectory so that the loader knows where to look, or provide a full path for each file.

The following code sets the search directory for the loader and loads a file from that directory.

Call gObjDMLoader.SetSearchDirectory("c:\midiplay\media")
' This needs to be done only once.
 
Dim objSeg As DirectMusicSegment

' FileName is a string containing the short name of the file
Set objSeg = gObjDMLoader.LoadSegment(FileName)

Next: Step 3: Play the MIDI File