Mirage Source
Looping Sound - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Looping Sound (/showthread.php?tid=1259)



Looping Sound - shaded - 06-09-2007

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.


Re: Looping Sound - Robin - 06-09-2007

There's already a tutorial for this.


Re: Looping Sound - shaded - 06-09-2007

Sorry, I did a search before, but never found one.