Subsystem

Introduction

This guide teaches Subsequence by building one piece of music with it, from a first drum beat to a lead line that follows the weather.

Already have Python and Subsequence installed, and an instrument connected? Go straight to A first beat.

What Subsequence is for

Subsequence is a MIDI sequencer you write in Python. Each part of a piece is a pattern: a short function that places notes. Subsequence runs that function again before every cycle of the pattern, and hands it what is happening at that moment, such as the current chord, the section of the piece and how many cycles have gone by. So a pattern can play something different every time round, react to the rest of the piece, and still be exactly as repeatable as you want it to be.

It makes MIDI, and nothing else. The sound comes from your own instruments: hardware synths and drum machines, or software instruments in a DAW.

Who it is for

This guide is written for a musician or producer who knows MIDI, and is willing to learn a little Python without having written any before. Beats, bars, scales, chords, velocity and CC are taken as known. The Python is not: each chapter teaches what it needs, where it first needs it.

If you already write Python fluently, Subsequence also has a Direct Pattern API, which this guide does not teach. Going further, at the end of the last chapter, says what it is for.

The piece

The guide builds one piece, a part at a time, and every chapter adds to what the one before it left:

Each kind of thing Subsequence does is shown at least once, and each chapter links to the API reference for the rest of that kind.

How to read it

A chapter is one script that grows as the chapter goes: each block of code continues the one before it, and copying them in order gives you what the chapter built. Once the piece has begun, each chapter opens with the piece so far, folded away, so you can start there without reading what came before.

How the examples are checked

Every example in this guide is run against the version of Subsequence it describes, each time the site is built. What an example makes is written down, MIDI channel by MIDI channel, and compared with what it made when the chapter was written, so an example that stops doing what the page says stops the site from being published.

Under an example, a few lines of that record show what it made: each note's bar and beat, its name and number, its velocity and its length. Your own run makes the same, because every example that draws anything at random is given a seed, and a seed makes the same choices every time.

A few things cannot be run while the site is built: a command typed in a terminal, the name of your MIDI device, and playing live. A block of code like that says so above it.