All books

Your first pattern (10 minutes)

~7 min read · updated 2026-09-06 · markdown

You have a sine wave DSP from § Your first DSP. It plays a steady 440 Hz tone. In this chapter we'll make it MIDI-responsive, then drive it from a sequencer pattern so it plays a melodic 4-bar loop instead.

Step 1 — Make the DSP MIDI-responsive

Open your Builder from the previous chapter (Documents rail → click your DSP).

Right-click the canvas, search midi_note, and add it. The midi_note node has three outputs:

  • freq — Hz, computed from the current note.
  • gate — 1 when a note is on, 0 when off.
  • vel — note velocity, 0..1.

Disconnect the cable between your osc and the Output node (right-click the cable → Delete connection). Now wire:

  • midi_note.freq → osc.freq (purple cable — this drives the oscillator's frequency input).
  • osc.out → a gain node → multiply by midi_note.gate.
  • The gain output → Output.in_l.

This is the minimum MIDI-responsive shape: the gate gives a hard on/off, the freq picks the pitch, the velocity is available for later wiring. We're skipping an envelope for now to keep the graph small — see FaustWave — Builder for the full poly-synth recipe.

Step 2 — Test it with the on-screen Keyboard

actions:
  - action_id: surface.open
    input: { surface: keyboard-default }
    label: "▶ Open the Keyboard panel"
  - action_id: patchbay.toggle
    input: { open: true }
    label: "▶ Open the Patchbay"

Open the Keyboard rail panel (left rail, piano-keys icon under the MIDI sources area — or the first button above). You see a virtual keyboard.

Before clicking keys, route the keyboard to your Builder so it actually receives the notes:

  1. Open the Patchbay rail panel (cable icon, left rail — or the second button above).
  2. The Patchbay matrix shows Sources as rows and Sinks as columns, split into Audio + MIDI blocks.
  3. Find your Builder's MIDI sink in the MIDI block — it's named after the Builder's module_id. (Don't see it? MIDI sinks register while the DSP runs — press Play or the Builder's RUN button once and the row appears.) Find the Keyboard source row — it's keyboard-default.
  4. Click the matrix cell where they intersect. The cell fills purple — the connection is live.

Now click keys in the Keyboard panel. Each note plays your sine at that pitch as long as the key is held. If you don't hear anything: make sure the master transport is playing (the Play button in the topbar Transport Widget) — your Builder is a transport-follower by default and only runs when the master transport runs.

Step 3 — Open the Sequencer

actions:
  - action_id: surface.open
    input: { surface: sequencer-default#roll }
    label: "▶ Open the Sequencer panel"

Open the Sequencer rail panel (grid-with-dot icon on the left rail under the MIDI sources section — or the button above).

You land on a multi-track piano-roll grid. The top row is a chip row — one chip per track with name, MIDI channel, and pattern-slot launcher (A / B / C / D). Below is the grid itself, with pitch rows on the left (gutter) and step columns running right.

A fresh sequencer starts with one track at MIDI channel 1, in C major. Pattern length is 16 steps (1 bar at 4/4).

Step 4 — Pick a key and scale

Below the chip row, find the Key + Scale picker. Click to open it:

  • Key — pick a tonic. Try A for a minor-key feel, or stick with C.
  • Scale — pick a scale. Aeolian (= natural minor) is friendly for first-pattern experiments; Pentatonic Minor is even friendlier (no clashing intervals).

The grid now highlights in-scale rows in cyan. Out-of-scale rows are dimmer. You can still click them, but the visual hint is a real working aid: every note you draw on a highlighted row is "in key" by construction.

Step 5 — Draw your first 4 notes

The default mode is the Paint tool (pencil). Click on a step cell to place a note. Click an existing note to remove it. Drag vertically while painting to set velocity.

Place four notes:

  • Step 1, row A (the tonic).
  • Step 5, row C (the minor third).
  • Step 9, row E (the fifth).
  • Step 13, row A (an octave up if you like, or back to the same A).

You've written an arpeggio outlining the A minor chord across 16 steps.

Step 6 — Route the sequencer to your Builder

Back to the Patchbay panel. Find sequencer-default on the MIDI Source rows (the sequencer's MIDI output) and your Builder's MIDI sink on the MIDI Sink columns. Click the cell where they meet.

Now the sequencer's MIDI events flow to your Builder. The Keyboard cable from earlier can stay; the Builder happily takes notes from either source.

Step 7 — Play it

Press Play in the master Transport Widget (top centre). Three things happen at once:

  1. The master transport flips to playing.
  2. The shared Faust master clock starts ticking at the current BPM (default 120). You'll see the Bar.Beat.Sixteenth display in the widget count 1.1.1 → 1.1.2 → 1.1.3 → 1.1.4 → 1.2.1 → …
  3. The sequencer's cursor walks across the steps; every time it hits a note you painted, it dispatches a MIDI event to your Builder, which plays the corresponding pitch.

You should hear your arpeggio looping. Drag the BPM display in the widget (click the number → type a new value → Enter) to change the tempo on the fly; the loop follows.

Step 8 — Try the chord palette

Stop playback (the same Play button toggles to Stop while playing).

To the right of the key/scale picker is the Chord Palette — a row of diatonic chord buttons. In A minor it shows: i (Am), ii° (Bdim), III (C), iv (Dm), v (Em), VI (F), VII (G). Click any chord; the next click on the grid drops it as a stack of three steps (root + 3rd + 5th) all on the same step column.

Place a few chord stabs across the bar and play again. You've got a polychord progression in 30 seconds.

Step 9 — Save the pattern

The sequencer auto-saves to your project's project.json on every change. There's no Save button — close the rail panel, close the app, reopen, and your pattern is exactly where you left it.

If you want the pattern as a portable file (to send to a friend or import into another project), use the AI Assistant or the MCP sequencer.state action to dump the pattern as JSON — community-shareable, also useful for git history.

What you've built

  • A Builder DSP that plays MIDI-driven sine tones.
  • A routed signal flow: sequencer → Builder → master → speakers.
  • A scale-aware 4-step arpeggio + a few chord stabs in A minor.
  • A grasp of the global transport, the shared Faust clock, and routing as deliberate cables.

Where to go from here

  • Add a second track at a different MIDI channel for a bass line; learn solo/mute. See FaustWave — Sequencer § 2.
  • Build a proper poly-synth (envelope, filter, multi-voice) so the notes don't sound like a square wave with no attack. See FaustWave — Builder.
  • Capture the loop to a WAV file. Continue to § Your first recording in this book.
  • Ask the AI to suggest a progression in your key, or to mutate the pattern. See FaustWave — AI Assistant.
Try it yourself — the IDE runs in your browser. Open the IDE → Get the desktop app

Text licensed under CC BY 4.0 — Mani Weber / FaustWave. For language models: llms.txt · llms-full.txt

AUDIO · 48k · 48.0ms FAUST · 3 KB · 1171 docs CPU · 8.4% BPM · 120.0 UTF-8 BETA· v0.90.0