0
0

Hi,

Can you provide some code explaining how to play
a midifile using a .dls file as playback ?

I’ve tried with the samples provided with fmod but no luck
it crashed the VB6 IDE.

Let say I want to play a midifile located in C:\midifiles\midi.mid
and the dls is in the same folder called midi.dls

Any help would be GREATLY appreciated, strange this is not present
in the examples… and crowled the forum and haven’t found anything…

THANKS

  • You must to post comments
0
0

What do I need to add to this code to tell fmod
to play that midifile with a dls file located in c:\midifiles\ and called
midi.dls ?

‘ ===============================================================================================
‘ playstream example
‘ Copyright (c), Firelight Technologies Pty, Ltd 2004-2005.

‘ This example shows how to simply play a stream, such as an mp3 or wav.
‘ The stream behaviour is achieved by specifying FMOD_CREATESTREAM in the call to
‘ FMOD_System_CreateSound.
‘ This makes FMOD decode the file in realtime as it plays, instead of loading it all at once.
‘ This uses far less memory, in exchange for a small runtime cpu hit.
‘ ===============================================================================================
Option Explicit

Dim system As Long
Dim Sound As Long
Dim channel As Long
Dim createsoundexinfo As FMOD_CREATESOUNDEXINFO

Private Sub Form_Load()
Dim result As FMOD_RESULT
Dim version As Long

' Create a System object and initialize.
result = FMOD_System_Create(system)
ERRCHECK (result)

result = FMOD_System_GetVersion(system, version)
ERRCHECK (result)

If version <> FMOD_VERSION Then
    MsgBox "Error!  You are using an old version of FMOD " & Hex$(version) & ". " & _
           "This program requires " & Hex$(FMOD_VERSION)
End If

result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, 0)
ERRCHECK (result)

result = FMOD_System_CreateStream(system, "c:\midifiles\midi.mid", (FMOD_2D Or FMOD_HARDWARE), Sound)
ERRCHECK (result)

End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim result As FMOD_RESULT

' Shutdown

If Sound Then
    result = FMOD_Sound_Release(Sound)
    ERRCHECK (result)
End If

If system Then
    result = FMOD_System_Close(system)
    ERRCHECK (result)

    result = FMOD_System_Release(system)
    ERRCHECK (result)
End If

End Sub

Private Sub Timer_Timer()
Dim result As FMOD_RESULT
Dim ms As Long
Dim lenms As Long
Dim playing As Long
Dim paused As Long

If channel Then
    result = FMOD_Channel_IsPlaying(channel, playing)
    If ((result <> FMOD_OK) And (result <> FMOD_ERR_INVALID_HANDLE) And (result <> FMOD_ERR_CHANNEL_STOLEN)) Then
        ERRCHECK (result)
    End If

    result = FMOD_Channel_GetPaused(channel, paused)
    If ((result <> FMOD_OK) And (result <> FMOD_ERR_INVALID_HANDLE) And (result <> FMOD_ERR_CHANNEL_STOLEN)) Then
        ERRCHECK (result)
    End If

    result = FMOD_Channel_GetPosition(channel, ms, FMOD_TIMEUNIT_MS)
    If ((result <> FMOD_OK) And (result <> FMOD_ERR_INVALID_HANDLE) And (result <> FMOD_ERR_CHANNEL_STOLEN)) Then
        ERRCHECK (result)
    End If

    result = FMOD_Sound_GetLength(Sound, lenms, FMOD_TIMEUNIT_MS)
    If ((result <> FMOD_OK) And (result <> FMOD_ERR_INVALID_HANDLE) And (result <> FMOD_ERR_CHANNEL_STOLEN)) Then
        ERRCHECK (result)
    End If
End If

StatusBar.SimpleText = "Time " & CInt(ms / 1000 / 60) & ":" & CInt(ms / 1000 Mod 60) & ":" & CInt(ms / 10 Mod 100) & _
                           "/" & CInt(lenms / 1000 / 60) & ":" & CInt(lenms / 1000 Mod 60) & ":" & CInt(lenms / 10 Mod 100)

If system Then
    result = FMOD_System_Update(system)
    ERRCHECK (result)
End If

End Sub

Private Sub cmdPlay_Click()
Dim result As FMOD_RESULT

result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, Sound, 0, channel)
ERRCHECK (result)

End Sub

Private Sub cmdPause_Click()
Dim result As FMOD_RESULT
Dim paused As Long

If channel Then
    result = FMOD_Channel_GetPaused(channel, paused)
    ERRCHECK (result)

    If paused Then
        result = FMOD_Channel_SetPaused(channel, 0)
    Else
        result = FMOD_Channel_SetPaused(channel, 1)
    End If
    ERRCHECK (result)
End If

End Sub

Private Sub cmdExit_Click()
Unload Me
End
End Sub

Private Sub ERRCHECK(result As FMOD_RESULT)
Dim msgResult As VbMsgBoxResult

If result <> FMOD_OK Then
    msgResult = MsgBox("FMOD error! (" & result & ") " & FMOD_ErrorString(result))
End If

If msgResult Then
    End
End If

End Sub

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.