Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping Sound
#1
Code:
Public CurrentSong As String
Dim mssg As String * 255
Dim MIDIpos As Integer
Dim MIDILength As Integer


Public Sub PlayMidi(Song As String)

Dim i As Long

    If CurrentSong  Song Then
    
        

        i = mciSendString("close all", 0, 0, 0)
        i = mciSendString("open """ & App.Path & MUSIC_PATH & Song & """ type sequencer alias background", 0, 0, 0)
        i = mciSendString("play background notify", 0, 0, frmMirage.hWnd)
        i = mciSendString("status background length", mssg, 255, 0)
        
        MIDILength = mssg
        CurrentSong = Song

    Else
        If MIDILength = MIDIpos Then
            i = mciSendString("play background from 0", 0&, 0, 0)
                      
    End If
        End If
    
    i = mciSendString("status background position", mssg, 255, 0)
    MIDIpos = mssg

End Sub



Just place:
Code:
If Map.Music > 0 Then
            Call PlayMidi("music" & Trim(STR(Map.Music)) & ".mid")
        End If

.....into GameLoop


I know a lot of people have switched to directsound, Fmod, etc.
Reply
#2
There's already a tutorial for this.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
Sorry, I did a search before, but never found one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)