Sorry, you need a Java-enabled browser to see the simulation.I'm not aware of a Java browser for Mac or Windows 3.11, but ifyou're running UNIX or 32-bit Windows, the latest version ofNetscape will support Java.
You might also want to try this version of the applet, which has better and more accurate sound but requires Java 2.
This java applet is a simulation that demonstrates Fourier series, which is a method of expressing an arbitrary periodic function as a sum of cosine terms. In other words, Fourier series can be used to express a function in terms of the frequencies (harmonics) it is composed of.

To select a function, you may press one of the following buttons: Sine, Triangle, Sawtooth, Square, and Noise. The function is displayed in white, with the Fourier series approximation in red. If you only see a red graph, that means the Fourier approximation is nearly the same as the original function. (The red graph is drawn on top of the white one.)

Below the function you will see a graph of the Fourier coefficients. Each one represents a frequency, or harmonic. There are two sets of terms; on top are the magnitude terms, and on the bottom are the phase terms. Low frequencies are on the left and higher frequencies are on the right. (If you're only familiar with Fourier series expansions that involve sines and cosines, rather than phases, check out this page.)

The "Number of Terms" slider will adjust the number of terms in the expansion. The more terms there are, the better the approximation. Try sliding the "Number of Terms" slider from left to right slowly to see the Fourier terms added up one by one.

If you move the mouse over one of the harmonics, it will turn yellow, and the corresponding Fourier term (frequency) will be drawn on top of the function in yellow. So if you move the mouse over all the harmonics, you can see each of the terms individually. Also, if you click with the right mouse button on one of the harmonics, the "Number of Terms" slider will be changed so that all higher-frequency terms will be taken out of the series.

You can modify the function in one of two ways. You can edit the function directly by clicking on it; in this case, the Fourier coefficients will be regenerated when you are done. Or, you can modify the Fourier coefficients, in which case the function will be changed to match. If you want to create a function from scratch, hit the "Clear" button.

The "Play" button will play the function at 220 Hz, if your browser supports it. (It works for me on windows but not on linux.) The frequency is adjustable using the "Playing Frequency" slider. Try playing various functions to see what they sound like. Also try isolating each harmonic, or mixing two or three harmonics together.

Note that any frequencies higher than 4000 Hz can't be played properly in a java applet, because the sampling rate is only 8000 Hz, and so they will come out sounding lower than they actually are. This is called aliasing. Even below that you may run into quantization distortion.

The "Clip" button can be used to simulate clipping, or distortion. It will increase the amplitude of the function, but will clip it if it goes out of range. Try doing this with a sine function. Using this button generally results in more jagged edges, which means more high-frequency terms will be involved in the expansion. Some functions, like the square wave, aren't affected much by clipping. Try playing the noise waveform and then hit "Clip" a few times to see if it changes.

The "Resample" button can be used to demonstrate aliasing. This is one of the effects which causes the "Play" button to produce such poor results. The function is replaced with samples at 12 points. This corresponds to a sampling frequency of 2640 Hz (at the default playing frequency of 220 Hz). In almost all cases this will cause aliasing, where new, unwanted frequencies will be introduced. For frequencies over 1320 Hz, the aliases will be stronger than the original frequency.

For example a frequency of 440 Hz, when resampled, will have aliases at 2200 Hz (2640-440), 3080 Hz (2640+440), 4840 Hz (2640*2-440), 5720 Hz (2640*2+440), and so on.

When the "Quantize" button is pressed, the values in the function are rounded off to the nearest multiple of 1/2. The resulting roundoff error causes new frequencies to be introduced; these can be heard when the function is played. This is called quantization distortion. (This is another reason the "Play" button produces such poor results; java sound routines only accept 8-bit waveforms, so some roundoff error occurs when trying to quantize a signal down to an 8-bit number.)

The "Rectify" button will zero out the function wherever it is negative. The "Full Rectify" button will take the absolute value of the function at all points. Try this with the sine or sawtooth function.

Other things to try:


Fun