Calculate all possible scales from a list of intervals

grigou's icon

Hello !

I'm trying to make a patch that generate all possible scales from a list of intervals.

For example, my patch generate 9 notes scales with all the possible combinaisons of minor second, major second, perfect fourth, augmented fourth and perfect fifth.

It gaves me 390 625 possible scales (most of them are non-octaviant scales).

I wanted to calculate the same thing for 10 notes scales, 11 notes scales and 12 notes scales, but Max can't handle /
those big calculations.

FOR 10 NOTES SCALES : 1 953 125 results
FOR 11 NOTES SCALES : 48 828 125 results
FOR 12 NOTES SCALES : 244 140 625 results

Is there a better way to make those calculations ?

Thanks for your help !

Max Patch
Copy patch and select New From Clipboard in Max.


Holland Hopson's icon

All those chained uzi objects are begging for trouble. Maybe you could create this using zl.rot and similar objects.

grigou's icon

Thanks for your help Holland !

I don't see how zl.rot could be useful in that case since it'll give me all permutations, but not all combinations.
Maybe I'm missing something.

Holland Hopson's icon

Good point, Grigou. This may be a time when java or javascript could be helpful. Have you looked at the list package for mxj? Something like [mxj list.Multiplex] could get you closer.

grigou's icon

Yep! I thought about javascript.

I checked for code already made on stackoverflow.com, since I don't know javascript.
The hard part for me with javascript is to understand how I can communicate between Max and Javascript, since I need to modify the code.

I was thinking about a message with a list of elements I want to combinate.

I didn't look at mxj. Most of the time, I try to avoid external objects or already made solution, since I like to find a way with Max standards objects as far as I can :)
For me, it's a challenge and a way for improving my knowledge, but sometimes like with this patch, I failed haha :)

An other thought : generate all the combinations outside of Max with an online calculator for example, copy / paste all results in a coll object and then, make filtering on that list for choosing scales I want.
Unfortunately, online calculator are limitated and can't handle 285 311 670 611 results!
100 000 is a maximum for most of them.
So I'm stuck...

By the way, I made a mistake in my first post.

The maximum length I need is 12 notes scales, so that's mean choosing11 intervals.
And I have a choice between 11 intervals to create my combinations from minor second to major seventh (I avoid unison and octave, since those intervals are not useful for creating scales).

Order is important and repetition are allowed, so I made a simulation with this website : https://www.mathsisfun.com/combinatorics/combinations-permutations-calculator.html
And it gives me 285 311 670 611 results.

Roman Thilenius's icon


24*23*22*21*20*19*18*17*16*15*14*13*12*11*10*9*8*7*6*5*4*3*2
==
620,448,401,733,239,439,360,000

https://www.wolframalpha.com/input/?i=24*23*22*21*20*19*18*17*16*15*14*13*12*11*10*9*8*7*6*5*4*3*2

grigou's icon

Hi Roman!

I don't understand why you multiply from 24 to 2 ?

Since I need a maximum of 11 items.

Here's the result of the site I used :

Types to choose from? 11
Number Chosen? 11
Is Order important? Yes
Is Repetition allowed? Yes

Short Answer: 2.8531167061e+11
Full Answer: 285311670611

So it should be 11*10*9*8*7*6*5*4*3*2 *1

Roman Thilenius's icon


to show that there is no limit in a proper math program.