0
0

Hi there,
I write a little programm to play Audio-Files.
Now i have a problem with the Channel_Callback.

I put the fmod.cs from the FMODEx-Package in a DLL and now im writing a new class in VB.NET
Here’s some Code:
[code:h7jwnv77]
Private Sys As New FMOD.System
Private Sound As FMOD.Sound
Private Channel As New FMOD.Channel
Private ExInfo As FMOD.CREATESOUNDEXINFO
Private Result As New FMOD.RESULT
Private IntPtr As New System.IntPtr

Private CHCallback As New FMOD.CHANNEL_CALLBACK(AddressOf MyChannelCallback)

‘Init
Public Sub New()
FMOD.Factory.System_Create(Sys)
Sys.init(iMaxChannels, INITFLAG.NORMAL, IntPtr)
End Sub

‘###############################
‘ Play
‘###############################

‘Play stream
Public Function PlayStream(ByVal sFile As String, _
ByVal boPaused As Boolean) As Boolean

  Sys.createSound(sFile, MODE.DEFAULT Or MODE.HARDWARE, Sound)
  Sys.playSound(CHANNELINDEX.REUSE, Sound, boPaused, Channel)

  'Callback
  Channel.setCallback(CHANNEL_CALLBACKTYPE.END, CHCallback, 0)
  Sys.update()

  Return True

End Function

‘Stop
Public Function StopPlaying() As Boolean
If Not IsNothing(Sound) Then
Channel.stop()
Sound.release

     Return True
  End If

End Function

Private Function MyChannelCallback(ByVal channelraw As System.IntPtr, _
ByVal type As FMOD.CHANNEL_CALLBACKTYPE, _
ByVal command As Integer, _
ByVal commanddata1 As UInteger, _
ByVal commanddata2 As UInteger) As FMOD.RESULT

  MsgBox(type.ToString & " - " & command)

End Function
[/code:h7jwnv77]

Playing, etc works all fine.
Now the function "MyChannelCallback" is only called when my application ends or i call "StopPlaying".
What’s wrong that the funcion isn’t called at the end of the track?

Thanks for your help.
Chris

  • You must to post comments
0
0

Are you calling System::update in your main loop? This callbacks are trigerred from this function so it needs to be called regularly.

  • You must to post comments
0
0

Ah. Ok. That looks to be the problem.

I have no main loop in my class. I thought i had to update the system only once. :roll:

Edit:
Now i made a timer which calls the sys.update
Works great now.
THX a lot. ๐Ÿ˜› ๐Ÿ˜‰

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.