Mathematics of musical scales
From Academic Kids

Contents 
Musical scales
A musical scale is a discrete set of pitches used in making or describing music. Typically a scale has an interval of repetition, which is normally the octave. This means that for any pitch in the scale, we have also an equivalent pitch an octave above and an octave below it. While the limits of human hearing are finite, matters are somewhat simplified if we ignore that fact, as is usually done in discussions of theory though of course never in practice. Because we are often interested in the relations or ratios between the pitches rather than the precise pitches themselves in describing a scale, it is usual to refer all the scale pitches in terms of their ratio from a particular pitch, which is given the value of one (often written 1/1 when discussing just intonation.) This note can be, but is not necessarily, a note which functions as the tonic of the scale. For comparison with the current standard tuning cents are often used. See also logarithmic scale.
The most important scale in the Western tradition is the diatonic scale, but the scales used and proposed in various historical eras and parts of the world have been many and varied. Scales may broadly be classed as scales of just intonation, tempered scales, and practicebased scales. A scale is in just intonation if the ratios between the frequencies for all degrees of the scale are either ratios of small integers, or obtained by a succession of such ratios. It is tempered if it represents an adjustment, or tempering, of just intonation. It is practicebased if it simply reflects musical practice, as for instance various measurements of the tuning of a gamelan might do.
Pythagorean tuning
Pythagorean tuning is tuning based only on the perfect consonances, the (perfect) octave, perfect fifth, and perfect fourth. Thus the major third is considered not a third but a ditone, literally "two tones", and is 81:64 = (9:8)^{2}, rather than the independent and harmonic just 5:4, directly below. A whole tone is a secondary interval, being derived from two perfect fifths, (3:2)^{2}/2 = 9:8.
Just intonation
If we take the ratios constituting a scale in just intonation, there will be a largest prime number to be found among their prime factorizations. This is called the prime limit of the scale; a scale which uses only the primes 2, 3 and 5 is called a 5limit scale. Below is a typical example of a 5limit justly tuned scale, one of the scales Johannes Kepler presents in his Harmonice mundi or Harmonics of the World of 1619, in connection with planetary motion. The same scale was given in transposed form by Alexander Malcolm in 1721 and theorist Jose Wuerschmidt in the last century and is used in an inverted form in the music of northern India. American composer Terry Riley also made use of the inverted form of it in his ‘‘Harp of New Albion’’. Despite this impressive pedigree, it is only one out of large number of somewhat similar scales.
0  1:1  unison 
1  135:128  major chroma 
2  9:8  major second 
3  6:5  minor third 
4  5:4  major third 
5  4:3  perfect fourth 
6  45:32  diatonic tritone 
7  3:2  perfect fifth 
8  8:5  minor sixth 
9  27:16  Pythagorean major sixth 
10  9:5  minor seventh 
11  15:8  major seventh 
12  2:1  octave 
(In theory unisons and octaves and their multiples are also "perfect" but this terminology is rarely used.)
To calculate the frequency of a note in a scale given in terms of ratios, the frequency ratio is multiplied by the frequency we associate to the unison, which will often be the tonic frequency. For instance, with a tonic of A4 (A natural above middle C), the frequency is 440 Hz, and a justly tuned fifth above it (E5) is simply
440*(3/2) = 660 Hz.
The just major third, 5:4 and minor third, 6:5, are a syntonic comma, 81:80, apart from their pythagorean equivalents 81:64 and 32:27 respectively. According to Carl Dahlhaus (1990, p.187), "the dependent third conforms to the Pythagorean, the independent third to the harmonic tuning of intervals."
Temperament
Western common practice music usually cannot be played in just intonation, even when it is confined to a single key. This is because the supertonic chord, or iichord, which is the most important of the minor triads in a major key, serves to bridge between the dominant and subdominant, having a root at once a minor third below the root of the subdominant triad, and hence sharing two of its notes, and a fifth above the root of the dominant triad or dominant seventh chord. The problem becomes still worse when modulation, the key changes so important to common practice music, comes into play. The scale of the Western tradition is by its very nature neither one of just intonation nor one defined only in practice, but is a systematically tempered scale. The tempering can involve either the irregularities of well temperament or be constructed as a regular temperament, either some form of equal temperament or some other regular meantone, but in all cases will involve the fundamental features of meantone temperament.
Meantone, however, is not the only worthwhile temperament nor is the equal division of the octave into twelve parts the only reasonable way to so divide it. Many other systems of temperament are possible, leading to a variety of harmonic relationships characteristic to them. These characteristics depend on what just intervals, called commas, which differ slightly from the unison become a unison when tempered.
In meantone, for example, the root of a iichord regarded as being a fifth above the dominant would be a major whole tone of 9/8 if the fifths were tuned justly, but would be a minor whole tone of 10/9 if it is taken to be a just minor third of 6/5 below a just subdominant degree of 4/3. These are being equated, so meantone temperament is tempering out the difference between 9/8 and 10/9. This means their ratio, (9/8)/(10/9) = 81/80, is tempered to a unison. The interval 81/80, called the syntonic comma or comma of Didymus, is the key comma of meantone temperament, and the fact that it becomes a unison in meantone temperament is a key fact of Western music.
Sound samples
Below are Ogg Vorbis files demonstrating the difference between just intonation and equal temperament. You may need to play the samples several times before you can pick the difference.
 Two sine waves played consecutively  this sample has half a second at 550 Hz (C# in the just intonation scale), followed by half a second at 554.37 Hz (C# in the equal temperament scale).
 Same two notes, with an A thrown in as well  this sample consists of a "dyad". The lower note is a constant A (440 Hz in either scale), the upper note is a C# in the just intonation scale for the first 1s, and a C# in the E.T. scale for the second 1s. Phase differences make it easier to pick the transition than in the previous sample.
See also
Source
 Dahlhaus, Carl. Gjerdingen, Robert O. trans. (1990). Studies in the Origin of Harmonic Tonality, p.1012. Princeton University Press. ISBN 0691091358.
External links
 Tonalsoft Encyclopaedia of Tuning (http://tonalsoft.com/enc/)
 Tuning for Beginners (http://www.microtonal.co.uk/start.htm)
 Music Acoustics (http://www.fortunecity.com/tinpan/lennon/362/english/acoustics.htm) by User:Alberto_Orlandini