Can someone please shed some light on why my DSP callback is not working?

Form code:

Dim System As Long
Dim Sound As Long
Dim channel As Long

Private Function GetFunctionPointer(fptr As Long) As Long
GetFunctionPointer = fptr
End Function

Private Sub Form_Load()
Dim result As FMOD_RESULT
Dim channels As Long, frequency As Long
Dim version As Long

Dim dsp As Long


channels = 2
frequency = 44100

' Global settings
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

'Setup DSP description properties
dspUser.name = "Custom DSP"
dspUser.version = 1
dspUser.channels = 0
dspUser.create = vbNull
dspUser.release = vbNull
dspUser.reset = vbNull
dspUser.read = GetFunctionPointer(AddressOf DSPCallback)
dspUser.setpos = vbNull

'Initialize FMOD
result = FMOD_System_Init(System, 32, 32, FMOD_INIT_NORMAL, 0)
ERRCHECK (result)

'Create stream from file
result = FMOD_System_CreateStream(System, "C:\a.mp3", FMOD_SOFTWARE, exinfo, Sound)
ERRCHECK (result)

'Play stream
result = FMOD_System_PlaySound(System, FMOD_CHANNEL_FREE, Sound, 0, channel)
ERRCHECK (result)

'Create the DSP
result = FMOD_System_CreateDSP(System, dspUser, dsp)
ERRCHECK (result)

'Add the DSP
result = FMOD_System_AddDSP(System, dsp)
ERRCHECK (result)

'Activate DSP
result = FMOD_DSP_SetActive(dsp, 1)
ERRCHECK (result)

End Sub

Module code:
Function DSPCallback(ByVal ptrDSP As Long, ptrInBuffer As Long, ptrOutBuffer As Long, dLength As Long, channelsInBuffer As Long, channelsOutBuffer As Long) As FMOD_RESULT
Debug.Print "DSP Callback"
End Function

At this point, I’m only really interested in getting it to fire using FMODEx. Or, if there is a better way to accomplish what I’m trying to do…I want to play a sound file on one computer and simultaneously stream the data to another computer on the network.

The solution I’ve come up with is to grab the buffer from the DSP callback, push it out the network and read it into a user created stream on the other PC(s). However, I’m having some issues getting the DSP callback working with Ex and VB6.

Additionally, is the DSP buffer still raw PCM data in Ex? Can it be fed directly into a user-created stream read callback?

Thanks in advance,


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.