Manually advancing pattern troubleshooting

Hi! I’m pretty new to sc and I’m sorry for bringing this up again. I’ve read the Unfixed Pbind duration and Advancing patterns by hand (or: unfixed pattern duration) but I can’t seem to understand how to work this thing out.

I want to step thru this pattern just by running ~stream.next(()).play; the problem is that the synth won’t release itself (from \sendGate, false I guess). Is there some way to fix this?

(

SynthDef(\treble, {|root, ratio1, ratio2, gate = 1|
	var osc1, osc2, sum;
	osc1 = Saw.ar(root * ratio1) * EnvGen.kr(Env.asr(0.01, 1, 1), gate, doneAction:2) * 0.5;
	osc2 = Saw.ar(root * ratio2) * EnvGen.kr(Env.asr(0.01, 1, 1), gate, doneAction:2) * 0.5;
	sum = osc1 + osc2;
	sum = sum!2;
	Out.ar(0, sum.tanh);
}).add;


Pdef(\part1,
	Pbind(
	\instrument, \treble,
	\root, 220,
	\ratio1, Pseq([2/1, 2/1, 2/1, 2/1, 2/1,
		12/5, 12/5, 12/5, 12/5, 12/5,
		3/2, 3/2, 3/2, 3/2, 3/2,
		2/1, 12/5, 6/2], inf),
	\ratio2, Pseq([Rest(), 7/4, 7/4, 7/4, 7/4,
		Rest(), 9/8, 9/8, 9/8, 9/8,
		Rest(), 4/3, 4/3, 4/3, 4/3,
		7/8, 1/1, 9/8], inf),
	\sendGate, false,
));

~stream = Pdef(\part1).asStream;

)

~stream.next(()).play;

It seems you want the sequence to be monophonic? Because otherwise it would be unclear, when a synth should be released.

In case you want to step through a monophonic sequence manually, Pmono | SuperCollider 3.13.0 Help can be used.

Pdef(\part1,Pmono(\treble,
	\root, 220,
	\ratio1, Pseq([2/1, 2/1, 2/1, 2/1, 2/1,
		12/5, 12/5, 12/5, 12/5, 12/5,
		3/2, 3/2, 3/2, 3/2, 3/2,
		2/1, 12/5, 6/2], inf),
	\ratio2, Pseq([Rest(), 7/4, 7/4, 7/4, 7/4,
		Rest(), 9/8, 9/8, 9/8, 9/8,
		Rest(), 4/3, 4/3, 4/3, 4/3,
		7/8, 1/1, 9/8], inf),
	\sendGate, false,
));

Thank you! That solved the problem in an easy way! Now the only thing is that I would like to have the opportunity to have each new pattern step to retrig the synth…I’ve tried to take away \sendGate, false but that doesn’t work.

I solve such things by introducing a custom tr variable which I simply set to 1 on each event.

(
SynthDef(\treble, {
	var root = \root.kr(100.0);
	var gate = \myGate.tr(1.0);
	var osc1 = Saw.ar(root * \ratio1.kr(100.0)) * Env.asr(0.01, 1, 1).kr(gate: gate) * 0.5;
	var osc2 = Saw.ar(root * \ratio2.kr(100.0)) * Env.asr(0.01, 1, 1).kr(gate: gate) * 0.5;
	var sum = osc1 + osc2;
	sum = sum!2;
	Out.ar(0, sum.tanh);
}).add;

)

(
Pdef(\part1,Pmono(\treble,
	\root, 220,
	\ratio1, Pseq([
		2/1, 2/1, 2/1, 2/1, 2/1,
		12/5, 12/5, 12/5, 12/5, 12/5,
		3/2, 3/2, 3/2, 3/2, 3/2,
		2/1, 12/5, 6/2
	], inf),
	\ratio2, Pseq([
		Rest(), 7/4, 7/4, 7/4, 7/4,
		Rest(), 9/8, 9/8, 9/8, 9/8,
		Rest(), 4/3, 4/3, 4/3, 4/3,
		7/8, 1/1, 9/8
	], inf),
	\myGate, 1.0,
));
)

~stream = Pdef(\part1).asStream;

~stream.next(()).play;

Thank you so much! This really helped me :slight_smile:

1 Like