/ Sound Wave Simulator Back
Web Audio API · Physics

🔊 Sound Wave Simulator

Watch particle oscillation animations and hear the actual sound simultaneously. Adjust frequency, waveform, and amplitude in real time — and experience beat frequencies with two-tone mode.

Parameters
Web Audio API not supported in this browser. Visual simulation only.
Presets
Two-tone mode (Beats)
Results
440
Frequency (Hz)
0.779
Wavelength λ (m)
2.27
Period T (ms)
--
Sound Level (dB)
Particle Oscillation Animation (transverse representation of pressure wave)
Particle
Oscilloscope View
Scope
Theory & Key Formulas

Theory Notes

Wave equation: Speed of sound $v = 343\,\text{m/s}$ (air at 20°C), wavelength $\lambda$, frequency $f$:

$$v = f \lambda \quad \Longrightarrow \quad \lambda = \frac{343}{f}$$

Beat frequency: When two waves with frequencies $f_1$ and $f_2$ (close in value) are superimposed, the combined amplitude fluctuates at $f_\text{beat}= |f_1 - f_2|$. Used by musicians for tuning.

$$y(t) = A\cos(2\pi f_1 t) + A\cos(2\pi f_2 t) = 2A\cos\!\left(2\pi\frac{f_1-f_2}{2}t\right)\cos\!\left(2\pi\frac{f_1+f_2}{2}t\right)$$

Sound pressure level (dB): $L = 20\log_{10}(A/A_0)$, where $A_0 = 2\times10^{-5}\,\text{Pa}$ (hearing threshold).

CAE connection: Acoustic FEM solves the wave equation $\nabla^2 p - \frac{1}{c^2}\frac{\partial^2 p}{\partial t^2}= 0$ in discretized space. Applications: automotive NVH analysis, architectural acoustics, noise prediction.

What is a Sound Wave?

🙋
What exactly is the "frequency" slider controlling in this simulator? I see the wave gets squished together when I increase it.
🎓
Basically, frequency is how many times the air particles vibrate back and forth per second, measured in Hertz (Hz). In practice, a higher frequency means a higher-pitched sound. Try moving the slider above from 200 Hz to 800 Hz—you'll hear the pitch go up and see the wave peaks get closer together because the wavelength gets shorter.
🙋
Wait, really? So the distance between peaks is the wavelength? How is that related to the speed of sound?
🎓
Exactly! The wave travels at a fixed speed in air (about 343 m/s). If you vibrate the air more times per second (higher frequency), the waves have to be packed tighter to keep that speed. This is the core relationship: Speed = Frequency × Wavelength. For instance, a 343 Hz tone has a wavelength of 1 meter. The simulator uses this physics to draw the wave correctly.
🙋
That makes sense. But what's the point of the "2nd Frequency" control? When I turn it on, I hear a weird pulsing sound.
🎓
Ah, you've discovered beats! That pulsing is a crucial phenomenon. When two sound waves of slightly different frequencies mix, they interfere. A common case is tuning a guitar—you listen for the beat to disappear when the strings are in tune. In the simulator, set the main frequency to 440 Hz and the second to 443 Hz. You'll hear and see a volume oscillation at 3 beats per second, which is the difference between the two frequencies.

Physical Model & Key Equations

The fundamental relationship governing any wave is between its speed, frequency, and wavelength. For sound in air at 20°C, the speed is constant.

$$v = f \lambda$$

Where $v \approx 343 \text{ m/s}$ is the speed of sound, $f$ is the frequency in Hertz (Hz), and $\lambda$ is the wavelength in meters (m). This tells us that a high-frequency sound has a very short wavelength.

When two sound waves of equal amplitude but different frequencies combine, they create a "beat" pattern. The resulting sound wave is mathematically described by the sum of two cosines.

$$y(t) = A\cos(2\pi f_1 t) + A\cos(2\pi f_2 t) = 2A\cos\!\left(2\pi\frac{f_1-f_2}{2}t\right)\cos\!\left(2\pi\frac{f_1+f_2}{2}t\right)$$

Here, $f_1$ and $f_2$ are the two frequencies, and $A$ is the amplitude. The final form shows a rapid oscillation at the average frequency $(f_1+f_2)/2$, whose amplitude is slowly modulated at the beat frequency $f_{beat} = |f_1 - f_2|$. This is the pulsing rate you hear.

