audacity-plugins/TONERATIO.ny

26 lines
808 B
Common Lisp

;nyquist plug-in
;version 4
;type generate
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
;preview linear
;name "Common Ratio Tone..."
;action "Generating Tone..."
;author "dm"
;control decay "Decay" float "" 0.5 0 1
;control ratio "Ratio" float "" 2 1 5
;control fund-freq "Frequency (Hz)" float "" 420 1 600
;control duration "Length (Seconds)" float "" 3 0 6
(setq loop-number (truncate
(/ (log (/ *sound-srate* fund-freq)) (log ratio))))
(do* ((cur-ind 1 (incf cur-ind))
(cur-pch (hz-to-step fund-freq) (hz-to-step (* ratio (step-to-hz cur-pch))))
(cur-vol decay (* decay cur-vol))
(result (scale cur-vol (sine cur-pch duration))
(sum result (scale cur-vol (sine cur-pch duration)))))
((>= cur-ind loop-number) result)
(print cur-pch)
(print cur-vol))