home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD149932152001.psc / modDM.bas < prev    next >
Encoding:
BASIC Source File  |  2001-02-15  |  1.7 KB  |  50 lines

  1. Attribute VB_Name = "modDM"
  2. 'These are used to create direct music
  3. Public dmLoader As DirectMusicLoader
  4. Public dmPerformance As DirectMusicPerformance
  5.  
  6. 'These are the segments the music will be stored in
  7. Public dmSegment As DirectMusicSegment
  8.  
  9. 'This creates direct music
  10. Sub DM_CreateLoaderPerformance(Hdl As Long)
  11.     'Sets the loader as the directx music loader
  12.     Set dmLoader = dxMain.DirectMusicLoaderCreate
  13.     'Sets the performance as the directx music performance
  14.     Set dmPerformance = dxMain.DirectMusicPerformanceCreate
  15.  
  16.     'Initializes the performance
  17.     Call dmPerformance.Init(Nothing, Hdl)
  18.     'Sets the active port for the performance
  19.     Call dmPerformance.SetPort(-1, 1)
  20. End Sub
  21.  
  22. 'This loads direct music and plays the selected file
  23. Sub DM_LoadPlayMidi(FileName As String)
  24.  
  25.     'this tells direct music to search for the files in the programs directory
  26.     Call dmLoader.SetSearchDirectory(App.Path)
  27.     'This creates the segment from a file
  28.     Set dmSegment = dmLoader.LoadSegment(FileName)
  29.  
  30.     'this says that if the file ends in .mid that it is a standard midi file
  31.     If StrConv(Right(FileName, 4), vbLowerCase) = ".mid" Then
  32.     Call dmSegment.SetStandardMidiFile
  33.     End If
  34.  
  35.     'this turns automatic downloading of instruments on
  36.     Call dmPerformance.SetMasterAutoDownload(True)
  37.     'downloads the selection for the current segment
  38.     Call dmSegment.Download(dmPerformance)
  39.  
  40.     'this plays the segment
  41.     Call dmPerformance.PlaySegment(dmSegment, 0, 0)
  42. End Sub
  43.  
  44. 'This unloads the midis and therefore stops them from playing
  45. Sub DM_UnloadStopMidi()
  46.     Set dmSegment = Nothing
  47.     Set dmPerformance = Nothing
  48.     Set dmLoader = Nothing
  49. End Sub
  50.