[CM] LADSPA implementation

Bill Schottstaedt bil@ccrma.Stanford.EDU
Tue, 19 Jun 2007 04:59:14 -0700


Your code looks right to me.  I think this select-sound kludge doesn't
do quite what I thought.  I added two optional arguments to
apply-ladspa to set the output sound index and channel number, so I
think your code can be:


#!/usr/local/bin/snd -b 
!# 
(use-modules (ice-9 format)) 
; set some global variables 
(set! (ladspa-dir) "/usr/lib/ladspa") 

(let* ((outsound (new-sound "out.wav" :channels 2)) 
       (insound (open-sound "in.wav"))) 

       (let ((readers 
               (list   (make-sample-reader 0 insound 0) 
                       (make-sample-reader 0 insound 1) ))) 

       ; execute the ladspa plugin 
       (apply-ladspa readers 
                       (list "amp.so" "amp_stereo" 0.5) 
                       (mus-sound-frames "in.wav") 
                       "applying amp_stereo"
                       outsound 0)

       ; free up the reader buffers 
       (for-each (lambda (r) (if r (free-sample-reader r))) readers)) 

       ; write outsound to disk 
       (save-sound-as "out.wav" :sound outsound) 

       (close-sound insound) 
       (close-sound outsound) 
) 
(exit)


I updated the CVS and snapshot versions of snd-ladspa.c, but
I don't have any easy way to test this change, so please let me know
if it's broken.