70 lines
2.1 KiB
Plaintext
70 lines
2.1 KiB
Plaintext
|
;nyquist plug-in
|
||
|
;version 4
|
||
|
;type generate
|
||
|
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
|
||
|
;author "dm"
|
||
|
;name "Reverb Impulse Drum..."
|
||
|
;action "Generating..."
|
||
|
;info ""
|
||
|
|
||
|
;control band-list "List: (center amplitude &optional bandwith)" string "" "(420 0.5 250) (1500 0.3 150) (4300 0.01) (7500 0.02 2000) (12345 0.01 3000) (3500 0.05 300)"
|
||
|
;control impulse-type "Kind of Impulse" choice "chirp, noise, spike" 0
|
||
|
;control impulse-volume "Volume of Impulse" float "" 0.5 0 1
|
||
|
;control impulse-length "Length of Impulse (ms)" float "" 10 1 50
|
||
|
;control decay "Decay" float "" 0.5 0.01 1
|
||
|
|
||
|
(setq impulse-length (mult 0.001 impulse-length))
|
||
|
|
||
|
;Stolen from David R. Sky's Sequencer2, I don't know how this works.
|
||
|
(defun string-to-list (string)
|
||
|
(read (make-string-input-stream (format nil "(~a)" string))))
|
||
|
|
||
|
(defun normalize (signal &optional (amplitude 1))
|
||
|
(setf factor (/ amplitude (peak signal ny:all)))
|
||
|
(scale factor signal)
|
||
|
);end normalize
|
||
|
|
||
|
(defun gen-noiseband (center &optional (amplitude 1) (bandwidth 1000))
|
||
|
(partial (hz-to-step center) (lowpass8 (normalize (noise 1) amplitude) bandwidth))
|
||
|
);end gen-noiseband
|
||
|
|
||
|
(defun gen-response (band-list dur)
|
||
|
(setf bands ())
|
||
|
(dolist (band-params (string-to-list band-list))
|
||
|
(setf bands (cons (apply #'gen-noiseband band-params) bands))
|
||
|
);end dolist
|
||
|
(mult (normalize (apply #'sim bands) impulse-volume)
|
||
|
(pwlv 1 (* dur 0.25) 0.1 dur 0))
|
||
|
);end response
|
||
|
|
||
|
(defun chirp-impulse (dur)
|
||
|
(mult (hzosc (sum
|
||
|
(pwlv (/ *sound-srate* 2.1) (* dur 0.3) 100 dur 1) ;frequency of hzosc
|
||
|
(scale 100 (noise dur)) ;noise to vary frequency of chirp randomly
|
||
|
));end of hzosc
|
||
|
(pwlv 1 dur 0)) ;envelope to get rid of click at and of impulse
|
||
|
);end gen-impulse
|
||
|
|
||
|
(defun noise-impulse (dur)
|
||
|
(noise dur)
|
||
|
)
|
||
|
|
||
|
(defun spike-impulse (dur)
|
||
|
(pwl (/ dur 5.0) 1 dur 0)
|
||
|
)
|
||
|
|
||
|
(defun gen-impulse (dur)
|
||
|
(cond ;chooses which kind of impulse
|
||
|
((= impulse-type 0) (chirp-impulse dur))
|
||
|
((= impulse-type 1) (noise-impulse dur))
|
||
|
((= impulse-type 2) (spike-impulse dur))
|
||
|
);end cond
|
||
|
)
|
||
|
|
||
|
|
||
|
(setf impulse (normalize (gen-impulse impulse-length) impulse-volume))
|
||
|
(setf response (gen-response band-list decay))
|
||
|
(lowpass8 (sum
|
||
|
impulse
|
||
|
(convolve impulse response))
|
||
|
15000)
|