I have been calling my synths till now only by wrapping them inside a routine/task and waiting on each iteration for a certain time etc. Now I am curious whether its possible to call synths in a more crazy way, e.g. by calling them when a trigger happens for instance by an Impulse. How could I do something like (the syntax is imaginary, I just am trying to convey what I mean)
so that the synth goes on each time a trigger happens. I am specifically interested in combining the various nice Demand classes for generating my data for arguments to the synth. How could I go about this?
Maybe its worth taking a look into the JITlib dialect?
I often use it to create a clock which runs all my Demandrate UGens
(
// create a trigger bus
Ndef(\trigger, {
Impulse.kr(freq: 4.0);
});
)
(
Ndef(\foo, {
var sig = Pluck.ar(
in: WhiteNoise.ar,
// reference the trigger bus
trig: Ndef.kr(\trigger, 1),
maxdelaytime: 0.2,
delaytime: LFDNoise0.kr(4.5).exprange(100, 400).reciprocal,
decaytime: LFDNoise3.kr(3.0),
)!2 * \amp.kr(0.2);
sig;
}).play;
)
// create a feedback loop between both
(
Ndef(\trigger, {
// get the audio of the \foo bus
var foo = Ndef.ar(\foo, 2).sum;
// use it to impact the generation of triggers
Impulse.kr(freq: 4.0) + Impulse.kr((Amplitude.kr(foo, releaseTime: 5.0) + 0.1).reciprocal.poll);
});
)
Ndef.clear;
You can also use trigger rate arguments rather than having a UGen triggering. The examples I posted at the bottom of the page might illustrate some ways to achieve what you’re looking for.