I’m trying to figure out how to do something every x happens. Like transpose a scale up an octave every 4 bars. or Pstutter a \dur every time “0.5” is chosedn from a Prand.
So for example I though this would work to make the last beat or a 7 beat sound quadruple in Frequency:
(
t = TempoClock(120/60).permanent_(true);
t.tempo_(120/60);
t.schedAbs(t.nextBar, {t.beatsPerBar_(7)});
~metro = {
("beat :" +((t.beats.floor)%t.beatsPerBar+1)).postln;
("bar :" +(t.bar)).postln;
"".postln;
1;
};
)
(
t.schedAbs(t.nextBar, {
~metro.value;
})
)
(
SynthDef(\hh, {arg freq=220, out=0, amp=1.0, res=0.5, pan=0;
var sig, env;
sig = WhiteNoise.ar(1);
sig = RHPF.ar(sig, freq*40*Line.ar(0.5, 1, 0.1), res);
env = EnvGen.ar(Env.perc(0.001, 0.1));
sig = (sig * env * amp * 2).softclip;
sig = Pan2.ar(sig, pan);
Out.ar(out, sig);
}).add;
)
(
c = t.beatInBar.round.postln %7;
Pbind(
\instrument, \hh,
\freq, 220,
\dur, Pif(c == 0, Pkey(\freq)*4, 1),
).play;
)
But it doesn’t work. I am not attached to this weird thing I got going on here, and expect there to be some super simple Pevery, or something of the sort I just don’t know about yet…but I have been looking for a while and can’t find one.
If you’ve ever used tidal cycles, you’d probably agree that doing a function every x cycles can make algorithmic composition super dynamic and awesome very easily. Since tidal is just sending OSC to SC, I imagine there’s a way to do this pretty easily.