Foreign plugin audio processors |
---|
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 "http://plugin.org.uk/swh-plugins/amp" 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 "http://plugin.org.uk/swh-plugins/amp" 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. (foreach-frame (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)) (foreach-frame (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) 64 (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." (foreach-frame (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." (foreach-frame (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) 0 SCRATCH> (free 8) SCRATCH> (set-rt-block-size 1)
Getting Started with Incudine | Home |