(definstrument squelchy (beg dur file skip squelch) (let* ((skipsamp (floor (* (or skip 0) (sound-srate file)))) (fdA (open-input file :channel 0 :start skipsamp :verbose t)) (two-chans (and (= (sound-chans file) 2) (= (mus-channels *output*) 2))) (fdB (and two-chans (open-input file :channel 1 :start skipsamp :verbose t))) (rdA (make-readin fdA)) (rdB (make-readin fdB)) (st (floor (* *srate* beg))) (nd (+ st (floor (* *srate* dur)))) ) (run (loop for i from st below nd do (let ((outvalA (readin rdA)) (outvalB (readin rdB))) (if (< (* -1 squelch) outvalA squelch) (setf outvalA 0)) (if (< (* -1 squelch) outvalB squelch) (setf outvalB 0)) (outa i outvalA) (if two-chans (outb i outvalB))) )) (close-input fdA) (if two-chans (close-input fdB)))) #| (compile-file "squelchy.ins") (load "squelchy.cmucl") (with-sound (:srate 44100 :channels 2 :statistics t :scaled-to .5 :output "/zap/squelchy.snd") (squelchy 0 10 "/home/bsack/sounds/apresafter.wav" 48 .005)) |#