# How to exponentially change time values in a Penv?

Hey everyone!

I’m quite new to SuperCollider and I wonder if there is a possibility (and as I know in SuperCollider there is one) to pan my Synth in a pattern in this special way: Starting at pan position 0, then -1, back to 0, then 1, back to 0 and starting all over.

I’ve tried this slightly changed “trick” described in the “Practical Guide to Patterns” by H. James Harkins:

(

SynthDef.new(\test, {

arg freq = 440, atk = 0.01, rel = 0.5, pan = 0, out = 0, amp = 0.05;

var sig, env;

sig = SinOsc.ar(freq);

env = Env.perc(atk, rel).ar(2);

sig = sig * env;

sig = Pan2.ar(sig, pan);

Out.ar(out, sig * amp);

)

(

Pbind(

\instrument, \test,

\dur, 0.2,

\freq, 440,

\pan, Pn(Pif(Ptime(inf) <= 20.0, Penv([0, -1, 0, 1, 0], [5, 5, 5, 5], 'lin')), inf),

).play;

)


This works well!

But what do I have to change to make this panning movement evolving exponentially in time?
I’ve tried to replace the time values in the Penv (also in one case wraped in a Ptuple) with Pseg but SuperCollider then says that there is no Boolean in test (+ “RECEIVER: a Pbinop”):

\pan, Pn(Pif(Ptime(inf) <= 20.0, Penv([0, -1, 0, 1, 0], Ptuple([(Pseg([5, 0], 20, 'lin', 1)), (Pseg([5, 0], 20, 'lin', 1)), (Pseg([5, 0], 20, 'lin', 1)), (Pseg([5, 0], 20, 'lin', 1))]), 'lin')), inf),


The reason seems to be that Ptime is missing some kind of time information or so…

Can someone tell me what to use or change?

Hey Pseg may be the answer you’re looking for

Pbind(
\default, \test,
\pan, Pseg(levels:[0,-1,0,1],durs:[16],curves:\exp,repeats:inf),
)


Hope that helps

MJ

Ah apologies, I think I misread your question - you’re wanting to develop the panning motion over time by using different panning models.

Thank you for your answer, but yeah as you say it: the panning motion should increase exponentially…

Certainly you could implement the acceleration in the language but I think it’s easier to use the server here. A dedicated pan synth can play to a bus from which the pattern / eventstreamplayer reads. Two variants then: the pan value can be read per event or the synths can be mapped to the bus. Slightly different effect and with the second variant you can go to faster movements.

(
SynthDef.new(\test, {
arg freq = 440, atk = 0.01, rel = 0.5, pan = 0, out = 0, amp = 0.05;
var sig, env;
sig = SinOsc.ar(freq);
env = Env.perc(atk, rel).ar(2);
sig = sig * env;
sig = Pan2.ar(sig, pan);
Out.ar(out, sig * amp);

SynthDef(\pan, { |out, duration, start = 0.1, end = 1.5|
Out.kr(out, SinOsc.kr(XLine.kr(start, end, duration), pi))

c = Bus.control(s, 1);
)

(
p = Pbind(
\instrument, \pan,
\duration, 20,
\dur, inf,
\start, 0.1,
\end, 1.5,
\out, c,
\group, g = Group.new
);

q = Pbind(
\instrument, \test,
\dur, 0.2,
\freq, 440,
\pan, Pfunc { c.getSynchronous }
);

r = Ptpar([0, p, 0.0001, q]).play;
)

(
r.stop;
g.free;
)

(
p = Pbind(
\instrument, \pan,
\duration, 20,
\dur, inf,
\start, 0.1,
\end, 20,
\out, c,
\group, g = Group.new
);

q = Pbind(
\instrument, \test,
\dur, 0.2,
\freq, 440,
\pan, c.asMap
);

r = Ptpar([0, p, 0.0001, q]).play;
)

(
r.stop;
g.free;
)


Different strategies of LFO-like pattern control like these are described in miSCellaneous_lib quark’s tutorial “Event patterns and LFOs”

2 Likes

Thank you very much! It works!
Interesting solution at all…

But what is actually the difference in detail between these two solutions?
The one with
\pan, Pfunc { c.getSynchronous }
doesn’t produce those kind of “artefacts” in terms of a frequency drop which I’ve got with the
\pan, c.asMap.

It actually sounds very remarkable…

But anyway, thank you very much for your help!

Best regards

With the first one the pitches are constant for every synth, with the second every event produces a glissanding synth. In other words with (1) you get overlapped clusters that give the impression of a glissando, with (2) you get a real glissando for every event and the overlappings produce a slow amplitude modulation of the glissando line.
The difference should become audibly striking if you take longer events of, say, one second. Also striking if you take, say, 100 as end frequency for (2), then you have the timbre of classical AM in every channel, whereas with (1) the fast panning cannot be taken over as the pan position is only polled 5 times per second.

I understand - really interesting…