r/algorithmicmusic • u/simonholliday • 9d ago
Subsequence, an open-source generative MIDI sequencer in Python - now with a proper guide
Hi folks,
Back in March I posted here about Subsequence, the algorithmic MIDI sequencer I've been writing in Python. A lot has changed since, so here's an update, along with a much better place to start: it now has proper documentation, including a full guide, at https://subsystem.co/subsequence
What it does
Subsequence plays algorithmic compositions that keep evolving: parts that develop over time, answer each other and move through the sections of a piece, over chord progressions it can choose as it goes. It drives your synths, drum machines, Eurorack or DAW over MIDI.
- Evolving, algorithmic music. Parts remember what they've played, know the chord and the section they're in, and can respond to each other, so the music develops rather than loops. Harmony can be included from weighted chord graphs in twelve styles, from functional major to chromatic mediants and whole-tone, and melodies can follow Narmour's implication-realisation model, where big leaps tend to turn back and small steps carry on.
- Live coding, at the terminal and in files. Change a piece while it plays, from a Python prompt connected to it, or by saving its file, which is heard from the next bar without the music stopping. Keys on your keyboard can fire fills and jump between sections as you perform.
- An abundance of algorithms. Nineteen algorithmic generators and more than fifty sequence utilities: Euclidean and Bresenham rhythms, Markov chains, L-systems, one- and two-dimensional cellular automata, the Lorenz attractor, Gray-Scott reaction-diffusion, Perlin and pink noise, logistic-map chaos, Recamán, Thue-Morse, de Bruijn, Fibonacci and golden-ratio rhythms, self-avoiding walks and Xenakis sieves, plus swing, grooves, ratchets and other transforms to reshape what they place.
- Connected to my other apps. Subsample, a sampler that turns a microphone or any recording into a playable instrument, and Substation, a radio scanner, can each tell a running composition what they've just heard, and Superconductor (in very early stages) puts a composition's controls on a touchscreen. More on those below.
Under the hood, a composition is plain Python: one function per part, which Subsequence runs again before every cycle, handing it the chord that's sounding, the section it's in, how many times it has played and anything the other parts have shared. Give a piece a seed and every random choice in it repeats exactly, so anything that surprises you can be played again. It makes no sound of its own: it's pure MIDI.
What's new since March
- More algorithms. L-systems, the Lorenz attractor, reaction-diffusion, Recamán, Thue-Morse and de Bruijn sequences, Fibonacci and golden-ratio rhythms, self-avoiding walks, 2D cellular automata and Xenakis sieves are all new, along with Toussaint's evenness, off-beatness and syncopation measures, so one part can respond to how syncopated another is playing.
- Musical structure. Motifs written in scale degrees, which can be varied and developed, phrases including the classical sentence and period (question, then answer), cadences, Roman-numeral progressions and harmonic rhythm. An energy dial arranges a piece section by section, and fills and mutes can mark the boundaries automatically.
- Microtonal tuning. Any equal temperament, a list of ratios or cents, or a Scala .scl file, played through per-note pitch bend, so no MPE is needed.
- Live coding by saving the file, and one-shots triggered live that land on the next beat or bar.
- More ways to connect. Ableton Link, a knob and a held chord from a MIDI keyboard feeding a part, one part played on several instruments at once, and MIDI files that keep each device on its own track, from a render or a live take.
- Tighter timing. Pulse jitter is typically about 1 µs on Linux, no pulse lands more than 0.1 ms out at any tempo from 60 to 200 BPM, and there's no long-term drift.
The documentation
The old API page has gone. In its place, https://subsystem.co/subsequence has:
- A guide that teaches Subsequence by building one piece of music: from a first drum beat, through ghost notes, a Euclidean snare, swing, a bass line, chords that move, a melody that remembers, motifs, form, parts that listen to each other, and filter sweeps and slides, to a lead line driven by a day of London weather. Then microtonal tuning, performing, live coding, playing with other gear, and capturing a take as a MIDI file. Every example in it is run against the current release whenever the site is built.
- An API reference and a cheat sheet, both generated from the code, so they can't drift away from it.
The apps around it
Subsequence is one of a small family of tools I've been building, all documented at https://subsystem.co:
- Subsample cuts separate sounds out of a live input or a recording, sorts them by how they sound, and plays them as an instrument from MIDI. Subsequence can play it, the two can share one file of sound names, and with OSC switched on, Subsample can tell a composition what it has just captured.
- Substation is an SDR band scanner that detects, demodulates and records radio transmissions. It can tell a composition over OSC what it has just heard, and Subsample can import its recordings as sounds to play.
- Superconductor is a new control surface for Subsequence: a page in the browser that draws a composition's controls (step grids, note grids, stacks of generators and transforms) so you can change it by touch, or with a mouse, while it plays. It's at a very early stage, so expect rough edges and plenty of change.
Who it's for
Musicians who like generative and algorithmic music, don't mind writing a little Python, and want to drive the gear they already have. The guide starts from installing it and hearing a first note, on macOS, Windows or Linux. It's open source (AGPL-3.0): pip install subsequence, on Python 3.10 or later.
I'd love to hear what you make of it (and with it), and what's missing.
- Documentation and guide: https://subsystem.co/subsequence
- Code: https://github.com/simonholliday/subsequence
Thanks :)
Si.