Appendix F · A Field Guide to the Generators

Where each algorithm comes from — and why it sounds the way it does.

Subsequence’s generators are borrowed from mathematics, physics, biology and computer science — ideas first dreamed up to model weather, simulate chemical reactions, draw straight lines on plotters, and grow textures for films. Pointed at rhythm and melody instead, each one carries a character you simply can’t get by placing notes by hand. The algorithms are the vocabulary; the rebuild engine is the grammar.

This is the story behind them — pure flavour, no code. The mechanics (how to call each one) live in Chapter 4 for rhythm and Chapter 12 for the full generative palette; come here when you want to know why a groove pulls or a line breathes.

Rhythm from number and geometry

Euclidean. Euclid set down his algorithm for the greatest common divisor around 300 BC. In 2003, Eric Bjorklund repurposed it to space the pulses of a spallation neutron source as evenly as possible; two years later Godfried Toussaint noticed the very same even-spacing patterns underlie traditional rhythms the world over — West African bell lines, the Cuban tresillo and clave, Turkish aksak. Ask for k hits across n steps and you land on the most evenly spread rhythm there is.

Bresenham. Jack Bresenham built his line-drawing algorithm at IBM in 1962 to step a pen-plotter along a slope using only integer arithmetic. Where the Euclidean rhythm chases maximum evenness, Bresenham distributes hits along a gradient — a subtly different, slightly leaning set of spacings.

Thue–Morse. Axel Thue described this sequence in 1906 studying patterns in words; Marston Morse rediscovered it in 1921 in geometry. The recipe is almost too simple — take the sequence so far, flip every bit, append it — yet the result never repeats, never stutters, and stays perfectly balanced. As a rhythm it feels endlessly varied but never random.

de Bruijn. Nicolaas de Bruijn formalised these sequences in 1946; a classic trick is cracking combination locks, because a de Bruijn sequence contains every possible code of a given length exactly once. As a generator it gives you a long line that visits every short pattern before anything comes round again.

Fibonacci. Fibonacci described his sequence in 1202 to count breeding rabbits, but the golden ratio it homes in on (φ ≈ 1.618) turns up everywhere in nature — the spiral of sunflower seeds, leaves around a stem, scales on a pinecone. The golden angle (≈ 137.5°) packs things with the least possible overlap; as rhythmic or melodic spacing it gives an organic, ever-shifting regularity.

Noise, chaos, and motion

Perlin noise. Ken Perlin invented gradient noise in 1982 to give the computer-generated world of Tron a natural look; the technique later won him an Academy Award. His insight: pure randomness looks artificial, but smoothly interpolated randomness looks alive — it drifts like wind, not dice. Ideal for a parameter that should wander rather than jump.

Pink noise. In 1975, Voss and Clarke found that the pitch and loudness of Bach, Scott Joplin and even radio broadcasts all follow a 1/f (“pink”) spectrum — change at every timescale at once, with the bigger moves happening more slowly. It sits between white noise (jittery and uncorrelated) and brown noise (a smooth random walk), and it matches the statistical fingerprint of how real music actually moves.

Logistic map. In 1976 the biologist Robert May popularised the map xr·x·(1 − x) as a model of populations booming and crashing season to season. It became the poster child of chaos theory: turn the single dial r up and the behaviour slides from steady, through a flurry of period-doublings, into full deterministic chaos around r ≈ 3.57 — predictable madness you can tune.

Lorenz attractor. The meteorologist Edward Lorenz stumbled on his strange attractor in 1963 while simulating weather convection. Its path never repeats, never settles, and two near-identical starts drift apart fast — the original “butterfly effect”. Map its three wandering coordinates onto musical parameters and you get motion that’s organic and bounded but never loops.

Growth and living systems

Cellular automaton. John von Neumann and Stanislaw Ulam dreamed up cellular automata in the 1940s as models of self-reproducing machines. In the 1980s Stephen Wolfram catalogued all 256 of the simplest one-dimensional rules — finding that Rule 110 is powerful enough to compute anything, and Rule 30 produces output indistinguishable from randomness. A single rule, applied to every cell at once, grows surprising patterns from a tiny seed.

L-system. Aristid Lindenmayer invented L-systems in 1968 to model how algae and plants branch and grow. A tiny rewriting rule applied over and over (“replace A with AB, B with A”) yields Fibonacci-length strings; richer rules grow ferns, trees and Koch curves. Unlike an ordinary grammar, every symbol is rewritten in parallel — which is exactly how living things grow.

Reaction–diffusion. Alan Turing proposed reaction–diffusion in 1952, in his last great paper, “The Chemical Basis of Morphogenesis.” Two substances spreading at different rates and reacting will spontaneously settle into spots, stripes and travelling waves — the maths now credited with leopard spots, zebra stripes and coral. As a generator it grows evolving textures rather than fixed patterns.

Self-avoiding walk. Paul Flory pioneered self-avoiding walks in the 1940s–50s to model how a polymer chain folds in solution: a path that can never cross itself. Simple to state and fiendish to count, it’s one of the most-studied objects in statistical physics — and as a melodic contour it explores freely without ever doubling back onto its own steps.

Groove and probability

Markov. Andrey Markov introduced his chains in 1906 by counting the runs of vowels and consonants in Pushkin’s Eugene Onegin, proving that even dependent random events obey the law of large numbers. The idea went on to underpin information theory, speech recognition and computer music — Hiller and Isaacson’s Illiac Suite (1957), one of the first scores composed by a computer, leaned on it. Feed it a style and it improvises in kind.

Ghost fill. Ghost notes are a drummer’s secret: barely-there hits tucked between the accents that give a groove its feel. Funk and hip-hop players — Bernard Purdie, Clyde Stubblefield, Questlove — turned them into an art, where what you almost don’t hear matters as much as the backbeat. The ghost-fill generator scatters those quiet in-between hits for you.

Thin. The mirror image of ghost fill — a subtractive partner to an additive process. Where ghost fill asks “what can I add?”, thin asks “what can I take away?”, pruning a busy part back to its essentials.

Ratchet. Borrowed from hardware sequencers: a single step fires as a quick burst of repeated hits instead of one note — the stutter-roll that snaps a line to attention.

Melody

Narmour’s Implication–Realization model. Eugene Narmour’s theory of melodic expectation describes how a leap implies a step back the other way, how small intervals tend to continue and large ones to reverse — the cognitive pull that makes a tune feel like it’s going somewhere. Subsequence’s melody engine uses it to shape lines that move the way listeners expect, and to break that expectation on purpose. See the “under the hood” treatment in Chapter 12.

Reference

melody(), MelodicState