I've been trying to implement a custom stream in FMOD - that is, I wish to generate my own sound in real time, via a callback buffer, and have FMOD play it back over the soundcard.
For starters, I just want to see that it works, i.e. by filling the buffer with zeroes, but whenever I call FSOUND_Stream_Play, it just crashes.
I suspect I didn't implement the callback with the correct interface? ... I even tried making a callback that does nothing at all, not even zeroing the buffer, but it still crashes.
Any help would be greatly appreciated...
Code: Select all
; FMOD Constants
#FSOUND_16BITS.l = $00000010
#FSOUND_SIGNED.l = $00000100
#FSOUND_MONO.l = $00000020
#FSOUND_FREE.l = -1
; Buffer Structure
#BufferSize.l = 1000*2*2
Structure BufferType
Sample.w[#BufferSize]
EndStructure
; Callback
Procedure.b MyStreamCallback(*Stream, *Buff.BufferType, Len.l, Param.l)
For Index.l = 0 To #BufferSize-1
*Buff\Sample[Index] = 0
Next
ProcedureResult = #true
EndProcedure
; Open a console, and play the stream until ENTER is pressed
OpenConsole()
PrintN("Initializing FMOD...")
FSOUND_Init(44100, 32, 0)
MyStream = FSOUND_Stream_Create(@MyStreamCallback, #BufferSize, #FSOUND_16BITS | #FSOUND_SIGNED | #FSOUND_MONO, 44100, 1)
FSOUND_Stream_Play(#FSOUND_FREE, MyStream)
Print("Press ENTER to quit")
Input()
FSOUND_Stream_Close(MyStream)
FSOUND_Close()
CloseConsole()
