Hey I am working on a continuously-variable-response expander plugin. I have the following basic formula (distilled from the quadratic equation) which I know works on a mathematical level:

the formula is: output = 1 - (sqrt (1 - (abs s))). [not in Nyquist syntax obviously]

A. How to apply the square root operation to the (1 - (abs s)). I am getting either “…did not return data” or a completely-used-up CPU and a frozen Audacity…it’s becoming obvious that I don’t get how square roots work in Nyquist.

B. Logical operation. The formula as it is basically rectifies the signal. I would like a simple formula that applies all the way from -1 to +1, but if an “if s is positive, return positive result; if s is negative, return the negative of the result” is necessary I am happy.

So I’m pretty much ready to have my mind blown if anybody wants to hack through this and/or help me get a handle on the way Nyquist handles these things so I can look for a more elegant solution.

Thanks for the reply Steve, and I’m glad there’s a place for Nyquist-specific questions here.

Is there no way using Nyquist to evaluate the square root of an expression that contains a sound? The (sqrt (1-s)) function is irreducible mathematically as far as I know. I worked last night and this morning to come up with some kind of workaround, but am still coming up empty-handed.

Thanks, steve! You are two for two making my day between this and my soft-clipping limiter.

Rookie mistake on my part. I called the function “expand” without realizing that it was a native Nyquist function.
So I applied the “clip” function and ended up with a delightful expander plug-in that works to counteract the effect of the soft-clipper you helped me with. I suspect the expander will work well to ameliorate some of the damage done to any heavily-compressed material, as long as it’s not hard-clipped.

So, anyway, here is the soft clipper:

;nyquist plug-in
;version 1
;type process
;name “soft-clipping brickwall limiter”

;action “Burnishing…”

(defun limit (s) (mult 1.999 (mult s (diff 1.0 (mult 0.5 (s-abs s))))))
(limit s)

And here is the expander:

;nyquist plug-in
;version 1
;type process
;name “soft-knee expander”