Hi,
I’m trying to achieve a kind of flexible/interactive-looper mechanism where a loop is set of pre-defined Synths and Effects triggered at pre-defined times. The “flexible/interactive” part is achieved through some kind of pattern or human intervention that would affect the normal behavior from to time.
The question is about being notified by the currently playing loop that she is done, before starting it again. A kind of ‘Done’ event.
This is how far am I now:
This is a basic example, with only 2 synths. In a real case, the loop could be build upon several unrelated Synth with synthesis, wav files, … A kind of collage.
(
// A basic Synth
SynthDef(\basic,
{ |out=1, freq=440, amp=0.1, form=0, gate=1, distort=0|
var sig=SinOsc.ar(freq*(1+LFNoise1.kr(500,distort))).pow(form.linexp(0,1,1,20,nil));
var env=EnvGen.kr(Env.asr(0.1,amp,0.3), gate,doneAction: 2);
Out.ar(out,sig*env);
},
variants: (bronze: [freq: 220, form: 0.5], silver:[freq: 232, form: -0.5])
).add;
)
// The loop
(
~loop= {
| i, distort = 0, start2=4, duration2=4 |
var osc = Array.fill(2,nil);
Post << "Play " <<< (i+1) << "e occurence" << Char.nl;
t = TempoClock(2);
t.schedAbs(0, { arg beat, sec;
osc[0]=Synth('basic.bronze');
nil; // don't repeat
});
t.schedAbs(start2, { arg beat, sec;
osc[1]=Synth.new('basic.silver',args:[\out,0, \distort: distort]);
nil; // don't repeat
});
t.schedAbs(5, { arg beat, sec;
osc[0].release;
nil; // don't repeat
});
t.schedAbs(start2+duration2, { arg beat, sec;
osc[1].release;
nil; // don't repeat
});
}
)
// Paying the loop in repetitive mode
(
~distort=Array.series(4,0,0.1);
{
5.do{arg j;
var s2=max(0,4+j.rand2);
var d2=max(4+j.rand2,0.1);
Post << s2 <<< ' --> ' <<< (s2+d2) << Char.nl;
~loop.value(j,
distort: ~distort.wrapAt(j).rand,
start2: s2,
duration2: d2
);
4.0.wait;
}
}.fork;
)
Instead of this hardcoded 4.0.wait
, I would like to take into account the duration of the loop. If it had be only about patterns this could be computed. But as my objective is to have human intervention, the duration loop cannot be computed.
So I’d like to replace that 4.0.wait
by a waitUntilReady
.
And to have in my loop definition, something like sendReadyEvent
t.schedAbs(start2+duration2, { arg beat, sec;
osc[1].release;
sendReadyEvent;
nil; // don't repeat
});
What would be the best way to do this ?
PS: any comment on the rest of my code is also welcome
Thanks,