Hello, Sound
Let’s make our first sounds. This page quickly covers the live-evaluation model and walks you through your first drum beat and melody.
How Live-Evaluation Works
Section titled “How Live-Evaluation Works”The common way to run Resonon code and hear changes live is using 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 will automatically start a new Resonon runtime with active server. Then it will send the highlighted code to the server to run. Subsequent code execution then uses that same runtime, so Resonon “remembers” what was exected before.
Alternatively you can use the Resonon extension menu in the sidebar to start a server-runtime and connect to it, before running any Resonon code.
As a first test write the line below into a new .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!
Session State
Section titled “Session State”Each evaluation shares the same session, so any state is “remembered” by the runtime and accessible in the code that gets evaluated after. To see this, select and execute the two following lines one by one. The first line defines a new greeting string and assigns the message.
The second line the prints the previously defined greeting to the console.
let greeting = "Hello";PRINT greeting;You can highlight and execute an arbitrary amount of Resonon code at once - Just make sure the highlighted code is valid.
Your First Sound
Section titled “Your First Sound”Resonon has a built-in sample engine. Let’s use it to play a simple drum rhythm. Execute the following code and you should hear it play. We will go over the example line by line afterwards.
use "std/instruments" { Sampler, Kit };
let sampler = Sampler(Kit("cr78"));
let drums = AudioTrack("drums");drums.load_instrument(sampler);
drums << [bd sd bd sd];
PLAY;You don’t have to understand all new concepts in their entirety just now. Tracks, instruments and patterns are all deep topics that can be explored as you progress in your Resonon journey. Check the relevant docs pages if you want to read more about anything unknown you encounter. The following guides will explain things in more detail.
Here is a quick explanation of 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.
Note that AudioTrack is an elementary feature of the language and needs no import.
let drums = AudioTrack("drums");Creates a new audio track called “drums”. Think of a tracks like channels in a regular DAW. They have volume and pan controls, you can load an instrument and a chain of effects onto them, and their output is default-routed to the master output.
let sampler = Sampler(Kit("cr78"));Creates a new Sampler instrument instance using the CR-78 drum sample Kit. Instruments can be loaded onto audio tracks, and then sent notes via patterns for playback. The Sampler is a Resonon built-in instrument used for non-melodic sample playback, like drums. A Kit is a set of sample .wav files with some metadata that can be loaded into Resonon sampler instruments. The metadata defines things like note-mappings, velocity layers, etc.
We will later learn about the SamplerMelodic for sampling melodic instruments, as well as loading any VST3 or CLAP plugin instrument, and even writing your own instruments fully within the Resonon lanuguage.
drums.load_instrument(sampler);Loads the sampler instrument we just created onto the audio track. Any track can have exactly one instrument loaded onto it. If we then send notes to the track, it will automatically forward them to the loaded instrument and output its sound. Of course, it is also possible to load effects onto a track for processing before track output, but for this guide let’s keep things simple.
drums << [bd sd bd sd];Assigns a pattern to the drums track for playback. The bd (bass drum) and sd (snare drum) are sample names from the CR-78 kit. Patterns are the heart of musical composition and sequencing in Resonon. The following guide will dive deeper into how patterns work. For now, just note that patterns are repeating and have a fixed length called the cycle-time. This is then divided by the number of events present in the pattern to determine their individual length. Per default, the cycle-time in resonon is set to 120bpm at 4 beats per cycle, so 2 seconds. In the above pattern we have 4 total events, so each drum hit gets exactly one beat of time - 0.5 seconds.
Think of a cycle as one bar of music. If we put 4 notes in a pattern, they will be played as quarter-notes. If you put 8 notes, they will play as eighth-notes, and so on.
If you ever worked with the legendary Alex McLean’s TidalCycles or its newer cousin strudel.cc, you will 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 respository.
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 will explore patterns in much more detail in the following guides.
Use _ (underscore) for silence:
drums << [bd _ _ sd, hh _ hh _];Rests take up the same time as a note — they create space in the pattern.
Transport Controls
Section titled “Transport Controls”Basic transport controls are controlleable via Resonon code, or the VSCode integration.
| Action | Code | Keybinding (VSCode Extension) |
|---|---|---|
| Play | PLAY; | F5 |
| Pause | PAUSE; | F5 (toggle) |
| Stop & Reset | STOP; | Shift+F5 |
| Reset | RESET; | Ctrl+Shift+F5 |
Next Steps
Section titled “Next Steps”Next, learn how melodies and more complex patterns are built, as well as how tracks and effects are used.
- Patterns & Tracks — chords, melodies, audio tracks, effects