Selection plays only once

I discovered the power of storing arays in variables and sequence these in Pbinds
I have three variables which store a pseq with a finite loop
These varables are then sequenced in a master Pseq with an infinite loop , but the problem is that it stops after all Pseqs are played

(
SynthDef (\simple,
{
|att=0.001,dec=0.200,mod=500,pitch=0,filterfreq=400,reso=0.5,vol=0.5,pan=0|
var sig,env;

   	env=EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]),doneAction:2);
   	sig=Pulse.ar(pitch.midicps,mul:0.5)+Saw.ar((pitch+12.1).midicps,mul:0.5);///////I an
   	sig=RLPF.ar(sig,filterfreq+(env*mod).clip(40,20000),rq:reso);
   	sig=sig*env;
   	sig=Pan2.ar(sig,pos:pan);
   	Out.ar(0,sig*vol)
}).add
);
/////
///sequences
~vag=Pseq([48,72,48,55,60,48,48,48]-10,4)
~lag=Pseq([48,72,48,\,60,48,48,48]-17,2)
~rag=Pseq([48,72,48,\,60,48,48,48]-15,2)
(
Pdef(\zxcv,

   Pbind(\instrument,\simple,
   	\dur,Pseq([1/2,1/2],inf),
   	\pitch,Pseq([
   		~vag,
   		~lag,
   		~rag,
   	],inf)+12,
   	\filterfreq,Prand([400,440,600,400,2000,400,900,350,3000],inf),
   	\dec,Prand([2,3,4],inf),
   	\att,Pwhite(0.001,0.01,inf),
   	\reso,Pseq([1,0.5,0.7],inf),
   	\vol,Pseq([0.1,0.2],inf),
   	\pan,Pseq([-0.3,1,0,0.3,1],inf),
   )
));

///////////
Pdef(\zxcv).play(t);
Pdef(\zxcv).stop;


t=TempoClock(120/60).permanent_(true)

Ok ,this is weird , I copied it in new tab , the exact same data and now it loops forever
Fwiw , it isn’t the first time I noticed some quirky behaviour

Just seeing that you’re using quite a few global variables in your code - it can often cause me to loose track of code that I have executed or not and thus make “quirky” things happen when for ex having multiple tabs open with variations of the same code. Especially with single letter global variables. Good coding practice is to declare all variables unless it’s really necessary to keep them global.

Unless if you’re livecoding then you just need to keep track I guess :wink:

Only three variables for the note data , they all played their nr. of repetitions and then stopped , while the parent Pseq was set to inf
Copied into a new tab and then it worked as it should.
No biggie , verry excited to learn new things everyday .
It’s a fantastic universe :+1:

The likely explanation is that there was a nil somewhere that you didn’t think there was. This could happen if one of your variables was accidentally nil.

Then, if you copied the code and reexecuted all of it, the variables would be reset and, problem gone.

There’s nothing special about the tab in any case.

hjh

Anyone know why a Pseq does not like multiple lists ?
If the lists itslef are inside a Pseq (declared ) then there is no issue
See variables for the duration
~een
~twee
~drie
If wrapped inside a Pbind ,Pseq [(~een,~twee,~drie],inf) …no luck
just one variable works without brackes Pbind,Pseq(~een,inf),
Or if all variables are declared Pseqs , then it also works

Not working example

(
SynthDef (\simple,
{
|att=0.001,dec=0.200,mod=500,pitch=0,filterfreq=400,reso=0.5,vol=0.5,pan=0|
var sig,env;

   	env=EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]),doneAction:2);
   	sig=Pulse.ar(pitch.midicps,mul:0.5)+Saw.ar((pitch+0.1).midicps,mul:0.5);///////I an
   	sig=RLPF.ar(sig,filterfreq+(env*mod).clip(40,20000),rq:reso);
   	sig=sig*env;
   	sig=Pan2.ar(sig,pos:pan);
   	Out.ar(0,sig*vol)
}).add
);
/////
///sequences
~vag=Pseq([48,72,48,55,60,48,48,48]-10,4)
~lag=Pseq([48,72,48,\,60,48,48,48]-17,2)
~rag=Pseq([48,72,48,\,60,48,48,48]-15,2)
//durs
~uno=Pseq([1/3,1/3,1/3],2)
~duo=Pseq([1/3,1/3,1/6],2)
~trio=Pseq([1/6,1/6,1/3,1/4,1/4,1/4,1/88,1/4,1/4,1/4,1/8],2)
~een=[1/3,1/3,1/3,1/6,1/6,1/6]
~twee=[1/4,1/4,1/4,1/4,1/8,1/8,1/8,1/8]
~drie=[1/4,1/6,1/4,1/6,1/4,1/6,1/4,1/6]


(
Pdef(\zxcv,

	Pbind(\instrument,\simple,
		\dur,Pseq([
			~een,~twee,~drie ],inf),
		\pitch,Pseq([
			~vag,
			~lag,
			~rag,
		],inf)+12,
		\filterfreq,Prand([400,440,600,400,2000,400,900,350,3000],inf),
		\dec,Prand([0.4,0.8,0.4],inf),
		\att,Pwhite(0.001,0.01,inf),
		\reso,Pseq([1,0.5,0.7],inf),
		\vol,Pseq([0.1,0.2],inf),
		\pan,Pseq([-0.3,1,0,0.3,1],inf),
	)
));

///////////
Pdef(\zxcv).play(t);
Pdef(\zxcv).stop;


t=TempoClock(120/60).permanent_(true)

I think this is the right solution , they def. need their own Pseq ,either declared or inside the pbind
This raises another issue ,example below works , but putting square brackets for the Pseq gives an error since the variable is an array that already has those
So how to acces the Pseq repeat status inside the pbind ?(talking about the dur )

~een=[1/3,1/3,1/3,1/6,1/6,1/6]
~twee=[1/4,1/4,1/4,1/4,1/8,1/8,1/8,1/8]
~drie=[1/4,1/6,1/4,1/6,1/4,1/6,1/4,1/6]


(
Pdef(\zxcv,

	Pbind(\instrument,\simple,
		\dur,Pseq([
			Pseq(~een),
			Pseq(~twee),
			Pseq(~drie),
		],inf),
		\pitch,Pseq([
			~vag,
			~lag,
			~rag,
		],inf)+12,
		\filterfreq,Prand([400,440,600,400,2000,400,900,350,3000],inf),
		\dec,Prand([0.4,0.8,0.4],inf),
		\att,Pwhite(0.001,0.01,inf),
		\reso,Pseq([1,0.5,0.7],inf),
		\vol,Pseq([0.1,0.2],inf),
		\pan,Pseq([-0.3,1,0,0.3,1],inf),
	)
));

You can do \dur, Pseq([ Pseq(~een, 2), Pseq(~twee, 4) etc. where 2 and 4 gives the total number of repetitions of the dur patterns in ~een and ~twee respectively.

All good folks ,
I got a bit confused by the number of [ ] already present in the array , we only need those for the master Pseq , nested pseq’s don’t need them (unless you want a chord ) , as Thor Madsen replied

1 Like