Using my online script you can produce a list of linear temperaments that fulfil a set of criteria. It's based on simple principles, which would be tedious to work through without a computer. For this explanation I'll use "linear temperament" as singular to define what should properly be termed a family of temperaments such as meantone. I'll also talk about tempered intervals being particular ratios instead of saying each time that they're only approximations.

Because equal temperaments are simpler than linear temperaments, finding a good set of one can be a first step to the other. The important detail is that we must use a mapping between ratios and scale steps, instead of taking the nearest approximation to each ratio as we go along. As well as avoiding problems of inconsistency, this gives the right information to carry out the next step.

As an example, take 12 note equal temperament. A fifth is 7 steps and approximates 3:2, so 3:1 is 12+7=19 steps. A major third is 4 steps and approximates 5:4, so 5:1 is 29 steps. The harmonic seventh of 7:4 is closer to 10 steps then anything else, so 7:1 is 34 steps.

The mapping of 12-equal to 2 3 5 7 can then be written as [12 19 29 34]. Mappings to other intervals can then be derived from this, like on the matrix page or wherever. The numbers are smaller if you reduce all the primes within the octave, but this makes it harder to work out other intervals because you aren't dealing with straight prime factorization. The nearest approximation to the primes needn't be the one that gives the mapping you want. So far, it is the only one my program generates. Because there's nothing special about them being prime numbers, I call them "prime intervals" for full generality.

To guess how useful an equal temperament will be, I take the worst error in the set of consonances under consideration as a proportion of the step size. For example, the 5-limit in 12-equal comes out as

ratio | cents | number of steps | error in cents |
---|---|---|---|

3:2 | 701.96 | 7 | +1.96 |

5:4 | 386.31 | 4 | -13.69 |

6:5 | 315.64 | 3 | +15.64 |

As the step size of 12-equal is 100 cents, you can easily convert from an error in cents to an error in step sizes. For a computer, it's no more difficult for any ET. All it does is take the error in octaves (no need to worry about cents) and multiply by the number of steps to an octave. Only ETs with a worst error below a given cutoff make it through to the next stage. By default, this cutoff is 0.5 so that only consistent ETs are considered.

You can always define a linear temperament in terms of two equal temperaments. One way of thinking about this is that an MOS consists of two different sizes of steps. For a simple example, take the diatonic scale in terms of tones and semitones

C D E F G A B C t t s t t t s

You can break this down into the number of tones or semitones between each adjacent pair of notes.

C D E F G A B C t t s t t t s tones 1 1 0 1 1 1 0 semitones 0 0 1 0 0 0 1

The tones on their own could be taken to describe 5-equal, and the semitones 2-equal. That's a bit peculiar, so we can add tones and semitones to get a description of 7-equal

C D E F G A B C t t s t t t s 1 1 1 1 1 1 1 /7 1 1 0 1 1 1 0 /5

Or add them again to get 12-equal

C D E F G A B C t t s t t t s 2 2 1 2 2 2 1 /12 1 1 1 1 1 1 1 /7

Or yet again to get a pair of meantones.

C D E F G A B C t t s t t t s 3 3 2 3 3 3 2 /19 2 2 1 2 2 2 1 /12

All these descriptions are equivalent, in that they give the same pattern of large and small steps. The relative sizes of the large and small steps depends on what weight you give to each equal temperament.

This example has shown the numbers of steps to an octave. Because we've calculated the number of steps to other intervals, the approximations of those intervals in a linear temperament can be determined in the same way. In 12-equal, we have the 3:1 as 19 steps. In 19-equal, 3:1 approximates to 30 steps.

The number of diatonic steps to any interval is the number of steps of 19-equal minus the number of steps to 12-equal. For 3:1, that's 30-19=11 so 3:1 is a kind of twelfth. The number of chromatic steps is the number of steps from 12-equal. The number of tones is the difference between the number of chromatic and diatonic steps, in this cse 19-11=8. The number of semitones is the difference between the number of diatonic steps and the number of tones. Here, 11-8=3. So a 3:1 is 8 tones and 3 semitones.

