Reading an Array randomly


I’m getting stuck trying to read an Array randomly in a Pdef, I have a feeling I need ‘collect’, but I cant figure it out. Can someone jog my memory on the syntax to use please? At the moment I’m using a very silly (and clumsy) method to get around the whole thing:

\bufnum, Prand([~chords[0],~chords[1],~chords[2],~chords[3]], inf),

~chords = the Array of piano samples - if it’s of importance there’s 7 files in the Array.

Thanks in advance - Joesh

In your example case, you can use:

\bufnum, Prand(~chords, inf),

Or, more precisely, with just the 4 chords:

\bufnum, Prand(~chords[0..3], inf),

Thanks Scott, that’s great.

I’ve ended up using Pindex (which I’d never used before). Otherwise Daniel reminded me of the syntax I was thinking about:

\bufnum, Prand((0..3), inf).collect(~chords[_])