This simulation shows Polly the parrot sitting on a branch in front of a rock wall, sending out sound waves every time she speaks a phrase. Each wave is drawn as an expanding, fading ring of colour that travels across the scene; when a ring reaches the wall it triggers a second, delayed ring bouncing back toward Polly — a simple visual model of how an echo is really just your own sound reflecting off a hard surface and returning to your ears.
Every click of a phrase button emits a burst of expanding circular waves from Polly's beak. Once a wave's radius reaches the distance to the wall, the scene schedules an echo wave that starts from the wall and expands back outward in a different colour — showing sound leaving, hitting a surface, and returning as an echo.
Click any of the six phrase buttons (Hello!, Pretty bird!, Squawk!, Yummy!, Fly away!, Good night!) to make Polly speak and flap her wings. The Echo delay slider (30–120) controls how long the bounced wave waits before appearing, and the Wave volume slider (1–5) sets how many overlapping rings are emitted per phrase. A fact box below the controls cycles through a new sound-science fact each time Polly speaks.
Real sound travels through air at about 343 metres per second, and parrots can mimic sounds because they have an unusually flexible voice box called a syrinx — much more adaptable than the human larynx, which is one reason they're such good mimics.
Clicking a phrase button sets the speech bubble text and triggers the emitWaves() function, which spawns a burst of expanding ring shapes (their number set by the Wave volume slider) from Polly's position. It also flaps her wings for a short animation and shows the phrase in a speech bubble above her head as it fades out.
Each wave ring expands frame by frame. When its radius grows past the distance to the wall on the right of the scene, the simulation schedules a new wave using setTimeout, delayed by the Echo delay slider value. That new wave starts right at the wall and expands outward in a different colour, visually representing sound bouncing back.
Echo delay (range 30–120) sets how many milliseconds pass between a wave reaching the wall and its echo appearing — a higher value means a longer pause before you see the bounce. Wave volume (range 1–5) sets how many wave rings are emitted at once each time Polly speaks, with each extra ring slightly fainter than the last.
This is a visual, Canvas 2D model rather than an actual audio/Web Audio API simulation — no sound is played through your speakers. The circles are a simplified way of picturing how sound waves spread out from a source and reflect off a surface, designed to teach the idea of an echo rather than reproduce real acoustics.
The scene draws a single rock wall at a fixed position (87% of the screen width) so that waves travelling toward it have somewhere to bounce off. This keeps the echo effect predictable and easy to watch: every wave that reaches that edge produces exactly one delayed echo wave heading back the other way.