Repeat this for 5:1 and you get the definition of meantone temperament. Repeat for other pairs of equal temperaments, and you get different linear temperaments. That's all the program does -- it takes a list of equal temperaments and pairs them up to give linear temperaments.

The & operator is used to join a pair of equal temperaments to give a linear temperament. So meantone could be 5&7 or 7&12 or 12&19.

A pair of equal temperaments is a precise, but not a unique way of specifying a linear temperament. The unique specification is, like for an MOS or Well Formed scale, in terms of a period and generator. The relationship between these two ways of representing an MOS was given by Carey and Clampitt in their Perspectives of New Music article.

Say we have the temperament m&n. We can form a larger scale with m+n=d steps. The number of steps to a generator in that scale is g where g is such that (n*g + 1) mod d = 0. So all we have to do is try each value of g until we get one that works. This will never require g>d.

But no! It's a teensy bit more complicated than that because the period isn't always an octave. You can always make the number of periods to an octave the greatest common divisor of the numbers of steps to an octave. For example, the period of 12&22 is a half-octave. The period of 29&58 is a 29th of an octave. All we have to do then is divide by the gcd to get m, n and d in terms of the period rather than the octave. Or leave n and d as they were and find g where (n*g+gcd(n, d)) mod d = 0.

To ensure the same generator is always used for a given temperament, I take the smallest possible one. For sensible ET seeds, this will either be the first one to come out or the difference between that one and the period, whichever spans the smaller number of scale steps.

After catching your period and generator, you need to express you prime intervals in terms of them. We already know that the octave is a given number of periods. For the other intervals, we know the number of each kind of scale step that make them up, and the number of each kind of scale step to the period and generator. So moving from one to the other is a question of solving a matrix equation.

I showed above that meantone temperament can be specified as 5&7 or 7&12 or 12&19. 5&12 and 7&19 also work. But with 5&19 something strange happens. The algorithm gives a mapping of 2 generators to a fifth and 8 generators to a major third (ignoring octaves in both cases). For a meantone, these should be 1 and 4 respectively. So they're twice as big as they should be! This is contorsion.

It arose because 5- and 19-equal aren't adjacent on the meantone bit of the scale tree.

5 7 12 17 19

but it could have been becasue one of the ETs already had more notes than it needed, say 24 instead of 12.

You can always spot contorsion because the mapping of primes to generators has a common divisor. For this example, the generator can either be half a fifth (a neutral third) or half a fourth (between a major second or a minor third). Although either of them score twice as badly as meantone (because twice as many notes are needed for a given chord, although you get twice as many of them) the neutral third generated scale at least has a historical precedent. It's the quartertone or "enharmonic" scale as used by Vicentino with only 5-limit harmony.

Whether temperaments with contorsion should even be thought of as temperaments is a matter of debate. They're really a way of constructing a scale with a simpler temperament. One problem is that there's always more than one qualitatively different generator for a given linear temperament with contorsion. So the temperament isn't uniquely determined by the mapping by period and generator.

My program doesn't do anything special about contorsion, because the simpler temperament will probably arise from another pair of equal temperaments (at least if it's any good) and temperaments with contorsion appear more complex and aren't as prominent.

After generating all these linear temperaments, I don't want to keep duplicates like 12&7 and 12&19 which will both be meantones. So I need a unique label for each linear temperament. The period and generator mapping should be unique, but some strange ETs (and this is more of a problem in another context) don't make it obvious which generator is the smaller, or even the relative sizes of the period and generator.

So the simplest label that's guaranteed to be unique looks like the number of periods to an octave combined with the numbers of generators to each prime interval, ignoring periods. If the generator mapping wasn't generated using a rule that makes it unique, you can multiply by -1 if the first entry is negative.

This doesn't discriminate between different versions of a scale with contorsion, but they're not really important. Working backwards from the generator mapping and number of periods to an octave to the full specification of the temperament is left as an exercise for the reader.

