Hey,
i normally use an event \type
for passing envelopes into Patterns with this syntax:
~utils = ();
~utils.hasEnv = {
var durSeconds = ~sustain.value / thisThread.clock.tempo;
var envKeys = currentEnvironment.keys.select{|k|"[eE]nv$".matchRegexp(k.asString)};
envKeys.do{|param|
var value = currentEnvironment[param];
if (value.isArray.not) { value = [value] };
value = value.collect {|v|
if (v.isRest) { v } {
if (v.isKindOf(Env).not) { v = Env([v, v], [1]) }
};
v.duration = durSeconds;
};
currentEnvironment[param] = value;
};
};
Event.addParentType(\hasEnv,(
finish: ~utils[\hasEnv]
));
Pbind(
\type, \hasEnv,
[...]
\finish, ~utils[\hasEnv],
);
lately i was trying to use looping ctrlEnvs with passed envelopes to modulate parameters from a source synth inside Patterns like this, which is working fine (the ctrlEnv is actually more like a LFO with .range
i guess. EDIT: ive seen with the Auto Map Control Approach LFO and ModEnv could both be declared in the Pattern, which is really what im searching for.
(
SynthDef(\ctrlEnv, {
var ctrlEnv = \ctrlEnv.ar(Env.newClear(12).asArray);
var sig;
ctrlEnv = EnvGen.kr(ctrlEnv, \gt.kr(1), doneAction: Done.freeSelf);
sig = ctrlEnv.range(\ctrlMin.kr(0.1), \ctrlMax.kr(1.2));
Out.kr(\out.kr(0), sig)
}).add;
)
(
Pdef(\source,
Pbind(
\type, \hasEnv,
\instrument, \source,
\dur, 4,
\phase, ~bus[\ctrl][0].asMap,
[...]
\atk, 1,
\sus, 2,
\rel, 1,
\gainEnv, Pfunc{|e|
Env.linen(e.atk, e.sus, e.rel, curve: \sine)
},
\sustain, Pfunc { |ev| ev[\gainEnv].duration },
\finish, ~utils[\hasEnv],
)
);
)
(
Pdef(\ctrlEnv,
Pbind(
\type, \hasEnv,
\instrument, \ctrlEnv,
\dur, inf,
\ctrlMin, 0.1,
\ctrlMax, 1.2,
\atk, 0.5,
\sus, 1,
\rel, 0.5,
\ctrlEnv, Pfunc{|e|
Env([0, 0, 1, 0], [e.atk, e.sus, e.rel], \sin, releaseNode: 2, loopNode: 0);
},
\sustain, Pfunc { |ev| ev[\ctrlEnv].duration },
\out, ~bus[\ctrl][0],
\group, ~ctrlGrp,
\finish, ~utils[\hasEnv],
)
);
)
(
Pdef(\source_ctrl,
Ptpar([0, Pdef(\source), 0.0001, Pdef(\ctrlEnv)])
).play;
)
then ive seen this thread Composite notes: Auto-mapping synth controls to events where its own Event \type
\notemap
, declared in TempBus
is used to modulate parameters inside patterns with passed envelopes. Now my question is how do i combine / merge both of the event \types
? Because for all the other Envelopes beside the Ctrl ones i would still like to use \type \hasEnv
in the source. Im sorry for my probably general misunderstanding of Events.
I really like the idea of PAutomation
discussed there