Making patterns aware of bars and beats

Hi,

Still on this topic, I would like to align patterns using the offset parameter according to this example :

Where in my case I have 4 parts corresponding to one bar each so that it represents a 4 bars of 4 beats pattern.

Here is an example to illustrate the issue I’m facing :

(
t = TempoClock.new(100/60);
~postBeats = {("bar:" + ((t.beats/4).floor%4+1) + (" beat:" + (t.beats%4+1))).postln;1};
t.schedAbs(t.nextBar, {~postBeats.value});

~deg1 = [1,1,Rest(1),Rest(1)];
~deg2 = [1,1,1,Rest(1)];
)

(
//\degree, Pseq([part1, part2, part3, part4], inf, offset): 
//part1's degree is 1 (bar 1), part2's degree is 2 (bar 2), etc...
a = Pbindef(\test,
	\degree, Pseq([Pseq(~deg1,1),Pseq(~deg1+1,1),Pseq(~deg1+2,1),Pseq(~deg1+3,1)], inf,(t.beats/4).floor%4+1).trace
);
a.play(t, quant: 4);
)

// First case : the "\degree" parameter of the pattern "a" is modified -> bars and degrees are still aligned
Pbindef(\test,\degree, Pseq([Pseq(~deg2,1), Pseq(~deg2+1,1), Pseq(~deg2+2,1), Pseq(~deg2+3,1)], inf, (t.beats/4).floor%4+1)).quant_(4);
Pbindef(\test,\degree, Pseq([Pseq(~deg1,1), Pseq(~deg1+1,1), Pseq(~deg1+2,1), Pseq(~deg1+3,1)], inf, (t.beats/4).floor%4+1)).quant_(4);


// Second case : pattern "a" is stopped at the end of the bar and pattern "b" is started -> bars and degrees are not aligned
(
b = Pbindef(\test2,
	\degree, Pseq([Pseq(~deg2,1), Pseq(~deg2+1,1), Pseq(~deg2+2,1), Pseq(~deg2+3,1)], inf, (t.beats/4).floor%4+1).trace
);

t.schedAbs((t.nextTimeOnGrid(4)), {a.stop; b.play(t, quant: 4)});
t.schedAbs((t.nextTimeOnGrid(4)), {b.stop; a.play(t, quant: 4)});

The first case (one pattern modified) seems to be robust. But in the second case, where a pattern is stopped and another started, the alignment is lost and notes overlapping appears. Is there a mistake in the schedAbs arguments ? Would it be more reliable to use fastForward method instead, as shown here: Live Coding, Pdef, Quantization and timming - #10 by jamshark70 ?

mic