(bind-func audio_callback:PaStreamCallback
(let ((time 0)
(nchan 2) ;; assume stereo
(idx 0))
(lambda (input output frameCount timeInfo statusFlags userData)
(doloop (i frameCount)
(doloop (j nchan)
(set! idx (+ (* i nchan) j))
;; fill the output buffer with repeated values from our dsp
;; closure (no input in this version, but that's easy to do)
(pset! (convert output float*)
idx
(dsp 0.0 time j null)))
(set! time (+ time 1)))
;; to ensure the callback continues to be called
paContinue)))