Chords catalogue sequencing

Super newb and simple : I made a collection of chords, in the basic form of arrays: [52, 56, 63]. I have like hundred of them. Some of them are three notes, other four, five and many more.
I would like to store them in a catalogue and then be able to play them randomly in a Pbind, like if it was from a dice shot (but never play them twice before all have been played).
What is the simpliest way to achieve this ?

Thanks a lot.

Like this:

(
var chords = [[0,3,7], [0,4,7], [0,2,5]];

p = Pbind(
	\dur, 0.3,
	\midinote, Pn(Pshuf(chords+60))
);

p.play
)

And you can always put your chords in a dictionary!

Ok, great, thanks. But if I use a dictionary and map the chords to keys in the form " \a " what is the syntax to recall them inside a Pshuf ?

EDITED, SEE BELOW. THIS CURRENT EDITED CODE WILL WORK

Another solution that actually might be better in this case is to use environmental variables:

(
~inky=[0,3,7];
~blinky=[0,4,7];
~pinky=[0,2,5];
~clyde=[0,3,5];
~pacman=[0,5,10,15];
~mrsPacman=[0,4,7,11];

~ghosts = [~inky, ~blinky, ~pinky, ~clyde];
~pacFamily = [~pacman, ~mrsPacman];
~everyone = [~inky, ~blinky, ~pinky, ~clyde, ~pacman, ~mrsPacman];

p = Pbind(
	\instrument, \default,
	\dur, 0.3,
	\midinote, Pn(Pshuf(~ghosts)+60)
);

p.play
)

There is a way to access them from a dictionary, but something is wrong with my IDE right now and I can’t double check my answer. Give me a bit, but this is at least one way to approach it.

(
var ghosts = [~inky, ~blinky, ~pinky, ~clyde];
var pacFamily = [~pacman, ~mrsPacman];
var everyone = [~inky, ~blinky, ~pinky, ~clyde, ~pacman, ~mrsPacman];

~inky=[0,3,7];
~blinky=[0,4,7];
~pinky=[0,2,5];
~clyde=[0,3,5];
~pacman=[0,5,10,15];
~mrsPacman=[0,4,7,11];

ghosts
)

-> [ nil, nil, nil, nil ]

I’m afraid that this isn’t going to work as posted.

You have to populate the environment variables first. Variable references are not retroactive.

hjh

1 Like

Thank you! I had written out the environmental variables once and then packaged it up to post but put them in the wrong order. I had already evaluated the environmental variables before the pbind the first time so I didn’t run into the issue.

Pdict or Pnsym / Pnsym1.

c = (major: [0, 4, 7], minor: [0, 3, 7], sus4: [0, 5, 7]);

Pdict(c, Pn(Pshuf([\major, \minor, \sus4], 1), inf)).asStream.nextN(5)
-> [ [ 0, 4, 7 ], [ 0, 3, 7 ], [ 0, 5, 7 ], [ 0, 3, 7 ], [ 0, 5, 7 ] ]

Pnsym(Pn(Pshuf([\major, \minor, \sus4], 1), inf), c).asStream.nextN(5)
-> [ [ 0, 5, 7 ], [ 0, 4, 7 ], [ 0, 3, 7 ], [ 0, 4, 7 ], [ 0, 3, 7 ] ]

hjh

Thanks, but as I have hundred of chords is there a way to map them automatically to integer keys (like first chord is 0, last one is 100) in a dictionary or anything else to avoid to write them manually inside the Pshuf ?

First, if they’re “mapped to integer keys” then you could just use an array of chord forms… which brings you right back around to mjsyts’ original reply. If you don’t need symbolic keys, then don’t write them – no need to overcomplicate. (It’s true that you could use a dictionary but that doesn’t mean it’s the best fit for your use case.)

If you really want the symbolic keys, then for the shuffle streaming, you could skip the dictionary lookup pattern altogether:

Pn(Pshuf(myDict.values.as(Array), 1), inf)

… but this is writing symbolic keys into the dictionary, and then throwing them away, so the array is simpler.

hjh