Recursive structure of MOS scales: Difference between revisions
m →Recursive structure (chunking operation): Formatted the sections so that they appear in the table of contents |
Determining whether a scale has the MOS property section added, with algorithm |
||
Line 32: | Line 32: | ||
The recursive nature of moment-of-symmetry scales allows for two algorithms to be made: one that can determine whether an arbitrary scale of large and small steps is a valid moment-of-symmetry scale and another that can construct a moment-of-symmetry scale from any number of large and small steps, without any prior knowledge of the scale's structure. | The recursive nature of moment-of-symmetry scales allows for two algorithms to be made: one that can determine whether an arbitrary scale of large and small steps is a valid moment-of-symmetry scale and another that can construct a moment-of-symmetry scale from any number of large and small steps, without any prior knowledge of the scale's structure. | ||
( | == Determining Whether a Scale has the MOS Property == | ||
=== General Algorithm === | |||
==== Stepwise version ==== | |||
This is the general algorithm for determining whether a scale is maximally even (that is, it is a valid MOS). This version of the algorithm that uses the production rules in reverse: L -> Ls and s ->s; and L -> sL and s -> L. It is required to perform this on the string that represents the scale in its brightest mode. This algorithm is recursive. | |||
# Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen: | |||
## If both x and y are equal to 1, then the scale is maximally even. | |||
## If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is maximally even. If it's not the case that all of the substrings are identical or the substring is not maximally even, then the scale is not maximally even. | |||
# If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not maximally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not maximally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another. | |||
# Split the string into a sequence of chunks as described: if there are more L's than s's (or if x > y), then each chunk will consist of at least one L followed by exactly one s; if instead there are more s's than L's (or y > x), then each chunk will consist of exactly one L followed by at least one s. Preserve the order of these chunks. | |||
# Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not maximally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not maximally even. | |||
# If there are more L's than s's, then for each chunk, replace all but the last two characters with s's, and replace the last two characters with a single L. This process represents L->sL and s->L. If there are more s's than L's, then for each chunk, replace only the first two characters with a single L. This process represents L->Ls and s->s, but reversed. The scale produced this way is the parent scale. | |||
# Repeat the algorithm recursively on the parent scale. If that scale is maximally even, then the original scale is maximally even. | |||
==== Chunking version ==== | |||
This is the general algorithm for determining whether a scale is maximally even (that is, it is a valid MOS). This version of the algorithm reduces entire chunks into L's and s's based on the size of the chunks. It is recommended, but not required, to perform this on the string representing the scale in either its brightest or darkest mode. This algorithm is recursive. | |||
# Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen: | |||
## If either x or y is equal to 1, or both x and y are equal to 1, then the scale is maximally even. | |||
## If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is maximally even. If it's not the case that all of the substrings are identical or the substring is not maximally even, then the scale is not maximally even. | |||
# If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not maximally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not maximally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another. | |||
# Split the string into a sequence of chunks, not by splitting the strings into chunks that contain L's and s's, but AT the character that appears the least. Because every chunk contains at least one L and at least one s, removing the character that appears the least will not make any difference to how the chunks are ordered in terms of size. If there are more L's than s's, then there should be exactly y chunks consisting of only L's, and if there are more s's than L's, then there should be exactly x chunks consisting of only s's. If there is exactly one more string than expected, this may be because the string was in a mode that split one of the chunks into two; in this case, combine the first and last chunks in the sequence back into one chunk to get the correct number of chunks. | |||
# Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not maximally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not maximally even. | |||
# Produce a new scale consisting of L's and s's, based on the sequence of tokenized strings, as this will be the progenitor scale of the original; in the sequence, every instance of the larger string corresponds to an L in the progenitor scale, and every instance of the smaller string corresponds to an s in that scale. Call this algorithm recursively on that scale to determine whether that scale is also maximally even. If that scale is maximally even, then the original scale is maximally even. Otherwise, the scale is not maximally even. | |||
=== Pseudocode === | === Pseudocode === |