DirectX SDK |
This topic pertains only to application development in DirectX for Visual Basic.
After creating and initializing the performance, the DLSEffects sample loads the DLS file and a segment file, both from the directory represented by mediapath.
' dx is a DirectX7 object. ' perf is an initialized DirectMusicPerformance object. ' seg is declared as DirectMusicSegment. mediapath = FindMediaDir("sample.sgt", "dmusic") If mediapath <> vbNullString Then ChDir mediapath Dim loader As DirectMusicLoader Set loader = dx.DirectMusicLoaderCreate Set coll = loader.LoadCollection(mediapath & "boids.dls") Set seg = loader.LoadSegment(mediapath & "sample.sgt")
It does not matter what segment is loaded. The application does not play the segment, but it is necessary to have a DirectMusicSegment object to download DLS data.
Now, the application associates the DirectMusicCollection object with the segment and downloads it to the port. Any other instruments referred to by the segment are downloaded as well.
Call seg.ConnectToCollection(coll) Call seg.Download(perf)
The Boids.dls collection contains only a single instrument, called Vocals, which has patch number 127. You can assign this instrument to any channel by sending a MIDI patch message. The application assigns the instrument to two channels so that one of the samples that is to be played, the heartbeat sound, can be given a pitch bend without affecting other samples.
Const channel = 1 Const hbchannel = 2 Const patch = 127 Call perf.SendPatchPMSG(0, DMUS_PMSGF_REFTIME, channel, patch, 0, 0) Call perf.SendPatchPMSG(0, DMUS_PMSGF_REFTIME, hbchannel, patch, 0, 0)
Now, any note played on channels 1 or 2 uses the Vocals instrument. How this instrument is used to get different sound effects is covered in Step 2: Play Effects.