Redefine a fixed sequence in a Pbindef?

Continual randomness soon becomes dull:
Pbindef(\x, \degree, Prand((0..9),inf), \dur, 1/4).play

Repeating a randomly generated phrase is more interesting:

// step 1: generate a fixed melody
~mel = Array.rand(16,0,9)

// step 2: use it
Pbindef(\x, \degree, Pseq(~mel,inf))

// step 3: redefine
~mel = Array.rand(16,0,9)

// step 4: use new melody
Pbindef(\x, \degree, Pseq(~mel,inf))

Question: how would one be able to redefine ~mel and have the Pbindef immediately pick that up? In other words, without needing step 4 above. There must be a way, using something like Pdefn or Pfunc, but I can’t figure it out!

In standard SC you can use something like

Pn(Plazy { Pseq(~mel, 1) })

which replaces after finishing the loop when resetting.

But you can also check miSCellaneous_lib’s PLx suite. In combination with PLbindef – a wrapper for Pbindef – you can write

PLbindef(\x, \degree, PLrand((0..9)), \dur, 1/4).play

// step 2 & 3

~mel = { 9.rand } ! 16

~x.degree = PLseq(\mel)


// now shortened step 2 & 3

~mel = { 9.rand } ! 8

Shorter than above with EventShortcuts

EventShortcuts.on

~x.de = PLseq(\mel)

1 Like

Of course: Plazy! That’s what I was forgetting thanks :slight_smile: