O mod Music está bugado... para fazelo funcionar troque-o por este:
Creditos:
Robin por criar e disponibilizar
Eu por trazer para aldeia
- Código:
Option Explicit
Private Const inDevelopment as Boolean = False
' Maximum sounds
Private Const MAX_SOUNDS as byte = 32
' Hardcoded sound effects
Public Const Sound_ButtonHover As String = "Cursor1.wav"
Public Const Sound_ButtonClick As String = "Decision1.wav"
' Last sounds played
Public lastButtonSound As Long
Public lastNpcChatsound As Long
' Init status
Public bInit_Music As Boolean
Public curSong As String
' Music Handlers
Private songHandle As Long
Private streamHandle As Long
' Sound pointer array
Private soundHandle(1 To MAX_SOUNDS) As Long
Private soundChannel(1 To MAX_SOUNDS) As Long
Private soundIndex As Long
Public Function Init_Music() As Boolean
Dim result As Boolean
If inDevelopment Then Exit Function
On Error GoTo errorhandler
' init music engine
result = FSOUND_Init(44100, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH)
If Not result Then GoTo errorhandler
' return positive
Init_Music = True
bInit_Music = True
Exit Function
errorhandler:
Init_Music = False
bInit_Music = False
End Function
Public Sub Destroy_Music()
' destroy music engine
Stop_Music
FSOUND_Close
bInit_Music = False
curSong = vbNullString
End Sub
Public Sub Play_Music(ByVal song As String)
On Error GoTo errorhandler
If Not bInit_Music Then Exit Sub
' exit out early if we have the system turned off
If Options.Music = 0 Then Exit Sub
' does it exist?
If Not FileExist(App.path & MUSIC_PATH & song) Then Exit Sub
' don't re-start currently playing songs
If curSong = song Then Exit Sub
' stop the existing music
Stop_Music
' find the extension
Select Case Right$(song, 4)
Case ".mid", ".s3m", ".mod"
' open the song
songHandle = FMUSIC_LoadSong(App.path & MUSIC_PATH & song)
' play it
FMUSIC_PlaySong songHandle
' set volume
FMUSIC_SetMasterVolume songHandle, 150
Case ".wav", ".mp3", ".ogg", ".wma"
' open the stream
streamHandle = FSOUND_Stream_Open(App.path & MUSIC_PATH & song, FSOUND_LOOP_NORMAL, 0, 0)
' play it
FSOUND_Stream_Play FSOUND_FREE, streamHandle
' set volume
FSOUND_SetVolume streamHandle, 150
Case Else
Exit Sub
End Select
' new current song
curSong = song
Exit Sub
errorhandler:
Destroy_Music
End Sub
Public Sub Stop_Music()
On Error GoTo errorhandler
If Not streamHandle = 0 Then
' stop stream
FSOUND_Stream_Stop streamHandle
' destroy
FSOUND_Stream_Close streamHandle
streamHandle = 0
End If
If Not songHandle = 0 Then
' stop song
FMUSIC_StopSong songHandle
' destroy
FMUSIC_FreeSong songHandle
songHandle = 0
End If
' no music
curSong = vbNullString
Exit Sub
errorhandler:
Destroy_Music
End Sub
Public Sub Play_Sound(ByVal sound As String, Optional ByVal x As Long = -1, Optional ByVal y As Long = -1)
Dim dX As Long, dY As Long, volume As Long, distance As Long
On Error GoTo errorhandler
If Not bInit_Music Then Exit Sub
' exit out early if we have the system turned off
If Options.sound = 0 Then Exit Sub
If x > -1 And y > -1 Then
' x
If x < GetPlayerX(MyIndex) Then
dX = GetPlayerX(MyIndex) - x
ElseIf x > GetPlayerX(MyIndex) Then
dX = x - GetPlayerX(MyIndex)
End If
' y
If y < GetPlayerY(MyIndex) Then
dY = GetPlayerY(MyIndex) - y
ElseIf y > GetPlayerY(MyIndex) Then
dY = y - GetPlayerY(MyIndex)
End If
' distance
distance = dX ^ 2 + dY ^ 2
volume = 150 - (distance / 2)
Else
volume = 150
End If
' cap the volume
If volume < 0 Then volume = 0
If volume > 256 Then volume = 256
' load the sound
Load_Sound sound
FSOUND_Sample_SetDefaults soundHandle(soundIndex), -1, volume, FSOUND_STEREOPAN, -1
' play it
FSOUND_PlaySound FSOUND_FREE, soundHandle(soundIndex)
Exit Sub
errorhandler:
Destroy_Music
End Sub
Public Sub Load_Sound(ByVal sound As String)
Dim bRestart As Boolean
On Error GoTo errorhandler
' next sound buffer
soundIndex = soundIndex + 1
' reset if we run out
If soundIndex > MAX_SOUNDS Or soundIndex < 1 Then
bRestart = True
soundIndex = 1
End If
' load the sound
soundHandle(soundIndex) = FSOUND_Sample_Load(FSOUND_FREE, App.path & SOUND_PATH & sound, FSOUND_NORMAL, 0, 0)
Exit Sub
errorhandler:
Destroy_Music
End Sub
Creditos:
Robin por criar e disponibilizar
Eu por trazer para aldeia