Skip to content

Patterns, Tracks & Effects

On this page you build a beat while it plays: you change its patterns, add a bass track, and put a filter and a delay on the drums. The music never stops until you stop it.

Work in the hello project from Your First Sound. Write each step into src/main.non, select it, and press Cmd+Enter. Every step adds to what the previous one built.

Open hello/src/main.non. Evaluate RESET; on its own, then remove that line. The session should be silent before you run the setup below; this also clears earlier effects. Each later block adds to the setup.

use "std/instruments" { Sampler, Kit };
let drums = AudioTrack("drums");
drums.set_instrument(Sampler(Kit("CR-78")));
drums << [bd sd bd sd];
PLAY;

Run this line early in the bar, and then run it late in the bar:

drums << [bd _ sd _, hh hh hh hh];

The change never happens in the middle of the bar. The current cycle finishes, and the new pattern starts on the next downbeat.

A second track plays next to the first one, in time with it:

let bass = AudioTrack("bass");
bass.set_instrument(Sampler(Kit("TR-808")));
bass << [bd _ _ bd, _ _ bd _];

It starts on the next cycle. Each track has its own instrument and its own pattern.

An effect processes the sound of a track, like an insert on a mixer channel. Put a lowpass filter on the drums:

use "std/effects" { Lowpass, Delay };
drums.set_effects(#[Lowpass("lowpass", 1200)]);

The drums sound darker. Now run the same line with a delay after the filter:

drums.set_effects(#[Lowpass("lowpass", 1200), Delay("delay", 0.25, 0.4)]);

The drums echo. .set_effects() takes the whole chain, in order. The filter was not built again: it is the same filter, with the same settings, and it did not stop for a moment. You can add, remove and reorder effects this way while the music plays.

Try the keys while src/main.non is open:

  • F5 pauses. Press it again, and the music plays on from the same place.
  • Shift+F5 stops and goes back to the start. The echoes of the delay ring out.
  • Press Shift+F5 three times, and everything that still sounds is cut.

The tracks are still there after a stop. Press F5, and the beat comes back from the start.

  • Your First Project — the next tutorial: save the beat as a piece and run it from the terminal
  • Transport — exactly what PLAY, PAUSE, STOP and RESET do
  • Pattern Basics — after Getting Started, explore step lengths, pitches and variations