Triggering different versions of Pbinddef/Pbind with MIDI controller

A likely simple answer needed here:

The Pattern Cookbook discusses triggering patterns using MIDI:
However I need to sequentially trigger different versions of a Pbind/Pbinddef pattern (each sharing the same name). Thus far when doing this manually i simply “⌘+enter” to execute each iteration of the pattern.

That’s fine if live coding with the computer in front of me. But I need to trigger different iterations from a MIDI controllers various softkeys. How do I associate a particular Pbind section such that i can play different iterations that share the same name?


what do you mean by “iterations”?

Different Pbindefs can’t have the same name by definition. If you need several versions of such a pattern, you should use the unnamed variant PbindProxy.
You can draw it out of the Pbindef (or Pdef with the same name, which is identical) as follows: pat = Pbindef(\x).source. All these versions of pat you can then keep in an array, maybe under the key in a dictionary:

~versions =;
~saveVersion = { |key| 
	var pat = Pdef(key).source;
	~versions[key] = ~versions[key].add(pat) 
~loadVersion = { |key, index| 
	var versions = ~versions[key]; 
	index = index ?? { versions.lastIndex }; 
	Pdef(key, versions.wrapAt(index))

Maybe you want to check if it isn’t nil etc.


I think I’ve figured it out. I simply throw the different Pbinds with the same name into functions, assign these to variables, and then call .value on them using a It only dawned on me to use a pbind in a function when i was looking at cuePlayer which is basically what i meant by “iterations” (iterations = cue).

Appreciate the support, @julian.!

ah yes, of course, this always works!

1 Like