Pfunc returning list

Hi guys,
I have a question about using lists inside patterns in a dynamic way.

Say I have a global variable I want to change from time to time:

~note = 0;

And then I have an event pattern which will use that variable and react to its modification in real time.

To do this I’ve learnt to use a Pfunc evaluating the global var like that:

 (
 Pbind(
     \degree, Pfunc({~note}),
     \dur, 1
 ).play;
 )

But, what if I want to do the same exact thing with a list instead of a simple number?

The following code is giving me an error:

~notes = [0,1,2,5,6];

(
Pbind(
	\degree, Pseq( Pfunc({~notes}), inf),
	\dur, 1
).play;
)

Post window tells me Pseq is expecting a list but I’m passing it a Pfunc.

So how to convert this Pfunc to a list?
Is there any other way I can achieve the desired behaviour?

Thank you so much, as always, for your help.

Didn’t that come up already in this thread that you started ? (some solutions given there) :slight_smile:

It has also come up twice again within the last weeks, maybe this topic needs an extra tutorial - though I have already written one (“Event patterns and Functions” in miSCellaneous_lib)

BTW ~note is not a global variable, it’s an environmental variable, means it’s bound to the local Environment we’re in currently (currentEnvironment). Just because most people are not changing the current Environment, it somehow feels like global, but it’s essential to keep in mind that it’s not (-> Environment help).

1 Like

Thank you @dkmayer.
It was a long time since my original question about the same topic (I didn’t remember it at all :stuck_out_tongue:).
Thank you also for explaining me the difference between the global varaible and environment varaible!