Audio Input
Resonon can capture audio from microphones, instruments, and other input devices. Route inputs to tracks, monitor in real time with effects, record multi-track takes, and save recordings to disk.
Device Discovery
Section titled “Device Discovery”Use audio_devices() to list all audio devices on your system. Each entry is a dict with these fields:
| Field | Type | Description |
|---|---|---|
name | String | Device name |
input_channels | Number | Number of input channels |
output_channels | Number | Number of output channels |
sample_rate | Number | Default sample rate (Hz) |
is_default | Boolean | Whether this is the system default |
let devices = audio_devices();for d in devices { if d.input_channels > 0 { PRINT d.name + " (" + d.input_channels + " inputs)"; }}Input Configuration
Section titled “Input Configuration”For projects that use a fixed recording setup, define named input channels in your configuration file (~/.config/resonon/config.toml):
[audio.input]device = "Focusrite Scarlett 2i2"
[audio.input.channels]mic = [0]vocals = [0, 1]guitar = [2]Channel mapping rules:
- Single-element array (e.g.
[0]) — mono input from that channel - Two-element array (e.g.
[0, 1]) — stereo input from those channels
Once configured, use the channel name with .input() instead of the device name:
let vox = AudioTrack("vocals");vox = vox.input("vocals"); // Resolves to channels [0, 1] on the ScarlettRouting Input to a Track
Section titled “Routing Input to a Track”Use .input(name) on an AudioTrack to route an audio input:
let mic = AudioTrack("mic_track");mic = mic.input("MacBook Pro Microphone");The argument can be either a device name or a named channel from your [audio.input.channels] configuration. The method is chainable — it returns the AudioTrack.
Arming and Monitoring
Section titled “Arming and Monitoring”Arming
Section titled “Arming”Arm a track for recording with .arm(). The track must have an input source configured via .input() first — calling .arm() without one produces an error. Only armed tracks capture audio when RECORD is triggered. Disarm with .disarm().
mic = mic.arm();// ... record ...mic = mic.disarm();Monitoring
Section titled “Monitoring”Control whether the input signal is heard through the output with .monitor(mode):
| Mode | Behavior |
|---|---|
"in" | Always hear input through output |
"auto" | Hear input only when the track is armed or recording |
"off" | Input is not monitored (silent) |
mic = mic.monitor("in"); // Always hear the microphonemic = mic.monitor("auto"); // Hear only when armed/recordingmic = mic.monitor("off"); // Silence monitoringRecording
Section titled “Recording”RECORD
Section titled “RECORD”Starts playback and begins capturing audio on all armed tracks simultaneously:
RECORD;Stops playback and recording. Tracks remain armed and ready to record again:
PAUSE;Stops recording, disarms all tracks (armed and recording), and resets the transport to the beginning:
STOP;| Command | Stops playback | Stops recording | Disarms tracks | Resets transport |
|---|---|---|---|---|
PAUSE | Yes | Yes | No | No |
STOP | Yes | Yes | Yes | Yes |
A typical recording session in the REPL:
mic = mic.arm();mic = mic.monitor("auto");RECORD;// ... play or sing ...PAUSE;Multi-Track Recording
Section titled “Multi-Track Recording”Arm multiple tracks to record from different inputs simultaneously. RECORD captures on all armed tracks at once:
let vocals = AudioTrack("vocals");vocals = vocals.input("mic").arm().monitor("auto");
let guitar = AudioTrack("guitar");guitar = guitar.input("guitar").arm().monitor("auto");
RECORD;// ... perform ...PAUSE;
// Each track has its own independent recordinglet vocal_take = vocals.take();let guitar_take = guitar.take();Retrieving and Saving Recordings
Section titled “Retrieving and Saving Recordings”There are two ways to get recordings from a track:
.take() — Retrieve as Recording object
Section titled “.take() — Retrieve as Recording object”Returns a RecordedAudio object for inspection and saving, or NUL if nothing was captured. Consumes the buffer — calling .take() again returns NUL until a new recording is made.
let take1 = mic.take();if take1 != NUL { PRINT take1.duration(); take1.save("take1.wav");}.save(path) — Save directly from track
Section titled “.save(path) — Save directly from track”Saves the recording directly to a WAV file and returns the AudioTrack (chainable). Also consumes the buffer.
mic.save("takes/vocals_01.wav");Both approaches consume the recording buffer, so use one or the other — not both for the same take.
Live Processing
Section titled “Live Processing”Monitored input flows through the track’s effect chain before reaching the output. This means you can apply effects to a live input signal:
let vox = AudioTrack("vocals");vox = vox.input("mic");vox = vox.load_effect(Reverb(0.3, 0.5));vox = vox.load_effect(Compressor(-18, 4, 0.01, 0.1));vox = vox.monitor("in");// Now hear your voice with reverb and compression in real timeLive effects also work with routing. Use .send_to() to route processed input to other tracks:
let reverb_bus = AudioTrack("reverb_bus");reverb_bus = reverb_bus.load_effect(Reverb(0.5, 0.7));
let vox = AudioTrack("vocals");vox = vox.input("mic").monitor("in");vox = vox.send_to(reverb_bus, 0.4); // Send 40% to reverb busAudioTrack Recording Methods
Section titled “AudioTrack Recording Methods”| Method | Returns | Description |
|---|---|---|
.input(name) | AudioTrack | Route an input device or named channel |
.arm() | AudioTrack | Arm track for recording |
.disarm() | AudioTrack | Disarm track |
.monitor(mode) | AudioTrack | Set monitor mode: "in", "auto", or "off" |
.take() | RecordedAudio / NUL | Retrieve recording (consumes buffer) |
.save(path) | AudioTrack | Save recording to WAV file (consumes buffer) |
.is_armed() | Boolean | True if the track is armed or recording |
.is_recording() | Boolean | True if the track is actively recording |
Recording Methods
Section titled “Recording Methods”| Method | Returns | Description |
|---|---|---|
.duration() | Number | Length of the recording in seconds |
.samples() | Number | Total sample count |
.sample_rate() | Number | Sample rate in Hz |
.save(path) | RecordedAudio | Save to a WAV file (chainable) |
let take1 = mic.take();if take1 != NUL { PRINT take1.duration(); PRINT take1.samples(); PRINT take1.sample_rate(); take1.save("recording.wav");}Chaining example — save and continue using the recording:
let take1 = mic.take();if take1 != NUL { take1.save("backup.wav").save("archive/backup_copy.wav");}Complete Example
Section titled “Complete Example”// 1. Discover input deviceslet devices = audio_devices();for d in devices { if d.input_channels > 0 { PRINT d.name; }}
// 2. Create tracks with different inputslet vocals = AudioTrack("vocals");vocals = vocals.input("mic");vocals = vocals.load_effect(Compressor(-18, 4, 0.01, 0.1));
let guitar = AudioTrack("guitar");guitar = guitar.input("guitar");guitar = guitar.load_effect(Reverb(0.2, 0.4));
// 3. Arm and enable auto monitoringvocals = vocals.arm().monitor("auto");guitar = guitar.arm().monitor("auto");
// 4. RecordRECORD;// ... perform ...PAUSE;
// 5. Retrieve and save recordingslet vocal_take = vocals.take();if vocal_take != NUL { PRINT "Vocals: " + vocal_take.duration() + "s"; vocal_take.save("takes/vocals_01.wav");}
guitar.save("takes/guitar_01.wav");
// 6. Disarm (or use STOP to disarm all at once)vocals = vocals.disarm();guitar = guitar.disarm();See Also
Section titled “See Also”- Effects — Apply effects to input signals
- Signals — Automate track parameters
- Configuration — Audio input device and channel configuration
- Functions Reference —
audio_devices()and other audio functions