Print Page | Close Window

Music Loop

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=139
Printed Date: 20 December 2006 at 5:52pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Music Loop
Posted By: Sync
Subject: Music Loop
Date Posted: 11 February 2006 at 3:05pm
Difficulty: Medium 3/5

Originaly Posted By: Mr.Saturn

This ones by EnigmaWave...

'In the client, open modSound.bas.

'Add this line to the top:
'Code:
Public CurrentSong As String


'Replace the PlayMidi and StopMidi subs with these:
'Code:
Public Sub PlayMidi(Song As String)
If CurrentSong <> Song Then
CurrentSong = Song

Dim i As Long

i = mciSendString("close all", 0, 0, 0)
i = mciSendString("open """ & App.Path & "\Music\" & Song & """ type sequencer alias background", 0, 0, 0)
i = mciSendString("play background notify", 0, 0, frmMirage.hWnd)
End If
End Sub

Public Sub StopMidi()
Dim i As Long
CurrentSong = ""
i = mciSendString("close all", 0, 0, 0)
End Sub


'Add this sub under the StopMidi sub:
'Code:
Public Sub MakeMidiLoop()
Dim SBuffer As String * 256

Call mciSendString("STATUS background MODE", SBuffer, 256, 0)

If Left$(SBuffer, 7) = "stopped" Then
Call mciSendString("PLAY background FROM 0", vbNullString, 0, 0)
End If
End Sub


'Open modGameLogic.bas.
In the GameLoop sub find this code:Code:
' Calculate fps
If GetTickCount > TickFPS + 1000 Then
GameFPS = FPS
TickFPS = GetTickCount
FPS = 0
Else
FPS = FPS + 1
End If

DoEvents

Loop


'In between the End If and the DoEvents, add this:Code:
Call MakeMidiLoop


'Open modClientTCP.bas.
'In the HandleData sub, find "mapdone".
'Underneath it, replace this:
'Code:
' Play music
Call StopMidi
If Map.Music > 0 Then

Call PlayMidi("music" & Trim(STR(Map.Music)) & ".mid")
End If
'with this:
'Code:
' Play music
If Map.Music > 0 Then
Call PlayMidi("music" & Trim(STR(Map.Music)) & ".mid")
Else
Call StopMidi
End If


'After those changes have been made; the midis will loop, and they will not restart every time you change maps unless the song on the new map is different. Also, all of your midis will be stored in a folder called "Music" instead of being in the same folder as client.exe.

'Also; there is a small bug I found that can easily be fixed.
'The bug is that if you close the client while music is still playing, the music doesn't stop.

'In modGameLogic.bas, add this line to the top of the GameDestroy sub:Code:
Call StopMidi



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info