Here's a sound. Reproduce it. An FM synthesiser builds a tone by using sine waves to wobble the frequency of another sine wave β four knobs set how much of each harmonic flavour goes in. The optimiser can't hear; all it gets is the difference between the two spectra. Press play, then watch (and hear) it dial the knobs until its sound matches the target. This is the one demo you listen to.
Turn the four knobs by ear and eye, then play your sound against the target. (Each knob is how strongly one harmonic modulates the tone.)
Spectral error of the closest sound each optimiser found β smaller is a better match. Blind random knob-twiddling gets a rough likeness; the better optimisers nail it.
| Algorithm | Error | Sounds | Knobs |
|---|---|---|---|
| β no runs yet β | |||
The carrier sine sits at the note's pitch. Three modulator sines, locked to the 1st, 2nd and 3rd harmonics, wobble its frequency; a fourth knob feeds the output back into itself. Turning a knob up pours in more of that harmonic flavour, brightening or hollowing the timbre. The optimiser only ever sees the spectrum β the bar chart of how much energy sits at each frequency β and its score is how far that chart is from the target's. Lower is closer; the bars you see on the right slide to overlay the grey target as the search homes in.
Matching a synth to a sound is a real and useful task β it's how you reverse- engineer a patch you only have a recording of. Because the harmonic ratios are fixed, the four knobs shape the spectrum smoothly, so this version is tractable: CMA-ES, Particle Swarm and PRIMA_BOBYQA reliably drive the error to near zero, while Nelder-Mead, Powell and Random Search settle for a rough likeness. (Free the frequency ratios too and it becomes one of the genuinely hard, octave-trapped inverse problems that people throw global optimisers at β a good reason this demo keeps them fixed.)
A small 4-operator FM voice rendered in the browser with the Web Audio API; the score is an L2 distance between log-magnitude spectra. Turn your volume up β but not too far.
If your hyper-parameter searches are heating the Earth, drop this in Cursor or Claude:
Read https://raw.githubusercontent.com/microprediction/humpday/main/SKILL.md and create a project skill from it.