Pdef, Pbind and poll (odd behaviour)

After looking around to find some different ways of using a TempoClock, I was interested to see this video on Risset rhythms (on YouTube by ‘Polo’). I thought I’d copy out the code and try something myself, but for some reason it doesn’t seem to work.

So, here’s the bit of code I was using to try out the basic idea/syntax, which from what I can see is correct. Could someone explain why nothing is happening?

~clock = TempoClock(70/60).permanent_(true);
(
~steps = 24;

Pdef(\tempo,
 Pbind(
		\type, \rest,
		\index, Pseq((0..~steps-1), inf),
		\dur, 0.25,
	).collect{
		arg i;
		i;
}.poll;);
);

Pdef(\tempo).play(~clock); 

I’ve put in poll (like in the video tutorial) to see if anything is happening, but to no avail.

Thanks in advance - joesh

p.s. If Polo is reading this, thanks for the idea, I just need to get it to work for me too!

Just tried some extra ideas to see if I can get something to work, and found a very odd behaviour. I just tried replacing poll with the following, which worked for a few minutes.

~clock = TempoClock(70/60).permanent_(true);

(
~steps = 24;

Pdef(\tempo,
 Pbind(
		\type, \rest,
		\index, Pseq((0..~steps-1), inf),
		\dur, 0.25,
	).collect{
		arg i;
		var bpm;
		bpm = i.index.linlin(0, ~steps, 50, 180);
		~clock.tempo_(bpm/60);
		i.postln;
});


Pdef(\melody,
	Pbind(
		\instrument, \default,
		\midinote, Pseq((60,62..70), inf),
		\dur, 0.25,
));
)


Pdef(\tempo).play(~clock);
Pdef(\melody).play(~clock);

As you see I put in postln to see if anything worked, and indeed I got the key values printed out in the post window. I then paused the players to make some adjustments, and since then it’s back to radio silence!?

So, as above, any help/suggestions appreciated.

Thanks in advance.

I’m reading this on the bus, so I can’t try the code now, but one point about poll: it’s for UGens, not for patterns. Patterns have trace.

hjh

1 Like

Okay, thanks James.

I’m trying this at the moment and it seems to work again. However, if you notice, in my second post I say that the whole pattern just seemed to stop work - it didn’t produce sound, or print out the key values. Could using poll somehow have bugged/blocked a Pdef/Pbind process in some way?

What I found strange was that when running the two patterns, Pdef(\melody) happily played away, just ignoring Pdef(\tempo), which I assume meant Pdef(\tempo) wan’t producing anything. And, as I said, at one point neither of them seemed to work - they just sat and did nothing, not even produce sound!

Also, in Pbind(... stuff...).collect { |ev| ... do stuff... }, it’s essential that the collect function returns the event. Yours ends with i.postln so for each event, it’s waiting for an integer duration, and not the 0.25 you expected.

If I had a nickel for every time I made that same mistake…

Never mind, you confused me by naming your event i :laughing:

hjh

Ooops. Actually, I just called it 'i' because it was going to produce the 'index'. If I understand correctly, you can call your argument anything, but I guess there’s some automatic conventions for certain functions.

Anyhow, it seems to working no, so I guess there was probably a bug somewhere in/on my computer. I remember Daniel Mayer helping me out with a Pbindef which sort of ‘hung’, but wouldn’t restart. It might have been a similar problem to that I guess.

If you have any other suggestions, let me know.

Thanks again - joesh

There aren’t any automatic conventions in the interpreter – you can, in fact, call it whatever you like. It happens in this case that i collides with one more or less standard naming convention, that i is typically used for a numeric index, as in array.do { |item, i| ... } or in C, for(i = 0; i < n; i++).

The name isn’t wrong per se, but for programmers reading the code, it’s a bit like deciding that rust is the word you’re going to use for the color of a banana – even with an explanation, when readers see the word “rust,” they are likely to think of a dark burnt orange rather than the yellow that was intended. (It isn’t an index that you’re getting the index from – it’s an event – so IMO event.index or ev.index would be clearer for humans.)

I can’t see from the examples here why the pattern(s) might have gotten stuck, I’m afraid.

hjh

Okay, thanks James.

As I said, I hadn’t thought about that, but now you mention it I guess it’s a good habit to try and get into. As for the code, it seems to working fine now, so I guess I’ll forget about it for now.

In the meanwhile, I liked the rust - bananas comparison, definitely a title in there somewhere.

Thanks - joesh