Hello all,
I have a sound source SynthDef and a separate one for effects.:
(
s.bind{
~bAmono.free;
s.newBusAllocators;
s.sync;
~bAmono = Bus.audio(s,1);
~bAmono.postln;
};
SynthDef(\test,{
// src
x = Saw.ar(\freq.kr(65));
x = x * Env.asr.kr(2,\gate.kr(1));
Out.ar(\out.kr(0),x*\amp.kr(0));
}).add;
SynthDef(\testFX,{
var trigger;
// in
x = In.ar(\in.kr(0),1);
// RLPF
y = Env(
levels: [820,210],
times: [\rel.kr(1)],
curve: -4
).kr(0,\gate.kr(1));
x = RLPF.ar(
in: x,
freq: y.poll,
rq: 0.13);
// out
x = Pan2.ar(x);
x = LeakDC.ar(x);
Out.ar(\out.kr(0),x*\amp.kr(0.03));
}).add
)
I want to trigger the envelope in the effect SynthDef with a pattern. My first take was with a Pmono:
(
t = TempoClock(120/60);
Pdef(\pd,
Pbind(
\instrument, \test,
\dur, 1,
// pitch
\scale, Scale.minor,
\degree, Pseq([0,1,2,4],inf),
\mtranspose, -14,
// out
\amp, -18.dbamp,
\addAction, \addToHead,
\out, ~bAmono
)
).play(t);
p = Pmono(
\testFX,
\in, ~bAmono,
// rhythm
\dur, 2,
// RLPF
\rel, Pkey(\dur),
// out
\amp, 0.dbamp,
\addAction, \addToTail,
\out, 0
).play;
)
(
{
Pdef(\pd).stop;
1.wait;
p.stop;
}.fork;
)
However, in this case the Pmono can’t be stopped + it triggers the envelope only once. When I change doneAction: 2 in the effect’s SynthDef, the Pmono triggers the envelope once, the envelope runs through once and then frees the synth, so no sound afterwards.
Another way I thought of triggering the envelope in the effect SynthDef is via a set type Pbind, but no desired results:
(
~bpm = 120/60;
t = TempoClock(~bpm);
Pdef(\pd,
Pbind(
\instrument, \test,
\dur, 1,
// pitch
\scale, Scale.minor,
\degree, Pseq([0,1,2,4],inf),
\mtranspose, -14,
// out
\amp, -18.dbamp,
\addAction, \addToHead,
\out, ~bAmono
)
).play(t);
x = Synth(\testFX,[\in, ~bAmono],s,\addToTail);
p = Pbind(
\type, \set,
\id, x.nodeID,
\in, ~bAmono,
\args, #[\dur],
\dur, 1
).play;
)
I also tried dkmayer’s suggestion of using Trig.kr() seen in this thread, to no avail.
What am I missing here?
Thank you,
cd