Using Paul Falstad's Java applets
The platform independent Java applets (http://www.falstad.com/mathphysics.html) written by Paul Falstad are the best on the web, sometimes by a large margin. They cover a broad range of physics, but we focus here on a few that are extremely useful for illustrating acoustical and wave phenomena. These are
Ripple, Loaded String, Circular Membrane Waves, Rectangular Membrane Waves, Vowels, Bar Waves, Fourier Series, and Box Modes
Many of these applets generate sound real time, so you can listen, for example, to various Fourier series, or to strings built out of beads on a stretched filament.
Paul Falstad's Ripple (Harvard version)
Ripple is the two dimensional wave simulator that is behind so many concepts and illustrations in Why You Hear What You Hear. There are two versions of Ripple: the one on Paul Falstad's website, and the enhanced version at http://www.courses.fas.harvard.edu/~icgzmod/java_physics/ripple/
Harvard's modification of Paul Falstad's Ripple is the workhorse Java applet for this book, and also the most complex. Mr. Falstad graciously allowed us (specifically the Instructional Computing Group at Harvard University) to use his code as the basis for a few bells and whistles that enhance its utility, and allow saving of scenarios and data for future use. Up to four probes (or microphones if you wish) are available, set at positions that are selected with the mouse. Drawing tools for objects and waves are also enhanced.
An hour playing with the controls will certainly yield all the expertise needed to make discoveries.
Probe data can be saved by selecting "Actions...Save Probe Data". This pushes a file "rippleProbeData....txt" to your computer from the server, that you save to your drive.
The current scenario with all walls, wave sources, etc. can be saved with "Actions...Save State". This also pushes a file "rippleState....txt" to your computer from the server.
To load a saved state, go to http://www.courses.fas.harvard.edu/~icgzmod/java_physics/saved_state/upload.html and follow the instructions there to select the file you saved to your hard drive and submit it.
Ripple simulates waves in two dimensions, with reflecting boundaries and refracting elements that you design. The user also designs the waves to be sent at or into the staging area. Be sure to set "fixed edges" unchecked (it defaults as checked so you have to uncheck it, and resets to checked if the number of pixels is changed); that gives the solution for the pressure deviation as a function of time and place, with the right behavior at hard walls and refracting media that you can draw with the mouse. The rectangular edges of the window displayed in Ripple are not walls; rather you should think of the region displayed as being a window on a much larger region. In fact the numerical code tries to absorb waves which impinge on the edges; this is not 100% successful, especially at low frequencies. This sometimes needs to be taken into account when drawing conclusions, since the edges do reflect some amplitude back into the active region.
If you want a regular evenly spaced array of objects or source regions, use "Draw Matrix". Some rather complex shapes can be drawn by using the erase tools for walls or waves after first drawing other shapes, or using a setting of 0 for Medium when setting up lenses. One trick the author uses for shaping waves is to make a shape, let it propagate for some time, and then erase part of it.
There are many other parameters and features to discover; the best use of your time is to start to experment and develop a familiarity with them, rather than make a laundry list of them here.
What's going on in Ripple?
We can't get into any detail about the numerical algorithms going on in Ripple here, but suffice it to say that the algorithm propagates pressure variations on a two dimensional grid of pixels, each pixel representing a small region of air (you can choose the number of pixels, up to a 400 X 400 grid). Rules that embody the "push and push-back" picture, explained in Chapter 1, are used to decide how the pressure varies in each pixel with time. Time is divided into short slices, and what happens in the next slice in each pixel is decided from the neighboring pushing and shoving that just happened in the present time slice.
Using Loaded String is discussed in reasonable detail in chapter 8 of Why You Hear What You Hear.
Paul Falstad's Fourier Series, http://www.falstad.com/fourier/, is a remarkably useful, well conceived Java applet. It is based on Fourier's theorem and harmonic series, so the functions and sound it produces are always periodic (it is less flexible in this sense than MAX partials, that can specify arbitrary frequencies). However it permits the manipulation of many harmonic partials, including their phase. The applet is constructed so that the user can easily see Fourier's theorem at work, and hear the results at every stage. The user has a choice of manipulating the amplitudes of the various harmonic partials, together with their phases, or drawing the desired periodic function directly on screen. The amplitudes of the various partials that make up a drawn waveform can be read off.
Screenshot of Paul Falstad's Fourier Series applet, in this case displaying a sawtooth waveform. The Fourier series consists of 11 terms, as controlled by the Number of Terms slider. The sum of the 11 terms as shown as red, the exact sawtooth is white.
Suggested initial explorations
Check Mag/Phase view; this allows you to control the magnitude of each amplitude, and its phase. The dots under Magnitudes are movable by mouse, and if you raise the second one you will see a sinusoid appearing at the top. The frequency of that sinusoid is the current base frequency, this is changeable with the ``Playing Frequency'' slider. The height of the amplitude stalks squared are the power spectrum.
Clicking ``Sound'' allows you to hear the current waveform; you should do this whenever significant changes have been made.
Now try some of the presets. ``Sine'' and ``Cosine'' are seen to raise only the second amplitude, and to differ in phase. (The first amplitude merely adds a constant to the waveform, and can be considered to be a zero frequency term). ``Triangle'' excites more harmonics; at this point check ``Log View'' this causes the stalk height to be the logarithm of the amplitude, to better see the smaller amplitudes. You will see that only f, 3f, 5f, ... are non-zero. This is characteristic of a clarinet, for example, a fact that we shall later derive from first principles according to the construction of the instrument.
Click on ``Sawtooth'' and note the greater amplitude of the higher harmonics, and the fact that they are all nonzero. Evidently, the sawtooth takes more Fourier frequencies to reproduce reasonably well. The white line on screen is the target sawtooth function, and the red line is the current approximation obtained by adding up all the sinusoidal waves.
Next, lower the ``Number of Terms'' slider, that restricts the maximum frequency used in the Fourier series.Notice the degradation (rounding off) in the resultant waveform compared to a perfectly sharp sawtooth.
If at any point you hold your mouse over one of the stalks, a corresponding sinusoid (colored yellow) will appear along with the resultant waveform of all the sinusoids added together, at the top. The amplitude and phase of the yellow sinusoid are both correct.
Using the mouse in the region where the wave trace is plotted, you will find that you can draw any wave form you want, with the consequent amplitudes and phases automatically recomputed.
Leaving the sound on versus turning it off while changes are made to amplitudes and phases can lead to different impressions. As we will later discuss, most people are capable of both analytic and synthetic hearing. Analytic hearing decomposes a sound into its component parts, so that for example the fourth partial of a given periodic complex tone might be heard individually as a pure, sinusoidal tone ringing separately from the whole.
Synthetic hearing is listening to the sound as a unified whole. Most people find that making changes to the sound can drive them involuntarily to analytic listening, by focusing attention for example on a partial that has just been changed. However, the tendency to do this depends on the time interval that intervenes between listening to the "before" and "after" sound samples.
Fourier Series was never intended to create aperiodic waveforms; this is why Jean-Francios Charles wrote his MAX patch Partials. In MAX Partials the partials do not have to be related as multiples of some fundamental frequency.
Rectangular Membrane (try this version for sound)
This Java applet is well poised to examine either the sound in a two dimensional enclosure filled with air, or the displacement of a membrane. In the former case, leave "Fixed edges" unchecked, in which case the amplitude shown at the top is the pressure in the room. In the latter case, check fixed edges and the amplitude becomes that of a stretched membrane locked down on its perimeter. Square or rectangular shapes can be invesitgated.
The initial wave can be set by "poking", "striking", or "shaping" with the mouse, or set by placing the mouse in the boxs at the bottom (if "Show frequencies" is checked) and setting the amplitude and phase of the modes corresponding to the box. If fixed edges is checked, the upper left box controls the amount of the nodeless lowest mode. By experimenting after pressing "Clear" each time, you can place the mouse over other boxes, click and adjust the amount of other modes that have more and more nodes (in x or y), depending on how far the box is from the upper left corner.
Other Falstad applets
...are either described in the text or tranparent enough to need no introduction.