hey, i have been trying to create an Environment
which prepares a NodeProxy
with a trigger SynthDef
and a method .maskOn
to filter the triggers with a Demand Sequence:
(
SynthDef(\trig, {
var tFreq, trig;
tFreq = \tFreq.kr(8, spec: ControlSpec(1, 100, \exp));
trig = Impulse.ar(tFreq);
OffsetOut.ar(\out.kr(0), trig);
}).add;
)
(
~makeTriggers = { |synthDefName, initArgs=#[]|
Environment.make { |self|
~synthDef = SynthDescLib.global[synthDefName].def ?? {
Error("SynthDef '%' not found".format(synthDefName)).throw
};
~nodeProxy = NodeProxy.audio(s, 1);
~nodeProxy.prime(~synthDef).set(*initArgs);
~triggerMask = { |in|
var trig = in;
trig * Demand.ar(trig, 0, Dseq([1, 0, 0, 1, 0, 0, 1, 0], inf));
};
~maskOn = { |self|
self.nodeProxy.put(150, \filter -> ~triggerMask );
};
}.know_(true);
};
)
~trig = ~makeTriggers.(\trig, [\tFreq, 8]);
~trig.maskOn;
~trig.nodeProxy.play;
I would have thought that i can evaluate ~makeTriggers
and assign it to a variable like ~trig
, call .maskOn
and to play the NodeProxy
and get filtered Impulse triggers. But i get no sound at all.
if i do it the straightforward way without the Environment
, i can filter the triggers without any problem:
(
~triggerMask = { |in|
var trig = in;
trig * Demand.ar(trig, 0, Dseq([1, 0, 0, 1, 0, 0, 1, 0], inf));
};
)
~trig = NodeProxy.audio(s, 1).source_(\trig);
~trig.put(150, \filter -> ~triggerMask );
~trig.play;
whats wrong here? thanks