;nyquist plug-in ;version 4 ;type process ;preview linear ;name "Filter Sweep (Track Input)..." ;action "Filtering..." ;author "dm" ;control type "Filter Type" choice "Low-Pass,High-Pass,Band-Pass" 0 ;control intensity "Intensity" int-text "" 1 1 50 ;control max-cu-freq "Maximum Cutoff Frequency" float "" 15000 1 22030 ;clip to halfwave, scale to max cutoff freq, downsample to control rate, store, ;compute (defun store-as-cutoff (signal) (setf to-store (sim (s-rest 0) (force-srate *control-srate* (scale max-cu-freq (s-min (const 1) (s-max (s-rest 1) signal)))))) (putprop '*SCRATCH* (sim (s-rest 0) to-store) 'DM-FSWEEP-CUTOFF) *TRACK*) (defun clear-storage () (remprop '*SCRATCH* 'DM-SWEEP-CUTOFF)) (defun iter-lp (signal cutoff iter) (print (snd-length cutoff ny:all)) (dotimes (n iter signal) (setf signal (lp signal cutoff)))) (defun iter-hp (signal cutoff iter) (dotimes (n iter signal) (setf signal (hp signal cutoff)))) (defun apply-filter (cutoff) (let* ((bandwidth (/ *sound-srate* (float intensity) 5.0))) (case type (0 (iter-lp *TRACK* cutoff intensity)) (1 (iter-hp *TRACK* cutoff intensity)) (2 (reson *TRACK* cutoff bandwidth 1))))) (setq index (get '*TRACK* 'INDEX)) (setq tracks (length (get '*SELECTION* 'TRACKS))) (if (< tracks 2) (print "Select 2 tracks") (if (< index tracks) (store-as-cutoff *TRACK*) (let ((cutoff (get '*SCRATCH* 'DM-FSWEEP-CUTOFF))) (if (= index tracks) (clear-storage)) (multichan-expand #'apply-filter cutoff))))