SVF doesn't like res controlled with mouse set to warp

I love the SVF filter , which I think is an extemsnion
It seems that the resonance does not respond to Mouse position when set to warp 1 or 2
Switch \switchwap to 1 or 2 in the set line

``````(
SynthDef(\test,
{
|amp=0.2,amp2=0.2,freq=60,pan=0,detune=1,switchwarp=0|
var sig, sig2;
sig=Saw.ar(freq.midicps )*amp;
sig2=Pulse.ar((freq+detune).midicps)*amp2;
sig=SVF.ar(sig,MouseX.kr(20,20000,1),res:MouseY.kr(0,0.96,switchwarp))!2;
Out.ar(0,sig)
)
z=Synth(\test)
z.set(\amp,0.2,\amp2,0.2,\freq,30,\detune,0.4,\pan,0,\switchwarp,0,)
z.free

``````

SVF is fine.

TL;DR in exponential mapping, the boundaries of the range must not cross or touch 0.

• 1, 5 â€“ OK, both nonzero and positive
• -5, -1 â€“ OK, both nonzero and negative
• -1, 5 â€“ not OK, mixed signs
• 0, 5 â€“ not OK, touches 0
• -5, 0 â€“ not OK, touches 0

Why?

In my class, I first introduce the idea of mapping a normal range (0 â€¦ 1) onto a desired output range. Starting with a normal range simplifies the math.

Linear mapping is then based on the difference between the boundaries: if `x` is the normalized input, `y = (b - a) * x + a`.

Exponential mapping is based on the ratio between the boundaries: `b / a` instead of `b - a`. One way that I think of this is â€śpromotingâ€ť operators: subtraction gets pushed up to division (and addition, up to multiplication); and the `* x` gets pushed up to power-of.

``````(
f = { |x, a = 1, b = 2|
(b / a) ** x * a;
};
)

f.(0.5, 1, 0);
-> 0

f.(0.0, 1, 0);
-> 1.0

f.(0.5, 0, 1);
-> -nan

f.(0.5, -1, 1);
-> -nan
``````

If b is 0, then b/a = 0, and every nonzero x will produce 0! Which is correct according to the formula, but not useful, so, donâ€™t do it. (x == 0 produces 1.0 â€“ which is a dodge because mathematically, 0.0 ** 0.0 is undefined â€“ there are plenty of YouTube videos explaining this, I wonâ€™t repeat it here.)

If a is 0, then b/a = inf, and the result is â€śnot a numberâ€ť (this is an actual special-case floating-point value, for invalid calculations).

If b/a is negative, then raising that to a fractional power is very likely to require imaginary numbers (-4 ** 0.5 is invalid, but Complex(-4, 0) ** 0.5 == Complex( 1.2246467991474e-16, 2.0 ) which is 2i once you ignore the floating-point rounding error)â€¦ but floating-point is in the real-number domain, so, it canâ€™t be done (NaN again).

The 0 in your MouseY is OK for linear mapping, but mathematically impossible for exponential mapping. You will have to change the lower limit to a positive value when `switchwarp` is 2, e.g., `MouseY.kr((switchwarp >= 2) * 0.01, 0.96, switchwarp)`.

hjh

1 Like