Permutations?

Seb's icon

Hello,

I would like some help generating some permutations of TWO variables. In this case the variables are: rhythmic placement and the instrument.

So I have three instruments (let's say clarinet, violin and voice) and a time signature of 3/8.

The possible combinations of rhythmic placement for each instrument in a 3/8 bar is:

1) just the first beat
2) just the second beat
3) just the third beat
4) the first and second beat
5) the first and third beat
6) the second and third beat
7) all three beats

So each instrument has 7 options for rhythmic placement (discounting none at all). What I would like to generate in a list (or better still, a MIDI file!) is a cross referencing of each of these possibilities in relation to the other instruments.

There are several possible rhythmic placements and three instruments each which could have one of those placements. I think that means there is 7 * 7 * 7 = 343 possibilities. Is that right?

Any idea of how I can generate this? I tried the Real Time Composition library permute function, but this would only allow me to generate the combinations of one variable. What I need to end up with is something like:

Clarinet 1; Violin 1; Voice 1;
Clarinet 2; Violin 1; Voice 1;
...etc...
Clarinet 4; Violin 5; Voice 7;
...etc..

It doesn't have to be with Max if you can think of a better way.

Please let me know if you can help.

Best,
S

Rick's icon
Max Patch
Copy patch and select New From Clipboard in Max.
joeman's icon

Nice one Rick

Seb's icon

Thanks very much, excellent solution!

I am having trouble prepending the output of each number with

clarinet_
violin_
voice_

The underscore is not necessary if it makes a difference.

Thank you !

Rick's icon
Max Patch
Copy patch and select New From Clipboard in Max.
Seb's icon

Ah, so simple. Thanks!