Say I have a track with a bunch of clips already defined in it. They even have a labels track that coincides with the clip regions, if that helps. How can I apply an effect like fade-in to each clip (i.e. region) separately, but with one command? If select the track it will apply the effect only one time to the whole track. So how can make Audacity do the programming equivalent of “for each clip, apply effect”?
You would need to write a Nyquist Macro to run the effect “for each clip”.
See here for information about Nyquist Macros: Missing features - Audacity Support
I’m guessing that suggestion applies to a non-Nyquist plugin, called from a macro. I tested briefly and thankfully a VST one doesn’t get a GUI when called from a macro, so it is feasible solution. But an internal Nyquist plugin has to process the whole thing in one call. So it has to something like this for the latter:
; todo controls for these
(setq fade-in-time 1.3)
(setq fade-out-time 0.5)
(setq all-is-sel (and
(= (get '*selection* 'start) (get '*track* 'start-time))
(= (get '*selection* 'end) (get '*track* 'end-time))))
(setf track-clips (get '*track* 'clips))
(setq brk-env (list 0))
; todo: support selection window
(setq track-length (get '*track* 'end-time))
; todo: error checking for clp-times diff less than fade-in-time + fade-out-time
(dolist (clp-times track-clips)
(push (/ (first clp-times) track-length) brk-env) (push 0 brk-env)
(push (/ (+ (first clp-times) fade-in-time) track-length) brk-env) (push 1 brk-env)
(push (/ (- (second clp-times) fade-out-time) track-length) brk-env) (push 1 brk-env)
(push (/ (second clp-times) track-length) brk-env) (push 0 brk-env))
(setq brk-env (reverse brk-env))
(if all-is-sel
(mult (pwlv-list brk-env) *track*)
"Please select the whole track."))
By the way, if you wonder why the “if” is at the end: something like
(if t (return "Please select the whole track."))
at the Nyquist prompt hangs Audacity with 100% CPU usage. I’m not sure if that’s supposed to happen like that or it’s a bug. Mkay, it’s incorrect XLisp because the return is not in a supported context, but I’m guessing it should be spitting an error, not hanging. I filled github issue for the latter, as not to side-track this discussion further with that nuisance.