If I have the following PDefn:
// Set Pattern1 environment first with initial values
Pdefn(\Pattern1).set
(
\instrument, "bass",
\midinote, 40,
\dur, Pseq([1.0,1.0,1.0,1.0], inf),
\legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
\amp, 0.5,
\detune, 0.005
);
// Need to refer to Pattern1 environment in some way so
create a variable =
envir
e = Pdefn(\Pattern1).envir;
// Define Pattern1
Pdefn //(key,Pattern)
(
\Pattern1,
{
arg e;
Pbind
(
\instrument, e.instrument,
\midinote, e.midinote,
\dur, e.dur,
\legato, e.legato, //
/legato is a common synth parameter (find out
others)
\amp, e.amp,
\detune, e.detune
)
}
);
Which is played via instrument:
SynthDef("bass",
{
arg freq = 440, gate = 1, amp = 0.5,
slideTime = 0.17, ffreq = 1100,
width = 0.15,
detune = 1.005, preamp = 4;
var sig,
// --------------------------------------------------
env = Env.adsr(0.01, 0.3, 0.4, 0.1);
freq = Lag.kr(freq, slideTime);
sig = Mix(VarSaw.ar([freq, freq * detune], 0,
width, preamp)).distort *
amp
* EnvGen.kr(env, gate, doneAction: 2);
sig = LPF.ar(sig, ffreq);
// --------------------------------------------------
Out.ar(0, sig ! 2)
}).load(s);
Using the command:
Pseq([Pdefn(\Pattern1)], inf).play;
How do I change the environment for the next note in the sequence rather
than when the pattern is repeated?
For example setting a new \midinote:
Pdefn(\Pattern1).set(\midinote, 70);
Will only update once the pattern has come to the end of a repetition. How
can I update it immediately, or when it is next safe to do so?