I have searched a bit but could not find any Expander plugin written in Nyquist.
An expander has been adressed in some discussion (some dating back as far as 2010) but it looks like no Expander has been made.
Let me introduce myself, as far as it is necessary for this thread: I am novice, both to compressors/expanders and Nyquist. I’ve just created my first simple plugin for personal use (under Steve’s tutelage). What I am trying to do? Quite a lot of recent music is heavily compressed and for my own listening pleasure I would like to expand them to some degree but do that in a somewhat automated way using data coming from diverse analyses (like RMS and peak info).
What I have found on this forum:
Soft Clipping Limiter from back in 2011 - originally called Peak Limiter / Expander, finally got rid of the expander. But the final version of the Peak Processor looks promising except that it clips anything above 1.0 (which it should not, as far as I’m concerned).
Square Roots and If-Thens from 2010 - it’s soft-knee expander seemed to shift some audio data but didn’t quite work as expected.
In September 2017 Steve explained the use of the (gate…) function to create an expander in the thread Nyquist code with the opposite of the Compressor effect but there was no follow-up.
Then there was some talk about using Dynamic Mirror as an expander but as far I can tell it mirrors some reference track only: Envelope follower / ducker from October 2017.
The oldest Nyquist plugin wasn’t even found on this Audacity forum but apparently its predecessor: Nonlinear Compressor/Limiter/Expander from 2008 by Igor Chernenko.
To me Steve’s Peak Processor is probably the best ticket so far.
;nyquist plug-in ;version 1 ;type process ;categories "http://lv2plug.in/ns/lv2core/#DynamicsPlugin" ;name "Peak Processor..." ;action "processing peaks..." ;info "Peak Limiter / Expander.\nBy Steve Daulton (www.easyspacepro.com). Released under GPL v2.\n" ;; Version 1.1 ;; peakprocess.ny by Steve Daulton, January 2011 ;; Released under terms of the GNU General Public License version 2 ;; http://www.gnu.org/copyleft/gpl.html ;control thresh "Threshold" real "linear" 0.5 0 1.0 ;control ratio "Ratio [Compress]" real "[Expand]" 0 -20 20 (setq ratio (float ratio)) (defun compress (s-in val) (let ((pos (s-max 0 s-in)) (neg (mult -1 (s-min 0 s-in)))) (sim (mult (/ val)(sum -1 (s-exp (mult val pos)))) (mult (/ -1 val)(sum -1 (snd-exp (mult val neg))))))) (defun expansion (s-in val) (let ((pos (s-max 0 s-in)) (neg (mult -1 (s-min 0 s-in))) (val (mult -1 val))) (sim (mult (/ val)(s-log (sum 1 (mult val pos)))) (mult (/ -1 val)(s-log (sum 1 (mult val neg))))))) (defun process (s-in) (let* ((nthresh (* -1 thresh)) (tops (s-max s-in thresh)) (mids (s-max (s-min s-in thresh) nthresh)) (bottoms (s-min s-in nthresh))) (if (< ratio 0) (sim mids (compress (sum (mult -1 thresh) tops) ratio) (compress (sum thresh bottoms) ratio)) (if (> ratio 0) (progn ;; Prevent inf and nan sample values (setq tops (s-min tops (sum thresh -0.0000001 (/ ratio)))) (setq bottoms (s-max bottoms (mult -1 (sum thresh -0.0000001 (/ ratio))))) (clip (sim mids (expansion (sum (mult -1 thresh) tops) ratio) (expansion (sum thresh bottoms) ratio))1.0)) (format nil "Ratio at zero.\nNothing to do."))))) (multichan-expand #'process s)
Or the gate function:
(gate gatefollow lookahead risetime falltime floor threshold)
Or as it is defined in the Github repository:
(defun gate (sound lookahead risetime falltime floor threshold) (cond ((< lookahead risetime) (break "lookahead must be greater than risetime in GATE function")) ((or (< risetime 0) (< falltime 0) (< floor 0)) (break "risetime, falltime, and floor must all be positive in GATE function")) (t (let ((s (snd-gate (seq (cue sound) (abs-env (s-rest lookahead))) lookahead risetime falltime floor threshold))) (snd-xform s (snd-srate s) (snd-t0 sound) (+ (snd-t0 sound) lookahead) MAX-STOP-TIME 1.0)))))
Probably Igor’s expander is worth a look too. Has anyone else some other suggestions as to where this expander idea has been discussed?