Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple DirectX MIDI's
#1
Ok its all client, and its simple, just change ModSound to this,
Code:
Public Sub StopMIDI()
On Error Resume Next
    Preformance.Stop Segment, Nothing, 0, 0
End Sub

Public Sub PlaySound(Sound As String)
    Call sndPlaySound(App.Path & "\" & Sound, SND_ASYNC Or SND_NOSTOP)
End Sub

Public Sub PlayMidi(filename As String)
On Error Resume Next
    Set Segment = Loader.LoadSegment(filename)
    If Err.Number  DD_OK Then MsgBox "Error: Could not load MIDI file!", vbExclamation, "ERROR!"
    Preformance.PlaySegment Segment, 0, 0
End Sub

And then search for ' Play Music and change it to,
Code:
' Play music
        Call StopMIDI
        If Map.Music > 0 Then
        Call PlayMIDI(App.Path & "\Music\" & "music" & Trim(STR(Map.Music)) & ".mid")
        End If
        
        Exit Sub
    End If

Add this in sub InitDirectX
Code:
Call InitializeMusic

Add this to the bottom of ModDirectX
Code:
Sub InitializeMusic()

Set Loader = DX.DirectMusicLoaderCreate
    Set Preformance = DX.DirectMusicPerformanceCreate
        Preformance.Init Nothing, frmMirage.hWnd
        Preformance.SetPort -1, 1
        Preformance.SetMasterAutoDownload True
    If Err.Number  DD_OK Then

    End If
    
End Sub

And last but not least add this in with your declares,
Code:
' for playing music
Public Loader As DirectMusicLoader
Public Preformance As DirectMusicPerformance
Public Segment As DirectMusicSegment

And if you have a preview button in the map editor add this to your buttons,

PREVIEW
Code:
PlayMIDI(App.Path & "\Music\" & "music" & scrlMusic.Value & ".mid")

STOP
Code:
StopMIDI
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)