/ 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.
Frequency (Hz) 440 Hz
20 Hz2000 Hz
Amplitude (Volume) 0.50
Presets
Two-tone mode (Beats)
440
Frequency (Hz)
0.779
Wavelength λ (m)
2.27
Period T (ms)
--
Sound Level (dB)
Particle Oscillation Animation (transverse representation of pressure wave)
Oscilloscope View

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.

Related Engineering Fields

The "synthesis of single waves" you're experimenting with here is the very gateway to Fourier analysis. You learned that square waves and triangle waves are composed of harmonics, right? Conversely, when you capture a complex sound (e.g., engine noise or a guitar sound) with a microphone and input it into a computer, you can decompose it into its constituent frequency components (spectrum) by applying Fourier analysis. This technology is fundamental to Vibration and Noise Analysis (NVH). It is directly applied in evaluating the quality of a car door closing sound or in designing quieter motors for home appliances.

Furthermore, since sound waves are a type of "wave," their behavior is mathematically similar to other wave phenomena. For instance, similar partial differential equations (wave equations) appear in electromagnetic wave analysis (antenna design, radio wave propagation) and structural vibration/wave propagation analysis (seismic waves, ultrasonic testing). Learning to set boundary conditions (walls, sound-absorbing materials) in acoustic simulation also builds foundational skills for thinking about radiation patterns around antennas or how seismic waves propagate within buildings.

On a more practical level, it is deeply connected to Digital Signal Processing (DSP). Behind the real-time generation and synthesis of waveforms in this simulator lies discrete sampling and computation. In actual audio equipment or speech recognition systems, this DSP technology is used for noise removal and emphasizing specific frequency bands (equalizers). CAE tools and DSP can be said to be the two essential wheels for a modern acoustics and vibration engineer.

For Further Learning

As a recommended next step, try incorporating the concept of "phase." Right now, the simulator simply adds two waves, correct? But in reality, the "timing misalignment" (phase difference) between waves greatly affects the result. For example, even if you superimpose two identical 440Hz sine waves, if they are 180 degrees (π radians) out of phase, they will cancel each other out and the sound almost disappears (destructive interference). This principle is used in active noise-cancelling headphones. When you start considering synthesis with phase in mind, the world of acoustics expands significantly.

If you want to deepen the mathematical background, study the wave equation. The fundamental equation for sound waves in one dimension looks like this: $$ \frac{\partial^2 p}{\partial x^2} = \frac{1}{c^2} \frac{\partial^2 p}{\partial t^2} $$ Here, $p$ is sound pressure and $c$ is the speed of sound. By solving this partial differential equation, you can understand the behavior of sound propagating through space (reflection, diffraction, attenuation) more realistically. CAE acoustic analysis software is essentially solving this equation numerically for complex shapes.

A practical learning path could be: 1. Develop intuition with this simulator → 2. Learn the basics of Fourier series/transforms and understand the relationship between waveforms and spectrum mathematically → 3. Try writing simple digital filter programs (low-pass, high-pass) (possible with `numpy` and `scipy` in Python) → 4. Solve a simple model using free CAE acoustic analysis software (e.g., OpenFOAM's acoustic module, SU2). Learning with both theory and tools is the shortcut to building skills you can use in practice.