Visualizations
327 / 500

327 · Fractals

Sound of Mandelbrot

Hover the Mandelbrot set to see and hear orbits: each bulb's period plays as a loop.

Inside the Mandelbrot set, the orbit of z -> z^2 + c usually settles into an attracting cycle, and each bulb has its own period: the main cardioid pulls orbits to a fixed point, the disc beside it to a 2-cycle, the bulbs above and below to 3-cycles, and so on forever. The interior is colored by that period, found by watching the orbit return to a saved point and then walking once around the cycle, and shaded by the cycle's multiplier, which is 0 at a bulb's center and 1 on its rim. Hovering a point draws its orbit and final cycle and plays it with Web Audio: each step is a note whose pitch comes from where z is, so a fixed point holds one steady tone, a period-n bulb loops an n-note arpeggio, points near the boundary wander, and escaping orbits shoot upward and vanish. Locked orbits keep playing together, so bulbs of different periods make polyrhythmic chords, and a piano roll shows every voice even with the sound off. The set itself renders progressively, coarse to fine, and re-renders as you zoom.

Try it. Hover to trace and hear an orbit (the first click turns sound on), and click to lock up to five orbits into a chord; click a locked marker to remove it. Scroll to zoom and drag to pan into smaller bulbs. M mutes, C clears the locked orbits, Q switches between a pentatonic scale and continuous pitch, [ and ] change the tempo and 0 resets the view.

  • Web Audio
  • Sonification
  • Period detection
  • Cycle multipliers
  • Escape-time rendering
  • Progressive rendering

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a Mandelbrot set you can listen to, with JavaScript, the HTML canvas element and the Web Audio API: hovering a point draws its orbit and plays it as notes. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window.
- Render the Mandelbrot set into a smaller offscreen canvas, a few rows per frame, and scale it up, with the outside in dark blues.
- For points inside, find the period of the cycle the orbit settles into: iterate a few hundred times, save z, then keep iterating until z comes back within a tiny distance. The number of steps it took is the period. Color the interior by period (period 1 blue, period 2 purple, period 3 amber and so on).
- When I hover a point c, compute its orbit 0, c, c^2 + c, ... and draw it as a polyline with dots over the set.

Once that works, add sound:
- Create the AudioContext on the first click (browsers require a user gesture) and show a small "Click for sound" hint until then.
- Use one oscillator for the hovered point. Eight times a second, advance the orbit one step and set the oscillator's pitch from z, for example by mapping its real and imaginary parts onto a pentatonic scale.
- If the pitch is the same as the last note, just hold it: inside the main cardioid this gives one steady tone, and a period-3 bulb plays a three-note loop.
- When the orbit escapes, sweep the pitch upward, fade out and restart from z = 0.
- Click to lock a point so it keeps playing alongside the hovered one.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as shading bulbs by the cycle multiplier, a scrolling piano roll of the notes, or zooming into smaller bulbs.
PreviousTopological SnakeSnake on a torus, a Klein bottle and a projective plane, with the real surface turning beside it. NextMoon LanderVector-line lunar descent on a green phosphor tube, with a suicide-burn autopilot.

Related visualizations

  • BuddhabrotFractals Escaping Mandelbrot orbits stacked into a deep-space nebula by Metropolis-Hastings.
  • Road to ChaosMath The logistic map's bifurcations, Mandelbrot bulbs and a cobweb, linked in one picture.
  • Mandelbrot ZoomFractals An endless dive into the Mandelbrot set, 10^31 times deep.
  • MandelbulbFractals A 3D fractal, ray marched pixel by pixel on the CPU.
  • Julia SetFractals A fractal that reshapes itself as its complex constant wanders.
  • Oscilloscope MusicRetro A phosphor XY scope draws a 4D tesseract, knots and text from the stereo sound you hear.
  • Chord OrbifoldMath Tymoczko's geometry of chords: a twisted prism and a Mobius strip you can hear.
  • Lyapunov FractalFractals Type a string of A and B and the logistic map grows gold and teal enamel jewelry.
  • Magnetic PendulumFractals A pendulum over three magnets, and the fractal map of where every release point ends up.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs