| Mirage Source http://web.miragesource.net/forums/ |
|
| Simple DirectX MIDI's http://web.miragesource.net/forums/viewtopic.php?f=210&t=4016 |
Page 1 of 1 |
| Author: | jsventor [ Sun Jul 20, 2008 4:29 pm ] |
| Post subject: | Simple DirectX MIDI's |
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
|
|
| Author: | Robin [ Sun Jul 20, 2008 4:54 pm ] |
| Post subject: | Re: Simple DirectX MIDI's |
Isn't there already a tutorial for this? Could have sworn I wrote it up >_> |
|
| Author: | jsventor [ Sun Jul 20, 2008 5:11 pm ] |
| Post subject: | Re: Simple DirectX MIDI's |
Oh I had no clue, dont see it though >.< |
|
| Author: | Poyzin [ Sun Jul 20, 2008 11:01 pm ] |
| Post subject: | Re: Simple DirectX MIDI's |
Jsventor where have you been on MSN?? Been waiting for u fer like 3 weeks!!! Also, nice tut. I'm gonna use that one |
|
| Author: | jsventor [ Mon Jul 21, 2008 1:30 am ] |
| Post subject: | Re: Simple DirectX MIDI's |
Poyzin wrote: Jsventor where have you been on MSN?? Been waiting for u fer like 3 weeks!!! Also, nice tut. I'm gonna use that one I was in the big apple |
|
| Author: | Mozza [ Tue Jul 22, 2008 11:35 am ] |
| Post subject: | Re: Simple DirectX MIDI's |
http://www.mikeschmoyer.com/tutorials/vb_dxmusic.htm |
|
| Author: | Robin [ Tue Jul 22, 2008 11:46 am ] |
| Post subject: | Re: Simple DirectX MIDI's |
Mark, that tutorial doesn't handle how to do it in Mirage itself so it's made obsolete by Jsventor. Jsventor, it's pretty nice but I don't understand why you have to load the midi then play it. I quickly merged those two together: Code: 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 Delete LoadMIDI and replace PlayMidi with the above. |
|
| Author: | jsventor [ Wed Jul 23, 2008 4:08 am ] |
| Post subject: | Re: Simple DirectX MIDI's |
Robin wrote: Mark, that tutorial doesn't handle how to do it in Mirage itself so it's made obsolete by Jsventor. Jsventor, it's pretty nice but I don't understand why you have to load the midi then play it. I quickly merged those two together: Code: 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 Delete LoadMIDI and replace PlayMidi with the above. I honestly didn't even think of that.. wow, thanks, I'm trying to learn DX right now, so, although I might post things that work I'm not sure if its the best methods I'm using, so the help is always appreciated |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|