Thanks @scztt, this is clearly some of the wisdom you get when you spend some time on Event.sc
We were just missing some extra []
around ["/error", -1]
. Iāll post below what I ended up doing for my use case, with addEventType
and a conditional toggle.
But first, Iām sorry I didnāt find this post earlier, which Iām clearly duplicating:
So I also want to thank @jamshark70 for the answer he gave there.
Here is what I ended up doing. Since I only want to hide errors when the Synth is released, I turn on the ~hideErrors
toggle only right before calling .release
// new event type because we like encapsulation
Event.addEventType(\noteHideErrors, Event.eventTypes[\note], (
schedBundleArray: #{ | lag, offset, server, bundleArray, latency |
if (~hideErrors ? false) {
bundleArray = [["/error", -1]] ++ bundleArray;
};
schedBundleArrayOnClock(offset, thisThread.clock, bundleArray, lag, server, latency);
}
));
// test code
// create synth on new group
(
a = { SinOsc.ar(100) * 0.1 * EnvGen.kr(
Env.asr(releaseTime: \fadeTime.kr(3)), \gate.kr(1),
doneAction: Done.freeGroup
)}.play(Group(s));
)
// Pattern: now with new type for conditional error hiding
(
b = EventPatternProxy(Pbind(
\type, \noteHideErrors, \dur, 0.1,
\group, a.group, \action, \addToTail,
))
)
// setting the env before playing avoid some kind of click later
b.set(\hideErrors, false); b.play
a.onFree { b.stop };
// turn on error hiding right before release
b.set(\hideErrors, true); a.release