A seven-planet resonant chain that chimes on every transit and weaves its own spirograph.
Seven Earth-mass planets circle a red dwarf in a chain of resonances like those of TRAPPIST-1 and TOI-1136: neighboring periods stand at 3:2, 3:2, 3:2, 3:2, 4:3 and 3:2, so their orbital frequencies form a stack of perfect fifths. It is a full N-body simulation, integrated with Yoshida's sixth-order symplectic composition, and the starting state was prepared by simulating migration in a gas disk until every pair was captured: each pair's resonant angle librates instead of circulating, as the dials show. Every planet chimes when it crosses the line of sight, at a pitch proportional to its current orbital frequency, so the chain plays a polyrhythm on a pentatonic chord, and the light curve below shows the transits as an astronomer would see them. Conjunctions leave glowing spokes and the line between each neighboring pair is woven into a slowly fading layer, a spirograph of the resonances. Kick a planet and its pitch goes sour and its dial starts to spin; turn the disk back on and migration plus eccentricity damping pull the ratios back into tune.
Try it. Click for sound (M mutes). Drag from a planet and release to kick it. Press T or the Retune button to bring back the gas disk, K kicks a random planet, R restarts the chain, up and down change the speed and Space pauses. Left alone, it plays, kicks one planet, then retunes the chain.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a musical planetary system whose planets chime as they pass in front of their star, with JavaScript, the HTML canvas element and the Web Audio API. 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. Paint it near-black, with a glowing red dwarf in the middle.
- Place five planets on circular orbits whose periods form a resonant chain: each period 1.5 times the one inside it (Kepler's third law gives the radius). Use G = 1, a star of mass 1 and planets of mass about 3e-5.
- Simulate full N-body gravity (every body pulls on every other) with velocity Verlet at a fixed small step, many steps per frame.
- Draw each planet as a colored dot with a faint orbit ring, and a dashed line from the star toward the bottom of the screen: the direction of Earth.
- Create the AudioContext only after the first click. Each time a planet crosses the line toward Earth, play a short sine tone with a quick decay, at a pitch proportional to its orbital frequency, so the outermost is lowest.
Once that works, make it beautiful:
- Every few frames, draw a faint line between each pair of neighboring planets onto a second canvas that fades slowly: the lines build up rosettes, a spirograph of each resonance.
- Draw a scrolling light curve along the bottom, dipping whenever a planet passes in front of the star.
- Let me drag a planet to kick it, and show each pair's period ratio so I can see and hear the chain detune.
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 a higher-order symplectic integrator, dials for each pair's resonant angle, or a gas disk that drags the planets back into resonance.