The positive integer sums of a given number are called the partitions or additive partitions of the number. This goes back to Euler and is commonly referred to as p(n) or A(n). So A(12) is the set of all intervals that sum to an octave. A(12) does not regard the order. With scales the order of the intervals counts. The function that lists all partitions including all unique orders is commonly called a(n). Interestingly enough these are called compositions. According to "Additive and Multiplicative Partitions" at http://mathpages.com/home/kmath091.htm a(n) = 2^(n-1) So a(12) = 2^11 = 2048 Note that this is all possible scales of one octave "Interesting" and "Less Interesting" included. Definiton of "Interesting" scales. 1. 5 - 8 notes plus the octave. So the pentatonic and the octatonic scales are "Interesting". 2. Not excessively chromatic which is strictly defined as not a proper substring of any scales of length 9, 10, 11, or 12, which we can call "Mostly Chromatic". For 5 note scales the first 4 intervals do not match exactly the first 4 intervals of a "Mostly Chromatic" scale. For 6 note scales the first 5 intervals do not match exactly the first 5 intervals of a "Mostly Chromatic" scale. And so on. Python algorithm for generating all compositions (scales) def compositions(t,s): """knuth 7.2.1.3 - t+1 items sum to s""" q = [0] * (t+1) r = None q[0] = s while True: yield q[:] if q[0] == 0: if r==t: break else: q[0] = q[r] - 1 q[r] = 0 r = r + 1 else: q[0] = q[0] - 1 r = 1 q[r] = q[r] + 1 for L in compositions(0,12): str1 = " ".join(str(x) for x in L) if not "0" in str1: print str1 -------- This program did not work right with 1, 2, 3, and 12 note scales. All other scales are output to 4.txt, ..., 11.txt. All are combined into scales_all.txt with manual corrections made where the program did not run correctly. Total number of scales 2048 notes - quantity 1 - 1 2 - 11 3 - 55 4 - 165 5 - 330 6 - 462 7 - 462 8 - 330 9 - 165 10 - 55 11 - 11 12 - 1 Notice the symmetry. Scales 5-8 - 1584 Scales 9-12 - 232 4*232=928 1584-928=656 "Interesting" scales (maybe) It will be a simple database task to output only the "Interesting" scales and generate midi files for each. Since interesting scales are made up of only intervals of 1 digit the midi files can be named by listing the intervals without spaces for example a minor pentatonic scale could be named 32232.mid and the whole note scales could be named 222222.mid. Alternatively the length of the scale and a dash could prepend the interval structure giving us 5-32232.mid and 6-222222.mid.