jcrev.scm 2.25 KB
Newer Older
1 2
(provide 'snd-jcrev.scm)

3 4 5
(if (provided? 'snd)
    (require snd-ws.scm)
    (require sndlib-ws.scm))
6 7


8
(definstrument (jc-reverb low-pass (volume 1.0) amp-env)
9
  "(jc-reverb (low-pass #f) (volume 1.0) (amp-env #f)) -- Chowning reverb"
10 11 12 13 14 15 16 17 18
  (let ((allpass1 (make-all-pass -0.700 0.700 1051))
	(allpass2 (make-all-pass -0.700 0.700  337))
	(allpass3 (make-all-pass -0.700 0.700  113))
	(comb1 (make-comb 0.742 4799))
	(comb2 (make-comb 0.733 4999))
	(comb3 (make-comb 0.715 5399))
	(comb4 (make-comb 0.697 5801))
	(chns (channels *output*))
	(file-dur (framples *reverb*)))
19

20
    (let ((len (floor (+ *clm-srate* file-dur)))
21 22 23 24 25 26 27 28
	  (filts (if (= chns 1) 
		     (vector (make-delay (seconds->samples .013)))
		     (vector (make-delay (seconds->samples .013))
			     (make-delay (seconds->samples .011)))))
	  (combs (make-comb-bank (vector comb1 comb2 comb3 comb4)))
	  (allpasses (make-all-pass-bank (vector allpass1 allpass2 allpass3))))

      (if (or amp-env low-pass)
29
	  (let ((flt (and low-pass (make-fir-filter 3 #r(0.25 0.5 0.25))))
30 31 32 33 34 35 36 37
		(envA (make-env :envelope (or amp-env '(0 1 1 1)) :scaler volume :duration (/ len *clm-srate*))))
	    (if low-pass
		(do ((i 0 (+ i 1)))
		    ((= i len))
		  (out-bank filts i (* (env envA) (fir-filter flt (comb-bank combs (all-pass-bank allpasses (ina i *reverb*)))))))
		(do ((i 0 (+ i 1)))
		    ((= i len))
		  (out-bank filts i (* (env envA) (comb-bank combs (all-pass-bank allpasses (ina i *reverb*))))))))
38 39 40 41 42 43 44 45 46 47 48 49
	  (if (= chns 1)
	      (let ((gen (filts 0)))
		(do ((i 0 (+ i 1)))
		    ((= i len))
		  (outa i (delay gen (* volume (comb-bank combs (all-pass-bank allpasses (ina i *reverb*))))))))
	      (let ((gen1 (filts 0))
		    (gen2 (filts 1)))
		(do ((i 0 (+ i 1)))
		    ((= i len))
		  (let ((val (* volume (comb-bank combs (all-pass-bank allpasses (ina i *reverb*))))))
		    (outa i (delay gen1 val))
		    (outb i (delay gen2 val))))))))))
50
  
51
;;; (with-sound (:reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount .3))
52 53 54
;;; (with-sound (:reverb jc-reverb) (outa 0 .1) (outa 0 .5 *reverb*))
;;; (with-sound (:reverb jc-reverb :reverb-data '((:low-pass #t))) (outa 0 .1) (outa 0 .5 *reverb*))
;;; (with-sound (:statistics #t :reverb jc-reverb :reverb-data '((:low-pass #t))) (outa 0 .1) (outa 100000 .1) (outa 0 .5 *reverb*) (outa 100000 .5 *reverb*))