Appendix D · API Quick Reference¶
A fast lookup of Subsequence’s public API, grouped by what you’re trying to do — every entry links to the chapter that teaches it and points you at the exhaustive cheatsheet for full signatures. This is the page a returning user reaches for: not to learn a method, but to remember its name.
Note
This appendix is organised by task, not exhaustive on signatures. It names the
method and tells you which chapter teaches it; for every argument, default, and
return type, go to the source of truth — the sequencer’s own
api-cheatsheet.md (the v0.6.2 method catalog). Names here are cross-checked
against that cheatsheet; where a method’s full arguments matter, the chapter link
shows it in context.
D.1 The verb-family idea: learn one verb, predict the rest¶
Subsequence’s surface is large, but it is regular. The generators, the expression ramps, and the value transforms each form a family whose members share argument names and shapes. Learn one member properly and you can predict the rest — which is exactly what makes a quick-reference like this usable instead of overwhelming.
See also
The conventions behind that regularity — the front the chord verbs share, what
(low, high), seed=, and probability always mean, the velocity defaults, and
which methods chain — are written out in full in
Appendix G: Learn One Verb, Predict the Rest.
Three families do most of the work:
Family |
Shared shape |
Members (all on |
|---|---|---|
Rhythm generators |
|
|
Expression ramps |
|
|
Value transforms |
|
|
The pattern-generator chapter sets this idea out in full — see §4.5 (“learn one verb, predict the rest”) — and the motif chapter (Chapter 8) shows the transform family returning new values.
Important
seed= / rng= are the determinism pair, and they sit on almost every
generator. Pass seed= (an int) for a repeatable choice that survives a live
reload; pass rng= (a random.Random) to drive a generator from a shared stream.
Leave both off and the choice is fresh each run. The whole precedence story is
Chapter 11.
Warning
Three idioms were retired before v0.5 — do not use them. They appear in old forum posts and pre-v0.5 drafts and will mislead you:
chord=Trueon the decorator is gone. To receive the current chord, declare a parameter namedchordon your pattern function — Subsequence injects it by name (§6.2).quantizedoes not touch pitch.quantizeandswingare timing tools. To pull pitches into a scale usep.snap_to_scale(...)(§5.2).p.note(pitch)with no beat is invalid. The beat is required:p.note(pitch, beat=...)(§3.1).
D.2 Composition methods by topic¶
composition is the conductor — it owns tempo, output, the form, the harmony
engine, and every live control. The methods below are grouped by the job you’d
reach for them to do. For arguments and return types see api-cheatsheet.md.
D.2.1 Setup, transport, and rendering¶
Method |
What it does |
Taught in |
|---|---|---|
|
Create the piece — tempo, MIDI port, key, and the master |
|
|
The decorator that registers a function as a repeating pattern. |
|
|
Render to a MIDI file headlessly — no real time, no instrument. |
|
|
Stream MIDI live off the wall clock (Ctrl-C to stop). |
|
|
Change tempo instantly, or ramp smoothly over a number of bars. |
|
|
Turn on the live terminal dashboard (status line, optional ASCII grid). |
|
|
Inspect the live state, or the active patterns keyed by name. |
D.2.2 Rhythm, layering, and one-shots¶
Method |
What it does |
Taught in |
|---|---|---|
|
Combine several builder functions into one MIDI pattern (one channel). |
|
|
Fire a one-shot pattern now or on the next quantized boundary. |
reference only — see |
|
Run a plain function on a repeating beat-based cycle (sonification, automation). |
D.2.3 Harmony and chords¶
Method |
What it does |
Taught in |
|---|---|---|
|
Turn on the live chord engine — patterns can then receive |
|
|
Declare a self-contained chord part at a chosen harmonic rhythm. |
|
|
The chord sounding at the playhead; the active |
|
|
Force the chord at a bar — fiat over the live generator. |
reference only — see |
|
Ask the live engine to approach a cadence arriving at a bar. |
reference only — see |
|
Capture the live harmony into an editable |
D.2.4 Form, sections, and energy¶
Method |
What it does |
Taught in |
|---|---|---|
|
Define the structure — a list form or a graph form. |
|
|
Set per-section energy — the arranging dial — as one dict. |
|
|
Declare boundary material: an automatic fill or mute, in one line. |
|
|
Bind a |
|
|
Bind a |
|
|
Close every pass of a section with a cadence. |
reference only — see |
|
A part that plays whatever Motif/Phrase the current section binds. |
|
|
Live navigation: jump now, queue the next section, or freeze a graph walk. |
|
|
Run a callback on every section change. |
D.2.5 Motifs and phrases (placement helpers)¶
Method |
What it does |
Taught in |
|---|---|---|
|
Bind values to sections (see §D.2.4 above). |
|
|
The composition-level part that renders each section’s bound material. |
D.2.6 Live performance and control¶
Method |
What it does |
Taught in |
|---|---|---|
|
Hot-swap code: reload on save, run an eval server, or apply a source string. |
|
|
Override / read / clear a running pattern’s parameters live. |
|
|
Mute, unmute, or fully remove a running pattern. |
|
|
Bind a single key to an action; enable the global key listener. |
|
|
Pin a stream’s realization; release it; deal it a fresh seed. |
|
|
Run a callback on a sequencer event ( |
reference only — see |
D.2.7 External input, output, and sync (I/O)¶
Method |
What it does |
Taught in |
|---|---|---|
|
Configure a MIDI input for sync/messages; track held keys for arpeggiation. |
|
|
Register an extra output device; send MIDI clock to hardware. |
|
|
Add or remove mirror destinations on a running pattern (one part, many devices). |
|
|
Forward an incoming CC to output, or map it into |
|
|
Enable bi-directional OSC; register a custom OSC handler. |
|
|
Enable the realtime Web UI dashboard (beta). |
|
|
Enable Ableton Link tempo/phase sync. |
|
|
Set a global microtonal tuning for the whole composition. |
D.2.8 Determinism and inspection¶
Method |
What it does |
Taught in |
|---|---|---|
|
The master seed; the effective derived seed for a named stream. |
|
|
Pin / release / re-deal a stream’s randomness (also under live control). |
|
|
The underlying |
D.3 Pattern-builder (p.*) methods by topic¶
Inside a pattern function the one argument p is the builder — the palette you
paint onto. Almost every method returns p, so calls chain. Grouped by task:
D.3.1 Notes, beats, and durations¶
Method |
What it does |
Taught in |
|---|---|---|
|
Place one note at a beat. |
|
|
Place short hits at a list of beat positions. |
|
|
Place short hits at grid step positions (0-indexed). |
|
|
Multi-parameter step sequencer — parallel lists for pitch/vel/dur. |
|
|
Repeat one note at a fixed beat interval across the pattern. |
|
|
Set a fixed length; fill to the next onset; guarantee a gap before it. |
|
|
Sustained notes that span cycles, and the All-Notes-Off panic. |
|
|
The legacy mini-notation string parser (a single aside, not an entry point). |
D.3.2 Rhythm generators and timing feel¶
Method |
What it does |
Taught in |
|---|---|---|
|
Spread |
|
|
Line-algorithm spread; weighted polyphonic spread across drum voices. |
|
|
Subdivide existing notes into rapid rolls / ratchets. |
|
|
Probability-biased ghost notes; the bias weights behind them. |
|
|
Apply swing feel — a timing tool (not pitch). |
|
|
Apply a |
|
|
Add small random timing/velocity variation — humanise. |
|
|
Shift / flip / scale the bar in time; change the pattern’s length. |
|
|
Remove notes by rhythmic position, or at random. |
D.3.3 Melody, pitch, and scales¶
Method |
What it does |
Taught in |
|---|---|---|
|
Pull every note to the nearest scale pitch — the pitch-correction tool. |
|
|
Shift all pitches; mirror them around a pivot. |
|
|
Generate a single line by querying a persistent |
|
|
Walked / rewritten / mutating / fractal-tree melodies. |
|
|
Chaos, automata, and reaction-diffusion as note sources. |
|
|
Number-theoretic and combinatorial pitch/rhythm generators. |
D.3.4 Harmony, chords, and arpeggios¶
Method |
What it does |
Taught in |
|---|---|---|
|
Place a chord at |
|
|
Cycle a chord’s notes one at a time at regular beat intervals. |
|
|
Arpeggiate in a chosen/random order; strum with a small per-note offset. |
|
|
Lay a |
Tip
To receive the current chord, don’t call a method — declare a parameter named
chord (and optionally key, scale) on the pattern function, and Subsequence
injects it each cycle (§6.2). The p.chord* methods are for
placing a chord you already hold.
D.3.5 Placing motifs and phrases¶
Method |
What it does |
Taught in |
|---|---|---|
|
Place an immutable |
|
|
Place this cycle’s window of a |
|
|
Read the notes placed so far back out as a new |
|
|
The Motif/Phrase bound to the current section (and part), or |
D.3.6 Velocity and expression¶
Method |
What it does |
Taught in |
|---|---|---|
|
Spread the velocity of everything placed evenly across a range. |
|
|
Multiply velocities per step; build a ramp list to hand to it. |
|
|
Build a per-step velocity-multiplier list for sidechain-style ducking. |
reference only — see |
|
One CC write at a beat; a CC swept over a beat range. |
|
|
Single bend, a swept bend, or bend one note by index. |
|
|
Glide between consecutive notes; TB-303-style selective slide. |
|
|
NRPN/RPN writes and sweeps; program/bank change; raw SysEx. |
|
|
Emit an OSC message, or sweep an OSC float over a beat range. |
|
|
Apply a microtonal tuning to this one pattern via pitch-bend injection. |
D.4 Values and factories (Motif / Phrase / Progression / Section / Form)¶
These are immutable values: every transform returns a new value, so you can
build a library by hand and reshape it without surprises. The factories below are
pure — they need no Composition, which makes them easy to try in isolation:
>>> from subsequence import Motif, Form, progression, motif, sentence
>>> m = motif([1, 3, 5, 1], beats=[0, 1, 2, 3]) # a 4-beat idea, key-relative degrees
>>> ph = sentence(m, bars=4, seed=1) # grow it into a 4-bar phrase
>>> pr = progression([1, 6, 4, 5], key="C") # I vi IV V as scale degrees
>>> fm = Form([("intro", 4), ("verse", 8)]).with_energy({"verse": 0.7})
>>> m.length, ph.length, pr.length, fm.bars
(4.0, 16.0, 16.0, 12)
D.4.1 Building values (factories)¶
Factory |
What it builds |
Taught in |
|---|---|---|
|
A |
|
|
Drum-hit, euclidean, named world-rhythm, and generated motifs. |
|
|
The classical sentence and period, as thin phrase combinators. |
|
|
Grow a motif into a phrase by a development plan. |
|
|
Build a |
|
|
Generate a progression from a chord-graph walk. |
|
|
The form value and its sections. |
|
|
Parse |
D.4.2 Transforming Motif / Phrase (return a new value)¶
The same verb means the same thing on both types — this is the value-transform family from §D.1.
Method (on a |
What it does |
Taught in |
|---|---|---|
|
Shift pitch (degrees or semitones), mirror around a pivot, flip in time. |
|
|
Rotate onsets, scale time, snap onsets to a grid. ( |
|
|
Reset velocities, repitch every note, or strip to a rhythmic skeleton. |
|
|
Sequential concat; parallel merge; repeat; the |
|
|
Smallest variation; call→response tail; add accent velocity. |
|
|
A window onto the value; collapse a phrase to one long motif. |
|
|
Swap one segment; regenerate only named bars, keeping the rest. |
|
|
Attach control gestures as data — mirrors the |
D.4.3 Shaping a Progression¶
Method (on a |
What it does |
Taught in |
|---|---|---|
|
Resolve relative spans to a key; print it; inspect the realised timeline. |
|
|
Voicing spread (close/open/wide); inversions; slash/pedal bass. |
|
|
Add 7/9/11/13/sus; borrow from the parallel scale; approach-by-fifths. |
|
|
Swap a chord; reshape harmonic rhythm; substitute a named cadence. |
D.4.4 Shaping a Form¶
Method (on a |
What it does |
Taught in |
|---|---|---|
|
Set the energy payload on named sections. |
|
|
Insert a section; replace one whole or by field. |
|
|
One-section-per-line summary; total length in bars. |
D.4.5 Supporting values¶
Type / factory |
What it is |
Taught in |
|---|---|---|
|
A timing/velocity template; from swing %, or an Ableton |
|
|
Microtonal tunings, including Scala |
|
|
Persistent melodic context that scores a single line (for |
|
|
The harmony atoms: a named chord, one span of harmonic time, a nameless sonority. |
|
|
MIDI notes of a scale in a range; register a custom scale. |
|
|
14-bit bank → (MSB, LSB); a custom chord quality; a varying harmonic rhythm. |
D.5 Where to go deeper¶
This page is the map; the places below hold the territory.
For… |
Go to |
|---|---|
Exhaustive signatures — every argument, default, and return type |
The sequencer’s |
The Direct Pattern API — |
Appendix A — the power-user path below the
|
The analysis & set-theory toolkit — Toussaint metrics, Xenakis sieves,
contour ( |
Appendix B. The Toussaint metrics and contour
helpers live in |
MIDI routing and troubleshooting — port names per OS, virtual ports,
|
|
A term you don’t recognise — musical or Subsequence-specific |
Tip
Two reading habits make the rest of the library predictable. First, the verb
families (§D.1): when you meet a new generator, expect
seed=/rng=; when you meet a new ramp, expect start/end/beat_start/
beat_end. Second, values are immutable: a Motif/Phrase/Progression
transform always returns a new value, so you can chain freely and never lose the
original.