In musical tuning, a temperament is a tuning system that slightly compromises the pure intervals of just intonation to meet other requirements. Most modern Western musical instruments are tuned in the equal temperament system. Tempering is the process of altering the size of an interval by making it narrower or wider than pure. "Any plan that describes the adjustments to the sizes of some or all of the twelve fifth intervals in the circle of fifths so that they accommodate pure octaves and produce certain sizes of major thirds is called a temperament." Temperament is especially important for keyboard instruments, which typically allow a player to play only the pitches assigned to the various keys, and lack any way to alter pitch of a note in performance. Historically, the use of just intonation, Pythagorean tuning and meantone temperament meant that such instruments could sound "in tune" in one key, or some keys, but would then have more dissonance in other keys.
In the words of William Hubbard's Musical Dictionary (1908), an anomalous chord is a "chord containing an interval" that "has been made very sharp or flat in tempering the scale for instruments of fixed pitches".
The development of well temperament allowed fixed-pitch instruments to play reasonably well in all of the keys. The famous Well-Tempered Clavier by Johann Sebastian Bach takes full advantage of this breakthrough, with pieces written in all 24 major and minor keys. However, while unpleasant intervals (such as the wolf interval) were avoided, the sizes of intervals were still not consistent between keys, and so each key still had its own character. This variation led in the 18th century to an increase in the use of equal temperament, in which the frequency ratio between each pair of adjacent notes on the keyboard was made equal. In other words, the ratio between two notes that were one octave apart was kept pure, and the twelve notes in between the octave were equally spaced from one another. This allowed music to be transposed between keys without changing the relationship between notes.
Temperament, in music, the accommodation or adjustment of the imperfect sounds by transferring a part of their defects to the more perfect ones, in order to remedy, in some degree, the false intervals of those instruments, the sounds of which are fixed; as the organ, harpsichord, piano-forte, etc.
Temperament is what the Italians call participatione, or system temperato, because it is founded on temperature; that is, on the diminution of some intervals and augmentation of others, by which it partakes of the diatonic and chromatic systems.
"Temperament refers to the various tuning systems for the subdivision of the octave," the four principal tuning systems being Pythagorean tuning, just intonation, mean-tone temperament, and equal temperament. In just intonation, every interval between two pitches corresponds to a whole number ratio between their frequencies, allowing intervals varying from the highest consonance to highly dissonant. For instance, 660 Hz / 440 Hz (a ratio of 3:2) constitutes a fifth, and 880 Hz / 440 Hz (2:1) an octave. Such intervals (termed "just") have a stability, or purity to their sound, when played simultaneously (assuming they are played using timbres with harmonic partials) because pure intervals do not waver or beat regularly.; the proportions of their frequencies can be expressed as whole numbers. If one of those pitches is adjusted slightly to deviate from the just interval, a trained ear can detect this change by the presence of beats, which are periodical oscillations in the note's intensity. If, for example, two sound signals with frequencies that vary just by 0.5 Hz are played simultaneously, both signals are out of phase by a very small margin, creating the periodical oscillations in the intensity of the final sound (caused by the superposition of both signals) with a repetition period of 2 seconds (following the equation Tr=1/Δf, Tr being the period of repetition and Δf being the difference in frequencies between both signals), because the amplitude of the signals is only in phase, and therefore has a maximum superposition value, once every period of repetition.
When a musical instrument with harmonic overtones is played, the ear hears a composite waveform that includes a fundamental frequency (e.g., 440 Hz) and those overtones (880 Hz, 1320 Hz, 1760 Hz, etc.)—a series of just intervals. These just intervals, due to their acoustic nature, are present in many contexts: everything from a blacksmith's hammer to a clock bell will naturally produce these intervals. The waveform of such a tone (as pictured on an oscilloscope) is characterized by a shape that is complex compared to a simple (sine) waveform, but remains periodic. When two tones depart from exact integer ratios, the shape waveform[clarification needed] becomes erratic—a phenomenon that may be described as destabilization. As the composite waveform becomes more erratic, the consonance of the interval also changes. Furthermore, every interval created by two sustained tones creates a third tone, called a differential (or resultant) tone. This third tone is equal to the lower pitch subtracted from the higher pitch. This third tone then creates intervals with the original two tones, and the difference between these is called a second differential. Differentials are soft and difficult for the untrained ear to detect. Nevertheless, these relationships between differentials play a large role in determining which tunings create consonant sound.
Tempering an interval involves the deliberate use of such minor adjustments (accepting the related destabilization) to enable musical possibilities that are impractical using just intonation. The most widely known example of this is the use of equal temperament to address problems of older temperaments, allowing for consistent tuning of keyboard and fretted instruments and enabling musical composition in, and modulation among, the various keys.
Main article: Meantone temperament
Before Meantone temperament became widely used in the Renaissance, the most commonly used tuning system was Pythagorean tuning. Pythagorean tuning was a system of just intonation that tuned every note in a scale from a progression of pure perfect fifths. This was quite suitable for much of the harmonic practice until then (See: Quartal harmony), but in the Renaissance, musicians wished to make much more use of Tertian harmony. The major third of Pythagorean tuning differed from a just major third by an amount known as syntonic comma, which musicians of the time found annoying. A comma (in musical parlance) is the distance between two tones that are close enough that they share the same name but that are precisely calculated via different proportional spacing, creating a small difference in their exact pitches. 
Their solution, laid out by Pietro Aron in the early 16th century, and referred to as meantone temperament (or quarter-comma meantone temperament), was to temper the interval of a perfect fifth slightly narrower than in just intonation, and then proceed much like Pythagorean tuning, but using this tempered fifth instead of the just one. With the correct amount of tempering, the syntonic comma is removed from its major thirds, making them just. This compromise, however, leaves all fifths in this tuning system with a slight beating. However, because a sequence of four fifths makes up one third, this beating effect on the fifths is only one quarter as strong as the beating effect on the thirds of Pythagorean tuning, which is why it was considered a very acceptable compromise by Renaissance musicians.
Pythagorean tuning also had a second problem, which meantone temperament does not solve, which is the problem of modulation (see below), which is restricted because both have a broken circle of fifths. A series of 12 just fifths as in Pythagorean tuning does not return to the original pitch, but rather differs by a Pythagorean comma, which makes that tonal area of the system more or less unusable. In meantone temperament, this effect is even more pronounced (the fifth over the break in the circle is known as the Wolf interval, as its intense beating was likened to a "howling"). The use of 53 equal temperament provides a solution for the Pythagorean tuning, and 31 equal temperament for the Meantone.
Just intonation has the problem that it cannot modulate to a different key (a very common means of expression throughout the common practice period of music) without discarding many of the tones used in the previous key, thus for every key to which the musician wishes to modulate, the instrument must provide a few more strings, frets, or holes for him or her to use. When building an instrument, this can be very impractical.
Well temperament is the name given to a variety of different systems of temperament that were employed to solve this problem, in which some keys are more in tune than others, but all can be used. This phenomenon gives rise to infinite shades of key-colors, which are lost in the modern standard version: 12-tone equal temperament (12-TET). Unlike meantone temperament, which alters the fifth to "temper out" the syntonic comma, 12-TET tempers out the Pythagorean comma, thus creating a cycle of fifths that repeats itself exactly after 12 steps. This allowed the intervals of tertian harmony, thirds and fifths, to be fairly close to their just counterparts (the fifths almost imperceptibly beating, the thirds a little milder than the syntonic beating of Pythagorean tuning), while permitting the freedom to modulate to any key and by various means (e.g. common-tone and enharmonic modulation, see modulation). This freedom of modulation also allowed substantial use of more distant harmonic relationships, such as the Neapolitan chord, which became very important to Romantic composers in the 19th century.