Recursive structure of MOS scales: Difference between revisions
→Finding a generator: Better worded explanation of output, clarified that the first half is the generator and the second half its octave complement; code comments |
m →General algorithm: Clarified wording; removed stray punctuation |
||
Line 290: | Line 290: | ||
=== General algorithm === | === General algorithm === | ||
This is the general algorithm for finding a moment of symmetry scale's generator and its [[octave complement]] for a mos xL ys as two, not-necessarily-equal halves of the mos pattern xL ys | This is the general algorithm for finding a moment of symmetry scale's generator and its [[octave complement]] for a mos xL ys as two, not-necessarily-equal halves of the mos pattern xL ys. If the mos is multi-period, its generator and period complement are returned as two halves of the period. This algorithm will produce these intervals without any prior knowledge of how the scale's steps are ordered. This algorithm is recursive. Let x be the number of L's and y the number of s's. | ||
# If either x or y is equal to 1 (base cases): | # If either x or y is equal to 1 (base cases): | ||
Line 298: | Line 298: | ||
# If neither x nor y is equal to 1 (recursive cases): | # If neither x nor y is equal to 1 (recursive cases): | ||
## Let k be the greatest common factor of x and y. | ## Let k be the greatest common factor of x and y. | ||
## If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the | ## If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the generator and complement for (x/k)L (y/k)s; the intervals returned this way will apply to the period rather than the octave. | ||
## If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then: | ## If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then: | ||
### Let m1 = min(x, y) and m2 = max(x, y). | ### Let m1 = min(x, y) and m2 = max(x, y). | ||
### Let z = m2 mod m1 and w = m1 - z. | ### Let z = m2 mod m1 and w = m1 - z. | ||
### Let gen be the scale's generator and comp be the generator's octave complement | ### Let gen be the scale's generator and comp be the generator's octave complement for the mos zL ws. Recursively call this algorithm to find these intervals for zL ws; the final scale's generator and complement will be based on this. | ||
### If x < y, reverse the order of characters in gen and comp, then swap gen and comp. This is only needed if there are more L's than s's in the scale. | ### If x < y, reverse the order of characters in gen and comp, then swap gen and comp. This is only needed if there are more L's than s's in the scale. | ||
### To produce the scale's | ### To produce the scale's generator and complement, the L's and s's of both intervals must be replaced with substrings consisting of L's and s's. Let u = ceil(m2/m1) and v = floor(m2/m1). | ||
#### If x > y, every instance of an L in both | #### If x > y, every instance of an L in both intervals is replaced with one L and u s's, and every s replaced with one L and v s's. This produces the final scale's generator and complement. | ||
#### If y > x, every instance of an L in both | #### If y > x, every instance of an L in both intervals is replaced with u L's and one s, and every s replaced with v L's and one s. This produces the final scale's generator and complement. | ||
==== Notes on output ==== | ==== Notes on output ==== | ||
The algorithm described here returns what is known as the chroma-positive generator, or bright generator, and is usually what is meant by ''the'' generator of a scale. The octave-complement returned this way is the scale's chroma-negative generator, or dark generator. More specifically, the bright generator | The algorithm described here returns what is known as the chroma-positive generator, or bright generator, and is usually what is meant by ''the'' generator of a scale. The octave-complement returned this way is the scale's chroma-negative generator, or dark generator. More specifically, the bright generator is in its perfect form, and the dark generator is in its augmented form. If the perfect dark generator is needed instead, a quick way to produce it is to replace one L in the dark generator with an s. | ||
If the number of steps in the generators is needed, simply count the total number of L's and s's in each generator. | If the number of steps in the generators is needed, simply count the total number of L's and s's in each generator. |