Just intonation
The above applet demonstrates intonation of the musical interval of the perfect fifth (A3 to E4 in the default setup).
The sliders at the bottom allow you to adjust the timbre of the “organ” tone, produced here by Fourier synthesis. The sliders at the top allow for adjustment of the pitches being played. The first slider adjusts the frequency of the lower pitch. The higher pitch has a frequency 3/2 that value in just intonation. The next two sliders allow for adjustment of the relative strengths of the two tones. Set one of these amplitudes to zero to see how adjusting the harmonics affects the shape of the waveform. Finally, the fourth slider allows continuous adjustment between just intonation (usually the preferred intonation of serious musicians) and even temperament (the compromise tuning system that subdivides the octave into twelve equally-spaced pitch intervals).
The waveform is timed to the lower-pitched of the two tones, roughly as it would be on an oscilloscope (the marker draws the waveform from left to right and repeats itself in such a way as to produce a smooth curve). In just intonation, this timing is also correct for the higher pitch, so the combination is stable.
If the intonation is offset from just, then the two oscillations shift relative to one another. Watch the waveform carefully and compare the shape of the waveform with the unsteady timbre that you hear.
In the interval of a fifth, the uneven timbre associated with poor intonation is caused by slow beating of the third harmonic of the lower tone with the (slightly detuned) second harmonic of the higher tone; and also of the sixth harmonic of the lower tone with the (slightly detuned) fourth harmonic of the higher tone. (There are higher harmonics that beat as well, but the tones we’re playing with here have only six harmonics.) If you adjust the bottom sliders to completely turn off either the second or third harmonic, then you will remove the slower beating. If you also turn off either the fourth or sixth harmonic, then you’ll remove the faster beating. Doing both of these will make it so that the timbre still sounds clean even if the interval is detuned (as in even temperament). Even in this case, the waveforms of the two pitches still “shift” relative to one another, but the effects of this shifting aren’t obvious to the ear as they are in the case of the slow beating.
The visualizations above made use of JSXGraph, an extremely useful JavaScript library for interactive plotting, and Gibberish, a wonderful digital signal processing engine.
The visualization is a bit computationally intensive. I find it works best on an actual computer (as opposed to a mobile device), in Google Chrome.