34 lines
939 B
Plaintext
34 lines
939 B
Plaintext
|
;nyquist plug-in
|
||
|
;version 4
|
||
|
;type process
|
||
|
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
|
||
|
;preview linear
|
||
|
;name "Harmonize..."
|
||
|
;action "Harmonizing..."
|
||
|
;author "dm"
|
||
|
|
||
|
;control decay "Decay" float "" 0.5 0 1
|
||
|
;control harmonics "Harmonics" int "" 2 1 10
|
||
|
|
||
|
(setq minor-third (/ 6.0 5.0))
|
||
|
(setq major-third (/ 5.0 4.0))
|
||
|
|
||
|
(defun get-ratio (index)
|
||
|
(if (evenp index)
|
||
|
(/
|
||
|
(* (expt minor-third (float (/ index 4)))
|
||
|
(expt major-third (float (/ (+ 2 index) 4)))))
|
||
|
(*
|
||
|
(expt minor-third (float (+ 1 (/ index 4))))
|
||
|
(expt major-third (float (/ (+ 1 index) 4))))))
|
||
|
|
||
|
(defun normalize (signal)
|
||
|
(let ((x (* (peak signal ny:all) 0.95)))
|
||
|
(setq signal (scale (/ x) signal))))
|
||
|
|
||
|
(do* ((index 0 (incf index))
|
||
|
(ratio nil (get-ratio index))
|
||
|
(vol 1.0 (* vol decay))
|
||
|
(result *TRACK*
|
||
|
(sum result (scale vol (pitshift *TRACK* ratio 1.0)))))
|
||
|
((>= index harmonics) (normalize result)))
|