Scheduling when an OSC parameter change takes effect

Hi. I’m new here, so sorry if this has been asked before. I’m at the pointy end of a Master’s degree project and I’m on a very steep learning curve without much time to go through all the previous questions, but happy to be pointed at anything relevant.

I have a Pbindef pattern that lasts for 2 beats looped inf times. I would like to change a parameter (z in the code below) while it is playing, and have the change take effect at the beginning of the loop, but I can only get it to happen on the next beat. So sometimes it’s beat 1, sometimes it’s beat 2 depending on when I execute the change. I’ve tried playing with quantisation and I’m currently trying to look at what can be done with TempoClock, but there’s a lot to it so if anyone is able to shortcut my learning a bit, that would be appreciated!
Thanks :slight_smile: :smiley:

(
z = ‘neg’;
switch(z,
‘neu’,{[a = [’\sK’,’\sSn’], b=[1,2]]},
‘pos’,{a = [’\mK’,’\mSn’]},
‘neg’,{a = [’\hK’,’\hSn’]});

y = Pbindef(\rhythm,
\instrument, \kickplay,
\dur, Pseq([1/4,1/4,1/4,1/4,1/2,1/2],inf),
\buf, Pseq([d[a[0]],d[a[0]],d[a[1]]],inf),
\rate,1,
\amp, 1,
);

)
y.play(quant:0);
y.stop;

Hi Nicki welcome and good luck with your master’s project!

I prefer to use Pdefn to make quantised changes to the inside of an event pattern. Here is a boiled down example of it that may help you (if I understand your problem correctly)

(
Pbindef(\shittypiano, 
		\dur, 0.5,
		\freq, Pdefn(\external_freq, 100)
).play
)

// This will change the freq on the next note (as immediate as possible)
Pdefn(\external_freq, 200)

// This will quantise your change to the master clock (TempoClock.default)
Pdefn(\external_freq, rrand(100,200)).quant(1)
1 Like

Hi Nick,

If I understand your problem correctly, I think you’ll need to either use the .shedAbs method (you’ll find it under TempoClock), or eventually plain quant. With shedAbs you could use the .nextBar method. The example you’ll find under TempoClock shows this, which is maybe what you’re looking for:

t= TempoClock.new;
t.schedAbs(t.nextBar, {t.beatsPerBar_(3)});
t.beatsPerBar; 

Or, you could look more closely at the quant method, which you’ll find under Pdef. When using .play(quant:), you can get much more precise settings, which might be useful:

val can be an array [quant, phase, timingOffset, outset] , or just [quant, phase] etc.

phase is where it starts in the bar, but maybe outset could be useful for you. You’ll find more detailed information if you look at Quantizing and outset under Pdef.

I hope that helps.