For any given linear temperament (which I should be calling a "temperament family") the sizes of the period and generator are free parameters. For what we need to know, the period can be left as an exact division of the 2:1 octave so all we need to do is find the best value for the generator.

There are two ways of optimizing that my program does -- minimax and minimum RMS. In both cases intervals that are a whole number of periods aren't affected by the optimization, and so they can be removed from consideration. As octaves are perfect and the consonances are octave-equivalent, only those consonances between a unison and half-octave need to be considered.

The minimax finds the generator for which the worst tuned consonance isn't as bad as the worst tuned consonance would be for any other value of the generator. Quarter comma meantone is the minimax 5-limit tuning. The minimax will always be where some interval is fixed as just, but that interval needn't be one of the original consonances. So to find it, you set each consonance in turn to be just and see how bad the worst consonance is. Then you have to check each pair of consoances being tuned the same as well.

The minimum RMS finds the lowest value for the root mean square of the
errors of all the consonances.
This is easy enough to do as an iteration over all consonances,
but the calculation can be made more efficient.
The lowest value of a curve is always where the derivative is zero.
For a curve ax^{2} + bx^{2} + cx^{2}
(you can safely ignore the square root)
this means
2a + 2b + 2c = 0.
The error in each consonance is a linear combination of
the errors in the prime intervals.

The error in each consonance is g*map-ideal where g is the size of
generator we're looking for, map is the number of generators for this
consonance, and ideal is the perfect tuning adjusting for periods.
The error squared is then (g*map-ideal)^{2} or
map^{2}g^{2} - 2*map*ideal - ideal^{2}
and the derivative is 2*map^{2}*g - 2*ideal.
The optimum is found by setting the sum over all consonances of
2*map^{2}*g - 2*ideal
to zero, which is the same as the sum over map^{2}*g - ideal.
It gives a value of g=sum(ideal)/sum(map^{2}).
The second derivative is 2*map^{2}.
This is always positive so the stationary point is always a minimum.

Using these algorithms, the mimimum RMS can be found much faster than the mimimax, so I use the former when running through a large number of temperaments. But, for one temperament at a time, minimax is still the default.

The idea is to get the best temperaments at the top of the list, where "best" means
the smallest error for the lowest number of notes.
The error comes from one of the optimization methods described above,
currently minimum RMS.
The number of notes or complexity is the difference between the largest and smallest generator
steps needed to describe a consonance (including the unison) multiplied by the
number of periods to an octave.
This means if you have an MOS with n notes to the octave there will be complexity-n
complete chords using the specified consonances.
The formula used to combine the error and complexity can be specified by the user,
and defaults to error*complexity^{2}.
Low values rise to the top.

So far, the talk's been of "octaves" and vaguely defined "consonances" and "prime intervals". You can use any interval in place of an octave, so long as other intervals are expressed as a proportion of it.

The prime intervals are by default the logarithms of prime numbers to base 2, but can be any intervals using which your consonances can be defined using integer coefficients. Usually the prime intervals will be linearly independent, so no prime interval can be defined in terms of the others. They needn't have anything to do with integer ratios or the harmonic series.

Consonances are by default an odd limit -- that is, all ratios with no odd number in either the numerator or denominator that exceeds a given number, and reduced and unique within an octave. They can also be the intervals between an arbitrary list of odd numbers, or any integer combination of the prime intervals you like. They always have to be octave-equivalent, with your arbitrary definition of "octave".

The online script currently allows for only odd-limits of limits derived from a list of integer harmonics. In that latter case, you can find duplicate temperaments in the list if some prime numbers aren't involved in ratios. That's because the mappings for these primes are arbitrary, but still counted when labeling the temperaments.

The list of equal temperaments used as the seed is restricted to a certain error as a proportion of step size, and a certain number of notes. To save time, linear temperaments are also thrown away if they exceed a certain error or complexity.