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]

Here's the actual plugin as I have it now:

;nyquist plug-in

;version 1

;type process

;name "soft expander"

(defun expand (s) (diff 1 (sqrt (diff 1 (s-abs s)))))

(expand s)

The problems I am having are twofold:

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.