# Subsequence **A generative MIDI sequencer for Python — your composition, expanded by algorithms you direct, playing your synths, drum machines and DAW.** You bring the ideas; Subsequence gives you the tools to shape them. Place notes by hand, or hand parts to generators you steer — Euclidean rhythms, evolving harmony, motifs and form — deciding how far each takes your music and tuning exactly how it behaves. Reach for them where you want movement, and keep a tight hand everywhere else. It makes no sound of its own: it speaks pure MIDI, so your own instruments give it voice. ## Where to start ::::{grid} 1 1 3 3 :gutter: 3 :class-container: sd-mt-4 :::{grid-item-card} 📖 Cookbook :link: cookbook/index :link-type: doc :class-card: start-card **New here? Start with this.** A gentle, step-by-step guide from your first drum loop to live generative performance. +++ Learn step by step → ::: :::{grid-item-card} ⚙️ API Reference :link: api/subsequence/index :link-type: doc :class-card: start-card Already building? Look up any class, method or function — pinned to the same version as the cookbook. +++ Look something up → ::: :::{grid-item-card} 💻 Source on GitHub :link: https://github.com/simonholliday/subsequence :class-card: start-card Want the code? The full source, examples and issue tracker. +++ Open the repo → ::: :::: ## What's inside ::::{grid} 1 2 3 3 :gutter: 3 :class-container: sd-mt-3 :::{grid-item-card} 🔁 Music that evolves Every part stays aware of its surroundings — the current chord, the section, the other parts — and keeps developing as the piece plays, so your music grows rather than repeats. ::: :::{grid-item-card} 🎲 Generative building blocks Euclidean rhythms from geometry, cellular automata and L-systems from nature, Perlin noise from animation, Markov chains and chaotic maps from probability — combine and layer them freely. ::: :::{grid-item-card} 🎹 A harmony engine Chord progressions, weighted chord graphs, and voice-leading that models how listeners expect music to move. ::: :::{grid-item-card} 🏗️ Real composition Motifs, phrases, sections and form — shape a whole piece at the macro level, not just one bar at a time. ::: :::{grid-item-card} 🎚️ Control or chaos Place every note by hand, hand the whole thing to the algorithms, or blend the two and dial it to taste. ::: :::{grid-item-card} 🎛️ Live & connected Live coding, deterministic seeds, Ableton Link, OSC, MIDI in/out and external clock, a web dashboard (beta), and MIDI recording. ::: :::: ## A taste A whole evolving groove in a handful of lines — drums and a bassline that keep shifting as they play: ```{testcode} home import subsequence import subsequence.constants.instruments.gm_drums as gm_drums comp = subsequence.Composition(bpm=120, key="A", scale="minor", seed=1) @comp.pattern(channel=10, beats=4, drum_note_map=gm_drums.GM_DRUM_MAP) def drums(p): p.euclidean("kick_1", pulses=4) # four on the floor p.euclidean("hi_hat_closed", pulses=11, velocity=(60, 90)) # 11 hits over 16 steps — a rolling groove p.euclidean("snare_1", pulses=16, probability=0.15) # sparse, ever-shifting ghost snares @comp.pattern(channel=1, beats=4) def bass(p): p.euclidean(45, pulses=5, duration=0.4) # a five-pulse bassline, in key comp.render(bars=8, filename="demo.mid") # writes a MIDI file — or call comp.play() to drive your gear live ``` Every bar is rebuilt from scratch with the current musical context, so those parts keep drifting and developing as the piece runs — and because it's seeded, the same performance plays back perfectly every time. ## Runs on what you've already got Subsequence is free and open-source under AGPL-3.0. With no audio engine to power, it's light to run — an old laptop or a Raspberry Pi is plenty — so you don't need expensive hardware to make serious generative music. Composition, after all, is about *ideas* — rhythm, harmony and shape — more than equipment. ```{toctree} :hidden: Cookbook (tutorial) API Reference ```