Real-World Applications

Musical Instrument Tuning: Musicians use the beat phenomenon to tune instruments. When two notes are very close in frequency, the audible beat pulses slowly. As the musician adjusts the pitch, they aim for the beats to disappear, indicating the frequencies are perfectly matched. This is a precise, auditory method used before electronic tuners existed.

Ultrasound Imaging: Medical ultrasound uses sound waves at frequencies far above human hearing (MHz range). The very short wavelength at these high frequencies allows the waves to reflect off tiny structures inside the body, creating detailed images. The same wave equation governs how these waves propagate through different tissues.

Noise-Canceling Headphones: These devices work on the principle of wave interference. A microphone picks up ambient low-frequency noise (like an airplane engine). The headphone's processor generates a sound wave that is the exact opposite (180° out of phase) and plays it, causing destructive interference that cancels the noise wave before it reaches your ear.

Sonar and Echolocation: Bats, dolphins, and ship sonar systems emit sound pulses and listen for the echo. By knowing the speed of sound and measuring the time delay of the return echo, they can calculate the distance to an object. The frequency used is often chosen based on the desired resolution and range, following the wavelength relationship.

Common Misconceptions and Points to Note

First, keep in mind that this simulator deals with "simple sound waves in free space." Practical CAE acoustic analysis is far more complex. For instance, do you think "doubling the amplitude also doubles the volume (sound pressure level)"? Actually, that's not correct. Sound pressure level is expressed on a logarithmic scale in decibels (dB). Even if the amplitude doubles, the sound pressure level only increases by about 6dB (precisely, $20 \log_{10}(2) \approx 6.02 \text{dB}$). So be careful, it doesn't become "twice as loud."

Next, regarding waveform selection. Square waves and sawtooth waves theoretically contain infinite harmonics, but there is a limit to the frequencies that can be reproduced by this simulator and by actual speakers. For example, trying to generate a 1kHz square wave requires high harmonics like 15kHz or 20kHz. However, once these exceed the speaker's performance or the human audible range (approx. 20Hz–20kHz), those harmonics cannot be reproduced or heard. Therefore, the "clean square wave" in the simulator and the sound from actual equipment can be slightly different. This is an important concept called "bandwidth limitation" that you should always keep in mind in practical work too.

Finally, a common pitfall in the beat experiment is making the frequency difference too large. For example, superimposing 440Hz and 500Hz (a 60Hz difference) will sound more like two separate tones or a dissonance rather than a beat. A beat is clearly perceptible when the difference is roughly below 15Hz or so. Remember that the beats used for tuning instruments involve a very slight difference of about 1–3Hz.

How to Use

  1. Set primary frequency (20–20,000 Hz) using freqSlider; observe wavelength λ = c/f where c = 343 m/s in air at 20°C
  2. Adjust amplitude with ampSlider (0–100%) to control sound pressure level (SPL) in decibels relative to 20 µPa reference
  3. Enable twoToneToggle and configure freqSlider2 to generate beat frequency effects; audible beat rate = |f1 – f2| Hz
  4. Monitor Period T (ms) = 1000/f and particle oscillation animation synchronized to acoustic wave propagation

Worked Example

A 440 Hz concert A-note (violin fundamental) with 75% amplitude: wavelength λ = 343/440 = 0.78 m, period T = 1000/440 = 2.27 ms. Two-tone simulation at 440 Hz and 445 Hz produces 5 Hz beat frequency (audible tremolo). At 75% amplitude, SPL ≈ 85 dB. Particle velocity amplitude = 2πfA; for f = 440 Hz and A = 0.5 cm displacement, particle velocity ≈ 1.38 m/s.

Practical Notes

  1. Human hearing spans 20 Hz (infrasound perception threshold) to 20 kHz (age-dependent upper limit); test personal high-frequency rolloff above 12 kHz
  2. Beat frequency experiments (f1 = 256 Hz, f2 = 260 Hz yields 4 Hz beats) demonstrate wave interference in timpani tuning and acoustic engineering
  3. SPL doubling (perceived loudness increase) requires 10 dB boost; 85 dB sustained exposure limits per OSHA are 8 hours maximum
  4. Wavelength inversely scales with frequency—1 kHz = 0.34 m (room acoustics), 100 Hz = 3.4 m (bass trapping design requirement)