Skip to content

Hello, Sound

Let’s make some sound right away. Once you’ve heard it, we’ll explain how the live-coding workflow actually works.

Resonon has a built-in sample engine. We’ll use it to play a simple drum rhythm. In Visual Studio Code, write the code below into a new .non file, select (highlight) it, and press Cmd+Enter. You should hear a beat. We’ll go over the example line by line afterwards.

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

You don’t have to understand every new concept just now. Tracks, instruments, and patterns are all deeper topics you can explore as you progress — the following guides cover them in detail. For now, here’s what each line does.

use "std/instruments" { Sampler, Kit };

Imports Sampler and Kit from the Resonon standard library, so we can use them in our program.

let drums = AudioTrack("drums");

Creates a new audio track called “drums”. Think of a track like a channel in a regular DAW. It has volume and pan controls, you can load an instrument and a chain of effects onto it, and its output is routed to the master output by default. AudioTrack does not require an import.

let sampler = Sampler(Kit("CR-78"));

Creates a new Sampler instrument from the CR-78 drum sample Kit. The Sampler is a Resonon built-in instrument for non-melodic sample playback, like drums. A Kit is a set of sample .wav files plus some metadata (note mappings, velocity layers, and so on).

Later we’ll meet the SamplerMelodic for melodic sampling, learn to load any VST3 or CLAP plugin instrument, and even write our own instruments entirely in Resonon code.

drums.load_instrument(sampler);

Loads the sampler onto the track. A track can have exactly one instrument loaded. Once it does, any notes sent to the track are forwarded to that instrument for playback. You can also load effects onto a track to process its sound — but let’s keep things simple here.

drums << [bd sd bd sd];

Sends a pattern to the drums track for playback. bd (bass drum) and sd (snare drum) are sample names from the CR-78 kit. Patterns are the heart of musical sequencing in Resonon, and the next guide dives deep into them. For now, just know that a pattern repeats and has a fixed length called the cycle-time. That length is divided evenly among the events in the pattern. By default the cycle-time is 120 BPM at 4 beats per cycle — 2 seconds — so the 4 events above each get one beat, 0.5 seconds.

Think of a cycle as one bar of music. Put 4 notes in a pattern and they play as quarter-notes; put 8 and they play as eighth-notes, and so on.


If you’ve ever worked with the legendary Alex McLean’s TidalCycles or its newer cousin strudel.cc, you’ll see many parallels in how Resonon patterns work. We’re standing on the shoulders of giants here.


PLAY;

Starts playback, so you hear the sequenced sounds.

For a full list of available kits, their samples, and metadata, see the “kits” folder in the Resonon source repository.

So what just happened when you pressed Cmd+Enter? The common way to run Resonon code and hear changes live is the select-and-execute workflow in Visual Studio Code: you write Resonon code in a .non file, select (highlight) it, and press Cmd+Enter to execute it.

The first time you do this, the extension automatically starts a new Resonon runtime with an active server, then sends the highlighted code to the server to run. Every subsequent execution reuses that same runtime, so Resonon remembers what was executed before.

Alternatively, you can use the Resonon extension menu in the sidebar to start a server-runtime and connect to it before running any code.

Code doesn’t have to make sound, of course. Write the line below into your .non file, select it, and press Cmd+Enter. The output appears in VSCode’s “OUTPUT” panel (select “RESONON” from the dropdown).

PRINT "Hello, RESONON!";

Hello, Resonon!

Each evaluation shares the same session, so any state is “remembered” by the runtime and available to code you evaluate afterwards. That’s exactly why the drums track from earlier is still around — we can keep sending it new patterns without redefining it.

To see this directly, select and execute the two lines below one at a time. The first defines a greeting string; the second prints it.

let greeting = "Hello";
PRINT greeting;

This is the basis of the live-coding workflow: execute bits of Resonon code to continuously shape and modify your live session. You start with a blank canvas and progressively build it up — set up tracks, load instruments and effects, and send sequences of notes to play.

Now try a slightly more interesting beat. What do you hear?

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

Using commas creates a layered pattern — all layers play simultaneously. The kick-snare rhythm plays alongside steady hi-hats. You’ll explore patterns in much more detail in the following guides.

Use _ (underscore) for silence:

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

A rest takes up the same time as a note — it creates space in the pattern.

Basic transport controls are available from Resonon code or the VSCode integration.

ActionCodeKeybinding (VSCode Extension)
PlayPLAY;F5
PausePAUSE;F5 (toggle)
StopSTOP;Shift+F5
ResetRESET;Ctrl+Shift+F5

STOP; halts playback, returns to the start, and mutes the output. RESET; is heavier — it clears the entire session (all variables, tracks, instruments, and effects), giving you a blank runtime.

Next, learn how melodies and more complex patterns are built, as well as how tracks and effects are used.