;nyquist plug-in
;version 3
;type process
;name "Multi-Tap Test 2..."
;action "Multi-Tap Test 2..."
;info "This is a test plugin, not for production use."
;control delay "Room Size" real "ms" 30 15 100
;control decay "Intensity" real "%" 50 25 75
;control cutoff "Brightness" real "Hz" 2000 500 5000
;control rolloff "Damping" real "%" 25 10 50
;control taps "Density" int " " 5 1 10
;control diff "Diffusion" int " " 10 4 20
(setf delay (* 0.001 (min 100 (max 15 delay))))
(setf decay (* 0.01 (min 75 (max 25 decay))))
(setf cutoff (min 5000 (max 500 cutoff)))
(setf rolloff (* 0.01 (- 100 (min 50 (max 10 rolloff)))))
(setf taps (min 10 (max 1 (round taps))))
(setf diff (min 20 (max 4 (round diff))))
(format t "delay ~a~%" delay)
(format t "decay ~a~%" decay)
(format t "cutoff ~a~%" cutoff)
(format t "rolloff ~a~%" rolloff)
(format t "taps ~a~%" taps)
(format t "diff ~a~%" diff)
(defun tapped-delay (snd delay)
(do ((del delay (+ del delay)) ; delay time
(dec decay (* dec decay)) ; volume level
(cut cutoff (* cut rolloff)) ; lowpass frequency
(i 0 (1+ i))) ; tap counter
((= i taps) snd)
(setf snd (sum snd (mult dec (at-abs del (cue (lp snd cut))))))))
;; The prime numbers must be in a range of 1:2 (octave)
(setf prime-offset ; prime numbers
(case diff ( 4 0) ; 11 .. 19
( 5 2) ; 17 .. 31
( 6 4) ; 23 .. 43
( 7 5) ; 29 .. 53
( 8 7) ; 37 .. 67
( 9 9) ; 43 .. 79
(10 10) ; 47 .. 89
(11 11) ; 53 .. 101
(12 11) ; 53 .. 103
(13 12) ; 59 .. 109
(14 12) ; 59 .. 113
(15 15) ; 71 .. 139
(16 18) ; 83 .. 163
(17 19) ; 89 .. 173
(18 20) ; 97 .. 181
(19 20) ; 97 .. 191
(20 20))) ; 97 .. 193
(defun prime-number (n)
(aref #(11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79
83 89 97 101 103 107 109 113 127 131 137 139 149 151
157 163 167 173 179 181 191 193)
(+ prime-offset n)))
;; A delay "base" number is computed by dividing the delay time by the
;; smallest prime number, the result is then rounded to the next integer
;; sample time. Multiplying this base number with integer prime numbers
;; will always produce delay times that match integer sample times.
;; round (/ delay first-prime) to the next integer sample value
(setf delay (/ (round (* (/ delay (prime-number 0)) *sound-srate*))
*sound-srate*))
(format t "rounded delay ~a~%" (* delay (prime-number 0)))
(format t "delay base is ~a samples" (* delay *sound-srate*))
(defun multi-tap (snd)
(let ((tap (s-rest)))
(dotimes (n diff)
;; (format t "prime ~a~%" (prime-number n 0))
(setf tap (sum tap (tapped-delay snd (* delay (prime-number n))))))
(mult (/ 1.0 (1+ diff)) ; 1 / (snd + number-of-taps)
(sum snd (extract-abs 0.0 (get-duration 1.0) tap)))))
(defun early-reflections (snd)
(if (arrayp snd)
(vector (multi-tap (aref snd 0))
(multi-tap (aref snd 1)))
(multi-tap snd)))
(early-reflections s)