I am trying to understand phasor behavior when setting starting values bigger than the endpoint. Like this:
Here the linear ramp is as expected bottom to top
{Phasor.ar(0, SampleRate.ir.reciprocal*100, -1, 1)}.plot(0.1);
Here I will expect the other way, a linear ramp from top to bottom:
{Phasor.ar(0, SampleRate.ir.reciprocal*100, 1, -1)}.plot(0.1);
Like this:
{Phasor.ar(0, SampleRate.ir.reciprocal*100, -1, 1).neg}.plot(0.1);
I can see a fast drop to the end point then a linear ramp back to top.
Of course, I am interested in arbitrary starts and endpoints and I found my way with linear interpolations
Phasor.ar(0, SampleRate.ir.reciprocal*100).linlin(0, 1, pos, pos.neg);
where pos
is a target value set from outside the synth.
I know, I can do it with EnvGen.ar but I like to understand Phasor behavior.
Thanks
Here I will expect the other way, a linear ramp from top to bottom:
{Phasor.ar(0, SampleRate.ir.reciprocal*100, 1, -1)}.plot(0.1);
If you want the ramp to go downward, then “rate” must be negative. But you’ve supplied a positive rate – so the ramp can only go upward over time.
I can see a fast drop to the end point then a linear ramp back to top.
That’s expected in this case: It’s going upward, starting at the top, which requires an immediate wraparound back to the bottom.
Of course, I am interested in arbitrary starts and endpoints
A helper function could determine the sign of the rate automatically:
f = { |trig, absRate, start, end, resetPos|
Phasor.ar(trig, rate * sign(end - start), start, end, resetPos)
};
hjh
Thank you James, negative rate of course! as in Sweep
.