In sample by sample processing, a foreign plugin returns one value of SAMPLE type or a FRAME (foreign array of SAMPLE type). In block by block processing, a foreign plugin returns a foreign array or a foreign array of arrays and the type depends on the plugin.

Here is an example with LV2 and LADSPA:

(require :incudine-lv2)

(in-package :scratch)

SCRATCH> (set-rt-block-size 1)

(lv2->vug "" swh.amp)

(dsp! amp-test (gain)
  (stereo (swh.amp gain (white-noise 1))))

SCRATCH> (rt-start)

SCRATCH> (amp-test -10 :id 8)

SCRATCH> (set-control 8 :gain -30)

SCRATCH> (free 8)

;; block by block processing
SCRATCH> (set-rt-block-size 64)

(lv2->vug "" swh.amp*)

(dsp! amp-test* (gain)
  (with ((in (make-f32-array (block-size)))
         (out (cffi:null-pointer)))
    (declare (type pointer in out))
    ;; The sample type in LADSPA and LV2 is single precision float.
      (setf (f32-ref in current-frame)
            (coerce (white-noise 1) 'single-float)))
    ;; Not within FOREACH-FRAME loop because SWH.AMP*
    ;; computes a block of samples.
    (setf out (swh.amp* gain in))
      (stereo (sample (f32-ref out current-frame))))))

SCRATCH> (rt-start)

SCRATCH> (amp-test* -10 :id 123)

SCRATCH> (set-control 123 :gain -30)

SCRATCH> (free 123)

SCRATCH> (require :incudine-ladspa)

SCRATCH> (block-size)

(ladspa->vug "caps" "Plate" plate-reverb)

;; Test with a UGEN.
(compile-vug 'plate-reverb 'pointer)

(define-vug rev-input ((in pointer))
  "Read a block of audio samples from the first Incudine input port."
    (setf (f32-ref in current-frame)
          (coerce (audio-in 0) 'single-float))))

(define-vug rev-output ((out pointer))
  "Write two blocks of audio samples to two Incudine output ports."
    (out (f32-ref (ptr-ref out 0) current-frame)
         (f32-ref (ptr-ref out 1) current-frame))))

(dsp! rev-test (bw tail damping blend)
  (with ((in (make-f32-array (block-size)))
         (out (cffi:null-pointer)))
    (declare (pointer out))
    (rev-input in)
    (setf out (plate-reverb bw tail damping blend in))
    (rev-output out)))

SCRATCH> (rev-test .75 .5 .25 .25 :id 8)

SCRATCH> (set-controls 8 :tail .8 :dumping .1 :blend .5)

SCRATCH> (get-bytes-consed-in 5)

SCRATCH> (free 8)

SCRATCH> (set-rt-block-size 1)

Sourceforge project page