# Resonon full reference Alternating [function] fn Alternating(...elements: Pattern | Note | Array) -> Pattern Creates an alternating pattern (one element per cycle). Parameters: elements: Pattern | Note | Array — the elements, one played per cycle; a lone Array is the list of elements itself Returns: Pattern — a pattern cycling through the elements Examples: `Alternating(C4, E4, G4)` cycles through notes. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#alternating --- Array [class] class Array Ordered collection of values. Construct with `#[1, 2, 3]`. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#array --- Array.concat [method] fn concat(other: Array) -> Array Returns a new array with elements from both arrays. Parameters: other: Array — array to append Returns: Array — a new array with the elements of both Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#concat --- Array.contains [method] fn contains(value: Any) -> Boolean Returns true if the array contains the given value. Parameters: value: Any — the value to search for Returns: Boolean — true if the value is present Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#contains --- Array.filter [method] fn filter(func: Function) -> Array Returns a new array with only elements satisfying the predicate. Parameters: func: Function — fn(element) -> bool Returns: Array — a new array of matching elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#filter --- Array.get [method] fn get(index: Number) -> Any Returns the element at the given index. Errors if the index is out of bounds. Parameters: index: Number — zero-based position Returns: Any — the element at `index` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#get --- Array.iter [method] fn iter() -> Iterator Returns an iterator over the array elements. Returns: Iterator — an iterator over the elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#iter --- Array.length [method] fn length() -> Number Returns the number of elements. Returns: Number — the element count Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#length --- Array.map [method] fn map(func: Function) -> Array Applies a function to each element, returns a new array. Parameters: func: Function — fn(element) -> new_element Returns: Array — a new array of transformed elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#map --- Array.pop [method] fn pop() -> Any Removes and returns the last element. Errors on empty array. Returns: Any — the removed last element Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#pop --- Array.push [method] fn push(value: Any) -> Array Adds an element to the end of the array. Parameters: value: Any — the element to add Returns: Array — the array, for chaining Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#push --- Array.reduce [method] fn reduce(func: Function, initial: Any) -> Any Reduces the array to a single value. Parameters: func: Function — fn(accumulator, element) -> new_accumulator initial: Any — starting accumulator value Returns: Any — the final accumulated value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#reduce --- Array.reverse [method] fn reverse() -> Array Returns a new array with elements in reverse order. Returns: Array — a new reversed array Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#reverse --- Array.slice [method] fn slice(start: Number, end: Number) -> Array Returns a subarray from start (inclusive) to end (exclusive). Parameters: start: Number — start index (inclusive, 0-based) end: Number — end index (exclusive) Returns: Array — the subarray Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#slice --- AudioClip [class] class AudioClip A reference into recorded audio: marker, length and arrangement position. Provides methods to inspect the clip and save it out to a WAV file. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audioclip --- AudioClip.duration [method] fn duration() -> Number Returns the duration of the clip in seconds. Returns: Number — the duration in seconds Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#duration --- AudioClip.left [method] fn left() -> Array Returns the left channel as an array of sample values. Returns: Array — the left-channel sample values Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#left --- AudioClip.mono [method] fn mono() -> Array Returns a mono mixdown as an array of sample values. Returns: Array — the mono mixdown sample values Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mono --- AudioClip.position [method] fn position() -> Number? Returns where the clip sits in the arrangement, in cycles. A take arrives placed at the cycle its recording pass began on — the position `seek` and `.at()` take — with the measured round trip already corrected inside the clip. `NUL` for a clip that was never placed. Returns: Number — the arrangement position in cycles, or NUL Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#position --- AudioClip.right [method] fn right() -> Array Returns the right channel as an array of sample values. Returns: Array — the right-channel sample values Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#right --- AudioClip.sample_rate [method] fn sample_rate() -> Number Returns the sample rate of the clip's audio. Returns: Number — the sample rate in Hz Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sample_rate --- AudioClip.samples [method] fn samples() -> Number Returns the total number of samples in the clip. Returns: Number — the total sample count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#samples --- AudioClip.save [method] fn save(path: String) -> AudioClip Saves the clip to a WAV file. Writes the clip, not the whole sample: an export begins where the clip begins. Parameters: path: String — output file path Returns: AudioClip — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#save-1 --- AudioTrack [class] class AudioTrack A track in the audio engine for sample playback and routing. Create with `session.create_track("name")`; look it up with `session.track("name")`. The name is the track's identity: one name, one track. The session owns the track until it is deleted. The setters return the track, so a whole channel strip is one builder chain. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audiotrack --- AudioTrack.add_solo [method] fn add_solo() -> AudioTrack Adds the track to the soloed tracks and keeps the others soloed, as a Cmd-click on Live's Solo button. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#add_solo --- AudioTrack.arm [method] fn arm() -> AudioTrack Arms the track for recording. The track must have an input source set via `set_input()` first. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#arm --- AudioTrack.clear_punch [method] fn clear_punch() -> AudioTrack Clears all punch points from this track. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear_punch --- AudioTrack.color [method] fn color() -> Number The track colour. A new track takes the next free palette colour. Returns: Number — palette index from 0 to 23 Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#color --- AudioTrack.delay [method] fn delay() -> Number Returns this track's output delay in milliseconds, as set by `set_delay`. Returns: Number — the output delay in milliseconds; 0 on a track that has none Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#delay --- AudioTrack.delete [method] fn delete() -> NUL Deletes the track and releases its resources, as `session.delete_track(name)` does. The name is freed for a new track. A deleted track no longer counts toward the track limit, even while a variable holds it. Tracks that output to it now output to `session.nowhere` (Sends Only; see [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/)), sends to it are removed and sidechain inputs it fed are unwired; a warning names each track affected. A take it was recording is discarded. Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#delete --- AudioTrack.disarm [method] fn disarm() -> AudioTrack Disarms the track, stopping recording. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#disarm --- AudioTrack.effect [method] fn effect(name: String) -> Effect Returns a modulatable handle to an effect by its slot name. Parameters: name: String — slot name of the effect Returns: Effect — the effect with that slot name Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effect --- AudioTrack.effects [method] fn effects() -> Array Returns an array of all effects in chain order. Returns: Array — the effects in chain order Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effects-1 --- AudioTrack.input [method] fn input() -> Array? The configured input channels, or NUL when none is selected. Returns: Array? — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#input --- AudioTrack.instrument [method] fn instrument() -> Instrument? Returns the instrument currently attached to this track. Returns: Instrument? — the attached instrument, or NUL if the track has none Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#instrument --- AudioTrack.is_armed [method] fn is_armed() -> Boolean Returns true if this track is armed for recording. Returns: Boolean — true when the track is armed Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_armed --- AudioTrack.is_muted [method] fn is_muted() -> Boolean Returns whether the track is muted. Returns: Boolean — true if the track is muted Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_muted --- AudioTrack.is_punched [method] fn is_punched() -> Boolean Returns true if this track has punch points configured. Returns: Boolean — true if punch points are configured Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_punched --- AudioTrack.is_recording [method] fn is_recording() -> Boolean Returns true if this track is currently capturing audio. Arming alone is not enough: an armed track starts capturing at RECORD, or, when punch points are set, at its punch-in cycle and no later than its punch-out. STOP leaves the track armed but no longer capturing. Returns: Boolean — true when the track is recording Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_recording --- AudioTrack.is_soloed [method] fn is_soloed() -> Boolean Returns whether the track is soloed. Returns: Boolean — true if the track is soloed Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_soloed --- AudioTrack.key [method] fn key() -> Key? The track key, or NUL when none is configured. Returns: Key? — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#key --- AudioTrack.monitor [method] fn monitor() -> Monitor The input monitoring mode. Returns: Monitor — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#monitor --- AudioTrack.mpe [method] fn mpe() -> Array? The MPE range and low/high member channels, or NUL when MPE is disabled. Returns: Array? — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mpe --- AudioTrack.mute [method] fn mute() -> AudioTrack Mutes the track, like Live's Track Activator. The track goes silent at the end of its chain: its output, every send and a hardware output. Its instrument and effects keep running, so tails are live when you unmute, and its meter and sidechain taps still show the signal. The change fades over 10 ms, so it does not click. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mute --- AudioTrack.name [method] fn name() -> String The name identifying this track. Returns: String — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#name --- AudioTrack.output [method] fn output() -> Dict? The selected output: kind, label and amount when routed to a track or master. Returns: Dict? — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#output --- AudioTrack.pan [method] fn pan() -> Number The track pan setting, from -1 to 1. Returns: Number — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#pan --- AudioTrack.punch [method] fn punch(in_cycle: Number, out_cycle: Number) -> AudioTrack Sets punch-in and punch-out points for time-bounded recording. Recording activates at `in_cycle` and deactivates at `out_cycle`. Parameters: in_cycle: Number — cycle at which recording starts out_cycle: Number — cycle at which recording stops Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#punch --- AudioTrack.punch_in [method] fn punch_in(cycle: Number) -> AudioTrack Sets only the punch-in point. Recording starts at the given cycle and continues until manually stopped. Parameters: cycle: Number — cycle at which recording starts Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#punch_in --- AudioTrack.punch_out [method] fn punch_out(cycle: Number) -> AudioTrack Sets only the punch-out point. Recording starts immediately with RECORD and stops at the given cycle. Parameters: cycle: Number — cycle at which recording stops Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#punch_out --- AudioTrack.punch_points [method] fn punch_points() -> Array The punch-in and punch-out cycles; an unset point is NUL. Returns: Array — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#punch_points --- AudioTrack.remove_instrument [method] fn remove_instrument() -> AudioTrack Detaches the instrument from this track, leaving it with none. The outgoing instance fades out over 10 ms rather than clicking; a no-op if the track has no instrument. Effect chain and routing are untouched. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#remove_instrument --- AudioTrack.remove_send [method] fn remove_send(destination: AudioTrack | Master) -> AudioTrack Removes a parallel send. The track's main output stays connected. Parameters: destination: AudioTrack | Master — destination of the send to remove Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#remove_send --- AudioTrack.reset_routing [method] fn reset_routing() -> AudioTrack Resets the track's routing: output back to master, every send removed. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#reset_routing --- AudioTrack.routing_report [method] fn routing_report() -> NUL Displays detailed routing info for this track. Shows instrument, effects, volume/pan, receives, and routes. Sends are post-fader: they tap the signal after volume and pan. Returns: NUL — nothing; prints the routing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#routing_report --- AudioTrack.save [method] fn save(path: String) -> AudioTrack Collects one recorded pass, as `take` does (the oldest pass not yet collected), and writes it to a WAV file. Does nothing when no pass is waiting. A pass goes to `take` or to `save`, not to both. Unlike `take`, it does not stop a track that is still recording. Parameters: path: String — output file path; `.wav` is added when it has no extension Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#save --- AudioTrack.send [method] fn send(destination: AudioTrack | Master) -> SendParam Returns a modulatable handle to an existing send's level. The send must already exist (created via `set_send`). Supports `.set(amount)` and `<< signal`, symmetric to `effect(name).parameter(name)`. Parameters: destination: AudioTrack | Master — the send destination Returns: SendParam — a modulatable handle to the send level Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#send --- AudioTrack.sends [method] fn sends() -> Array> The auxiliary sends, each with dest and amount; the selected output is separate. Every send is post-fader: it taps the signal after volume and pan. Returns: Array> — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sends --- AudioTrack.set_color [method] fn set_color(index: Number) -> AudioTrack Sets the track colour. It shows on the track's header, clips and Mixer strip. Parameters: index: Number — palette index from 0 to 23: 12 bright hues, then the same muted Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_color --- AudioTrack.set_delay [method] fn set_delay(ms: Number) -> AudioTrack Sets this track's output delay, to line it up with outboard gear. Use it when the track runs out through a hardware effect or an amp and back: delay the output by that device's round-trip time and the PDC system nudges every other track to keep the mix aligned. Recordings made on this track shift to match. Not modulatable — setting it re-plans the graph's latency compensation, so it is a calibration, not an automation target. Read it back with `delay`. Parameters: ms: Number — output delay in milliseconds; must not be negative Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_delay --- AudioTrack.set_effects [method] fn set_effects(effects: Array) -> AudioTrack Declaratively sets the whole effect chain, reconciling the live graph. The chain is made to match the given list exactly — inserting new slots, removing absent ones, and reordering to match. Slot identity is the effect's name (its required leading constructor argument): a kept slot preserves its live instance, so its running modulation survives. Constructor args are parameter writes: a freshly executed `Filter("lp", FilterType.lowpass, 12000)` sets the kept slot's cutoff, as it would a new one's — the last write executed wins. Args left out write nothing, and re-placing a bound handle writes nothing either, so a value tweaked since survives. Names must be unique. Passing an empty array clears the chain. A kept slot costs nothing to re-declare: the chain is planned against the live graph first, so no plugin is loaded and no dsp effect compiled for a slot that is being preserved. Editing a dsp effect body is handled without losing the slot — the recompiled graph is crossfaded into the live instance, so the edit is audible while the slot's parameter values, modulation and sidechain connections carry over. An edit that changes the parameter set has nowhere to carry them, so it rebuilds the slot. Parameters: effects: Array — the effects, in the desired chain order Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_effects --- AudioTrack.set_input [method] fn set_input(channel: Number, right: Number? = NUL) -> AudioTrack Sets the hardware input channels for monitoring and recording. Channels are indices into the current input device, counting from 0, the same way `Output` counts. Pass one for mono, two for a stereo pair. The device itself is `[audio] input` in your preferences; with none named, the first call opens the system default input. A channel the device does not have is an error, not silence. Parameters: channel: Number — mono channel, or the left channel of a stereo pair right: Number? — right channel (optional) Returns: AudioTrack — the track, for chaining Examples: `vocals.set_input(0)` records channel 0 as mono; `drums.set_input(2, 3)` records channels 2 and 3 as stereo. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_input --- AudioTrack.set_instrument [method] fn set_instrument(instrument: Instrument) -> AudioTrack Sets the instrument on this track. The declarative front door for the instrument; reconciles the live graph. Re-attaching one of the same identity preserves the live instance — its parameter edits, modulation and sounding voices survive; a plugin matches by type, a sampler by kit, a dsp instrument by definition (an edited body is crossfaded in). A different identity replaces the instrument outright. Read the attached instrument back with `instrument()`. Parameters: instrument: Instrument — the instrument to attach: a plugin, a dsp instrument or a sampler Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_instrument --- AudioTrack.set_key [method] fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> AudioTrack Set a track-level key for degree resolution and auto-quantization. Degrees (^1, ^2, ...) resolve from this key without .in_key(), and absolute notes are quantized to the nearest scale tone. A change is heard from the next cycle, on a pattern already playing. Pass a Key value, or a scale name/Scale with a root note. Parameters: scale: Key | String | Scale — a Key value, or a scale name/Scale value root: Note? — root note (e.g. C4, or a MIDI number such as 60); omit when passing a Key Returns: AudioTrack — the track, for chaining Examples: `track.set_key(Key(C4, "major"))` or `track.set_key("major", C4)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_key --- AudioTrack.set_monitor [method] fn set_monitor(mode: Monitor) -> AudioTrack Sets the input monitoring mode. Parameters: mode: Monitor — when the input is heard Returns: AudioTrack — the track, for chaining Examples: `vocals.set_monitor(Monitor.auto)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_monitor --- AudioTrack.set_mpe [method] fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> AudioTrack Enable MPE (per-note channel allocation) for polyphonic microtonal output. Parameters: range: Number? — pitch-bend range in semitones (optional, defaults to 48) zone_lo: Number? — low member channel (optional, defaults to 2) zone_hi: Number? — high member channel (optional, defaults to 16) Returns: AudioTrack — the track, for chaining Examples: `track.set_mpe()`, `track.set_mpe(24)`, `track.set_mpe(48, 2, 9)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_mpe --- AudioTrack.set_name [method] fn set_name(name: String) -> AudioTrack Changes the track name. Existing handles keep following this track. Parameters: name: String — unique track name Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_name --- AudioTrack.set_pan [method] fn set_pan(value: Number) -> AudioTrack Sets track pan. Parameters: value: Number — pan position (-1.0 = hard left, 0.0 = center, 1.0 = hard right) Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_pan --- AudioTrack.set_send [method] fn set_send(destination: AudioTrack | Master, amount: Number | Signal | Pattern) -> AudioTrack Adds a parallel aux send to the given destination, leaving the output edge untouched. The send is post-fader: it taps the signal after volume and pan. If the destination is already the track's exclusive output (see `>>`), this sets that output edge's level instead — which is how you build a crossfade, by giving the wet and dry legs complementary amounts. Parameters: destination: AudioTrack | Master — target track, bus or the master amount: Number | Signal | Pattern — send level (0.0-1.0), or a signal or pattern that moves it Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_send --- AudioTrack.set_tuning [method] fn set_tuning(bend_range: Number? = NUL) -> AudioTrack Enable microtonal pitch bend output. Uses the MIDI default ±2 semitone range (works with any synth). Parameters: bend_range: Number? — pitch-bend range in semitones (optional; default ±2) Returns: AudioTrack — the track, for chaining Examples: `track.set_tuning()`, `track.set_tuning(48)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_tuning --- AudioTrack.set_velocity [method] fn set_velocity(vel: Number | Signal | Pattern) -> AudioTrack Sets the velocity for notes played on this track. A new track plays at 100. A note with its own velocity keeps it. Parameters: vel: Number | Signal | Pattern — note velocity (1-127), or a signal or pattern read as each note fires; a value from a signal or pattern is held to 1-127 Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_velocity --- AudioTrack.set_volume [method] fn set_volume(value: Number) -> AudioTrack Sets track volume. Parameters: value: Number — volume in dB (0 = unity, -70 = mute, +6 = max boost) Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_volume --- AudioTrack.solo [method] fn solo() -> AudioTrack Solos the track, and only this track: every other solo is released, as a plain click on Live's Solo button. Solo is in place — the buses and returns the track feeds stay audible, so its sends still sound. Soloing a bus solos the tracks that output to it. Soloing a return keeps every send into it and silences the senders' own outputs. The change fades over 10 ms, so it does not click. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#solo --- AudioTrack.take [method] fn take() -> AudioClip? Collects one recorded pass as an AudioClip. Every pass is kept, so a track that was recorded twice hands them back in the order they were performed: oldest first, one per call. Returns: AudioClip — the oldest pass not yet collected, or NUL if none is waiting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#take --- AudioTrack.tuning [method] fn tuning() -> Number? The pitch bend range, or NUL when tuning is disabled. Returns: Number? — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#tuning --- AudioTrack.unmute [method] fn unmute() -> AudioTrack Unmutes the track. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#unmute --- AudioTrack.unsolo [method] fn unsolo() -> AudioTrack Releases the track's solo. When no track is soloed, every track is heard. Returns: AudioTrack — the track, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#unsolo --- AudioTrack.velocity [method] fn velocity() -> Number | Signal | Pattern The configured note velocity source; 100 until `set_velocity` changes it. Returns: Number | Signal | Pattern — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#velocity --- AudioTrack.volume [method] fn volume() -> Number The track fader setting in dB. Returns: Number — the current setting Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#volume --- BEAT_EDGE [dsp-builtin] BEAT_EDGE: Number Single-sample trigger pulse (1.0) at the start of each beat, 0.0 otherwise. Meaningful only inside `dsp signal` blocks. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#beat_edge --- BEAT_PHASE [dsp-builtin] BEAT_PHASE: Number Sawtooth phase ramping 0.0→1.0 across each beat (fract(CYCLES * BPC)). Meaningful only inside `dsp signal` blocks; reads 0.0 elsewhere. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#beat_phase --- BPC [dsp-builtin] BPC: Number Beats per cycle — number of beats spanning one transport cycle (default 4.0). Live transport value inside `dsp signal` blocks; the static default elsewhere. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#bpc --- Bezier [class] class Bezier An automation segment shaped as a cubic Bezier curve, as CSS's `cubic-bezier()`. `Bezier(x1, y1, x2, y2)`: the segment runs from (0, 0) to (1, 1), and the control points (x1, y1) and (x2, y2) set its shape. x1 and x2 are times, from 0 to 1; a y outside 0-1 overshoots the target value. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#bezier --- Blur [function] fn Blur(name: String) -> Visual A blur visual: TouchDesigner's Blur TOP. It blurs its primary input (set via `src >> Blur("…")`), all four channels, with a kernel `size` pixels wide: one pass along each axis. As in TD, `size` is a whole number of taps; a fraction fades between the two sizes around it, so a modulated size moves smoothly. Sizes are in composition pixels, so a blur looks the same at every `screen.set_quality`. `preshrink` blurs a smaller image, so a wide blur costs less: 2 halves the width and height with a 2×2 box, then the kernel runs over the small image, which makes it `preshrink` times wider. The size is limited to 4096 render pixels per pass; use `preshrink` for wider blurs. TD's Dither is left out: it only matters for 8-bit images, and visuals are 16-bit float. Parameters: name: String — the operator's name; its identity on screen Uniforms: method — the axes to blur, a `BlurMethod` (default horizontal_and_vertical) type — the kernel shape, a `BlurType` (default catmull_rom) extend — the edge condition, a `BlurExtend` (default hold) preshrink — how many times smaller the blurred image is (default 1, none) size — the kernel width in pixels (default 7) sample_step — the distance between taps, in `sample_step_unit`s (default 1) sample_step_unit — the unit of `sample_step`, a `Unit` (default pixels) rotate — the kernel's rotation in degrees, counterclockwise (default 0) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#blur --- BlurExtend [enum] enum BlurExtend { hold, repeat, mirror } What a `Blur` sees beyond the image edges: TD's Blur Extend menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#blurextend --- BlurMethod [enum] enum BlurMethod { horizontal_and_vertical, horizontal, vertical } The axes a `Blur` blurs along: TD's Blur Method menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#blurmethod --- BlurType [enum] enum BlurType { catmull_rom, gaussian, box, bartlett, sinc, hanning, blackman } The kernel shape of a `Blur`: TD's Blur Type menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#blurtype --- CPS [dsp-builtin] CPS: Number Cycles per second — tempo-derived frequency (e.g. 120 BPM = 2.0 CPS). Live inside `dsp signal` blocks; static default elsewhere. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cps --- CYCLE [dsp-builtin] CYCLE: Number The song's current whole cycle number (0, 1, 2, …), taken at the first sample of each block. For a 0.0→1.0 ramp across each cycle, use CYCLE_PHASE. Live inside `dsp signal` blocks; static elsewhere. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cycle --- CYCLES [dsp-builtin] CYCLES: Number Local position in cycles since the signal's anchor. A tempo change bends its rate and never jumps it. Available in `dsp signal` blocks only. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cycles --- CYCLE_EDGE [dsp-builtin] CYCLE_EDGE: Number Single-sample trigger pulse (1.0) at the start of each transport cycle, 0.0 otherwise. Meaningful only inside `dsp signal` blocks. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cycle_edge --- CYCLE_PHASE [dsp-builtin] CYCLE_PHASE: Number Sawtooth phase ramping 0.0→1.0 across each transport cycle (fract(CYCLES)). Meaningful only inside `dsp signal` blocks; reads 0.0 elsewhere. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cycle_phase --- Cc [function] fn Cc(cc_number: Number, channel: Number? = NUL) -> Signal Creates a MIDI CC input signal (0 to 1 output). Reads the CC from any channel, or from one channel when `channel` is given. Requires an active MIDI input connection. Parameters: cc_number: Number — CC number (0-127) channel: Number? — MIDI channel (1-16); omit to read from any channel Returns: Signal — a control signal tracking the CC value, normalized to 0..1 Examples: `Cc(74)` reads CC 74 from any channel; `Cc(74, 1)` reads CC 74 from channel 1 only. Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#cc --- CcOutput [class] class CcOutput A MIDI track's CC lane, from `track.cc(number)`. Takes a value, a pattern or a signal via `<<`, and sends on wherever the track is routed. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#ccoutput --- CcOutput.send_rate [method] fn send_rate() -> Number The CC send rate in Hz. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#send_rate --- CcOutput.set_send_rate [method] fn set_send_rate(hz: Number) -> CcOutput Set the CC send rate in Hz (default 30). Higher values produce smoother automation but more MIDI traffic. Parameters: hz: Number — send rate in Hz Returns: CcOutput — the CC output handle, for chaining Examples: `track.cc(74).set_send_rate(60) << Sine(0.5).range(0, 127)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_send_rate --- Cc_learn [function] fn Cc_learn() -> Signal MIDI learn: waits for a CC knob/fader to be moved, then returns a Signal bound to that CC channel and number. Prints the equivalent call, e.g. `Learned: Cc(74, 1)`, to hardcode later. Blocks for up to 10 seconds. Requires an active MIDI input. Returns: Signal — a control signal bound to the learned CC, normalized to 0..1 Examples: `let cutoff = Cc_learn()` Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#cc_learn --- Clip [class] class Clip A MIDI clip that loops at its stored beat length. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clip --- Clip.query [method] fn query(cycle: Number) -> Pattern Returns the pattern for a cycle. Parameters: cycle: Number — cycle to query Returns: Pattern — this clip, for the pattern query Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#query --- ClipNote [class] class ClipNote One authored MIDI clip note, including its mute state. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clipnote --- Clone [class] class Clone A value that can make an independent copy of itself with `.clone()`. A class implements it by defining `clone()`, returning its own class: ```resonon class Point implements Clone { let x; let y; fn new(x, y) { this.x = x; this.y = y; } fn clone() -> Point { return Point(this.x, this.y); } } let a = Point(1, 2); let b = a.clone(); b.x = 10; assert a.x == 1; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#clone --- Clone.clone [method] fn clone() -> Self Returns an independent copy: a change to the copy is not seen through the original, nor the other way round. A copy holds what the original holds. Each value inside it that is `Clone` is cloned too; every other value, such as a track, a pattern or an instance of a class that is not `Clone`, is shared. A section or timeline copy is not attached to the original's tracks. Returns: Self — the copy, of the same type as the original ```resonon let a = #[1, #[2, 3]]; let b = a.clone(); b[1].push(4); assert a[1].length() == 2; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#clone-2 --- Composite [function] fn Composite(name: String) -> Visual A composite visual: TouchDesigner's Composite TOP. It combines its primary input `A` (TD's input 1, set via `src >> Composite("…")`) with a second input `B` (TD's input 2, set via `c.parameter("b") << node`, where `node` may be a forward node or `prev` inside `feedback(...)`) by the `operand` operation, e.g. `c.parameter("operand") << Operand.subtract`. Parameters: name: String — the operator's name; its identity on screen Uniforms: operand — the operation, an `Operand` (default multiply) Inputs: b — second input B, blended with the primary input A Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#composite --- Curve [enum] enum Curve { linear, step, exp, smooth, ease_in, ease_out, ease_in_out, ease } The shape of an automation segment, from its breakpoint to the next one. For a shape of your own, give a `Bezier` instead. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#curve --- DSP Builtins [module] Native (`__native`) constants and functions usable inside `dsp` blocks. SR: Number — Current sample rate in Hz. PI: Number — Pi (3.14159...) TWOPI: Number — Two pi / tau (6.28318...). INV_SR: Number — Inverse sample rate (1.0 / SR). CYCLE: Number — The song's current whole cycle number (0, 1, 2, …), taken at the first sample of each block. CPS: Number — Cycles per second — tempo-derived frequency (e.g. 120 BPM = 2.0 CPS). BPC: Number — Beats per cycle — number of beats spanning one transport cycle (default 4.0). CYCLE_PHASE: Number — Sawtooth phase ramping 0.0→1.0 across each transport cycle (fract(CYCLES)). BEAT_PHASE: Number — Sawtooth phase ramping 0.0→1.0 across each beat (fract(CYCLES * BPC)). CYCLE_EDGE: Number — Single-sample trigger pulse (1.0) at the start of each transport cycle, 0.0 otherwise. BEAT_EDGE: Number — Single-sample trigger pulse (1.0) at the start of each beat, 0.0 otherwise. TIME: Number — Local time in seconds since the signal's anchor. CYCLES: Number — Local position in cycles since the signal's anchor. POSITION: Number — Local position since the signal's anchor, counted in its timebase: cycles unless `.set_timebase()` sets another unit. sin(x) -> Number — Sine function. cos(x) -> Number — Cosine function. tan(x) -> Number — Tangent function. tanh(x) -> Number — Hyperbolic tangent — useful for soft clipping. exp(x) -> Number — Exponential function (e^x). log(x) -> Number — Natural logarithm (ln). log2(x) -> Number — Base-2 logarithm. log10(x) -> Number — Base-10 logarithm. sqrt(x) -> Number — Square root. abs(x) -> Number — Absolute value. floor(x) -> Number — Round down to the nearest integer. ceil(x) -> Number — Round up to the nearest integer. round(x) -> Number — Round to the nearest integer. fract(x) -> Number — Fractional part (x - floor(x)). mtof(midi) -> Number — MIDI note number to frequency in Hz. ftom(freq) -> Number — Frequency in Hz to MIDI note number. pow(base, exp) -> Number — Raise base to exponent. min(a, b) -> Number — Minimum of two values. max(a, b) -> Number — Maximum of two values. clamp(value, min, max) -> Number — Clamp a value to a range. lerp(a, b, t) -> Number — Linear interpolation between two values. svf_lp(input, cutoff, resonance) -> Number — State variable filter — lowpass (Zavalishin topology-preserving transform). svf_hp(input, cutoff, resonance) -> Number — State variable filter — highpass. svf_bp(input, cutoff, resonance) -> Number — State variable filter — bandpass. svf_notch(input, cutoff, resonance) -> Number — State variable filter — notch (band-reject). svf_allpass(input, cutoff, resonance) -> Number — State variable filter — allpass. svf_peak(input, cutoff, resonance) -> Number — State variable filter — peak (bell). onepole(input, coeff) -> Number — One-pole lowpass filter. delay(input, time) -> Number — Integer sample delay (circular buffer, max 1 second). delay_interp(input, time) -> Number — Fractional delay with linear interpolation (max 1 second). noise() -> Number — White noise generator. sample_hold(input, trigger) -> Number — Sample and hold — captures input on rising edge of trigger. cc(cc_num, channel) -> Number — Read a MIDI CC value, normalized to 0.0–1.0. aftertouch(channel) -> Number — Read MIDI channel aftertouch, normalized to 0.0–1.0. pitchbend(channel) -> Number — Read MIDI pitch bend, normalized to -1.0–1.0. Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/ --- Delay [function] fn Delay(name: String, time: Number? = NUL, feedback: Number? = NUL) -> Effect Creates a feedback delay, half dry and half wet by default, its time in seconds. A change of Time glides, as a tape delay does: the echoes bend in pitch. On a return track, set `Mix` to 1.0: the source track already plays the dry signal. Parameters: name: String — slot name (identity in a track's effect chain) time: Number? (optional) — delay time in seconds feedback: Number? (optional) — feedback amount Returns: Effect — a built-in delay ```resonon drums.set_effects(#[Delay("echo", 0.25, 0.5)]); delay_bus.set_effects(#[Delay("echo", 0.125).set_parameter("Mix", 1.0)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#delay-1 --- Dict [class] class Dict Key-value mapping with String or Number keys. Construct with `#{"key": value}` literal syntax. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#dict --- Dict.contains_key [method] fn contains_key(key: String | Number) -> Boolean Returns true if the dict contains the given key. Parameters: key: String | Number — the key to check Returns: Boolean — true if `key` is present Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#contains_key --- Dict.entries [method] fn entries() -> Array> Returns an Array of [key, value] pairs. Returns: Array — one `[key, value]` pair per entry Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#entries --- Dict.filter [method] fn filter(func: Function) -> Dict Filters entries by predicate. Parameters: func: Function — fn(key, value) -> bool Returns: Dict — a new dict with matching entries Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#filter-2 --- Dict.get [method] fn get(key: String | Number) -> Any Returns the value for the given key, or NUL if not found. Parameters: key: String | Number — the key to look up Returns: Any — the value for `key`, or NUL if absent Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#get-1 --- Dict.iter [method] fn iter() -> Iterator Returns an Iterator over the keys. Returns: Iterator — an iterator over the keys Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#iter-2 --- Dict.keys [method] fn keys() -> Array Returns an Array of all keys. Returns: Array — all keys Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#keys --- Dict.length [method] fn length() -> Number Returns the number of entries. Returns: Number — the entry count Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#length-3 --- Dict.map [method] fn map(func: Function) -> Dict Transforms values using a function. Parameters: func: Function — fn(key, value) -> new_value Returns: Dict — a new dict with transformed values Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#map-2 --- Dict.merge [method] fn merge(other: Dict) -> Dict Returns a new dict with entries from both dicts merged. Does not mutate either dict. Parameters: other: Dict — dict to merge in (its keys override on conflict) Returns: Dict — a new merged dict Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#merge --- Dict.reduce [method] fn reduce(func: Function, initial: Any) -> Any Reduces entries to a single value. Parameters: func: Function — fn(accumulator, key, value) -> new_accumulator initial: Any — starting accumulator value Returns: Any — the final accumulated value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#reduce-1 --- Dict.remove [method] fn remove(key: String | Number) -> Any Removes a key in place. Parameters: key: String | Number — the key to remove Returns: Any — the removed value, or NUL if the key was not found Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#remove --- Dict.set [method] fn set(key: String | Number, value: Any) -> Dict Sets a key-value pair in place. Parameters: key: String | Number — the key to set value: Any — the value to associate Returns: Dict — the dict, for chaining Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#set --- Dict.values [method] fn values() -> Array Returns an Array of all values. Returns: Array — all values Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#values --- Displace [function] fn Displace(name: String) -> Visual A displace visual: TouchDesigner's Displace TOP. Each pixel of its primary input (set via `src >> Displace("…")`) is read from another place, set by a displacement field fed into the `by` slot (`d.parameter("by") << field`, or `d.parameter("by") << prev` inside `feedback(...)`). As in TD, the field's red moves the lookup across and its blue moves it up, so a `Slope` feeds it directly. Each pixel at `uv` reads the input at `uv × uv_weight + offset × offset_weight + 2 × displace_weight × (field − midpoint)`, per axis, in fractions of the width and height: a field of 0.75 at weight 0.1 moves the lookup a twentieth of the image. `extend` sets what is read beyond the edges. Fixed at TD's defaults: Horizontal Source red, Vertical Source blue. The alpha is 1. Parameters: name: String — the operator's name; its identity on screen Uniforms: displace_weight_x — how far the field moves the lookup across (default 1) displace_weight_y — how far the field moves the lookup up (default 1) midpoint_x — the red value that does not move the lookup (default 0.5) midpoint_y — the blue value that does not move the lookup (default 0.5) uv_weight — weight of the pixel's own position; at 0 every pixel starts from the offset (default 1) offset_x — start of the lookup across, before offset_weight (default 0.5) offset_y — start of the lookup up, before offset_weight (default 0.5) offset_weight — weight of the offset (default 0) extend — the edge condition, an `Extend` (default hold) Inputs: by — displacement field Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#displace --- Distortion [function] fn Distortion(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect Creates a distortion effect (asymmetrical/transistor-style clipping). Uses tanh for positive half-cycles and soft clipping for negative, producing odd and even harmonics. Includes DC blocker and tone filter. Parameter names, for `parameter()` and `set_parameter()`: `Drive`, `Tone`, `Level`, `Mix`. Parameters: name: String — slot name (identity in a track's effect chain) drive: Number? (optional) — distortion intensity tone: Number? (optional) — post-distortion brightness Returns: Effect — a built-in distortion effect ```resonon bass.set_effects(#[Distortion("dist", 0.6, 0.4)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#distortion-1 --- DrumSample [class] class DrumSample A reference to a single drum sample slot. Obtained via `.slot()` on a Sampler (e.g. `kit.slot("bd")`). Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#drumsample --- DrumSample.envelope [method] fn envelope() -> Array The current [attack_ms, decay_ms, sustain, release_ms] envelope of this placed pad. Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#envelope --- DrumSample.name [method] fn name() -> String Returns the sample name. Returns: String — the sample name Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#name-1 --- DrumSample.note [method] fn note() -> Number Returns the MIDI note number for this sample. Returns: Number — the MIDI note mapped to this sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#note --- DrumSample.parameter [method] fn parameter(name: String) -> InstrumentParam Returns a parameter reference for this slot. Parameters: name: String — parameter name: "gain", "pan", "attack", "decay", "sustain", "release", "slice_start", "slice_end", "reverse" Returns: InstrumentParam — supports `.get()`, `.set()`, and `<<` for modulation Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#parameter --- DrumSample.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList with this slot's parameters. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#parameters --- DrumSample.set_envelope [method] fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSample Sets the ADSR envelope for this sample. Parameters: attack_ms: Number — attack time in milliseconds decay_ms: Number — decay time in milliseconds sustain: Number — sustain level (0.0-1.0) release_ms: Number — release time in milliseconds Returns: DrumSample — the slot reference, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_envelope --- DrumSample.set_parameter [method] fn set_parameter(name: String, value: Number) -> DrumSample Sets a parameter value by name. Parameters: name: String — parameter name (e.g. "gain", "pan", "attack") value: Number — new parameter value Returns: DrumSample — the slot reference, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_parameter --- DspInstrument [class] class DspInstrument An instrument a `dsp instrument` definition makes: `Pad()` for `dsp instrument Pad { ... }`. A symbolic handle, as a plugin instrument is: `set_parameter` before placement is recorded and written to the instance the track builds; `parameter` and `parameters` need an instance and say so. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#dspinstrument --- DspInstrument.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList of the instrument's parameters, headed by its name. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameters-1 --- DspInstrument.set_parameter [method] fn set_parameter(name: String, value: Number) -> DspInstrument Sets a parameter value by name. Parameters: name: String — parameter name, as the definition's `param` declares it value: Number — new value in the parameter's range Returns: DspInstrument — the instrument, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_parameter --- Duration [class] class Duration A length of time in the unit it was written in: cycles, beats or seconds. Construct with `cycles`, `beats`, `note_value`, `seconds` or `ms`. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#duration --- Duration.dotted [method] fn dotted() -> Duration Returns the duration half again as long: a dotted note value. Returns: Duration — 1.5 times the length, in the same unit Examples: `note_value(1, 8).dotted()` — a dotted eighth, 3/16 Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#dotted --- Duration.triplet [method] fn triplet() -> Duration Returns the duration two thirds as long: a triplet note value, three in the space of two. Returns: Duration — 2/3 of the length, in the same unit Examples: `note_value(1, 4).triplet()` — a quarter triplet, 1/6 Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#triplet --- Edge [function] fn Edge(name: String) -> Visual An edge visual: TouchDesigner's Edge TOP. It finds the edges in the luminance of its primary input (set via `src >> Edge("…")`), with a 3×3 Sobel whose taps are `sample_step` pixels apart, and draws them in white on black: the soft cells of a noise field become bright contour lines. As in TD, the edge is `sqrt(strength × (1 − black_level) × gradient² / sample_step) − black_level`, clamped to 0..1. Fixed at TD's defaults: Select luminance (0.3 R + 0.6 G + 0.1 B), white edges, no comp over the input. The alpha is 1, not the edge. The step is in composition pixels, so the edges are the same at every quality. Parameters: name: String — the operator's name; its identity on screen Uniforms: strength — edge gain; the edge grows with its square root (default 1) black_level — taken off the edge, so weak edges go to black (default 0) sample_step — distance from each pixel to its taps, in pixels (default 1) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#edge --- Effect [class] fn Effect(name: String, plugin: String, plugin_id: String? = NUL) -> Effect An audio effect processor. Unified type wrapping four backends: - **Built-in** — a device that ships with Resonon, described by constructors like `Filter("lp", FilterType.lowpass)` or `Reverb("room")`. - **DSP** — DSP code, described by constructors like `Delay("echo")` or by `dsp effect` blocks. Processing runs as compiled bytecode. - **CLAP plugin** — named by `Effect("slot", "name")` when a CLAP bundle is found. - **VST3 plugin** — named by `Effect("slot", "name")` when a VST3 bundle is found (or when CLAP is unavailable and VST3 is). All backends support parameter access, state save/load, and can be loaded onto audio tracks and the master bus. GUI and program methods are backend-specific and emit warnings when called on unsupported backends. An effect is a **symbolic handle**. A constructor describes one; `track.set_effects(#[...])` is what builds it. Before placement the parameter *writers* (`set_parameter`, `load_state`, `set_program`) record what they were asked to do and write it to the slot when the track places the effect — a new slot or one the chain kept; the *readers* (`parameter`, `parameters`, `programs`, `save_state`, `connect_input`, `backend`, the GUI methods) need an instance and say so. After placement every method works on the effect live in that slot, re-resolved on each call — so a handle kept across a re-execute never points at a replaced instance. Every effect carries a **slot name** — its required first constructor argument. When a track's chain is set with `set_effects(#[...])`, effects are identified by slot name, so re-running with the same name preserves that slot in-place rather than duplicating it. The recorded writes still land: re-running `Filter("lp", FilterType.lowpass, 12000)` sets the kept slot's cutoff — the last write executed wins. ```resonon let room = Effect("room", "ValhallaRoom"); room.set_parameter("Mix", 0.3); // recorded; the set_effects() line below writes it let delay = Delay("echo", 0.25, 0.5); drums.set_effects(#[room, delay]); ``` Loads an effect plugin (CLAP or VST3). Searches CLAP plugins first, then VST3. File extensions are added automatically. Parameters: name: String — slot name (identity in a track's effect chain) plugin: String — plugin name or full path (e.g. "Valhalla Room") plugin_id: String? — plugin ID, auto-detected if only one plugin in bundle (optional) Returns: Effect — the loaded effect plugin Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effect --- Effect.backend [method] fn backend() -> String Returns the device backend type ("Built-in", "CLAP", "VST3", or "dsp"). Returns: String — the backend type Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#backend --- Effect.connect_input [method] fn connect_input(name: String, source: AudioTrack) -> Effect Connects a named sidechain input port to a source audio track. Some effects (e.g. compressors) have sidechain input ports that accept audio from another track. This method sets up that routing in the audio graph. The source track must be processed before the effect's track (enforced by topological sort). The port name is the effect's own, matched exactly: a plugin's is the name it gives its input bus (MCompressor and TDR Molot GE say "Sidechain", Shadow Hills "Stereo Aux In", FETish "Aux"), a `dsp effect`'s is the name of its extra `input`. To find it, connect any name — the error lists the ports the effect has. Backends: CLAP, VST3, and `dsp effect` blocks that declare a second `input`. Parameters: name: String — the sidechain input port name, as the effect reports it source: AudioTrack — the track whose output feeds this port Returns: Effect — `this`, for method chaining Errors: RuntimeError — if the effect has no port with the given name; lists the ports it has ```resonon let comp = Effect("comp", "TDR Molot GE"); bass.set_effects(#[comp]); // place first: the port lives on the slot comp.connect_input("Sidechain", kick_track); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#connect_input --- Effect.hide_gui [method] fn hide_gui() -> NUL Closes the plugin GUI window. For CLAP/VST3 plugins, closes the native editor window if open. For built-in DSP effects, prints a warning and returns NUL. Backends: CLAP, VST3. Warns on DSP. Returns: NUL ```resonon fx.hide_gui(); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#hide_gui --- Effect.inputs [method] fn inputs() -> Array> Returns the placed effect's sidechain connections. Each entry has port, source (track name), and active (whether that port currently exists). Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#inputs --- Effect.load_state [method] fn load_state(path: String) -> Effect Loads a preset file into the effect. Restores the effect's state from a file previously created by `save_state()`. The preset's plugin name must match this effect's plugin name. Backends: all. Parameters: path: String — file path of the preset to load Returns: Effect — `this`, for method chaining Errors: RuntimeError — if the file doesn't exist or the plugin name mismatches ```resonon fx.load_state("presets/warm_reverb.preset"); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#load_state --- Effect.name [method] fn name() -> String Returns the slot name of this effect. The slot name is the effect's required first constructor argument. Backends: all. Returns: String — the effect's slot name ```resonon Delay("echo").name(); // => "echo" Effect("room", "ValhallaRoom").name(); // => "room" ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#name-1 --- Effect.parameter [method] fn parameter(name: String) -> EffectParam Returns a parameter reference for the named parameter. Uses fuzzy case-insensitive matching: exact path first, then substring match on path and display name. Use `.get()`, `.set()`, `.set_norm()` on the returned reference, or pipe it with `<<` for modulation. Backends: all. Parameters: name: String — parameter name (e.g. "Room", "Mix", "Cutoff") Returns: EffectParam — a parameter reference with `.get()`, `.set()`, `.set_norm()` methods Errors: RuntimeError — if no parameter matches or match is ambiguous ```resonon let d = Delay("delay", 0.25, 0.5); drums.set_effects(#[d]); // place it first — reading needs an instance d.parameter("Time").get(); // => 0.25 d.parameter("Time").set(0.5); // set to 0.5 d.parameter("Time") << Sine(2).range(0.1, 0.8); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameter-1 --- Effect.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList of all effect parameters. Prints as a formatted table (headed by the effect name and backend) with columns Parameter, Value, Text, Range, Default. Text is the value as the effect shows it (`1.20 kHz`, `250 ms`). Use `.data` for the raw array of dicts; each entry has `name`, `value` (what `set_parameter` takes), `norm` (the value as a fraction of the range, what `.set_norm()` takes), `text`, `min`, `max`, `default`, `min_text`, `max_text`, `default_text`, `group`, `path`, and `step`. Backends: all. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) ```resonon drums.set_effects(#[fx]); // place it first — reading needs an instance print(fx.parameters()); // all parameters print(fx.parameters("freq")); // only parameters containing "freq" let rows = fx.parameters().data; // raw array of parameter dicts ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameters-3 --- Effect.program [method] fn program() -> Number? Reads the selected VST3 program index, or NUL if unavailable. Backends: VST3. NUL on CLAP, DSP. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#program --- Effect.programs [method] fn programs() -> Array Lists all program/preset names built into the plugin. Only VST3 plugins expose factory programs. For CLAP and built-in DSP effects, prints a warning and returns an empty array. Backends: VST3. Warns on CLAP, DSP. Returns: Array — array of program name strings, e.g. `#["Init", "Warm", "Bright"]` ```resonon let fx = Effect("diva", "Diva"); lead.set_effects(#[fx]); // place it first — reading needs an instance fx.programs(); // => #["Init", "Juno Saw", "Warm Pad", ...] ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#programs --- Effect.save_state [method] fn save_state(path: String) -> Effect Saves the effect's state to a preset file. For CLAP/VST3 plugins, saves the full binary plugin state (includes all internal state beyond just parameter values). For built-in DSP effects, saves parameter values only. The file format is a resonon preset file (`.preset` extension recommended). Backends: all. Parameters: path: String — file path for the preset Returns: Effect — `this`, for method chaining ```resonon fx.save_state("presets/warm_reverb.preset"); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#save_state --- Effect.set_parameter [method] fn set_parameter(name: String, value: Number | Variant) -> Effect Sets a parameter value by name in its native range. The value is clamped to the parameter's declared range. For normalized [0,1] input use `parameter(name).set_norm()` instead. Backends: all. Parameters: name: String — parameter name (e.g. "Room", "Mix") value: Number | Variant — new value in the parameter's native range; a variant of the parameter's enum for a built-in device's stepped parameter (`FilterType.peak` for a Filter's Type) Returns: Effect — `this`, for method chaining Errors: RuntimeError — if no parameter with the given name exists ```resonon Delay("delay").set_parameter("Time", 0.8).set_parameter("Feedback", 0.3); // written when placed drums.effect("delay").set_parameter("Time", 0.4); // edits the live one ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_parameter-1 --- Effect.set_program [method] fn set_program(index: Number) -> Effect Selects a factory program/preset by index. Only VST3 plugins support program selection. For CLAP and built-in DSP effects, prints a warning and returns the effect unchanged. Backends: VST3. Warns on CLAP, DSP. Parameters: index: Number — zero-based program index Returns: Effect — `this`, for method chaining Errors: RuntimeError — if the index is out of range (VST3 only) ```resonon let fx = Effect("diva", "Diva"); fx.set_program(2); // recorded now, applied to the instance set_effects() builds lead.set_effects(#[fx]); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_program --- Effect.show_gui [method] fn show_gui() -> NUL Opens the plugin GUI window. For CLAP/VST3 plugins with GUI support, opens the plugin's native editor window. For built-in DSP effects, prints a warning and returns NUL (no error). Backends: CLAP, VST3. Warns on DSP. Returns: NUL Errors: RuntimeError — if the plugin does not support GUI (CLAP/VST3 only) RuntimeError — if running in headless mode ```resonon let fx = Effect("room", "ValhallaRoom"); drums.set_effects(#[fx]); // place it first — the GUI needs an instance fx.show_gui(); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#show_gui --- Effect.supports_gui [method] fn supports_gui() -> Boolean Returns whether this effect supports a graphical user interface. Built-in DSP effects always return `false`. CLAP and VST3 plugins return `true` if the plugin provides a GUI. Backends: all (DSP always returns false). Returns: Boolean — `true` if `show_gui()` will open a window ```resonon drums.effect("delay").supports_gui(); // => false, for a built-in DSP effect drums.effect("room").supports_gui(); // => true, for a placed plugin ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#supports_gui --- EffectParam [class] class EffectParam A parameter of an effect, obtained via `effect.parameter("name")`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effectparam --- Event [class] class Event A single note with pitch, velocity, and timing. The track's output picks the MIDI channel it plays on. Obtained from pattern iterators or event queries. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#event --- Event.detune [method] fn detune(cents: Number) -> Event Returns a new event detuned by the given number of cents (100 = one semitone). Parameters: cents: Number — cent offset (positive = up, negative = down) Returns: Event — a new detuned event Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#detune --- Event.duration [method] fn duration() -> Number Returns the duration in cycles. Returns: Number — the duration in cycles Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#duration-1 --- Event.end [method] fn end() -> Number Returns the end time (start + duration). Returns: Number — the end time in cycles (start + duration) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#end --- Event.note [method] fn note() -> Number Returns the MIDI note number. Returns: Number — the MIDI note number Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#note --- Event.ratio [method] fn ratio(ratio: Number) -> Event Returns a new event with its note's frequency scaled by the given ratio. Multiplying frequency by ratio adds 12*log2(ratio) semitones; ratio must be > 0. Parameters: ratio: Number — frequency ratio (must be > 0) Returns: Event — a new event with the scaled note Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#ratio --- Event.start [method] fn start() -> Number Returns the start time in cycles. Returns: Number — the start time in cycles Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#start --- Event.transpose [method] fn transpose(semitones: Number) -> Event Returns a new event transposed by the given number of semitones. Parameters: semitones: Number — semitone offset (positive = up, negative = down) Returns: Event — a new transposed event Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#transpose --- Event.velocity [method] fn velocity() -> Number Returns the velocity the note plays at (1-127). Returns: Number — the velocity (1-127) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#velocity-1 --- Extend [enum] enum Extend { hold, zero, repeat, mirror } What is read beyond the image edges: TD's Extend menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#extend --- Filter [function] fn Filter(name: String, type: FilterType? = NUL, cutoff: Number? = NUL, resonance: Number? = NUL, gain: Number? = NUL) -> Effect Creates a filter effect: one state-variable filter whose Type chooses the response, as Live's Auto Filter does. Parameters: name: String — slot name (identity in a track's effect chain) type: FilterType? (optional) — the response (default: FilterType.lowpass) cutoff: Number? (optional) — cutoff frequency in Hz; the center of a band or a bell resonance: Number? (optional) — resonance (Q) gain: Number? (optional) — gain at the cutoff in dB; only `FilterType.peak` uses it Returns: Effect — a built-in filter ```resonon drums.set_effects(#[Filter("lp", FilterType.lowpass, 800)]); bass.set_effects(#[Filter("bell", FilterType.peak, 250, 1.0, -6)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#filter --- FilterType [enum] enum FilterType { lowpass, highpass, bandpass, notch, allpass, peak } The response of a `Filter`: the steps of its Type parameter, in order. Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#filtertype --- Format [class] class Format A value with a canonical source form. The native source printer covers numbers, strings, arrays, dicts, notes, clip notes and clips. Only built-in types have a source form. User classes cannot add one yet. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#format --- INV_SR [dsp-builtin] INV_SR: Number Inverse sample rate (1.0 / SR). Useful for phase increment calculations. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#inv_sr --- Instrument [function] fn Instrument(name: String, plugin_id: String? = NUL) -> PluginInstrument Describes an instrument plugin (CLAP or VST3). Loading happens when a track places it. The plugin name is resolved against the installed bundles immediately, so a typo fails here — but nothing is opened: `track.set_instrument(...)` is what loads and activates the plugin, and a re-execute that keeps the live instrument loads nothing at all. Searches CLAP plugins first, then VST3. File extensions are added automatically. Parameters: name: String — plugin name or full path (e.g. "Surge XT") plugin_id: String? — plugin ID, auto-detected if only one plugin in bundle (optional) Returns: PluginInstrument — the instrument plugin, to place with `track.set_instrument(...)` An instrument: what a track plays its notes through. A plugin (`PluginInstrument`), a `dsp instrument` (`DspInstrument`) and the samplers (`Sampler`, `SamplerMelodic`) are each one, and `track.set_instrument()` takes any of them. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#instrument-2 --- Instrument.name [method] fn name() -> String Returns the instrument's name: a plugin's as written before placement and as the live instrument reports it after, a `dsp instrument`'s definition name, a sampler's kit name. Returns: String — the instrument name Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#name-2 --- Instrument.parameter [method] fn parameter(name: String) -> InstrumentParam Returns a parameter reference by name. Parameters: name: String — parameter name (e.g. "Cutoff", "Mix", "gain") Returns: InstrumentParam — a parameter reference with .get(), .set(), .set_norm() Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameter-2 --- Instrument.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList of the instrument's parameters. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameters-4 --- Instrument.set_parameter [method] fn set_parameter(name: String, value: Number) -> Instrument Sets a parameter value by name. Parameters: name: String — parameter name (e.g. "Cutoff", "Mix") value: Number — new value in the parameter's native range Returns: Instrument — the instrument, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_parameter-2 --- InstrumentParam [class] class InstrumentParam A parameter of an instrument, obtained via `instrument.parameter("name")`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#instrumentparam --- Iterator [class] class Iterator Lazy sequence of values with chainable transformations. Obtain from .iter() on arrays, strings, or patterns. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#iterator --- Iterator.all [method] fn all(func: Function) -> Boolean Returns true if all elements match the predicate. Parameters: func: Function — fn(element) -> bool Returns: Boolean — true if every element matches Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#all --- Iterator.any [method] fn any(func: Function) -> Boolean Returns true if any element matches the predicate. Parameters: func: Function — fn(element) -> bool Returns: Boolean — true if at least one element matches Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#any --- Iterator.chain [method] fn chain(other: Iterator) -> Iterator Chains another iterator after this one. Parameters: other: Iterator — iterator to append Returns: Iterator — a lazy iterator over both in sequence Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#chain --- Iterator.collect [method] fn collect() -> Array Collects all remaining elements into an array. Returns: Array — the remaining elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#collect --- Iterator.count [method] fn count() -> Number Counts remaining elements (consumes the iterator). Returns: Number — the count of remaining elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#count --- Iterator.enumerate [method] fn enumerate() -> Iterator Returns a lazy iterator yielding [index, value] pairs. Returns: Iterator — a lazy iterator of `[index, value]` pairs Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#enumerate --- Iterator.filter [method] fn filter(func: Function) -> Iterator Returns a lazy iterator yielding the elements that match the predicate. Parameters: func: Function — fn(element) -> bool Returns: Iterator — a lazy iterator of matching elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#filter-3 --- Iterator.find [method] fn find(func: Function) -> Any Returns the first element matching the predicate, or `NUL`. Parameters: func: Function — fn(element) -> bool Returns: Any — the first matching element, or `NUL` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#find --- Iterator.first [method] fn first() -> Any Returns the first element, or `NUL` if empty. Returns: Any — the first element, or `NUL` if empty Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#first --- Iterator.flatten [method] fn flatten() -> Array Flattens nested arrays into a single array. Returns: Array — the flattened elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#flatten --- Iterator.fold [method] fn fold(initial: Any, func: Function) -> Any Folds the iterator to a single value. Parameters: initial: Any — starting accumulator value func: Function — fn(accumulator, element) -> new_accumulator Returns: Any — the final accumulated value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#fold-1 --- Iterator.last [method] fn last() -> Any Returns the last element, or `NUL` if empty. Warning: consumes the entire iterator; hangs on infinite iterators. Returns: Any — the last element, or `NUL` if empty Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#last --- Iterator.map [method] fn map(func: Function) -> Iterator Returns a lazy iterator applying a function to each element. Parameters: func: Function — fn(element) -> new_element Returns: Iterator — a lazy iterator of transformed elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#map-3 --- Iterator.next [method] fn next() -> Any Returns the next value, or `NUL` if exhausted. Returns: Any — the next value, or `NUL` if exhausted Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#next --- Iterator.skip [method] fn skip(n: Number) -> Iterator Returns a lazy iterator that skips the first n elements. Parameters: n: Number — number of elements to skip Returns: Iterator — a lazy iterator past the first `n` elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#skip --- Iterator.step_by [method] fn step_by(step: Number) -> Iterator Returns a lazy iterator yielding every nth element. Parameters: step: Number — take every nth element Returns: Iterator — a lazy iterator over every `step`-th element Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#step_by --- Iterator.take [method] fn take(n: Number) -> Iterator Returns a lazy iterator yielding the first n elements. Parameters: n: Number — maximum number of elements to yield Returns: Iterator — a lazy iterator over the first `n` elements Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#take --- Iterator.zip [method] fn zip(other: Iterator) -> Iterator Zips this iterator with another, yielding [a, b] pairs. Parameters: other: Iterator — iterator to zip with Returns: Iterator — a lazy iterator of `[a, b]` pairs Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#zip --- Json [class] class Json A value with a JSON form: `to_json()` writes what `json()` returns in its place. A class implements it by defining `json()`, returning plain data or other `Json` values: ```resonon class Point implements Json { let x; let y; fn new(x, y) { this.x = x; this.y = y; } fn json() -> Any { return #[this.x, this.y]; } } assert to_json(#{"at": Point(1, 2)}) == "{\"at\":[1,2]}"; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#json --- Json.json [method] fn json() -> Any Returns the value that stands for this one in JSON: what `to_json()` writes in its place. A track returns its name. A key returns its root, as a note name and a MIDI note number, its scale's name, its intervals in semitones and the period they repeat in. A Note returns {name, note}, a Scale {name, intervals, period}, and a Duration {length, unit}, with unit cycles, beats or seconds. Devices return {name, backend, id}: their name, backend (dsp/CLAP/VST3) and device identity. Returns: Any — plain data, or other `Json` values ```resonon assert session.create_track("drums").json() == "drums"; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#json-2 --- Key [class] fn Key(root: Note, name: String | Scale) -> Key A Key — a Scale rooted at a note, for scale-relative composition. All rooted operations (degrees, diatonic chords, quantize) live here. Construct with `Key(root, name)` or `Key(root, scale)`. Access the underlying Scale with `k.scale`, the root with `k.root`, and the scale name with `k.name`. Examples: `Key(D4, "dorian")` or `Key(D4, Scale(#[0, 2, 3.5, 5, 7, 8.5, 10]))`. Creates a Key value for scale-relative composition. Methods: degree(n), chord(deg), chord7(deg), notes(), quantize(note), transpose(semitones). Parameters: root: Note — root note (e.g. D4, or a MIDI number such as 62) name: String | Scale — scale name (see scale_names()) or a Scale value Returns: Key — the constructed key Examples: `Key(D4, "dorian")` or `Key(D4, Scale(#[0, 2, 3, 5, 7, 9, 10]))`. Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#key --- Key.chord [method] fn chord(deg: Number, quality: String | Number? = NUL, inv: Number? = NUL) -> Array Returns a chord (array of Notes) built on the given scale degree. With only `deg`: the diatonic triad. The optional second argument is either a chord-quality String (e.g. "min7") or an inversion Number. A third argument adds an inversion to an explicit quality. Parameters: deg: Number — scale degree (1-indexed, >= 1) quality: String | Number? — chord quality String, OR an inversion Number (optional) inv: Number? — inversion to apply when `quality` is given (optional) Returns: Array — the chord as an array of Notes Examples: `k.chord(1)`, `k.chord(1, 1)`, `k.chord(1, "min7")`. Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#chord --- Key.chord7 [method] fn chord7(deg: Number, inv: Number? = NUL) -> Array Returns a diatonic 7th chord (4 Notes) on the given scale degree. Parameters: deg: Number — scale degree (1-indexed, >= 1) inv: Number? — inversion to apply (optional) Returns: Array — the 7th chord as an array of four Notes Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#chord7 --- Key.degree [method] fn degree(n: Number) -> Note Returns the Note at the given scale degree. Degrees are 1-indexed; degrees > scale length wrap up an octave. Non-positive degrees go below the root: 0 = one step below, -1 = two below. Parameters: n: Number — scale degree (1 = root, 5 = fifth, 8 = root + octave, etc.) Returns: Note — the note at that scale degree Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#degree --- Key.notes [method] fn notes() -> Array Returns one octave of the key's scale as an array of Notes (rooted). Returns: Array — one octave of the scale as rooted Notes Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#notes --- Key.quantize [method] fn quantize(note: Note) -> Note Snaps a note to the nearest tone in this key's scale. Parameters: note: Note — the note to quantize (e.g. C4, or a MIDI number such as 60) Returns: Note — the nearest in-scale note Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#quantize --- Key.transpose [method] fn transpose(semitones: Number) -> Key Returns a new Key with the root shifted by the given semitones. Parameters: semitones: Number — semitones to shift (positive or negative) Returns: Key — a new key with the shifted root Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#transpose --- Kit [class] fn Kit(kit_name: String? = NUL) -> Kit A drum kit's metadata: its samples, the notes they sit on and their files. Construct with `Kit(name)`; pass it to `Sampler()` or `SamplerMelodic()`. Loads kit metadata (samples, notes, files) without creating a plugin. Parameters: kit_name: String? — name of the kit (optional, defaults to "CR-78") Returns: Kit — kit metadata, inspectable or passable to Sampler()/SamplerMelodic() Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#kit --- Kit.author [method] fn author() -> String Returns the kit's author. Returns: String — the author, or an empty string when none is given Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#author --- Kit.mode [method] fn mode() -> String Returns how the kit plays: "oneshot" or "melodic". Returns: String — the playback mode Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#mode --- Kit.name [method] fn name() -> String Returns the kit's display name. Returns: String — the name from the kit's metadata Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#name --- Kit.sample_info [method] fn sample_info() -> Array> Returns each sample with its note and file, sorted by note. Returns: Array — one `[name, note, file]` array per sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample_info --- Kit.samples [method] fn samples() -> Array Returns the kit's sample names. Returns: Array — one String per sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#samples-1 --- LaneLayer [class] class LaneLayer One named layer of a lane, from `.layer(name)` on any lane. `<<` replaces the layer's contents; `.at(start, duration) << ...` masks a span. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#lanelayer --- LaneLayer.at [method] fn at(start: Number, duration: Number) -> TimelineSlot | SectionParam | SectionVisual Addresses a span of this layer for a `<<` write. Parameters: start: Number — where the span begins, in cycles (>= 0, before the end) duration: Number — how long it lasts, in cycles (> 0) Returns: TimelineSlot | SectionParam | SectionVisual — a handle to the span, of the lane's own kind Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#at --- LaneLayer.clear [method] fn clear() -> LaneLayer Drops every entry on this layer. Returns: LaneLayer — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear --- LaneLayer.mute [method] fn mute() -> LaneLayer Silences the whole layer without destroying it. Returns: LaneLayer — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mute-1 --- LaneLayer.unmute [method] fn unmute() -> LaneLayer Brings a muted layer back. Returns: LaneLayer — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#unmute-1 --- Lookup [function] fn Lookup(name: String) -> Visual A lookup visual: TouchDesigner's Lookup TOP. It replaces the colours of its primary input (set via `src >> Lookup("…")`, the index) with colours from a lookup table: a line across the image in the `table` slot (`l.parameter("table") << ramp`), from `dark_u`, `dark_v` to `light_u`, `light_v`. By default the line runs across the middle of the table, so a `Ramp("…")` makes a palette: an index of 0 takes the colour at its left, 1 the colour at its right. As in TD, the index range maps `index_start` to the dark end and `index_end` to the light end and holds beyond them; reversed, it reverses the table. The table is the line read at as many points as the table image is pixels wide or high, whichever is more, and the lookup blends between neighbouring points. With `output_lookup` at 1 it draws the table itself, left to right. Checked against TD's float exports: within one 8-bit filter step on every probe. The table image is the size of the screen, where TD's has its own size. TD's CHOP method is left out: visuals take no CHOPs. The alpha is 1, where TD's is the table's. Parameters: name: String — the operator's name; its identity on screen Inputs: table — the image to take the lookup table from, e.g. a `Ramp("…")` Uniforms: index_channel — how the index picks from the table a `LookupChannel` (default rgba_independent) index_start — the index at the dark end of the table (default 0) index_end — the index at the light end of the table (default 1) dark_u — the dark end across, in `dark_unit`s (default 0) dark_v — the dark end up, in `dark_unit`s (default 0.5) dark_unit — the unit of `dark_u` and `dark_v`, a `Unit` (default fraction) light_u — the light end across, in `light_unit`s (default 1) light_v — the light end up, in `light_unit`s (default 0.5) light_unit — the unit of `light_u` and `light_v`, a `Unit` (default fraction) output_lookup — 1 draws the table, 0 looks the image up in it (default 0) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#lookup --- LookupChannel [enum] enum LookupChannel { luminance, red, green, blue, alpha, rgb_average, rgba_average, rgb_maximum, rgba_maximum, rgba_independent } How a `Lookup` index colour picks from the table: TD's Lookup Index Channel menu. Every choice but `rgba_independent` gives each channel the same point. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#lookupchannel --- LumaLevel [function] fn LumaLevel(name: String) -> Visual A luma-level visual: TouchDesigner's Luma Level TOP. It sets the levels of the luminance of its primary input (set via `src >> LumaLevel("…")`) and scales each pixel's colour with it, so hue and saturation hold. As in TD, the luminance (0.3 R + 0.6 G + 0.1 B), clamped to 0..1, goes through `invert`, then `black_level`, then `brightness` (clamped to 1), then `gamma`, then `contrast` (not clamped). Black stays black. Fixed at TD's defaults: Source luminance and the Range, Step and Post pages. The alpha is 1. Parameters: name: String — the operator's name; its identity on screen Uniforms: invert — mix towards the inverted luminance, 0..1 (default 0) black_level — luminance at or below this goes to black (default 0) brightness — luminance gain (default 1) gamma — gamma correction; above 1 lifts the dark tones (default 1) contrast — gain about mid-grey (default 1) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#lumalevel --- Master [class] class Master The master output bus. Always present, cannot be deleted. Has its own effect chain and fader (volume/pan). Reached through `session.master`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#master --- Master.effect [method] fn effect(name: String) -> Effect Returns a modulatable handle to an effect by its slot name. Parameters: name: String — slot name of the effect Returns: Effect — the effect with that slot name Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effect --- Master.effects [method] fn effects() -> Array Returns an array of all effects in chain order. Returns: Array — the effects in chain order Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effects-1 --- Master.output [method] fn output() -> String Returns the selected hardware output, as Output(channel) or Output(left, right). Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#output-1 --- Master.pan [method] fn pan() -> Number Returns the master pan setting, from -1 to 1. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#pan-1 --- Master.set_effects [method] fn set_effects(effects: Array) -> Master Declaratively sets the whole effect chain, reconciling the live graph. The chain is made to match the given list exactly — inserting new slots, removing absent ones, and reordering to match. Slot identity is the effect's name (its required leading constructor argument): a kept slot preserves its live instance, so its running modulation survives. Constructor args are parameter writes: a freshly executed `Filter("lp", FilterType.lowpass, 12000)` sets the kept slot's cutoff, as it would a new one's — the last write executed wins. Args left out write nothing, and re-placing a bound handle writes nothing either, so a value tweaked since survives. Names must be unique. Passing an empty array clears the chain. A kept slot costs nothing to re-declare: the chain is planned against the live graph first, so no plugin is loaded and no dsp effect compiled for a slot that is being preserved. Editing a dsp effect body is handled without losing the slot — the recompiled graph is crossfaded into the live instance, so the edit is audible while the slot's parameter values, modulation and sidechain connections carry over. An edit that changes the parameter set has nowhere to carry them, so it rebuilds the slot. Parameters: effects: Array — the effects, in the desired chain order Returns: Master — the master bus, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_effects-1 --- Master.set_pan [method] fn set_pan(value: Number) -> Master Sets master pan. Clears any existing pan modulation. Parameters: value: Number — pan position (-1.0 = hard left, 0.0 = center, 1.0 = hard right) Returns: Master — the master bus, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_pan-1 --- Master.set_volume [method] fn set_volume(value: Number) -> Master Sets master volume. Clears any existing volume modulation. Parameters: value: Number — volume in dB (0 = unity, -70 = mute, +6 = max boost) Returns: Master — the master bus, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_volume-1 --- Master.volume [method] fn volume() -> Number Returns the master fader setting in dB. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#volume-1 --- MasterParam [class] class MasterParam The master bus fader, `session.master.volume` (in dB) or `session.master.pan`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#masterparam --- MeterFeed [class] class MeterFeed A live level from a track or the master: `track.rms`, `track.peak`, or a band of a spectrum (`session.master.fft.band(lo, hi)`). Bind it to a visual parameter with `<<`. `rms` and `peak` are linear amplitude, read after the fader: 1.0 is full scale (0 dBFS) and a clipping signal reads above 1. The value is the mean of the left and right channels. A band is the average magnitude of the spectrum bins in that range. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#meterfeed --- MeterFeed.get [method] fn get() -> Number Reads the session's display meter level at evaluation time, with the mixer's ballistics: the peak holds the highest value and falls back, the RMS rises and falls smoothly. So one read is what the meter shows at that instant, not a measurement over a time window. It never waits. Returns 0 without a live session. Range mapping applies; smoothing describes the visual binding only. Returns: Number — the current displayed level, linear (1.0 is 0 dBFS) before any range mapping Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#get --- MeterFeed.range [method] fn range(min: Number, max: Number) -> MeterFeed Maps the 0-to-1 level linearly onto [min, max]. Parameters: min: Number — value at a level of 0 max: Number — value at a level of 1 Returns: MeterFeed — a new feed with that range Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#range --- MeterFeed.smooth [method] fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> MeterFeed Smooths the level so it glides instead of strobing. With one time the rise and the fall are equal; give two for a separate release. Parameters: attack_ms: Number — rise time in milliseconds (>= 0) release_ms: Number? — fall time in milliseconds (>= 0; omit to match attack) Returns: MeterFeed — a new feed with that smoothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#smooth --- MidiLatency [enum] enum MidiLatency { auto, manual } How outgoing MIDI is aligned with the audio output. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midilatency --- MidiOutput [class] fn MidiOutput(alias: String, channel: Number? = NUL) -> MidiOutput MidiOutput: a MIDI output port and channel, a destination for `>>` — Live's "MIDI To". Made by `MidiOutput(alias, channel)`; it can only end a `>>` chain. A MIDI output port and channel, as a destination for `>>` — Live's "MIDI To". `track >> MidiOutput("synth", 2)` sends the track there; a playing pattern, its CC and its input thru move from the next cycle, with no `<<` needed. `track >> session.nowhere` sets it back to no output. Parameters: alias: String — output port alias, as a `[[midi.outputs]]` entry declares it channel: Number? — MIDI channel 1-16 (optional; default 1) Returns: MidiOutput — the port and channel, to route to with `>>` Examples: `bass >> MidiOutput("synth")`, `lead >> MidiOutput("daw", 2)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midioutput --- MidiTrack [class] class MidiTrack A MIDI track: plays patterns and CC to a hardware or virtual MIDI port. Create with `session.create_midi_track("name")` in `fn setup()`; look it up with `session.midi_track("name")`. Choose its output with `>>`, as in `track >> MidiOutput("synth", 2)`. A new track has no output until then. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#miditrack --- MidiTrack.add_solo [method] fn add_solo() -> MidiTrack Adds the track to the soloed tracks and keeps the others soloed, as a Cmd-click on Live's Solo button. Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#add_solo --- MidiTrack.cc [method] fn cc(cc_number: Number) -> CcOutput Get a CC output handle for the given controller number. Use `<<` to assign values, patterns, or signals. Parameters: cc_number: Number — CC controller number (0-127) Returns: CcOutput — a CC output handle, assignable with `<<` Examples: `track.cc(74) << Sine(0.5).range(0, 127)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#cc --- MidiTrack.color [method] fn color() -> Number The track colour. A new track takes the next free palette colour. Returns: Number — palette index from 0 to 23 Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#color --- MidiTrack.delete [method] fn delete() -> NUL Deletes the track and disconnects its input and output. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#delete --- MidiTrack.input [method] fn input() -> Dict? The input port and channel (NUL for all channels), or NUL when unset. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#input --- MidiTrack.is_muted [method] fn is_muted() -> Boolean Returns whether the track is muted. Returns: Boolean — true if the track is muted Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#is_muted --- MidiTrack.is_soloed [method] fn is_soloed() -> Boolean Returns whether the track is soloed. Returns: Boolean — true if the track is soloed Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#is_soloed --- MidiTrack.key [method] fn key() -> Key? The track key, or NUL when unset. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#key --- MidiTrack.monitor [method] fn monitor() -> Monitor The input monitoring mode. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#monitor --- MidiTrack.mpe [method] fn mpe() -> Dict? The MPE range and member channel bounds, or NUL when disabled. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#mpe --- MidiTrack.mute [method] fn mute() -> MidiTrack Mutes the track, like Live's Track Activator: its notes and CC stop at once, and the notes it holds get their note-offs. MIDI coming in through the track is muted too. Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#mute --- MidiTrack.name [method] fn name() -> String The track name. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#name --- MidiTrack.output [method] fn output() -> Dict? The output port and channel, or NUL for no output. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#output --- MidiTrack.set_color [method] fn set_color(index: Number) -> MidiTrack Sets the track colour. It shows on the track's header, clips and Mixer strip. Parameters: index: Number — palette index from 0 to 23: 12 bright hues, then the same muted Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_color --- MidiTrack.set_input [method] fn set_input(alias: String, channel: Number? = NUL) -> MidiTrack Set the MIDI input port and optional channel. Parameters: alias: String — input port alias, as a `[[midi.inputs]]` entry declares it, or `"all"` for every input channel: Number? — MIDI channel 1-16 (optional) Returns: MidiTrack — the track, for chaining Examples: `track.set_input("keys")`, `track.set_input("keys", 1)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_input --- MidiTrack.set_key [method] fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> MidiTrack Set a track-level key for degree resolution and auto-quantization. Degrees (^1, ^2, ...) resolve from this key without .in_key(), and absolute notes are quantized to the nearest scale tone. A change is heard from the next cycle, on a pattern already playing. Pass a Key value, or a scale name/Scale with a root note. Parameters: scale: Key | String | Scale — a Key value, or a scale name/Scale value root: Note? — root note (e.g. C4, or a MIDI number such as 60); omit when passing a Key Returns: MidiTrack — the track, for chaining Examples: `track.set_key(Key(C4, "minor"))` or `track.set_key("minor", C4)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_key --- MidiTrack.set_monitor [method] fn set_monitor(mode: Monitor) -> MidiTrack Set the monitor mode: whether what is played on the input passes through to the output. `Monitor.auto` passes it while the track is not playing its own material: the transport is stopped, or it has no pattern. Parameters: mode: Monitor — when the input passes through Returns: MidiTrack — the track, for chaining Examples: `track.set_monitor(Monitor.input)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_monitor --- MidiTrack.set_mpe [method] fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> MidiTrack Enable MPE (per-note channel allocation) for polyphonic microtonal output. Parameters: range: Number? — pitch-bend range in semitones (optional, defaults to 48) zone_lo: Number? — low member channel (optional, defaults to 2) zone_hi: Number? — high member channel (optional, defaults to 16) Returns: MidiTrack — the track, for chaining Examples: `track.set_mpe()`, `track.set_mpe(24)`, `track.set_mpe(48, 2, 9)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_mpe --- MidiTrack.set_name [method] fn set_name(name: String) -> MidiTrack Changes the track name. Existing handles keep following this track. Parameters: name: String — unique track name Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_name --- MidiTrack.set_tuning [method] fn set_tuning(bend_range: Number? = NUL) -> MidiTrack Enable microtonal pitch bend output. Uses the MIDI default ±2 semitone range (works with any synth). Parameters: bend_range: Number? — pitch-bend range in semitones (optional; default ±2) Returns: MidiTrack — the track, for chaining Examples: `track.set_tuning()`, `track.set_tuning(48)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_tuning --- MidiTrack.set_velocity [method] fn set_velocity(vel: Number | Signal | Pattern) -> MidiTrack Set the default velocity for this track. A new track plays at 100. A note with its own velocity keeps it. Parameters: vel: Number | Signal | Pattern — note velocity (1-127), or a signal or pattern read as each note fires; a value from a signal or pattern is held to 1-127 Returns: MidiTrack — the track, for chaining Examples: `track.set_velocity(80)` or `track.set_velocity([100 60 80 120])` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_velocity --- MidiTrack.solo [method] fn solo() -> MidiTrack Solos the track, and only this track: every other solo is released and every other track — audio and MIDI — falls silent, as a plain click on Live's Solo button. Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#solo --- MidiTrack.tuning [method] fn tuning() -> Number? The pitch-bend range in semitones, or NUL when disabled. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#tuning --- MidiTrack.unmute [method] fn unmute() -> MidiTrack Unmutes the track. Its pattern is heard again from its next note. Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#unmute --- MidiTrack.unsolo [method] fn unsolo() -> MidiTrack Releases the track's solo. When no track is soloed, every track is heard. Returns: MidiTrack — the track, for chaining Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#unsolo --- MidiTrack.velocity [method] fn velocity() -> Number | Signal | Pattern The configured velocity source; 100 until `set_velocity` changes it. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#velocity --- Monitor [enum] enum Monitor { off, input, auto } When a track's input is heard: Live's Monitor In / Auto / Off. Shared by `AudioTrack.set_monitor` and `MidiTrack.set_monitor`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#monitor --- Noise [function] fn Noise(name: String) -> Visual A noise generator: TouchDesigner's Noise TOP with type Simplex 3D, monochrome, aspect corrected, alpha one. The field is static; animate it by binding the translate, e.g. `n.parameter("tz") << Time(0.2).set_timebase(seconds(1))`. For the same coordinates it matches TD's field; a seed picks a different field than the same seed does in TD. Parameters: name: String — the operator's name; its identity on screen Uniforms: seed — which field; any number, each gives a different field period — feature size; the longer image side spans 4 / period units, positive harmonics — layers added on top of the base, 0–32, rounded down spread — frequency factor from one layer to the next gain — amplitude factor from one layer to the next exponent — signed power on the sum; above 1 pulls values toward 0 amplitude — weight of the base layer, before the exponent offset — added after the exponent; the midpoint of the output tx — moves the field right, in noise units ty — moves the field up, in noise units tz — moves through the field's third axis, in noise units Returns: Visual — a generator node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#noise --- Note [class] class Note A single MIDI pitch in semitones, fractional for microtonal values. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#note --- Note.detune [method] fn detune(cents: Number) -> Note Returns a new note detuned by the given number of cents (100 = one semitone). Parameters: cents: Number — cent offset (positive = up, negative = down) Returns: Note — a new detuned note Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#detune-1 --- Note.from [method] fn from(n: Number) -> Note A MIDI note number is a Note wherever a Note is asked for: `chord(60, "maj")`, `let n: Note = 60.5`. 60 is C4, and a fraction is microtonal (60.5 is a quarter-tone above C4). Parameters: n: Number — a MIDI note number; it must be finite Returns: Note — the note that number names Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#conversion --- Note.ratio [method] fn ratio(ratio: Number) -> Note Returns a new note with its frequency scaled by the given ratio. Multiplying frequency by ratio adds 12*log2(ratio) semitones; ratio must be > 0. Parameters: ratio: Number — frequency ratio (must be > 0) Returns: Note — a new note scaled by the ratio Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#ratio-1 --- Note.transpose [method] fn transpose(semitones: Number) -> Note Returns a new note transposed by the given number of semitones. Fractional semitones are preserved. Parameters: semitones: Number — semitone offset (positive = up, negative = down) Returns: Note — a new transposed note Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#transpose-1 --- Nowhere [class] class Nowhere Nowhere: a track's output that goes nowhere, `session.nowhere`. It can only end a `>>` chain, and only a track's output can be `session.nowhere`: the master's is always hardware. On an audio track it is Live's "Sends Only": `drums >> session.nowhere` takes the track out of the mix while its sends keep feeding their returns, so a reverb or parallel bus hears it fully wet. `drums >> session.master` puts it back in the mix at unity. On a MIDI track it is Live's "No Output", where a new MIDI track starts: `bass >> session.nowhere` stops it sending. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#nowhere --- Operand [enum] enum Operand { add, difference, maximum, minimum, multiply, over, screen, subtract, subtractive } How a `Composite` combines its inputs A and B: TD's Composite Operation menu. As in TD, no result is clamped: subtract can go below 0 and add above 1. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#operand --- Output [class] fn Output(left: Number, right: Number? = NUL) -> Output Output: hardware output channels of the audio device, a destination for `>>`. Made by `Output(left, right)`; it can only end a `>>` chain. Hardware output channels of the audio device, as a destination for `>>` — a track's output, or master's. Channels count from 0, the same way `set_input()` counts. One channel folds the stereo signal to mono at -3 dB; two are a stereo pair. A channel the device does not have is an error when the output is selected; after a switch to a smaller device, a pair with one channel left folds onto it the same way, and one with none is silent. Parameters: left: Number — the channel, or the left channel of a stereo pair right: Number? — right channel (optional) Returns: Output — the channels, to route to with `>>` Examples: `drums >> Output(2, 3)`, `session.master >> Output(0, 1)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#output --- Overdrive [function] fn Overdrive(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect Creates an overdrive effect (symmetrical/tube-style tanh clipping). Includes a DC-blocking filter before clipping and a one-pole tone filter after. Parameter names, for `parameter()` and `set_parameter()`: `Drive`, `Tone`, `Level`, `Mix`. Parameters: name: String — slot name (identity in a track's effect chain) drive: Number? (optional) — distortion intensity tone: Number? (optional) — post-distortion brightness Returns: Effect — a built-in overdrive effect ```resonon bass.set_effects(#[Overdrive("drive", 0.3, 0.5)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#overdrive --- PI [dsp-builtin] PI: Number Pi (3.14159...) Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#pi --- POSITION [dsp-builtin] POSITION: Number Local position since the signal's anchor, counted in its timebase: cycles unless `.set_timebase()` sets another unit. Available in `dsp signal` blocks only. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#position --- ParamList [class] class ParamList Wraps an array of parameter dicts from `.parameters()`. Prints as an aligned table — Parameter, Value, Text, Range, Default — where Text is the value as the device shows it (`1.20 kHz`), and Range and Default add the device's text where it differs from the number. Provides `.data` for programmatic access; `to_json()` writes it as the array of parameter dicts. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#paramlist --- ParamList.filter [method] fn filter(name: String) -> ParamList Filters parameters by name substring, case-insensitive; returns a new ParamList. Parameters: name: String — substring to match against parameter names Returns: ParamList — a new list of the matching parameters Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#filter --- ParamList.get [method] fn get(index: Number) -> Dict Returns the parameter dict at the given index. Parameters: index: Number — zero-based position Returns: Dict — the parameter entry at `index` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#get-1 --- ParamList.json [method] fn json() -> Array> Returns the parameter dicts, which `to_json()` writes for the list. The title is for the table only. Returns: Array> — one dict per parameter Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#json --- ParamList.length [method] fn length() -> Number Returns the number of parameters. Returns: Number — the parameter count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#length --- Parameter [class] class Parameter A parameter a musician sets, modulates and automates: an effect's or an instrument's, a track's or the master's fader, a send's level. Every one takes a value with `.set()`, a modulation with `<<`, and answers `.get()`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameter --- Parameter.get [method] fn get() -> Number | Variant Gets the parameter's current value. Returns: Number | Variant — the value in the parameter's own range: dB for a volume, -1.0 to 1.0 for a pan, 0.0 to 1.0 for a send; the variant of its enum for a built-in device's stepped parameter (`FilterType.peak`) ```resonon let track = session.create_track("pad"); track.volume.get(); // => 0.0 ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#get-2 --- Parameter.get_norm [method] fn get_norm() -> Number Reads the current parameter as a fraction of its declared range. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#get_norm --- Parameter.set [method] fn set(values: Number | Signal | Pattern | Array | Variant) -> Parameter Sets the parameter's value. Accepts a Number (a static value), a Signal or Pattern (modulation), or `[beat, value]` breakpoint arrays (an automation lane). A built-in device's stepped parameter takes a variant of its enum instead: `FilterType.peak` for a Filter's Type. Parameters: values: Number | Signal | Pattern | Array | Variant — a Number, a Signal, a Pattern, one or more `#[beat, value]` breakpoints, or a variant for a stepped parameter Returns: Parameter — this parameter, for chaining ```resonon let track = session.create_track("pad"); track.volume.set(-6); track.pan.set(Sine(2).range(-0.5, 0.5)); track.volume.set(#[0, -12], #[4, 0]); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set --- Parameter.set_norm [method] fn set_norm(value: Number) -> Parameter Sets the parameter by a fraction of its range. Parameters: value: Number — 0.0 = the minimum, 1.0 = the maximum Returns: Parameter — this parameter, for chaining ```resonon let track = session.create_track("pad"); track.volume.set_norm(0.5); ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_norm --- Parameter.set_text [method] fn set_text(text: String) -> Parameter Sets the parameter from text, as typed into a parameter box: the inverse of `.text()`. A plugin reads the text itself; a built-in effect reads a value in its unit (`"800 Hz"`, `"1.2k"`, `"35 ms"`, `"1.5 s"`, `"-6 dB"`, `"50 %"`), a fader dB or a pan position, a send dB. A number with no unit is in the smallest unit the value shows in: Hz, ms, dB or %. Text the device doesn't read is an error that shows how the parameter reads now. Parameters: text: String — the value as the device shows it: `"800 Hz"`, `"Saw"`, `"-6 dB"`, `"25L"`, `"C"` Returns: Parameter — this parameter, for chaining ```resonon let track = session.create_track("pad"); track.volume.set_text("-6 dB"); track.pan.set_text("25L"); track.pan.get(); // => -0.5 ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_text --- Parameter.text [method] fn text() -> String Gets the parameter's current value as its device shows it. A plugin's parameter reads in the plugin's own text, a built-in effect's in its unit, a fader in dB or as a pan position. A value with no text of its own reads as the number. Returns: String — the value as shown: `"1.20 kHz"`, `"35.0 ms"`, `"Saw"`, `"-6.0 dB"`, `"25L"`, `"C"` ```resonon let track = session.create_track("pad"); track.volume.set(-6); track.volume.text(); // => "-6.0 dB" track.pan.text(); // => "C" ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#text --- Pattern [class] class Pattern A MIDI note pattern for sequencing. Construct with `Sequence(...)`, `Stack(...)`, `Alternating(...)`, mini-notation, or pattern combinators. A class that implements `Pattern` is a pattern too: it defines `query(cycle)` and has every combinator. A combinator, `<<` or a parameter that takes a Pattern plays the instance as its fields are at that moment. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#pattern --- Pattern.at [method] fn at(index: Number) -> Pattern Returns the element at the given index (for indexable patterns). Parameters: index: Number — zero-based position Returns: Pattern — the sub-pattern at `index` Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#at --- Pattern.concat [method] fn concat(other: Pattern | Note | Array) -> Pattern Concatenates this pattern with another sequentially. Parameters: other: Pattern | Note | Array — pattern to append; a note or an array of notes plays as a sequence Returns: Pattern — the concatenated pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#concat --- Pattern.degrade [method] fn degrade(probability: Number | Pattern) -> Pattern Randomly removes events with the given probability. Parameters: probability: Number | Pattern — chance of removing each event (0.0-1.0), or a pattern of them Returns: Pattern — the degraded pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#degrade --- Pattern.describe [method] fn describe() -> String Returns a string description of the pattern structure. Returns: String — a human-readable description of the pattern structure Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#describe --- Pattern.elements [method] fn elements() -> Array Returns sub-patterns as an array. Sequence/Alternating: individual element patterns. Stack/Cat: layer patterns. Combinators: the wrapped source pattern. Generative: empty array. Returns: Array — the sub-patterns (empty for generative patterns) Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#elements --- Pattern.euclid [method] fn euclid(hits: Number, steps: Number, rotation: Number? = NUL) -> Pattern Applies a Euclidean rhythm to the pattern. Parameters: hits: Number — number of events to distribute steps: Number — total steps in the rhythm rotation: Number? — offset rotation (optional, defaults to 0) Returns: Pattern — the pattern with the Euclidean rhythm applied, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#euclid --- Pattern.fast [method] fn fast(factor: Number | Pattern) -> Pattern Speeds up the pattern by the given factor. Parameters: factor: Number | Pattern — speed multiplier from 0.0001 to 10000 (> 1.0 = faster), or a pattern of them; a step outside that range, or a rest, silences that cycle Returns: Pattern — the sped-up pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#fast --- Pattern.humanize [method] fn humanize(amount: Number | Pattern) -> Pattern Adds slight random timing variations for human feel. Parameters: amount: Number | Pattern — maximum offset, as a fraction of each event's step, or a pattern of them Returns: Pattern — the humanized pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#humanize --- Pattern.in_key [method] fn in_key(key: Key) -> Pattern Resolves degree elements (^N, ^N:quality) to MIDI notes using a Key. MIDI and sample pitches pass through unchanged. Parameters: key: Key — the key to resolve degrees against (e.g. Key(D4, "dorian")) Returns: Pattern — the pattern with degrees resolved to notes, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#in_key --- Pattern.iter [method] fn iter() -> Iterator Returns an infinite iterator over pattern events. Returns: Iterator — an infinite iterator over the pattern's events Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#iter --- Pattern.kind [method] fn kind() -> String Returns the concrete pattern kind ("Sequence", "Stack", "Fast", etc.). Returns: String — the concrete pattern kind Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#kind --- Pattern.length [method] fn length() -> Number Returns the number of events in cycle 0. Returns: Number — the event count in cycle 0 Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#length --- Pattern.map [method] fn map(func: Function) -> Pattern Transforms each event using a function. The function receives the note value as a local variable. Parameters: func: Function — fn(note) -> new_note Returns: Pattern — the transformed pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#map --- Pattern.map_with_timing [method] fn map_with_timing(func: Function) -> Pattern Transforms events with timing information. Parameters: func: Function — fn(note, start, duration) -> new_note Returns: Pattern — the transformed pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#map_with_timing --- Pattern.nudge [method] fn nudge(offsets: Number | Array | Pattern) -> Pattern Shifts individual events by per-event offsets. Parameters: offsets: Number | Array | Pattern — offsets as a fraction of each event's step: one for every event, one per event, or a pattern of them Returns: Pattern — the nudged pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#nudge --- Pattern.quantize [method] fn quantize(key: Key) -> Pattern Snaps all MIDI pitches to the nearest tone in the key's scale. Parameters: key: Key — the key whose scale pitches are snapped to Returns: Pattern — the quantized pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#quantize --- Pattern.query [method] fn query(cycle: Number) -> Note | Number | Rest | Array | Pattern? Returns what the pattern plays in one cycle. Parameters: cycle: Number — the cycle to play, counting from 0 Returns: Note | Number | Rest | Array | Pattern? — the cycle's notes: a Note or MIDI note number, an Array of them, a Pattern, or a Rest or NUL for silence ```resonon class Rise implements Pattern { fn query(cycle) -> Note | Number | Rest | Array | Pattern? { return 60 + cycle % 12; } } ``` Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#query --- Pattern.reverse [method] fn reverse() -> Pattern Reverses the pattern playback order. Returns: Pattern — the reversed pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#reverse --- Pattern.rotate [method] fn rotate(steps: Number) -> Pattern Rotates the pattern by the given number of steps. Parameters: steps: Number — number of positions to rotate Returns: Pattern — the rotated pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#rotate --- Pattern.slow [method] fn slow(factor: Number | Pattern) -> Pattern Slows down the pattern by the given factor. Parameters: factor: Number | Pattern — speed divisor from 0.0001 to 10000 (> 1.0 = slower), or a pattern of them; a step outside that range, or a rest, silences that cycle Returns: Pattern — the slowed-down pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#slow --- Pattern.stack [method] fn stack(other: Pattern | Note | Array) -> Pattern Stacks this pattern with another (polyphonic layering). Parameters: other: Pattern | Note | Array — pattern to layer on top; a note or an array of notes plays as a sequence Returns: Pattern — the combined polyphonic pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#stack --- Pattern.swing [method] fn swing(amount: Number | Pattern, grid: Number) -> Pattern Delays every second slot of a grid, like a drum machine's swing: whatever plays on the off-beat 8th or 16th plays late, and what plays on the beat stays. A stack of drums swings as one groove. Notes between grid lines move with their pair and keep their order. Parameters: amount: Number | Pattern — how late the second slot plays, as a fraction of a slot: 0 is straight, 0.33 a triplet feel, 0.5 dotted; or a pattern of them, one per cycle grid: Number — slots per cycle, an even number from 2 to 1024: 8 swings 8ths, 16 swings 16ths Returns: Pattern — the swung pattern, for chaining Examples: `[bd*4, _ cp _ cp, ch*16].swing(0.1, 16)` swings the hats; kicks and claps stay. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#swing --- Pattern.transpose [method] fn transpose(semitones: Number | Pattern) -> Pattern Transposes all notes by the given number of semitones. Parameters: semitones: Number | Pattern — semitone offset (positive = up, negative = down), or a pattern of them Returns: Pattern — the transposed pattern, for chaining Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#transpose --- Perlin [function] fn Perlin(freq: Number | Signal = 1) -> Signal Unipolar Perlin noise signal (0 to 1). Smooth, continuous. Parameters: freq: Number | Signal — noise rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar Perlin-noise control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#perlin --- PlateReverb [function] fn PlateReverb(name: String, size: Number? = NUL, damping: Number? = NUL, diffusion: Number? = NUL, predelay: Number? = NUL, mix: Number? = NUL) -> Effect Creates a plate reverb effect (Dattorro algorithm). Parameters: name: String — slot name (identity in a track's effect chain) size: Number? (optional) — tank size damping: Number? (optional) — high-frequency damping diffusion: Number? (optional) — diffusion amount predelay: Number? (optional) — pre-delay time in seconds (default: 0.0, range: 0.0–0.1) mix: Number? (optional) — dry/wet mix Returns: Effect — a built-in plate reverb effect ```resonon drums.set_effects(#[PlateReverb("plate", 0.7, 0.3, 0.8)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#platereverb --- PluginInstrument [class] class PluginInstrument A plugin instrument, CLAP or VST3, from `Instrument("Surge XT")`. An instrument is a **symbolic handle**. A constructor describes one; `track.set_instrument(...)` is what builds it. Before placement the parameter *writers* (`set_parameter`, `load_state`, `set_program`) record what they were asked to do and apply it to the instance the track builds; the *readers* (`parameter`, `parameters`, `programs`, `save_state`, the GUI methods) need an instance and say so. After placement every method works on the instrument live on that track, re-resolved on each call — so a handle kept across a re-execute never points at a replaced instance. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#plugininstrument --- PluginInstrument.backend [method] fn backend() -> String Returns the plugin format ("CLAP" or "VST3"). Returns: String — the plugin format Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#backend-1 --- PluginInstrument.hide_gui [method] fn hide_gui() -> NUL Closes the plugin GUI window. Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#hide_gui --- PluginInstrument.load_state [method] fn load_state(path: String) -> PluginInstrument Loads a preset file into the plugin. The preset's plugin name must match this instrument's plugin name. Parameters: path: String — file path of the preset to load Returns: PluginInstrument — the instrument, for chaining Errors: RuntimeError — if the file doesn't exist or the plugin name mismatches Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#load_state-1 --- PluginInstrument.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList of all instrument parameters. Prints as a formatted table (headed by the instrument name and backend) with columns Parameter, Value, Text, Range, Default. Text is the value as the plugin shows it (`1.20 kHz`, `Saw`). Use `.data` for the raw array of dicts; each entry has `name`, `value` (what `set_parameter` takes), `norm` (the value as a fraction of the range, what `.set_norm()` takes), `text`, `min`, `max`, `default`, `min_text`, `max_text`, `default_text`, `group`, `path`, and `step`. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) ```resonon lead.set_instrument(inst); // place it first — reading needs an instance print(inst.parameters()); // all parameters print(inst.parameters("freq")); // only parameters containing "freq" let rows = inst.parameters().data; // raw array of parameter dicts ``` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameters-6 --- PluginInstrument.program [method] fn program() -> Number? The current VST3 factory program index, or NUL when the plugin exposes no program selector or is not VST3. Backends: VST3. NUL on CLAP, DSP. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#program-1 --- PluginInstrument.programs [method] fn programs() -> Array Lists all program/preset names built into the plugin. Only VST3 plugins expose factory programs. For CLAP and built-in DSP instruments, prints a warning and returns an empty array. Backends: VST3. Warns on CLAP, DSP. Returns: Array — array of program name strings, e.g. `#["Init", "Warm", "Bright"]` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#programs --- PluginInstrument.save_state [method] fn save_state(path: String) -> PluginInstrument Saves the plugin state to a preset file. Parameters: path: String — file path for the preset Returns: PluginInstrument — the instrument, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#save_state-1 --- PluginInstrument.set_parameter [method] fn set_parameter(name: String, value: Number) -> PluginInstrument Sets a parameter value by name. Parameters: name: String — parameter name (e.g. "Cutoff", "Mix") value: Number — new value in the parameter's native range Returns: PluginInstrument — the instrument, for chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_parameter-3 --- PluginInstrument.set_program [method] fn set_program(index: Number) -> PluginInstrument Selects a factory program/preset by index. Only VST3 plugins support program selection. For CLAP and built-in DSP instruments, prints a warning and returns the instrument unchanged. Backends: VST3. Warns on CLAP, DSP. Parameters: index: Number — zero-based program index Returns: PluginInstrument — the instrument, for chaining Errors: RuntimeError — if the index is out of range (VST3 only) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_program-1 --- PluginInstrument.show_gui [method] fn show_gui() -> NUL Opens the plugin GUI window. Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#show_gui --- PluginInstrument.supports_gui [method] fn supports_gui() -> Boolean Returns true if the plugin supports a GUI window. Returns: Boolean — true if a GUI window is supported Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#supports_gui-1 --- PluginList [class] class PluginList Wraps an array of plugin dicts from `plugin_scan()`. Prints as an aligned table; provides `.data` for programmatic access. `to_json()` writes it as the array of plugin dicts. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#pluginlist --- PluginList.filter [method] fn filter(name: String) -> PluginList Filters plugins by name substring, returns a new PluginList. Matching is case-insensitive. Parameters: name: String — substring to match against plugin names Returns: PluginList — a new list of the matching plugins Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#filter-1 --- PluginList.get [method] fn get(index: Number) -> Dict Returns the plugin dict at the given index. Parameters: index: Number — zero-based position Returns: Dict — the plugin entry at `index` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#get-3 --- PluginList.json [method] fn json() -> Array> Returns the plugin dicts, which `to_json()` writes for the list. Returns: Array> — one dict per plugin (keys: name, id, vendor, format) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#json-1 --- PluginList.length [method] fn length() -> Number Returns the number of plugins. Returns: Number — the plugin count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#length-1 --- RampExtend [enum] enum RampExtend { hold, black, zero, repeat, mirror } What a `Ramp` draws below 0: TD's Ramp Extend Left menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rampextend --- RampExtendRight [enum] enum RampExtendRight { same_as_left, hold, black, zero, repeat, mirror } What a `Ramp` draws above 1: TD's Ramp Extend Right menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rampextendright --- RampFit [enum] enum RampFit { fill, fit_horizontal, fit_vertical, fit_best } How a radial or circular `Ramp` fits a non-square image: TD's Ramp Fit Aspect menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rampfit --- RampInterp [enum] enum RampInterp { step, linear, ease_in_ease_out, hermite } The curve between the keys of a `Ramp`: TD's Ramp Interpolate Notches menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rampinterp --- RampType [enum] enum RampType { vertical, horizontal, radial, circular } The shape of a `Ramp`: TD's Ramp Type menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#ramptype --- Rand [function] fn Rand(freq: Number | Signal = 1) -> Signal Unipolar random sample-and-hold signal (0 to 1). Deterministic. Parameters: freq: Number | Signal — sampling rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar sample-and-hold control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#rand --- Reverb [function] fn Reverb(name: String, room: Number? = NUL, damp: Number? = NUL, width: Number? = NUL, mix: Number? = NUL) -> Effect Creates a reverb effect (Freeverb algorithm). Parameters: name: String — slot name (identity in a track's effect chain) room: Number? (optional) — room size damp: Number? (optional) — high-frequency damping width: Number? (optional) — stereo width mix: Number? (optional) — dry/wet mix Returns: Effect — a built-in reverb effect ```resonon drums.set_effects(#[Reverb("verb", 0.7, 0.3)]); drums.set_effects(#[Reverb("short", 0.5, 0.5, 1.0, 0.2)]); ``` Module: std/effects Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/#reverb-1 --- RgbKey [function] fn RgbKey(name: String) -> Visual An RGB-key visual: TouchDesigner's RGB Key TOP. It pulls a key from the red, green and blue of its primary input (set via `src >> RgbKey("…")`): a pixel whose every channel lies between that channel's min and max is in the key (1), the rest is out (0). A soft low or soft high fades the key in below min or out above max over that distance, along a cosine; at 0 the edge is hard. As in TD, each channel is clamped to 0..1, as are min and max, and a min at or above its max keys nothing. The key is the product of the three channels, inverted by `invert` (0 to 1, a blend). `rgb_output` sets the colour: the image times the key, or the key itself. With TD's defaults every pixel is in the key, so the image passes through. Fixed at TD's default: Alpha Output new alpha. The alpha is 1. Parameters: name: String — the operator's name; its identity on screen Uniforms: red_min — the lowest red in the key (default 0) red_max — the highest red in the key (default 1) red_soft_low — how far below red_min the key fades in (default 0) red_soft_high — how far above red_max the key fades out (default 0) green_min — the lowest green in the key (default 0) green_max — the highest green in the key (default 1) green_soft_low — how far below green_min the key fades in (default 0) green_soft_high — how far above green_max the key fades out (default 0) blue_min — the lowest blue in the key (default 0) blue_max — the highest blue in the key (default 1) blue_soft_low — how far below blue_min the key fades in (default 0) blue_soft_high — how far above blue_max the key fades out (default 0) invert — inverts the key; 1 keeps what is out of the range (default 0) rgb_output — the colour, an `RgbOutput` (default multiply_alpha) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rgbkey --- RgbOutput [enum] enum RgbOutput { multiply_alpha, new_alpha } The colour an `RgbKey` draws: TD's RGB Key RGB Output menu. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#rgboutput --- SR [dsp-builtin] SR: Number Current sample rate in Hz. Set by the audio output device. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#sr --- Sample [function] fn Sample(path: String) -> AudioClip Loads a WAV file as an audio clip. A loaded file and a recorded take are the same thing — audio, whole — so both arrive as an `AudioClip` over all of it, unplaced. The path is relative to the .non file that names it, the way `use` and `load_file` are; an absolute path is taken as given. Nothing else is searched. For a sound out of a kit, go through the kit and name it as the kit does — `Sampler(Kit("CR-78")).sample("bd")`, not by filename. Parameters: path: String — path to the .wav file, relative to this file Returns: AudioClip — a clip over the whole of the loaded audio Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample --- Sampler [class] fn Sampler(kit: Kit? = NUL) -> Sampler A CLAP drum sampler plugin with per-sample note mapping. Construct with `Sampler(Kit("kit_name"))`. Creates a drum sampler instrument. No-arg form creates an empty sampler (use .load_kit() to load a kit later). Parameters: kit: Kit? — kit value from `Kit("name")` (optional) Returns: Sampler — the drum sampler Examples: `Sampler()` — empty sampler `Sampler(Kit("CR-78"))` — with kit Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sampler --- Sampler.choke_group [method] fn choke_group(name: String) -> Number? The choke group assigned to a sound, or NUL when unassigned. Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#choke_group --- Sampler.load_kit [method] fn load_kit(kit: Kit) -> Sampler Loads a kit into the sampler. Parameters: kit: Kit — the kit to load Returns: Sampler — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#load_kit --- Sampler.note [method] fn note(name: String) -> Number Returns the MIDI note number for the given sample name. Parameters: name: String — sample name Returns: Number — the MIDI note mapped to that sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#note-1 --- Sampler.parameter [method] fn parameter(name: String) -> InstrumentParam Returns a parameter reference by raw path. Tip: use .slot("bd").parameter("gain") for named access. Parameters: name: String — parameter path (e.g. "slot_0/gain", "slot_1/attack") Returns: InstrumentParam — supports `.get()`, `.set()`, and `<<` for modulation Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#parameter-1 --- Sampler.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList with all sampler parameters. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#parameters-2 --- Sampler.sample [method] fn sample(name: String) -> AudioClip Gets the audio behind a kit sound, as a clip. The clip is the material only — the sound's controls stay on the sampler. Parameters: name: String — sample name Returns: AudioClip — a clip over the whole of that sound's audio Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample-1 --- Sampler.sample_info [method] fn sample_info() -> Array> Returns an array of [name, note, file] for each sample. Returns: Array — one `[name, note, file]` entry per sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample_info-1 --- Sampler.samples [method] fn samples() -> Array Returns an array of loaded sample names. Returns: Array — the loaded sample names as Strings Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#samples-2 --- Sampler.set_choke_group [method] fn set_choke_group(group: Number, samples: Array) -> Sampler Assigns samples to a choke group. Samples in the same group cut each other off (e.g. open/closed hi-hat). Parameters: group: Number — choke group ID (1+) samples: Array — sample names in the group Returns: Sampler — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_choke_group --- Sampler.set_note [method] fn set_note(name: String, new_note: Note) -> Sampler Moves a sound to a different trigger note. The pad moves everywhere at once: the sampler's own mapping, the slots taken off it, and the patterns on the track it is loaded on. Its per-slot settings — gain, pan, envelope, slice — move with it. A note triggers one sound, so moving onto a note another sound already holds is refused; move that sound first. Parameters: name: String — sample name new_note: Note — the note to assign, e.g. `C2` or `36` Returns: Sampler — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_note --- Sampler.set_parameter [method] fn set_parameter(name: String, value: Number) -> Sampler Sets a parameter value by raw path. Parameters: name: String — parameter path (e.g. "slot_0/gain") value: Number — new value in the parameter's native range Returns: Sampler — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_parameter-1 --- Sampler.slot [method] fn slot(name_or_note: String | Note) -> DrumSample Returns a reference to a drum sample slot. Parameters: name_or_note: String | Note — the sound's name, or the note that triggers it Returns: DrumSample — a reference to that slot Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#slot --- SamplerMelodic [class] fn SamplerMelodic(kit: Kit? = NUL) -> SamplerMelodic A CLAP melodic sampler plugin with pitch-shifting. Construct with `SamplerMelodic(Kit("kit_name"))` or `SamplerMelodic()` for empty. Creates a melodic sampler. A kit-backed sampler loads its declared default sample immediately. A kit with one sample may infer that default; a multi-sample kit must declare `[kit].default_sample`. No-arg form creates an intentionally empty sampler (use .load_kit() to load a kit later). Pitch-shifts a single sample for melodic playback. Parameters: kit: Kit? — kit value from `Kit("name")` (optional) Returns: SamplerMelodic — the melodic sampler Examples: `SamplerMelodic()` — empty sampler `SamplerMelodic(Kit("keys"))` — with kit Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#samplermelodic --- SamplerMelodic.envelope [method] fn envelope() -> Array The current [attack_ms, decay_ms, sustain, release_ms] envelope. Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#envelope-1 --- SamplerMelodic.load_kit [method] fn load_kit(kit: Kit) -> SamplerMelodic Loads a kit into the sampler. Parameters: kit: Kit — the kit to load Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#load_kit-1 --- SamplerMelodic.load_sample [method] fn load_sample(name: String, root_note: Note? = NUL) -> SamplerMelodic Loads a sample from the kit directory. Parameters: name: String — sample name root_note: Note? — root note for pitch mapping, e.g. `C4` or `60` (optional) Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#load_sample --- SamplerMelodic.loop_normalized [method] fn loop_normalized() -> Array The current normalized [start, end] loop positions. Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#loop_normalized --- SamplerMelodic.loop_region [method] fn loop_region() -> Array? The current [start, end] loop positions in seconds, or NUL with no loaded sample. Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#loop_region --- SamplerMelodic.parameters [method] fn parameters(filter: String? = NUL) -> ParamList Returns a ParamList with all sampler parameters. Parameters: filter: String? — only include parameters whose name contains this substring, case-insensitive (optional) Returns: ParamList — parameter data (columns: Parameter, Value, Text, Range, Default) Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#parameters-2 --- SamplerMelodic.root [method] fn root(name: String) -> Number? Returns the root note for the given sample, or `NUL` if unset. For the loaded sample it follows `set_root()`. Parameters: name: String — sample name Returns: Number — the root note for that sample, or `NUL` if unset Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#root --- SamplerMelodic.sample [method] fn sample(name: String) -> AudioClip Gets the audio behind a kit sound, as a clip. The clip is the material only — the sound's controls stay on the sampler. Parameters: name: String — sample name Returns: AudioClip — a clip over the whole of that sound's audio Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample-1 --- SamplerMelodic.sample_info [method] fn sample_info() -> Array> Returns an array of [name, root, file] for each sample, with root `NUL` if unset. The root is the one the sample plays at: for the loaded sample it follows `set_root()`. Returns: Array — one `[name, root, file]` entry per sample Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#sample_info-2 --- SamplerMelodic.samples [method] fn samples() -> Array Returns an array of loaded sample names. Returns: Array — the loaded sample names as Strings Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#samples-2 --- SamplerMelodic.set_envelope [method] fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodic Sets the ADSR envelope for the current sample. Parameters: attack_ms: Number — attack time in milliseconds decay_ms: Number — decay time in milliseconds sustain: Number — sustain level (0.0-1.0) release_ms: Number — release time in milliseconds Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_envelope-1 --- SamplerMelodic.set_loop [method] fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodic Sets the loop region in seconds. Parameters: start_secs: Number — loop start time in seconds end_secs: Number — loop end time in seconds Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_loop --- SamplerMelodic.set_loop_normalized [method] fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodic Sets the loop region using normalized [0,1] positions. Parameters: start: Number — loop start position (0.0-1.0) end: Number — loop end position (0.0-1.0) Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_loop_normalized --- SamplerMelodic.set_parameter [method] fn set_parameter(name: String, value: Number) -> SamplerMelodic Sets a parameter value by name. Parameters: name: String — parameter name (e.g. "RootNote", "Gain") value: Number — new value in the parameter's native range Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_parameter-2 --- SamplerMelodic.set_root [method] fn set_root(note: Note) -> SamplerMelodic Overrides the root note for the current sample. Parameters: note: Note — the root pitch, e.g. `C4` or `60` Returns: SamplerMelodic — the sampler, for chaining Module: std/instruments Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/#set_root --- Saw [function] fn Saw(freq: Number | Signal = 1) -> Signal Unipolar sawtooth signal (0 to 1). Ramps up, then resets. Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar sawtooth control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#saw --- Saw2 [function] fn Saw2(freq: Number | Signal = 1) -> Signal Bipolar sawtooth signal (-1 to 1). Ramps up, then resets. Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a bipolar sawtooth control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#saw2 --- Scale [class] fn Scale(arg: String | Array, period: Number? = NUL) -> Scale A musical scale — a rootless, ordered set of pitch intervals. Construct with `Scale("name")` for built-in scales, or `Scale(#[0, 2, 4, 5, 7, 9, 11])` from a semitone array. Microtonal scales use fractional semitones: `Scale(#[0, 1.5, 3.5, 5, 7, 8.5, 10])`. Pass a `Scale` to `Key(root, scale)` or `track.set_key(scale, root)` to play it. Creates a Scale value, optionally with a custom period. Parameters: arg: String | Array — scale name (e.g. "major", "dorian") or an array of semitone intervals (must start with 0 and be strictly ascending, e.g. #[0, 2, 4, 5, 7, 9, 11]) period: Number? — period in semitones (optional; e.g. 19 for 19-TET). Use a non-12 period for non-octave tunings; only valid with an array `arg`. Returns: Scale — the constructed scale Examples: `Scale("minor")`, `Scale(#[0, 2, 3, 5, 7, 8, 10])`, `Scale(#[0, 2, 4, 5, 7, 9, 11], 19)`. Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#scale --- Scale.contains [method] fn contains(semitones: Number) -> Boolean Returns true if the scale contains the given interval (in semitones). Parameters: semitones: Number — interval from the root, in semitones Returns: Boolean — true if the interval is in the scale Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#contains --- Scale.intervals [method] fn intervals() -> Array Returns the interval array (semitones from root). Returns: Array — the semitone intervals from the root Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#intervals --- Scale.length [method] fn length() -> Number Returns the number of scale degrees. Returns: Number — the number of degrees in the scale Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#length --- Scale.mode [method] fn mode(n: Number) -> Scale Returns a new Scale rotated to the nth mode (1-indexed). Parameters: n: Number — mode index (1-indexed) Returns: Scale — the scale rotated to the nth mode Examples: `Scale("major").mode(2)` returns the dorian mode. Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#mode --- Scale.name [method] fn name() -> String Returns the scale's name. Returns: String — the scale name Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#name --- Scale.period [method] fn period() -> Number Returns the period in semitones (12 for a standard octave). Returns: Number — the period in semitones Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#period --- Screen [class] class Screen The display output sink. `screen` is a global: route a visual with `v >> screen`, then adjust presentation via its methods. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#screen --- Screen.quality [method] fn quality() -> Number The screen rendering quality scale. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#quality --- Screen.resolution [method] fn resolution(w: Number, h: Number) -> Screen Sets the composition size in pixels (default 1920 × 1080). Every operator renders at this size, multiplied by `set_quality` for SSAA. The live window preserves its aspect ratio with black bars; `snap` and `render(screen)` use the composition size. Changing size reallocates targets and clears feedback trails, without recompiling shaders or moving sequenced cuts. Parameters: w: Number — positive integer width, within the GPU texture limit including SSAA h: Number — positive integer height, within the GPU texture limit including SSAA Returns: Screen — the sink, for chaining Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#resolution --- Screen.set_quality [method] fn set_quality(n: Number) -> Screen Sets the supersampling (SSAA) quality — the internal render resolution as a multiple of the composition size (default 1, one sample per pixel). Higher is smoother but costs ~n² GPU work; clamped to the renderer's supported range. Takes effect live — including on a playing sequenced screen lane, whose spans are rescaled where they are (the cuts stay put and nothing recompiles). Parameters: n: Number — render-scale multiple (≥ 1) Returns: Screen — the sink, for chaining Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#set_quality --- Screen.show [method] fn show() -> Screen Opens the native live-rendering window for the routed visual, rendered on the GPU in-process from the routed graph, the transport and the live audio meter feeds. A no-op if the window is already open. Returns: Screen — the sink, for chaining Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#show --- Screen.snap [method] fn snap(path: String) -> Screen Renders the routed visual off-screen on the GPU and writes it to a PNG at the given path. An absolute path is taken as typed; a relative one lands under the project the piece belongs to, not beside whichever shell started resonon, and any directory it names is created. Works headless, so it also runs in an offline render of a file in a project. Rendered at the composition resolution (independent of the live window) with the SSAA set by `set_quality`. Parameters: path: String — output PNG path Returns: Screen — the sink, for chaining Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals (prelude) Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#snap --- Section [class] class Section A multi-track arrangement: one lane per track, plus automation and screen lanes. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#section --- Section.length [method] fn length() -> Number Returns the section length. Returns: Number — the length in cycles Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#length-3 --- Section.play [method] fn play() -> Section Binds every lane — notes, automation, screen — and plays from the top. Re-running it replays. A track with no instrument is skipped. Returns: Section — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#play --- Section.repeat [method] fn repeat(n: Number) -> Section Returns a new section holding `n` back-to-back copies of this one; the receiver is untouched. Parameters: n: Number — number of copies (> 0) Returns: Section — a new, independent section `n` times as long Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#repeat-1 --- Section.track_count [method] fn track_count() -> Number Returns how many tracks have a note lane. Returns: Number — the lane count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#track_count --- Section.tracks [method] fn tracks() -> Array Returns the tracks that have a note lane. Returns: Array — one track id per lane Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#tracks-1 --- SectionEffect [class] class SectionEffect An effect on a section lane's track, from `sec[track].effect(name)`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sectioneffect --- SectionEffect.parameter [method] fn parameter(name: String) -> SectionParam Addresses one of the effect's parameters as an automation lane. Parameters: name: String — the parameter name Returns: SectionParam — the automation lane for that parameter Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#parameter-3 --- SectionLane [class] class SectionLane A track's note lane in a section, from `sec[track]`. `<<` replaces the base; `.at(start, duration) << ...` masks a span. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sectionlane --- SectionLane.at [method] fn at(start: Number, duration: Number) -> TimelineSlot Addresses a span of the lane for a `<<` write. Parameters: start: Number — where the span begins, in cycles (>= 0, before the end) duration: Number — how long it lasts, in cycles (> 0) Returns: TimelineSlot — a slot that takes a pattern via `<<` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#at-2 --- SectionLane.clear [method] fn clear() -> SectionLane Drops every layer above `base`, leaving what the section laid down. Returns: SectionLane — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear-3 --- SectionLane.clear_all [method] fn clear_all() -> SectionLane Empties the lane: every layer, `base` included. Returns: SectionLane — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear_all-1 --- SectionLane.effect [method] fn effect(name: String) -> SectionEffect Addresses an effect on this lane's track, by slot name, for automation. The slot must exist on the track now. Parameters: name: String — slot name of the effect Returns: SectionEffect — a handle whose `.parameter(name)` is an automation lane Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#effect-3 --- SectionLane.entries [method] fn entries() -> Array> Returns the entries as written — the base first, then each layer — not the flattened result. `masked` is true for an entry hidden outright. Returns: Array — one `{start, duration, layer, masked}` dict per entry Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entries --- SectionLane.entry_count [method] fn entry_count() -> Number Returns how many entries have been written, on every layer. Returns: Number — the entry count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entry_count --- SectionLane.layer [method] fn layer(name: String) -> LaneLayer Addresses one named layer. Creates nothing: the first write through the handle creates the layer. Parameters: name: String — the layer name Returns: LaneLayer — a handle to that layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layer --- SectionLane.layers [method] fn layers() -> Array> Returns the layer stack, bottom-to-top (`base` first). Returns: Array — one `{name, entry_count, muted}` dict per layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layers --- SectionLane.set_layer_order [method] fn set_layer_order(names: Array) -> SectionLane Restacks the layers above `base`, bottom-to-top. Layers left out keep their relative order and end up on top. Every name must exist; re-running the line changes nothing. Parameters: names: Array — layer names, bottom-to-top (`base` may not be listed) Returns: SectionLane — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_layer_order-1 --- SectionParam [class] class SectionParam An automation lane in a section, from `sec[track].volume`, `.pan`, or `sec[track].effect(name).parameter(name)`. Takes a value or a curve via `<<`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sectionparam --- SectionParam.at [method] fn at(start: Number, duration: Number) -> SectionParam Narrows the next `<<` write to a span of the lane. Parameters: start: Number — where the span begins, in cycles (>= 0, before the end) duration: Number — how long it lasts, in cycles (> 0) Returns: SectionParam — the same lane, addressing that span Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#at-3 --- SectionParam.clear [method] fn clear() -> SectionParam Drops every layer above `base` — or, after `.at(start, duration)`, just the curve that starts there. Returns: SectionParam — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear-4 --- SectionParam.clear_all [method] fn clear_all() -> SectionParam Empties the lane: every layer, `base` included. On a playing section the automation stops. Returns: SectionParam — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear_all-2 --- SectionParam.entries [method] fn entries() -> Array> Returns the curves as written — the base first, then each layer — not the flattened result. `masked` is true for an entry hidden outright. Returns: Array — one `{start, duration, layer, masked}` dict per entry Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entries-2 --- SectionParam.entry_count [method] fn entry_count() -> Number Returns how many curves have been written, on every layer. Returns: Number — the entry count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entry_count-2 --- SectionParam.layer [method] fn layer(name: String) -> LaneLayer Addresses one named layer. Creates nothing: the first write through the handle creates the layer. Parameters: name: String — the layer name Returns: LaneLayer — a handle to that layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layer --- SectionParam.layers [method] fn layers() -> Array> Returns the layer stack, bottom-to-top (`base` first). Returns: Array — one `{name, entry_count, muted}` dict per layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layers --- SectionParam.set_layer_order [method] fn set_layer_order(names: Array) -> SectionParam Restacks the layers above `base`, bottom-to-top. Layers left out keep their relative order and end up on top. Every name must exist; re-running the line changes nothing. Parameters: names: Array — layer names, bottom-to-top (`base` may not be listed) Returns: SectionParam — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_layer_order-2 --- SectionVisual [class] class SectionVisual The screen lane of a section, from `sec[screen]`. Takes a visual via `<<`. Experimental: Visuals are experimental; expect breaking changes to the screen lane. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sectionvisual --- SectionVisual.at [method] fn at(start: Number, duration: Number) -> SectionVisual Narrows the next `<<` write to a span of the lane. Parameters: start: Number — where the span begins, in cycles (>= 0, before the end) duration: Number — how long it lasts, in cycles (> 0) Returns: SectionVisual — the same lane, addressing that span Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#at-4 --- SectionVisual.clear [method] fn clear() -> SectionVisual Drops every layer above `base` — or, after `.at(start, duration)`, just the visual that starts there. Returns: SectionVisual — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear-5 --- SectionVisual.clear_all [method] fn clear_all() -> SectionVisual Empties the lane: every layer, `base` included. On a playing section this blanks the screen. Returns: SectionVisual — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear_all-3 --- SectionVisual.entries [method] fn entries() -> Array> Returns the visuals as written — the base first, then each layer — not the flattened result. `masked` is true for an entry hidden outright. Returns: Array — one `{start, duration, layer, masked}` dict per entry Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entries-3 --- SectionVisual.entry_count [method] fn entry_count() -> Number Returns how many visuals have been written, on every layer. Returns: Number — the entry count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entry_count-3 --- SectionVisual.layer [method] fn layer(name: String) -> LaneLayer Addresses one named layer. Creates nothing: the first write through the handle creates the layer. Parameters: name: String — the layer name Returns: LaneLayer — a handle to that layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layer --- SectionVisual.layers [method] fn layers() -> Array> Returns the layer stack, bottom-to-top (`base` first). Returns: Array — one `{name, entry_count, muted}` dict per layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layers --- SectionVisual.set_layer_order [method] fn set_layer_order(names: Array) -> SectionVisual Restacks the layers above `base`, bottom-to-top. Layers left out keep their relative order and end up on top. Every name must exist; re-running the line changes nothing. Parameters: names: Array — layer names, bottom-to-top (`base` may not be listed) Returns: SectionVisual — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_layer_order-3 --- SendParam [class] class SendParam The level of one send, from `track.send(destination)`: 0.0 to 1.0. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sendparam --- Sequence [function] fn Sequence(...notes: Pattern | Note | Array) -> Pattern Creates a sequential pattern that plays notes one after another. Parameters: notes: Pattern | Note | Array — the notes, one after another; a lone Array is the list of notes itself Returns: Pattern — a sequential pattern Examples: `Sequence(C4, E4, G4)` plays notes in sequence. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#sequence --- Session [class] class Session The session: the tracks, the master bus and the routing targets of the piece. `session` is a global. Create a track once, in `fn setup()`, with `session.create_track("drums")`; look it up anywhere else with `session.track("drums")`. A track name belongs to one track, audio or MIDI. Two fields name the fixed routing targets; Resonon sets them, and code reads them only: - `session.master` — the master output bus. Always present, cannot be deleted. - `session.nowhere` — a track output that goes nowhere: Live's "Sends Only" on an audio track, "No Output" on a MIDI track (`drums >> session.nowhere`). Examples: `let drums = session.track("drums");` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#session --- Session.create_midi_track [method] fn create_midi_track(name: String) -> MidiTrack Creates a MIDI track with the given name. The name must be new, as for `create_track`. The track starts on No Output; route it with `bass >> MidiOutput("synth", 1)`. Parameters: name: String — the track's name (not empty, no leading or trailing space) Returns: MidiTrack — the new track Examples: `session.create_midi_track("bass")` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#create_midi_track --- Session.create_track [method] fn create_track(name: String) -> AudioTrack Creates an audio track with the given name. The name is the track's identity: it must be new. A track of either kind that already has the name is an error, so a typo never makes a second track. Create tracks in `fn setup()`, which runs on a fresh session. Parameters: name: String — the track's name (not empty, no leading or trailing space) Returns: AudioTrack — the new track Examples: `session.create_track("drums")` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#create_track --- Session.delete_track [method] fn delete_track(name: String) -> NUL Deletes the audio or MIDI track with the given name, as Delete Track in the mixer does. The session owns its tracks: a track stays until it is deleted, also when no variable holds it. A variable that still holds the deleted track gives an error when it is used. A name with no track is an error that lists the tracks there are; the master cannot be deleted. Parameters: name: String — the track's name Returns: NUL — nothing Examples: `session.delete_track("drums")` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#delete_track --- Session.master [field] master: Master The master output bus. Always present; cannot be deleted. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sessionmaster --- Session.midi_track [method] fn midi_track(name: String) -> MidiTrack The MIDI track with the given name. Nothing is created: a name with no track is an error that lists the tracks there are, and an audio track's name is an error naming its kind. Parameters: name: String — the track's name Returns: MidiTrack — the track with that name Examples: `let bass = session.midi_track("bass");` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#midi_track --- Session.modulations [method] fn modulations() -> Array> Every parameter in the session that a signal, an automation lane or a pattern drives: device parameters, track and master volume and pan, and sends. Each entry reads the parameter as `.get()` and `.text()` do, without waiting for audio. Ordered as the session is: audio tracks in mixer order, then master; on a track the instrument, the effects in chain order, then volume, pan and sends. MIDI CC outputs are not parameters and are not listed. Returns: Array — of dicts `{ track, device, parameter, dest, source, range, value, text }`: `track` is the track name or "master"; `device` the effect's slot name or the instrument's name, NUL for volume, pan and sends; `parameter` the name `.parameter()` takes, or "volume", "pan", "send"; `dest` the send's destination, else NUL; `source` the driving signal as it describes itself; `range` its declared `[min, max]`, NUL when it declares none (an automation lane, a pattern); `value` and `text` the parameter now. Examples: `print(to_json(session.modulations()))` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#modulations --- Session.nowhere [field] nowhere: Nowhere A routing target that sends no output. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#sessionnowhere --- Session.track [method] fn track(name: String) -> AudioTrack The audio track with the given name. Nothing is created: a name with no track is an error that lists the tracks there are, and a MIDI track's name is an error naming its kind. Parameters: name: String — the track's name Returns: AudioTrack — the track with that name Examples: `let drums = session.track("drums");` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#track --- Session.tracks [method] fn tracks() -> Array Every track in the session, audio and MIDI, in mixer order. The master is not a track; it is `session.master`. Returns: Array — the tracks, in mixer order Examples: `session.tracks().map(fn(t) { return t.name(); })` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#tracks --- Signal [class] class Signal A continuous control signal for modulation. Made by `std/signals` — `Sine`, `Sine2`, `Saw`, `Saw2`, `Tri`, `Tri2`, `Square`, `Square2`, `Rand`, `Perlin`, `Time`, `signal_ramp(...)`, `signal(pattern)` — and by a `dsp signal` definition. A signal has one clock, shared by everything it drives. `.clone()` makes a second modulator with the same settings and a clock of its own, which starts when the copy is bound. Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#signal --- Signal.at [method] fn at(time: Number, value: Number, curve: Curve | Bezier = Curve.linear) -> Signal Adds a breakpoint to an automation signal (builder pattern). Can only be called on signals created with `automation()`. Parameters: time: Number — breakpoint time in the signal's timebase (cycles by default) value: Number — value at this breakpoint curve: Curve | Bezier — shape of the segment from this breakpoint to the next Returns: Signal — a new signal with the added breakpoint, for chaining Examples: `automation().at(0, 400).at(4, 2000, Curve.smooth).at(8, 400)` Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#at --- Signal.continuous [method] fn continuous() -> Signal Opt out of bind-time re-anchoring. By default, signals reset their local time to 0 at the next cycle boundary after binding. Use `.continuous()` to keep the signal on the global playback clock — useful for LFOs where you want to tweak frequency without resetting phase. Like `.set_retrigger()`, this configures the source itself, so it holds everywhere that signal is used. Returns: Signal — the same signal, now on the global clock, for chaining Examples: `lpf.parameter("Cutoff") << Sine(2).set_timebase(seconds(1)).range(200, 4000).continuous()` Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#continuous --- Signal.get [method] fn get() -> Number Reads the signal at the current transport position without advancing DSP or waiting. A stateful source returns its latest published value. Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#get --- Signal.parameter [method] fn parameter(name: String) -> Number Reads a dsp signal's scalar parameter by its declared name. Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#parameter --- Signal.range [method] fn range(min: Number | Signal, max: Number | Signal) -> Signal Maps the signal output to a linear range [min, max]. Parameters: min: Number | Signal — output value at the bottom of the signal's range, or a signal that sets it max: Number | Signal — output value at the top of the signal's range, or a signal that sets it Returns: Signal — the rescaled signal, for chaining Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#range --- Signal.range_exp [method] fn range_exp(min: Number | Signal, max: Number | Signal) -> Signal Maps the signal output to an exponential range [min, max]. Useful for frequency modulation. Parameters: min: Number | Signal — output value at the bottom of the signal's range, or a signal that sets it max: Number | Signal — output value at the top of the signal's range, or a signal that sets it Returns: Signal — the exponentially rescaled signal, for chaining Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#range_exp --- Signal.retrigger [method] fn retrigger() -> Array Returns each source clock's configured retrigger period, in graph order. A continuous source has NUL; a signal without a clock returns an empty array. Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#retrigger --- Signal.set_parameter [method] fn set_parameter(name: String, value: Number) -> Signal Sets a named parameter on the signal. Parameters: name: String — parameter name value: Number — parameter value Returns: Signal — the signal with the updated parameter, for chaining Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#set_parameter --- Signal.set_retrigger [method] fn set_retrigger(period: Duration) -> Signal Resets the signal's phase every `period`. A musical period (cycles, beats, note values) resets on the song's grid; a seconds period resets on the clock. Without a retrigger the signal never resets. Configures the source itself, so the reset applies everywhere that signal is used — every binding and any scope show the same phase. Parameters: period: Duration — how often the phase resets Returns: Signal — the same signal, for chaining Examples: `Saw(4).set_retrigger(beats(1))`, `Saw(1).set_retrigger(note_value(1, 8).dotted())` Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#set_retrigger --- Signal.set_timebase [method] fn set_timebase(unit: Duration) -> Signal Sets the unit the signal counts time in: an oscillator's rate is periods per unit, and automation breakpoint times are in units. Musical units (cycles, beats, note values) follow the tempo; seconds do not. The default is `cycles(1)`. Like `.set_retrigger()`, this configures the source itself, so it holds everywhere that signal is used. Parameters: unit: Duration — the unit to count in Returns: Signal — the same signal, for chaining Examples: `Sine(1).set_timebase(note_value(1, 8).dotted())` — one sweep per dotted eighth; `Sine(2).set_timebase(seconds(1))` — 2 Hz at any tempo Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#set_timebase --- Signal.smooth [method] fn smooth(time_ms: Number | Signal) -> Signal Applies one-pole lowpass smoothing to the signal. Useful for removing zipper noise from MIDI CC signals. Parameters: time_ms: Number | Signal — smoothing time in milliseconds, or a signal that sets it Returns: Signal — the smoothed signal, for chaining Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#smooth --- Signal.timebase [method] fn timebase() -> Array Returns each source clock's timebase, in graph order. Module: std/signals (prelude) Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#timebase --- Sine [function] fn Sine(freq: Number | Signal = 1) -> Signal Unipolar sine wave signal (0 to 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar sine control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#sine --- Sine2 [function] fn Sine2(freq: Number | Signal = 1) -> Signal Bipolar sine wave signal (-1 to 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a bipolar sine control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#sine2 --- Slope [function] fn Slope(name: String) -> Visual A slope visual: TouchDesigner's Slope TOP. It measures how the luminance of its primary input (set via `src >> Slope("…")`) changes across and up, from taps `sample_step` pixels before and after each pixel, and writes it as a displacement field for `Displace`: red is the slope left to right, blue the slope bottom to top, each `zero_point + strength × difference / (4 × sample_step)`. As in TD, green is the zero point, alpha is 1 and the result is not clamped. Fixed at TD's defaults: luminance (0.3 R + 0.6 G + 0.1 B) and the previous and next pixels. The step is in composition pixels, so the field is the same at every quality. Parameters: name: String — the operator's name; its identity on screen Uniforms: strength — slope gain (default 1) zero_point — the value of a flat image (default 0.5) sample_step — distance from each pixel to its taps, in pixels (default 1) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#slope --- SpectrumFeed [class] class SpectrumFeed A live spectrum from a track or the master (`track.fft`), bound to a shader texture with `<<`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#spectrumfeed --- SpectrumFeed.band [method] fn band(low_hz: Number, high_hz: Number) -> MeterFeed Reduces a frequency band to a single level. It reads the unsmoothed spectrum, so smooth the result, not the spectrum. Parameters: low_hz: Number — bottom of the band in Hz (>= 0) high_hz: Number — top of the band in Hz (above `low_hz`) Returns: MeterFeed — the band's level, from 0 to 1 Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#band --- SpectrumFeed.smooth [method] fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> SpectrumFeed Smooths every bin so the spectrum glides between analysis frames. With one time the rise and the fall are equal; give two for a separate release. Parameters: attack_ms: Number — rise time in milliseconds (>= 0) release_ms: Number? — fall time in milliseconds (>= 0; omit to match attack) Returns: SpectrumFeed — a new feed with that smoothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#smooth-1 --- Square [function] fn Square(freq: Number | Signal = 1) -> Signal Unipolar square wave signal (0 or 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar square control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#square --- Square2 [function] fn Square2(freq: Number | Signal = 1) -> Signal Bipolar square wave signal (-1 or 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a bipolar square control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#square2 --- Stack [function] fn Stack(...notes: Pattern | Note | Array) -> Pattern Creates a stacked/layered pattern (chord). Parameters: notes: Pattern | Note | Array — the notes or patterns to layer; a lone Array is the list of layers itself Returns: Pattern — a stacked (polyphonic) pattern Examples: `Stack(C4, E4, G4)` plays a C major chord. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#stack-1 --- String [class] class String Text value with Unicode support. Construct with literal syntax `"hello"`. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#string --- String.contains [method] fn contains(needle: String) -> Boolean Returns true if the string contains the given substring. Parameters: needle: String — the substring to search for Returns: Boolean — true if `needle` is present Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#contains-1 --- String.ends_with [method] fn ends_with(suffix: String) -> Boolean Returns true if the string ends with the given suffix. Parameters: suffix: String — the suffix to check Returns: Boolean — true if the string ends with `suffix` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#ends_with --- String.iter [method] fn iter() -> Iterator Returns an iterator over the characters. Returns: Iterator — an iterator over the characters Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#iter-1 --- String.length [method] fn length() -> Number Returns the character count (Unicode-aware). Returns: Number — the character count Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#length-2 --- String.lowercase [method] fn lowercase() -> String Returns the string converted to lowercase. Returns: String — the lowercased string Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#lowercase --- String.repeat [method] fn repeat(n: Number) -> String Returns a new string by repeating this string n times. Parameters: n: Number — number of repetitions Returns: String — the repeated string Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#repeat --- String.replace [method] fn replace(old: String, new: String) -> String Returns the string with all occurrences of old replaced with new. Parameters: old: String — the substring to find new: String — the replacement string Returns: String — the string with replacements applied Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#replace --- String.split [method] fn split(delimiter: String) -> Array Splits the string by a delimiter, returns an array of strings. Parameters: delimiter: String — the string to split on Returns: Array — the parts as Strings Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#split --- String.starts_with [method] fn starts_with(prefix: String) -> Boolean Returns true if the string starts with the given prefix. Parameters: prefix: String — the prefix to check Returns: Boolean — true if the string starts with `prefix` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#starts_with --- String.substring [method] fn substring(start: Number, end: Number) -> String Returns a substring from start to end (Unicode-aware). Parameters: start: Number — start index (inclusive, 0-based) end: Number — end index (exclusive) Returns: String — the substring Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#substring --- String.trim [method] fn trim() -> String Returns the string with leading and trailing whitespace removed. Returns: String — the trimmed string Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#trim --- String.uppercase [method] fn uppercase() -> String Returns the string converted to uppercase. Returns: String — the uppercased string Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#uppercase --- TIME [dsp-builtin] TIME: Number Local time in seconds since the signal's anchor. Tempo never changes it. Available in `dsp signal` blocks only. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#time --- TWOPI [dsp-builtin] TWOPI: Number Two pi / tau (6.28318...). Full cycle in radians. Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#twopi --- Time [function] fn Time(rate: Number | Signal = 1) -> Signal Elapsed time in units of the timebase, times `rate`: the phase the other oscillators wrap, left unwrapped, so it keeps rising until a retrigger. It counts time like every signal: it holds on a pause, returns to 0 on a stop, and starts at its binding unless `.continuous()`. `.range(min, max)` maps 0 to `min` and one unit to `max`. Parameters: rate: Number | Signal — units of output per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a rising control signal Examples: `n.parameter("tz") << Time(0.2).set_timebase(seconds(1))` — 0.2 per second Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#time --- Timeline [class] class Timeline A single lane of patterns placed at positions along it. Assign with `t.at(start, duration) << pattern`; a later write masks the entries underneath for its span rather than cutting them. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#timeline --- Timeline.at [method] fn at(start: Number, duration: Number) -> TimelineSlot Addresses a span of the timeline for a `<<` write. Neither value is rounded to the ruler: `.at(2.5, 1.25)` means exactly that. Parameters: start: Number — where the span begins, in cycles (>= 0, before the end) duration: Number — how long it lasts, in cycles (> 0) Returns: TimelineSlot — a slot that takes a pattern via `<<` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#at-1 --- Timeline.clear [method] fn clear() -> Timeline Drops every layer above `base`, leaving what `arrange` laid down. Returns: Timeline — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear-1 --- Timeline.clear_all [method] fn clear_all() -> Timeline Empties the timeline: every layer, `base` included. Returns: Timeline — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear_all --- Timeline.entries [method] fn entries() -> Array> Returns the entries as written — the base first, then each layer — not the flattened result. `masked` is true for an entry hidden outright. Returns: Array — one `{start, duration, layer, masked}` dict per entry Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entries --- Timeline.entry_count [method] fn entry_count() -> Number Returns how many entries have been written, on every layer. Returns: Number — the entry count Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#entry_count --- Timeline.layer [method] fn layer(name: String) -> LaneLayer Addresses one named layer. Creates nothing: the first write through the handle creates the layer. Parameters: name: String — the layer name Returns: LaneLayer — a handle to that layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layer --- Timeline.layers [method] fn layers() -> Array> Returns the layer stack, bottom-to-top (`base` first). Returns: Array — one `{name, entry_count, muted}` dict per layer Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#layers --- Timeline.length [method] fn length() -> Number Returns the timeline length. Returns: Number — the length in cycles Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#length-2 --- Timeline.repeat [method] fn repeat(n: Number) -> Timeline Returns a new timeline holding `n` back-to-back copies of this one; the receiver is untouched. `t * n` does the same. Parameters: n: Number — number of copies (> 0) Returns: Timeline — a new, independent timeline `n` times as long Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#repeat --- Timeline.set_layer_order [method] fn set_layer_order(names: Array) -> Timeline Restacks the layers above `base`, bottom-to-top. Layers left out keep their relative order and end up on top. Every name must exist; re-running the line changes nothing. Parameters: names: Array — layer names, bottom-to-top (`base` may not be listed) Returns: Timeline — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_layer_order --- TimelineSlot [class] class TimelineSlot A span of a note lane, from `.at(start, duration)`. Takes a pattern via `<<`. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#timelineslot --- TimelineSlot.clear [method] fn clear() -> TimelineSlot Drops the entry that starts at this slot's start on this slot's layer, bringing back what it was masking. A start nothing occupies is a no-op. Returns: TimelineSlot — `this`, for method chaining Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clear-2 --- TrackParam [class] class TrackParam An audio track's fader, `track.volume` (in dB: 0 = unity, -70 = mute, +6 the most) or `track.pan` (-1.0 = hard left, 1.0 = hard right). Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#trackparam --- Transform [function] fn Transform(name: String) -> Visual A transform visual: a TouchDesigner-style Transform TOP that translates, rotates and scales its primary input (set via `src >> Transform("…")`) about a pivot. Positive `scale` zooms in, positive `rotate` spins counter-clockwise; rotation is aspect-corrected so a wide canvas spins without shearing. `extend` picks how pixels outside the source are filled. With the defaults it is a pass-through. Parameters: name: String — the operator's name; its identity on screen Uniforms: translate — uv-fraction offset (+x right, +y up), a vec2 rotate — rotation in degrees (positive is counter-clockwise) scale — per-axis zoom, a vec2 pivot — centre of rotate/scale, a vec2 extend — outside-source fill, an `Extend` (default hold) Returns: Visual — a filter node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#transform --- Tri [function] fn Tri(freq: Number | Signal = 1) -> Signal Unipolar triangle wave signal (0 to 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a unipolar triangle control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#tri --- Tri2 [function] fn Tri2(freq: Number | Signal = 1) -> Signal Bipolar triangle wave signal (-1 to 1). Parameters: freq: Number | Signal — oscillation rate in periods per unit of the timebase (cycles by default), or a signal that sets it Returns: Signal — a bipolar triangle control signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#tri2 --- Tuple [class] class Tuple Fixed-size, immutable, ordered group of values. Construct with `(a, b, c)`; index with `t[i]` or destructure with `let (a, b) = t`. Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#tuple --- Tuple.get [method] fn get(index: Number) -> Any Returns the element at the given index, like `t[index]`. Errors if the index is out of bounds. Parameters: index: Number — zero-based position Returns: Any — the element at `index` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#get-2 --- Tuple.length [method] fn length() -> Number Returns the number of elements. Returns: Number — the element count Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#length --- Unit [enum] enum Unit { pixels, fraction, fraction_aspect } The unit of a distance on an image: TouchDesigner's Pixels, Fraction and Fraction Aspect. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#unit --- Variant [class] class Variant A variant of any enum: `Curve.linear`, `Monitor.auto`. Every enum implements it without saying so; a class cannot. A variant of any enum fits a `Variant` annotation. A `Variant` value does not fit an annotation of one enum, such as `Curve`: the code must say which enum it means. ```resonon enum Style { staccato, legato } fn enum_of(choice: Variant) -> String { return type(choice); } assert enum_of(Style.legato) == "Style"; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#variant --- Visual [class] fn Visual(name: String, source: String) -> Visual A node in the GPU visual graph: a built-in operator (`Noise`, `Blur`, `Displace`, …) or a compiled shader (`Visual(name, source)`). Bind uniforms and wire input slots with `v.parameter("name") << …`, and route to the display with `v >> screen`. Every input an operator reads must be wired: its primary input (`>>`) and each of its slots. As in TouchDesigner, an operator missing an input is not drawn: a graph that holds one is an error, and the picture on screen stays. Built-in uniforms are always supplied without binding (declare and use them): - `iTime` — playhead position in seconds, not wall time: holds on a pause, follows a seek, rewinds to 0 on a stop - `iResolution` — size in pixels the shader draws at (vec2): the composition size times `iRenderScale` - `iRenderScale` — pixels drawn per composition pixel: the `screen.set_quality` value, rounded up to a whole number. Multiply a size in pixels by it to keep it the same size at every quality - `iBeat` — playhead position in beats - `iCycle` — playhead position in cycles - `iStage` — which of its passes a built-in operator draws (Blur draws three); always 0 in your own shader These names are reserved and cannot be bound. Custom shaders compiled with `Visual(name, source)` expose their own uniforms; any name is accepted. Live audio meter feeds are bindable: `v.parameter("kick") << drums.rms`, `v.parameter("level") << session.master.peak` (each track and the master expose `.rms` / `.peak`). Experimental: Expect breaking changes to shaders, operators and the visuals window. Compiles a fragment-shader source string into a Visual. Share GLSL between shaders by composing source strings in resonon, e.g. `Visual("plasma", load_file("shaders/lib.glsl") + frag)`. Re-running the line with an edited source hot-swaps the operator, keeping its wiring and bindings. Parameters: name: String — the operator's name; its identity on screen source: String — GLSL-ES fragment shader source (non-empty) Returns: Visual — a compiled visual, bindable with `<<` and routable with `>>` Examples: `let v = Visual("plasma", frag);` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#visual --- Visual.parameter [method] fn parameter(name: String) -> VisualParam Binds a uniform to a signal or value (`v.parameter("period") << sig`), or wires a texture input slot with a node (`c.parameter("b") << node` on Composite, `d.parameter("by") << field` on Displace, `l.parameter("table") << ramp` on Lookup). Each built-in operator lists its uniforms and slots on its constructor; a `Visual(name, source)` shader accepts any uniform it declares. Parameters: name: String — a uniform or texture-slot name Returns: VisualParam — a parameter reference, bound with `<<` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#parameter --- Visual.reset [method] fn reset() -> Visual Clears the operator's render state on the next frame — TouchDesigner's Reset pulse. On the node a `feedback` closure returns, the trail starts over from the feedback's seed and keeps building from there. Nothing else in the graph changes and nothing recompiles; on an operator that feeds nothing back it has no visible effect. Returns: Visual — the operator, for chaining Examples: `look.reset();` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#reset --- VisualParam [class] class VisualParam A reference to a visual operator's parameter, produced by `node.parameter("name")` and consumed by `<<` (`v.parameter("period") << sig`). Not used on its own. Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#visualparam --- aftertouch [dsp-builtin] aftertouch(channel) -> Number Read MIDI channel aftertouch, normalized to 0.0–1.0. Parameters: channel — MIDI channel (1–16); omit to read from any channel Returns: current aftertouch pressure in [0.0, 1.0] Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#aftertouch --- arrange [function] fn arrange(sections: Array) -> Timeline | Section Sequences clips and arrangements back-to-back into one Timeline, or sections into one Section. Each clip pattern occupies one cycle; each Timeline or Section element contributes its own length. Repeat an element with `elem * n` or `elem.repeat(n)`. What it lays down is the `base` layer, so masks written on top of the result survive a later whole-lane rewrite. Parameters: sections: Array — clips and arrangements, or sections, to play in order Returns: Timeline | Section — a Section when any element is a section (play it with `.play()`), else a Timeline; length is the sum of element lengths Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#arrange --- audio_buffer_size [function] fn audio_buffer_size() -> Number The number of frames the audio device delivers per callback. The device's own answer, read back from the audio callback — not what was asked for, which is `[audio] buffer_size` in `~/.resonon/preferences.toml`. Same value as `audio_latency()["buffer_frames"]`. Returns: Number — block size in frames Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_buffer_size --- audio_cpu_load [function] fn audio_cpu_load() -> Dict Returns a dict with audio CPU load information. Returns: Dict — keys: load (EMA-smoothed 0.0-1.0), peak (peak since last drain 0.0-1.0) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_cpu_load --- audio_input_devices [function] fn audio_input_devices() -> Array> Lists the devices this machine can record from. The names `[audio] input` is written in, and the channel counts `.set_input()` indexes into. `sample_rates` is what the microphone or interface reports it can run at — a diagnostic, not a setting: the session runs at one rate, chosen for the devices that will be open, so this is what explains an input that cannot join rather than a rate to pick. Returns: Array — dicts with keys: name, channels, sample_rate, sample_rates (Array), buffer_frames (Dict with min/max, or NUL), is_default Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_input_devices --- audio_latency [function] fn audio_latency() -> Dict Returns a dict with audio latency information. `output_ms`, `input_ms` and `monitor_ms` are measured from the devices' own timestamps, so they include the device latency and safety offset that a buffer-size calculation misses. `monitor_ms` is the whole monitoring path — the input device plus the output device, with nothing in between — and is absent until a monitored signal has actually been read. `record_compensation_ms` is the whole of what a recorded take is corrected by: the round trip it went through, the graph's compensation, and the `recording_offset()` residual on top. It is applied automatically; the take keeps every frame it captured either way. Returns: Dict — keys: sample_rate, buffer_frames, buffer_ms, pdc_samples, pdc_ms, output_ms, input_ms, device_ms, record_compensation_ms, record_compensation_frames, monitor_ms (only once measured) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_latency --- audio_output_devices [function] fn audio_output_devices() -> Array> Lists the devices this machine can play through. The names `[audio] output` is written in. `sample_rates` and `buffer_frames` are what `[audio] sample_rate` and `[audio] buffer_size` will be accepted for that device, so what to write in `~/.resonon/preferences.toml` is something you can read rather than something you find by guessing wrong. Returns: Array — dicts with keys: name, channels, sample_rate, sample_rates (Array), buffer_frames (Dict with min/max, or NUL), is_default Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_output_devices --- audio_sample_rate [function] fn audio_sample_rate() -> Number The sample rate the audio output is running at, in Hz. What the device is doing, which is not always what was asked for: set it with `[audio] sample_rate` in `~/.resonon/preferences.toml`, and a rate the device will not run at is reported at startup and not applied. Returns: Number — sample rate in Hz Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#audio_sample_rate --- automation [function] fn automation(...breakpoints: Array) -> Signal Creates an automation signal with breakpoint-based modulation. Call with breakpoint arrays, or empty for the builder pattern. Breakpoint times are in the signal's timebase: cycles unless `.set_timebase()` says otherwise. A breakpoint's curve, a `Curve` or a `Bezier`, shapes the segment from it to the next breakpoint; `Curve.linear` when left out. Parameters: breakpoints: Array — the breakpoints, each `#[time, value]` or `#[time, value, curve]`; omit for the builder pattern Returns: Signal — the automation signal (chain `.at(...)` to add more breakpoints) Examples: `automation(#[0, 400], #[4, 2000, Curve.smooth], #[8, 400])` `automation().at(0, 400).at(4, 2000, Curve.smooth).at(8, 400)` Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#automation --- beats [function] fn beats(n: Number) -> Duration A duration in beats. A beat is a quarter note, as BPM counts it: it follows the tempo. Parameters: n: Number — how many beats (positive) Returns: Duration — `n` beats Examples: `Tri(2).set_timebase(beats(1))` — two sweeps per beat Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#beats --- beats_per_cycle [function] fn beats_per_cycle() -> Number The current number of beats in a cycle. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#beats_per_cycle --- bpm [function] fn bpm() -> Number The current transport tempo in beats per minute, including external clock. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#bpm --- cc [dsp-builtin] cc(cc_num, channel) -> Number Read a MIDI CC value, normalized to 0.0–1.0. Parameters: cc_num — CC number (0–127) channel — MIDI channel (1–16); omit to read from any channel Returns: current CC value in [0.0, 1.0] Example: `__native("cc", 74, 1)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cc --- choose [function] fn choose(seed: Number, array: Array) -> Any Deterministic element selection from an array. The same seed and array always returns the same element. Parameters: seed: Number — integer seed value array: Array — non-empty array to choose from Returns: Any — the selected element of `array` Module: std/random Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/#choose --- choose_true [function] fn choose_true(array: Array) -> Any True random element selection from an array, drawn from the operating system's entropy. Different each call and each run, from the first call on. Parameters: array: Array — non-empty array to choose from Returns: Any — the selected element of `array` Module: std/random Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/#choose_true --- choose_weighted [function] fn choose_weighted(seed: Number, array: Array, weights: Array) -> Any Deterministic weighted element selection from an array. The same seed, array, and weights always returns the same element. Parameters: seed: Number — integer seed value array: Array — non-empty array to choose from weights: Array — non-negative weights, same length as `array` Returns: Any — the selected element of `array`, biased by `weights` Module: std/random Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/#choose_weighted --- chord [function] fn chord(root: Note, name: String, inversion: Number? = NUL) -> Array Returns an array of Notes forming a chord, optionally inverted. Parameters: root: Note — root note (e.g. C4, or a MIDI number such as 60) name: String — chord name: "major", "minor", "dim", "aug", "7", "maj7", "min7", "dim7", "aug7", "sus2", "sus4", "6", "min6", "9", "maj9", "min9", "add9", "power" inversion: Number? — inversion (optional): positive = classical inversion (raise lowest notes), negative = drop voicing (lower highest notes) Returns: Array — the chord as an array of Notes Examples: `chord(C4, "min7")` returns `[C4, Eb4, G4, Bb4]`; `chord(C4, "major", 1)` returns `[E4, G4, C5]` (1st inversion) Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#chord-1 --- chord_names [function] fn chord_names() -> Array Returns an array of all available chord names. Returns: Array — the built-in chord names as Strings Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#chord_names --- clip [function] fn clip(bars: Number, notes: Array) -> Clip Makes a MIDI clip. Bars use the current beats per cycle. Notes at or past the end stay stored but do not play. Overhanging notes stop at the end. Parameters: bars: Number — positive clip length in bars notes: Array — authored notes, including muted notes Returns: Clip — a pattern that loops at its own length Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#clip-1 --- clock [function] fn clock() -> Number Returns time in nanoseconds from an arbitrary reference point. Useful for benchmarking and timing operations. Returns: Number — nanoseconds from an arbitrary reference point Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#clock --- concat [function] fn concat(array1: Array, array2: Array) -> Array Concatenates two arrays. Parameters: array1: Array — first array array2: Array — second array Returns: Array — a new array containing all elements from both arrays Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#concat-1 --- cycle [function] fn cycle() -> Number The current fractional cycle position. Reading does not wait for playback. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#cycle --- cycles [function] fn cycles(n: Number) -> Duration A duration in cycles. A cycle is a bar: it follows the tempo. Parameters: n: Number — how many cycles (positive) Returns: Duration — `n` cycles Examples: `Saw(1).set_timebase(cycles(2))` — one sweep every two bars Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#cycles --- delay [dsp-builtin] delay(input, time) -> Number Integer sample delay (circular buffer, max 1 second). Parameters: input — audio signal time — delay time in samples Returns: delayed signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#delay --- delay_interp [dsp-builtin] delay_interp(input, time) -> Number Fractional delay with linear interpolation (max 1 second). Parameters: input — audio signal time — delay time in samples (fractional values supported) Returns: delayed signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#delay_interp --- dsp::abs [dsp-builtin] abs(x) -> Number Absolute value. Parameters: x — input value Returns: |x| Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#abs --- dsp::ceil [dsp-builtin] ceil(x) -> Number Round up to the nearest integer. Parameters: x — input value Returns: smallest integer >= x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#ceil --- dsp::clamp [dsp-builtin] clamp(value, min, max) -> Number Clamp a value to a range. Parameters: value — input value min — lower bound max — upper bound Returns: value clamped to [min, max] Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#clamp --- dsp::cos [dsp-builtin] cos(x) -> Number Cosine function. Parameters: x — angle in radians Returns: cos(x) in the range [-1, 1] Example: `__native("cos", phase * TWOPI)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#cos --- dsp::exp [dsp-builtin] exp(x) -> Number Exponential function (e^x). Parameters: x — exponent Returns: e raised to the power x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#exp --- dsp::floor [dsp-builtin] floor(x) -> Number Round down to the nearest integer. Parameters: x — input value Returns: largest integer `<= x` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#floor --- dsp::fract [dsp-builtin] fract(x) -> Number Fractional part (x - floor(x)). Parameters: x — input value Returns: fractional part in [0, 1) Example: `phase = __native("fract", phase + freq * INV_SR)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#fract --- dsp::ftom [dsp-builtin] ftom(freq) -> Number Frequency in Hz to MIDI note number. Parameters: freq — frequency in Hz Returns: MIDI note number (e.g. 440.0 -> 69) Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#ftom --- dsp::lerp [dsp-builtin] lerp(a, b, t) -> Number Linear interpolation between two values. Parameters: a — start value b — end value t — interpolation factor (0.0 = a, 1.0 = b) Returns: a + (b - a) * t Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#lerp --- dsp::log [dsp-builtin] log(x) -> Number Natural logarithm (ln). Parameters: x — input value (must be > 0) Returns: natural log of x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#log --- dsp::log10 [dsp-builtin] log10(x) -> Number Base-10 logarithm. Parameters: x — input value (must be > 0) Returns: log base 10 of x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#log10 --- dsp::log2 [dsp-builtin] log2(x) -> Number Base-2 logarithm. Parameters: x — input value (must be > 0) Returns: log base 2 of x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#log2 --- dsp::max [dsp-builtin] max(a, b) -> Number Maximum of two values. Parameters: a — first value b — second value Returns: the larger of a and b Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#max --- dsp::min [dsp-builtin] min(a, b) -> Number Minimum of two values. Parameters: a — first value b — second value Returns: the smaller of a and b Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#min --- dsp::mtof [dsp-builtin] mtof(midi) -> Number MIDI note number to frequency in Hz. Parameters: midi — MIDI note number (fractional values supported for microtonal) Returns: frequency in Hz (e.g. 69 -> 440.0) Example: `let freq = __native("mtof", note)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#mtof --- dsp::pow [dsp-builtin] pow(base, exp) -> Number Raise base to exponent. Parameters: base — base value exp — exponent Returns: base^exp Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#pow --- dsp::round [dsp-builtin] round(x) -> Number Round to the nearest integer. Parameters: x — input value Returns: nearest integer to x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#round --- dsp::sin [dsp-builtin] sin(x) -> Number Sine function. Parameters: x — angle in radians Returns: sin(x) in the range [-1, 1] Example: `__native("sin", phase * TWOPI)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#sin --- dsp::sqrt [dsp-builtin] sqrt(x) -> Number Square root. Parameters: x — input value (must be >= 0) Returns: square root of x Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#sqrt --- dsp::tan [dsp-builtin] tan(x) -> Number Tangent function. Parameters: x — angle in radians Returns: tan(x) Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#tan --- dsp::tanh [dsp-builtin] tanh(x) -> Number Hyperbolic tangent — useful for soft clipping. Parameters: x — input value Returns: tanh(x) in the range (-1, 1) Example: `__native("tanh", input * gain)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#tanh --- euclid [function] fn euclid(hits: Number, steps: Number, pattern: Pattern | Note | Array, rotation: Number? = NUL) -> Pattern Creates a Euclidean rhythm pattern. Distributes hits as evenly as possible across steps. The source's events are dealt onto the hits in order, and wrap when there are more hits than events. Parameters: hits: Number — number of events to place (>= 0) steps: Number — total steps in the pattern (> 0) pattern: Pattern | Note | Array — the pattern to apply at each hit; a note or an array of notes plays as a sequence rotation: Number? — offset rotation (optional, defaults to 0) Returns: Pattern — the Euclidean rhythm pattern Examples: `euclid(3, 8, [C4])` creates a classic 3-over-8 rhythm. Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#euclid-1 --- The Audio Graph [explanation] Every sound you make in resonon flows through an **audio graph**: a network of mixer channels that all feed one master output. If you've used a DAW, you already know its shape — tracks with an instrument and an effect chain, a fader, aux sends, and a master bus at the end. This page is the model behind that graph, so that routing, gain and modulation all hang on the same picture. Sections: - explanation/audio/01-the-audio-graph#a-graph-in-miniature | A graph in miniature - explanation/audio/01-the-audio-graph#a-track-is-its-name | A track is its name - explanation/audio/01-the-audio-graph#signal-flow-through-a-track | Signal flow through a track - explanation/audio/01-the-audio-graph#gain-staging | Gain staging - explanation/audio/01-the-audio-graph#one-output-any-number-of-sends | One output, any number of sends - explanation/audio/01-the-audio-graph#mute-and-solo | Mute and solo - explanation/audio/01-the-audio-graph#buses-and-dependency-order | Buses and dependency order - explanation/audio/01-the-audio-graph#parameters-are-modulation-targets | Parameters are modulation targets - explanation/audio/01-the-audio-graph#related | Related Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/ --- The Audio Graph > A graph in miniature [explanation] Here is a complete session with two channels: a drum track, and a reverb track the drums feed. ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Reverb }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("reverb"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let verb = session.track("reverb"); verb.set_effects(#[Reverb("reverb", 0.8, 0.3)]); drums << [bd sd bd sd]; drums.set_send(verb, 0.3); session.master.volume << -2; PLAY; ``` Two tracks, three routes. The drum track plays dry to `session.master` and sends a copy of itself to the `reverb` track at 30%. The reverb track plays its wet output to `session.master` as well. The master sums everything and turns it down 2 dB before it reaches your speakers. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#a-graph-in-miniature Next: explanation/audio/01-the-audio-graph#a-track-is-its-name --- The Audio Graph > A track is its name [explanation] `session.create_track("drums")` makes the channel, once: a name that exists is an error. `session.track("drums")` hands back that channel every time — same fader, same instrument, same effect chain. The name is not a label on a track; it *is* the track, the way a channel in Live is the channel whatever you did to it. That is what makes re-running code safe while the music plays: a line you execute again talks to the track that is already there instead of stacking a second one. The flip side is that two `session.track("bass")` calls mean one track. Two tracks need two names. The session owns every track. A track stays until it is deleted with `session.delete_track(name)`, also when no variable holds it: tracks that output to it now output to `session.nowhere`, and its name is free for a new track. A deleted track gives back its place in the track limit. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#a-track-is-its-name Previous: explanation/audio/01-the-audio-graph#a-graph-in-miniature Next: explanation/audio/01-the-audio-graph#signal-flow-through-a-track --- The Audio Graph > Buses and dependency order [explanation] Any track can act as a **bus**: route several tracks into it and its effect chain treats them as one. Because tracks feed tracks, the graph can be several layers deep (`track → bus → master`). Resonon processes tracks in dependency order — every track that feeds another is rendered first — and rejects routing cycles, so a bus always has its inputs ready before it runs. A **sidechain** input feeds a track's audio into an effect's detector rather than into the mix. It creates a dependency, so it is ordered like any other edge and cannot form a cycle, but the source is not heard through it. A mono sidechain port folds a stereo source down to `(L + R) / 2`. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#buses-and-dependency-order Previous: explanation/audio/01-the-audio-graph#mute-and-solo Next: explanation/audio/01-the-audio-graph#parameters-are-modulation-targets --- The Audio Graph > Gain staging [explanation] A track's `volume` is in decibels; `0` is unity. Its `pan` runs from `-1` (hard left) to `1` (hard right) with a **constant-power** law: a source keeps a steady perceived loudness as it moves across the stereo field. Centre is unity, and each side rises to +3 dB at the hard-panned extreme, so the total acoustic power stays constant — the behaviour of a DAW pan pot. The consequence is that a near-full-scale source can clip when hard-panned; trim its `volume` if it does. `session.master` is the last gain stage. Every track reaches it at unity unless you route it elsewhere, and `session.master.volume` trims the whole mix, exactly like a master fader. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#gain-staging Previous: explanation/audio/01-the-audio-graph#signal-flow-through-a-track Next: explanation/audio/01-the-audio-graph#one-output-any-number-of-sends --- The Audio Graph > Mute and solo [explanation] `mute()` is Live's **Track Activator**: the track stays in the graph and keeps running, but nothing leaves it. `solo()` is **solo-in-place**, as in Live. The soloed tracks are heard *where they are* in the mix: - The buses and returns a soloed track feeds stay audible, so its sends still sound. - Soloing a bus solos the tracks that output to it, as soloing a group track does. - Soloing a return keeps every send into it and silences the senders' own outputs: you hear the reverb alone. - A sidechain key keeps feeding its detector. A kick that ducks the bass still ducks it when only the bass is soloed. `solo()` is exclusive, like a plain click on Live's Solo button: every other solo is released. `add_solo()` adds a track to the soloed tracks, like a Cmd-click. MIDI tracks share the same solo set, so soloing a MIDI track silences every audio track, and the other way round. Master has neither: it is the mix itself. A gate fades over 10 ms to exact silence, so a mute or solo does not click. An offline render starts from the mix as it stands, without that fade, and `render(track)` writes a track the solo silences as a silent file — the stems still add up to master. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#mute-and-solo Previous: explanation/audio/01-the-audio-graph#one-output-any-number-of-sends Next: explanation/audio/01-the-audio-graph#buses-and-dependency-order --- The Audio Graph > One output, any number of sends [explanation] Every track has exactly **one output**. It starts as `session.master` at unity gain, which is why sound reaches your speakers without any wiring. `>>` sets that output — `drums >> bus;` — and setting it *replaces* it: there is nothing to add to, because there is only one. This is Live's **Audio To**, and like Live's chooser it is set on its own, apart from the track's definition. A **send** is different: it is an additional, post-fader copy to another destination, at a level of its own. The output keeps playing at unity, so a send layers on top of the dry signal — the classic reverb or delay return. Sending to the track's *own* output destination is the one case that doesn't add a copy: it sets the level of the output edge instead. That is what turns two ordinary sends into a dry/wet crossfade — `drums.set_send(rev, 0.6); drums.set_send(session.master, 0.4);` routes the track *through* a bus without doubling its level. It also explains an ordering rule: `>>` sets the output edge back to unity, so setting the route after a crossfade undoes the crossfade, automated level and all. The same rule holds the other way round: routing a track to a bus it sends to replaces the send, so `drums >> verb;` leaves one route to `verb`, the output, at unity. The output can also be the audio interface itself — `Output(2, 3)`, Live's **Ext. Out**. That is still the one output, so it replaces the route to master; the track's sends are unaffected, and it stays in the same latency compensation as the master, so it stays in time with the mix. `session.master` has an output too, and it can only be hardware; it starts on the first two channels. The output can also be `session.nowhere` — Live's **Sends Only**. `drums >> session.nowhere;` takes the track out of the mix, and its sends keep feeding their buses: a fully wet reverb feed, or a parallel bus with no dry signal. A track that reaches nothing at all is not heard, so its plugins' latency delays nothing else. Channel numbers belong in the piece because every rig has a channel 0; the device they belong to is a fact about your machine, set in preferences (see [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/)). Switching to an interface with fewer channels says which outputs it cannot play as routed: a stereo pair it has only one channel of plays folded to mono on that channel, and an output it has none of is silent. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#one-output-any-number-of-sends Previous: explanation/audio/01-the-audio-graph#gain-staging Next: explanation/audio/01-the-audio-graph#mute-and-solo --- The Audio Graph > Parameters are modulation targets [explanation] Faders, pans and send levels aren't just static numbers. The `<<` operator that sends a pattern to a track also binds a **signal** to a parameter: ```resonon continue use "std/signals" { Sine }; drums.volume << Sine(0.5).range(-12, 0); ``` The audio engine evaluates the signal as the graph runs, so the fader glides instead of stepping. [Signals & Time](/docs/explanation/audio/03-signals-and-time/) explains how a signal keeps time. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#parameters-are-modulation-targets Previous: explanation/audio/01-the-audio-graph#buses-and-dependency-order Next: explanation/audio/01-the-audio-graph#related --- The Audio Graph > Related [explanation] - [Your First Mix](/docs/tutorials/audio/01-your-first-mix/) — tracks, effects, sends and the master, step by step - [Group Tracks on a Bus](/docs/how-to/audio/04-group-tracks-on-a-bus/) — one fader and shared effects for a group - [Share an Effect with a Send](/docs/how-to/audio/05-share-an-effect-with-a-send/) — return tracks and send levels - [Descriptions & Slots](/docs/explanation/audio/02-descriptions-and-slots/) — why re-running a rig keeps what is playing - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — how the graph is driven in time Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#related Previous: explanation/audio/01-the-audio-graph#parameters-are-modulation-targets --- The Audio Graph > Signal flow through a track [explanation] A single track is a fixed chain. Audio enters at the top and leaves at the bottom: ```txt input (hardware channels, when the track has one) │ instrument (the sound source — Sampler, plugin, or DSP) │ effect chain (effects applied in order: filter, delay, …) │ fader (volume + pan; the meter and sidechain taps read here) │ sends ──[gate]───▶ other tracks / master (post-fader copies) │ [gate] (mute and solo) ▼ output (one: master, another track, or hardware channels) ``` The order is what matters: - **Input** is mixed into the track before anything else, so a live signal runs through the same effects and fader an instrument would. - The **instrument** generates the sound. A track holds exactly one. - The **effect chain** processes it in order, index `0` first. A filter-then-delay is not a delay-then-filter, so reordering the chain changes the sound. - The **fader** applies `volume` and `pan` after the effects. - **Sends** branch *post-fader*. Turn the track's fader down and its sends quieten with it. - **Mute and solo** gate the end of the chain: the output, every send and a hardware output. The instrument and effects keep running, so a reverb tail is still there when you unmute, and the meter and sidechain taps read the signal before the gate. Page: explanation/audio/01-the-audio-graph URL: https://resonon.org/docs/explanation/audio/01-the-audio-graph/#signal-flow-through-a-track Previous: explanation/audio/01-the-audio-graph#a-track-is-its-name Next: explanation/audio/01-the-audio-graph#gain-staging --- Descriptions & Slots [explanation] In a DAW you drag a device onto a track and it is there. In resonon you write the rig as code and run it — and then run it again, and again, while it plays. For that to be safe, running a line must make the session *become* what the line says, not add another copy of it. Two ideas make that work: a constructor is a description, and a device on a track is identified by its slot name. Sections: - explanation/audio/02-descriptions-and-slots#a-constructor-is-a-description | A constructor is a description - explanation/audio/02-descriptions-and-slots#a-chain-is-matched-by-name | A chain is matched by name - explanation/audio/02-descriptions-and-slots#a-layout-is-declarative | A layout is declarative - explanation/audio/02-descriptions-and-slots#related | Related Page: explanation/audio/02-descriptions-and-slots URL: https://resonon.org/docs/explanation/audio/02-descriptions-and-slots/ --- Descriptions & Slots > A chain is matched by name [explanation] `set_effects(#[...])` sets a track's **entire** chain in one call. The obvious worry is that re-running it throws away what is running. It doesn't: the name you gave each effect is its **slot identity**, and `set_effects` matches the list you passed against the chain that is already there, name by name. - A name already in the chain **keeps its live effect**. Modulation running on it survives, and the writes the line records land on the live effect: change `Filter("lp", FilterType.lowpass, 1200)` to `Filter("lp", FilterType.lowpass, 12000)`, re-run, and the cutoff moves to 12000. - A name not yet in the chain is built and inserted. - A name you removed from the list is taken out. - Moving a name reorders the chain around it. So you edit the list and re-run, and the chain becomes what you wrote while the music keeps playing. Parameter values follow one rule: **the last write executed wins.** Running a constructor writes the arguments you gave it — and only those, so `Filter("lp", FilterType.lowpass)` leaves the cutoff where it is. A `set_parameter` or a turn of the plugin's own knob is a write too, and it stands until the next one. Placing a handle you bound earlier doesn't run its constructor again, so `drums.set_effects(#[lp, delay])` with a `let lp = Filter("lp", FilterType.lowpass, 250)` from before leaves `lp`'s cutoff alone; re-running the `let` line is what writes 250 again. The one thing that *does* start a slot over is changing what kind of effect it is. Put a `Filter("delay", FilterType.lowpass, 800)` where a `Delay("delay", …)` used to be and the name no longer describes the same effect, so the slot is rebuilt from the arguments you just gave — there are no old parameters to carry across. Two rules follow. Names must be unique within a chain: two slots called `"delay"` on one track is an error, not a guess (different tracks may reuse a name). And `set_effects(#[])` clears the chain, because an empty list is still a description of what you want. An instrument follows the same rule with a single slot. `set_instrument(...)` compares what you asked for against what is loaded; when they are the same — the same plugin, the same kit — it keeps the live instance, with its modulation and any notes still sounding, and writes the parameters the line records onto it, by the same last-write-wins rule. Ask for something different and it replaces the instrument. Replacing it, or taking it off with `remove_instrument()`, fades the outgoing instrument out over a few milliseconds so it doesn't click; the track's effects, and their tails, stay. Page: explanation/audio/02-descriptions-and-slots URL: https://resonon.org/docs/explanation/audio/02-descriptions-and-slots/#a-chain-is-matched-by-name Previous: explanation/audio/02-descriptions-and-slots#a-constructor-is-a-description Next: explanation/audio/02-descriptions-and-slots#a-layout-is-declarative --- Descriptions & Slots > A constructor is a description [explanation] `Delay("delay", 0.25, 0.5)` does not build a delay. It writes down three things — the slot name `"delay"`, what kind of device to build, and the settings to give it — and hands you a **handle**. `drums.set_effects(#[...])` is what builds it. Until that line runs, nothing is compiled, nothing is loaded, and nothing makes a sound. The same holds for instruments: `Sampler(Kit("CR-78"))` describes a sampler, and `track.set_instrument(...)` builds it. That splits a handle's methods in two: - **Writes are recorded.** `set_parameter`, `set_program` and `load_state` on a handle that isn't placed yet remember what you asked for and write it when the track places the handle. Constructor arguments are recorded writes too: `Delay("delay", 0.25)` means *set Time to 0.25*. - **Reads need an instance.** `parameter`, `parameters`, `programs`, `save_state`, `connect_input` and the GUI methods have nothing to read until the device is on a track, and the error says so. ```resonon no-check let echo = Delay("delay", 0.25, 0.5); echo.set_parameter("Time", 0.4); // fine — recorded, written when it is placed print(echo.parameters()); // error: "delay" is not on a track yet drums.set_effects(#[echo]); // built here print(echo.parameters()); // now reads the live effect ``` `.name()` is the exception — it is the one thing a description already knows. Once placed, the handle stops being a description and becomes a *reference* to "the slot called `delay` on that track", re-resolved on every call. It keeps working across re-runs, even when the slot underneath is rebuilt. A plugin has two moments rather than one. Its **name** is resolved on the constructor line, so a typo or a bundle the scanner skipped is reported where you typed it. The expensive half — opening the binary, activating it, enumerating its parameters — waits for placement, so a plugin that resolves but fails to *load* reports on the placement line. Page: explanation/audio/02-descriptions-and-slots URL: https://resonon.org/docs/explanation/audio/02-descriptions-and-slots/#a-constructor-is-a-description Next: explanation/audio/02-descriptions-and-slots#a-chain-is-matched-by-name --- Descriptions & Slots > A layout is declarative [explanation] Put together, those rules mean a rig written as code is a *description of the rig you want*, and running it makes the live graph match. A function that builds tracks and returns their handles — a **layout** — is no new syntax, and running it a second time rebuilds nothing: the names line up, so you get the same tracks and the same effects, still playing. That is why editing a layout live is worth doing. Add an effect to a `.set_effects(#[...])` list and re-run — it is inserted in place. Delete one and it is removed. Move one and the chain reorders. Every name still in the list keeps its live instance, so running modulation and every value you didn't rewrite carry across the edit. You don't reset and you don't start the piece over; the code you are looking at simply becomes true. Page: explanation/audio/02-descriptions-and-slots URL: https://resonon.org/docs/explanation/audio/02-descriptions-and-slots/#a-layout-is-declarative Previous: explanation/audio/02-descriptions-and-slots#a-chain-is-matched-by-name Next: explanation/audio/02-descriptions-and-slots#related --- Descriptions & Slots > Related [explanation] - [Your First Mix](/docs/tutorials/audio/01-your-first-mix/) — write a rig as a layout, step by step - [Build an Effect Chain](/docs/how-to/audio/02-build-an-effect-chain/) — add, reorder and dial effects - [Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/) — the same idea for functions and modules - [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) — where the devices sit Page: explanation/audio/02-descriptions-and-slots URL: https://resonon.org/docs/explanation/audio/02-descriptions-and-slots/#related Previous: explanation/audio/02-descriptions-and-slots#a-layout-is-declarative --- Signals & Time [explanation] A **signal** is a value that moves. Anything you set with `<<` — an effect parameter, a track's volume or pan, a send level — can take a signal instead of a number, and the parameter follows it. In DAW terms, one operator covers both the modulation matrix and the automation lane. This page is about how a signal keeps time, because that decides what you hear when you re-run a line, pause, or seek. Sections: - explanation/audio/03-signals-and-time#a-signal-runs-at-audio-rate | A signal runs at audio rate - explanation/audio/03-signals-and-time#a-signal-counts-in-its-timebase | A signal counts in its timebase - explanation/audio/03-signals-and-time#a-signal-owns-its-clock | A signal owns its clock - explanation/audio/03-signals-and-time#the-transport-moves-signal-time-binding-restarts-it | The transport moves signal time, binding restarts it - explanation/audio/03-signals-and-time#a-modulator-loops-an-automation-lane-is-placed | A modulator loops, an automation lane is placed - explanation/audio/03-signals-and-time#some-settings-are-not-automatable | Some settings are not automatable - explanation/audio/03-signals-and-time#related | Related Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/ --- Signals & Time > A modulator loops, an automation lane is placed [explanation] `automation(#[0, 0], #[4, 1])` bound with `<<` is a signal like any other: its breakpoint times are measured from the moment its clock starts. It is a shape you attach to a parameter. An automation curve written into a [section](/docs/explanation/audio/04-the-arrangement-model/) lane is *placed* instead: `song[drums].volume.at(8, 8) << curve` sits at cycles 8–16 of the song, in absolute cycles, exactly like a clip on an arrangement track. It is bound the same way whether the song is playing or stopped, it masks the curve beneath it, and when the song reaches cycle 8 the swell is there. That is the difference between a modulator you perform and a lane you arrange. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#a-modulator-loops-an-automation-lane-is-placed Previous: explanation/audio/03-signals-and-time#the-transport-moves-signal-time-binding-restarts-it Next: explanation/audio/03-signals-and-time#some-settings-are-not-automatable --- Signals & Time > A signal counts in its timebase [explanation] A signal's numbers are counted in a unit: its **timebase**. By default the unit is one cycle, so `Sine(4)` sweeps four times per cycle and an LFO stays locked to the tempo when the tempo changes. A change mid-play bends its speed and never jumps its phase. `.set_timebase()` sets another unit, given as a duration. Musical durations follow the tempo: `Sine(1).set_timebase(note_value(1, 8).dotted())` sweeps once per dotted eighth, `Saw(1).set_timebase(cycles(2))` once every two bars. Seconds do not: `Sine(2).set_timebase(seconds(1))` runs at 2 Hz at any tempo, like an LFO with its sync switched off. The same unit applies to everything the signal counts, so an automation curve's breakpoint times and a `signal()` pattern's steps are in its timebase too. The unit belongs to the signal, not to the number. That is the difference from converting: a rate computed from the tempo of the moment goes stale when the tempo changes, and a timebase never does. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#a-signal-counts-in-its-timebase Previous: explanation/audio/03-signals-and-time#a-signal-runs-at-audio-rate Next: explanation/audio/03-signals-and-time#a-signal-owns-its-clock --- Signals & Time > A signal owns its clock [explanation] A signal has one clock, and it belongs to the signal — not to any particular binding. Its local time starts at zero on the next cycle boundary after you bind it, and binding it to the same parameter again restarts it. That's what you want for one-shots: re-running a `signal_ramp(0, 1, 4)` line restarts the ramp cleanly. A restart lands on the grid, so it can be up to a cycle away — and until it lands, the signal keeps running exactly as it was. Nothing drops out or jumps to the bottom of its range while it waits, the way a launch-quantized clip keeps playing until the downbeat. A signal you have just written, with no phase to carry yet, waits at its start value. Because the clock lives on the signal, everything reading that signal sees the same phase — every parameter it drives, and `scope()` too. Point one LFO at two parameters and they stay locked together. Binding a running signal to one more parameter doesn't restart it; rebinding it where it is already bound does, and every parameter it drives restarts with it. When you want two modulators that drift independently, make two signals. `.clone()` makes the second one from the first: the same settings, with a clock of its own that starts when the copy is bound. ```resonon use "std/signals" { Sine }; let lfo = Sine(1).set_timebase(beats(4)); let other = lfo.clone(); ``` The copy keeps the signal's shape. A source the signal uses twice, as in `lfo + lfo.range(0, 1)`, is one source in the copy too. Cloning an array of signals copies each one on its own, so two signals in it that shared an LFO no longer share one. Two settings on the signal change this. `.continuous()` puts it on the global clock instead, so you can change its speed without its phase jumping. `.set_retrigger()` resets its phase every period you give it: `.set_retrigger(cycles(1))` on every cycle, `.set_retrigger(beats(1))` on every beat, `.set_retrigger(note_value(1, 8).dotted())` every dotted eighth. Without one, a signal never resets. Like `.set_timebase()`, both configure the signal itself, so they hold wherever it is used and reach it through `.range()` and other wrappers in any order. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#a-signal-owns-its-clock Previous: explanation/audio/03-signals-and-time#a-signal-counts-in-its-timebase Next: explanation/audio/03-signals-and-time#the-transport-moves-signal-time-binding-restarts-it --- Signals & Time > A signal runs at audio rate [explanation] The engine evaluates a bound signal as the graph runs, not once per event, so a parameter glides instead of stepping. Signal arithmetic — `Sine(1) + Tri(3) * 0.5`, `-Sine(1)` — runs sample by sample with no allocation, so layering and nesting modulators costs little. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#a-signal-runs-at-audio-rate Next: explanation/audio/03-signals-and-time#a-signal-counts-in-its-timebase --- Signals & Time > Related [explanation] - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — LFOs in practice - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — ramps and breakpoint curves - [Signals](/docs/reference/stdlib/signals/) — every signal constructor and method - [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) — how placed automation masks and resumes Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#related Previous: explanation/audio/03-signals-and-time#some-settings-are-not-automatable --- Signals & Time > Some settings are not automatable [explanation] A few parameters take a plain number only, because changing them is not a change of level but a change to the graph. `track.set_delay(ms)` — the calibration for outboard gear — re-plans the graph's latency compensation when it is set, so it cannot be driven by a signal. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#some-settings-are-not-automatable Previous: explanation/audio/03-signals-and-time#a-modulator-loops-an-automation-lane-is-placed Next: explanation/audio/03-signals-and-time#related --- Signals & Time > The transport moves signal time, binding restarts it [explanation] A restart is a *binding* gesture — `<<` is the note-on. The transport does not retrigger anything: `PAUSE` freezes signal time along with the playhead, and the `PLAY` after it picks every signal up on exactly the phase it froze on. Moving the playhead is different. Signal time *is* the playhead, so `SEEK` takes it along — every signal restarts at the position you seeked to, right there rather than a cycle later. `STOP` is a seek to 0 and behaves the same way, including while the transport is stopped: `SEEK 8` then `PLAY` starts at cycle 8 with every signal already positioned there. The upshot is that phase depends only on where the playhead is, never on how it got there. Seek to the same place twice and you hear the same thing — which is also what makes a bounce reproducible. Page: explanation/audio/03-signals-and-time URL: https://resonon.org/docs/explanation/audio/03-signals-and-time/#the-transport-moves-signal-time-binding-restarts-it Previous: explanation/audio/03-signals-and-time#a-signal-owns-its-clock Next: explanation/audio/03-signals-and-time#a-modulator-loops-an-automation-lane-is-placed --- The Arrangement Model [explanation] A looping pattern is the right shape for live coding, but a finished piece has a form — an intro, a verse, a chorus. Resonon's arrangement model is the arrangement view of a DAW written as values: a **timeline** is one lane on a ruler, and a **section** is a slice of the whole piece — every track's clips, its automation and its picture under one length. This page explains the rules those values follow, which are chosen so that a song can be edited while it plays without anything being lost. Sections: - explanation/audio/04-the-arrangement-model#a-timeline-is-a-pattern | A timeline is a pattern - explanation/audio/04-the-arrangement-model#the-grid-is-what-you-snap-to | The grid is what you snap to - explanation/audio/04-the-arrangement-model#a-later-entry-masks-it-doesnt-cut | A later entry masks, it doesn't cut - explanation/audio/04-the-arrangement-model#writing-is-an-upsert | Writing is an upsert - explanation/audio/04-the-arrangement-model#layers | Layers - explanation/audio/04-the-arrangement-model#what-you-see-is-what-you-hear | What you see is what you hear - explanation/audio/04-the-arrangement-model#when-an-edit-is-heard | When an edit is heard - explanation/audio/04-the-arrangement-model#related | Related Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/ --- The Arrangement Model > A later entry masks, it doesn't cut [explanation] When two entries cover the same cycle, the later one wins — but the entry underneath is **masked**, not cut. It is still there, hidden for exactly as long as the mask lasts, and when the mask ends it **resumes in its own phase** rather than restarting. `show()` marks that with an offset: ```text timeline — 16 cycles, 2 entries layers: base, main, fills 0..4 [bd bd sd bd] main 4..6 [hh hh] fills 6..16 [bd bd sd bd] +6c main ``` After the fill, the groove picks up at **its own** cycle 6 instead of starting over. The same holds across a section boundary: a fill punched from the end of a verse into a chorus plays through the seam, and the chorus resumes where it would have been. Nothing is destroyed, which is what makes this safe to live-code. Lay down a groove, punch variations over it, and take them away again without retyping the groove. A continuous lane needs the edges spelled out. On an automation lane, the curve beneath a mask **holds its level right up to the mask edge and steps there**; it doesn't slide towards the mask across the preceding cycles. Clear the mask and the curve underneath comes back exactly as authored. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#a-later-entry-masks-it-doesnt-cut Previous: explanation/audio/04-the-arrangement-model#the-grid-is-what-you-snap-to Next: explanation/audio/04-the-arrangement-model#writing-is-an-upsert --- The Arrangement Model > A timeline is a pattern [explanation] A timeline isn't sound on its own; it is a pattern source. You send it to a track with `<<` like any other pattern, and when it reaches its end it loops. Each slot queries its pattern one cycle at a time across the slot's duration, so a one-cycle figure repeats and a multi-cycle pattern advances through its own cycles. Any cycle no slot covers is silent — gaps are how breaks and drops are written, not an oversight. A section adds the thing a set of timelines can't guarantee: one length for every lane. Because the length belongs to the section and not to each track's lane, the tracks cannot drift out of alignment, and a section boundary is a boundary for the whole piece. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#a-timeline-is-a-pattern Next: explanation/audio/04-the-arrangement-model#the-grid-is-what-you-snap-to --- The Arrangement Model > Layers [explanation] Masks live on **layers**, stacked bottom to top: - **`base`** is the structure. `arrange()` lays sections down here, and a bare `song[drums] << clip` replaces it. - **`main`** is where a plain `.at()` write goes. - **Named layers** — `.layer("fills")` — are stacked on top when first written to, and group punches you want to lift together with `.mute()` and bring back, in phase, with `.unmute()`. Because the structure and the punches live on different layers, rewriting the song underneath leaves your punches alone, and `.clear()` removes what you punched while keeping what `arrange()` built. A hand-built `timeline()` has an empty base — nothing laid a structure down — so every `.at()` write lands on `main`, and `.clear()` empties it outright. Only a write creates a layer. `.layer("fills")` on its own is a name and a target, so naming a layer that was never written to is an error rather than a silent no-op: a typo fails where you can see it. The stack order is declarative — `.set_layer_order(#[...])` states it, and running the line again changes nothing. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#layers Previous: explanation/audio/04-the-arrangement-model#writing-is-an-upsert Next: explanation/audio/04-the-arrangement-model#what-you-see-is-what-you-hear --- The Arrangement Model > Related [explanation] - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — the same model, task by task - [Arrange a Song](/docs/tutorials/getting-started/05-arrange-a-song/) — a guided first arrangement - [Signals & Time](/docs/explanation/audio/03-signals-and-time/) — a looping modulator versus a placed automation lane Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#related Previous: explanation/audio/04-the-arrangement-model#when-an-edit-is-heard --- The Arrangement Model > The grid is what you snap to [explanation] A timeline's length is a ruler in whole cycles, but nothing is placed by the ruler: a slot may begin and end anywhere. `.at(2.5, 1.25)` means exactly that. Positions a musician means stay exact — a third of a cycle is a third, not `0.3333` — so a run of triplet placements cannot drift. This matters most for material that was recorded. A take lands where latency compensation measured it, which is almost never on a cycle line; an arrangement that only knew the grid would have to round that measurement away. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#the-grid-is-what-you-snap-to Previous: explanation/audio/04-the-arrangement-model#a-timeline-is-a-pattern Next: explanation/audio/04-the-arrangement-model#a-later-entry-masks-it-doesnt-cut --- The Arrangement Model > What you see is what you hear [explanation] `show()` renders the **resolved** stack — one row per audible interval, tagged with the layer that won it. That is the answer to "what will this sound like", which the list of writes cannot give once masks are involved. A muted layer contributes no rows, and an entry that is completely hidden is not an interval at all. `.entries()` answers the other question — "what did I write here" — in authoring order, and flags an entry that is completely hidden as `masked`. That is the one thing the resolved view cannot tell you, and the reason a covered entry stays findable instead of mysterious. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#what-you-see-is-what-you-hear Previous: explanation/audio/04-the-arrangement-model#layers Next: explanation/audio/04-the-arrangement-model#when-an-edit-is-heard --- The Arrangement Model > When an edit is heard [explanation] Every lane edit on a playing song lands live, with no second `play()` and no rewind. "Live" means a different moment on each kind of lane: | Lane | Takes effect | Why | | ------------------------ | ------------------- | ---------------------------------------------------------------- | | Notes (`song[drums]`) | next cycle boundary | the lane swaps its pattern once per cycle, so notes already sounding are never cut off mid-cycle | | Automation (`.volume`) | next audio block | the merged curve re-binds and the engine picks it up on its next callback | | Screen (`song[screen]`) | next frame | the renderer re-selects the covering span every frame | So a note edit — including `.mute()` and `.clear()` on a note layer — is quantized to the cycle, and you hear the rest of the current cycle first. Automation and visuals are effectively immediate. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#when-an-edit-is-heard Previous: explanation/audio/04-the-arrangement-model#what-you-see-is-what-you-hear Next: explanation/audio/04-the-arrangement-model#related --- The Arrangement Model > Writing is an upsert [explanation] Re-running a line must not stack another copy of what it wrote. A write therefore **upserts by start**: editing `.at(4, 2)` to `.at(4, 1)` and running it again reshapes that same mask. `.clear()` on a position lifts the mask and brings back exactly what it was hiding. Page: explanation/audio/04-the-arrangement-model URL: https://resonon.org/docs/explanation/audio/04-the-arrangement-model/#writing-is-an-upsert Previous: explanation/audio/04-the-arrangement-model#a-later-entry-masks-it-doesnt-cut Next: explanation/audio/04-the-arrangement-model#layers --- Recording & Latency [explanation] Recording is where timing stops being abstract. You play along to sound that has already left the speakers, and what you play reaches the machine later still. This page explains how resonon keeps input and output on one timeline, and how it places a take where it was performed. Sections: - explanation/audio/05-recording-and-latency#the-piece-names-channels-the-machine-names-devices | The piece names channels, the machine names devices - explanation/audio/05-recording-and-latency#one-device-one-clock | One device, one clock - explanation/audio/05-recording-and-latency#one-session-one-sample-rate | One session, one sample rate - explanation/audio/05-recording-and-latency#a-take-is-a-reference | A take is a reference - explanation/audio/05-recording-and-latency#compensation-moves-where-a-take-begins | Compensation moves where a take begins - explanation/audio/05-recording-and-latency#monitoring-is-not-compensated | Monitoring is not compensated - explanation/audio/05-recording-and-latency#a-stall-doesnt-shorten-a-take | A stall doesn't shorten a take - explanation/audio/05-recording-and-latency#related | Related Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/ --- Recording & Latency > A stall doesn't shorten a take [explanation] If the machine stalls long enough that captured audio can't reach the recorder, the missing frames are held open as silence rather than deleted, so the take keeps its length and everything after the gap stays where it belongs. A stall longer than the input buffer can represent (~200 ms) is beyond that, and is reported as `input_record_align_lost`. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#a-stall-doesnt-shorten-a-take Previous: explanation/audio/05-recording-and-latency#monitoring-is-not-compensated Next: explanation/audio/05-recording-and-latency#related --- Recording & Latency > A take is a reference [explanation] A recorded clip is a *reference* into the audio that was captured, not a copy of it — the same thing a clip is in a DAW. It names the recording, the frame it starts at and how long it runs, so trimming a clip's head costs nothing and throws nothing away. Every pass you record is kept. Collecting takes hands them back one pass at a time, oldest first — the order they were performed, and the order an arrangement would show them in. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#a-take-is-a-reference Previous: explanation/audio/05-recording-and-latency#one-session-one-sample-rate Next: explanation/audio/05-recording-and-latency#compensation-moves-where-a-take-begins --- Recording & Latency > Compensation moves where a take begins [explanation] A take recorded while playing back arrives late by the output latency plus the input latency. Resonon measures both from the device's own timestamps and corrects for them automatically. Plugin delay compensation is part of it: a lookahead limiter on the master pushes the mix you play along to further back, and a take recorded against it is corrected by that much more — the same term MIDI output is aligned by. The correction moves **where the take begins**. It never deletes audio: the recording behind a clip holds every frame that was captured, and the clip starts at the corrected frame. If the correction is a hair too large, an attack transient stays recoverable rather than gone. It is also what places the take. A clip's position is where it was *performed* — the moment the audio reached the machine, plus the correction — so a take doesn't have to be lined up by hand against what it was played over. That position is rarely on a cycle line, which is why an arrangement places clips [off the grid](/docs/explanation/audio/04-the-arrangement-model/#the-grid-is-what-you-snap-to). Some interfaces report a latency that is not the one they have. `[audio] recording_offset_ms` is the residual correction for that — a property of the interface, so it lives in preferences, not in the piece. A number beyond ±500 ms is refused rather than clamped, because a number that large is a typo, not a rig. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#compensation-moves-where-a-take-begins Previous: explanation/audio/05-recording-and-latency#a-take-is-a-reference Next: explanation/audio/05-recording-and-latency#monitoring-is-not-compensated --- Recording & Latency > Monitoring is not compensated [explanation] While a track monitors its input, resonon bypasses its plugin-delay-compensation alignment delay. The input still runs through the track's effects, but the artificial delay that lines it up with higher-latency tracks is skipped — so you hear yourself promptly even when other tracks host heavy lookahead plugins. What you hear then is the two converters and your buffer, and nothing else. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#monitoring-is-not-compensated Previous: explanation/audio/05-recording-and-latency#compensation-moves-where-a-take-begins Next: explanation/audio/05-recording-and-latency#a-stall-doesnt-shorten-a-take --- Recording & Latency > One device, one clock [explanation] On macOS resonon runs playback and capture through **one** CoreAudio device, on one clock — one IO callback, and no buffer between what your microphone hears and what the mix renders against it. Name two different devices and it still does. `[audio] input` and `[audio] output` on separate interfaces are joined into a private aggregate device, built for the session and destroyed with it: the output is the clock, and macOS drift-corrects the input against it. Recording from the built-in microphone while playing out of the built-in speakers — two CoreAudio devices on every Mac — is an ordinary rig. A pair costs two things one interface does not. The block size is whatever both accept, so `[audio] buffer_size` is bounded by the stricter of the two. And they have to share a sample rate. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#one-device-one-clock Previous: explanation/audio/05-recording-and-latency#the-piece-names-channels-the-machine-names-devices Next: explanation/audio/05-recording-and-latency#one-session-one-sample-rate --- Recording & Latency > One session, one sample rate [explanation] A device has one nominal rate, and no amount of clock syncing changes that. So a session runs at a single sample rate, and resonon picks one that both directions can run at: an interface whose microphone runs only at 44.1 kHz while its outputs also do 48 opens the session at 44.1. Writing `[audio] sample_rate` makes that decision yours instead, and a rate you asked for is never overridden to accommodate a microphone. If the input can't join it, the input is refused, with the rates it does run at — playback is unaffected. You never choose a rate for your microphone; you choose one for the session, and the input follows. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#one-session-one-sample-rate Previous: explanation/audio/05-recording-and-latency#one-device-one-clock Next: explanation/audio/05-recording-and-latency#a-take-is-a-reference --- Recording & Latency > Related [explanation] - [Record a Take](/docs/how-to/audio/12-record-a-take/) — arm, monitor, record and save - [Correct Recording Latency](/docs/how-to/audio/15-correct-recording-latency/) — check and correct what a take is moved by - [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) — where input enters a track - [Preferences](/docs/reference/setup/02-preferences/) — the `[audio]` keys Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#related Previous: explanation/audio/05-recording-and-latency#a-stall-doesnt-shorten-a-take --- Recording & Latency > The piece names channels, the machine names devices [explanation] A track takes its input as channel numbers — `.set_input(0)`, `.set_input(2, 3)` — counting from 0, the way `Output()` does. The interface those channels belong to is `[audio] input` in `~/.resonon/preferences.toml`, never in the piece. Channel numbers are what make a project portable: the same script runs on another rig, which may have a different interface but still has a channel 0. The device name is a fact about your machine (see [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/)). The input device is opened at startup, before any of your code runs, so a rig configured for an interface monitors through its converters from the first moment rather than through the built-in microphone until something asks. Page: explanation/audio/05-recording-and-latency URL: https://resonon.org/docs/explanation/audio/05-recording-and-latency/#the-piece-names-channels-the-machine-names-devices Next: explanation/audio/05-recording-and-latency#one-device-one-clock --- The Plugin Database [explanation] A DAW keeps a database of the plugins installed on the machine, so that choosing one is a lookup rather than a search of your disk. Resonon does the same. This page explains how that database is kept up to date, and why it treats a misbehaving plugin the way it does. Sections: - explanation/audio/06-the-plugin-database#the-database-maintains-itself | The database maintains itself - explanation/audio/06-the-plugin-database#a-name-is-resolved-where-you-write-it | A name is resolved where you write it - explanation/audio/06-the-plugin-database#scanning-is-isolated | Scanning is isolated - explanation/audio/06-the-plugin-database#a-timeout-is-provisional | A timeout is provisional - explanation/audio/06-the-plugin-database#a-skipped-plugin-comes-back-when-it-changes | A skipped plugin comes back when it changes - explanation/audio/06-the-plugin-database#related | Related Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/ --- The Plugin Database > A name is resolved where you write it [explanation] `Effect(...)` and `Instrument(...)` resolve the plugin name on the constructor line: a full path, then a filename in your plugin folders, then a display name from the database. CLAP is tried before VST3. **There is no format preference.** With both a CLAP and a VST3 build of the same plugin installed, the piece says which one it means: ```resonon no-check Instrument("Diva"); // CLAP if there is one, VST3 otherwise Instrument("Diva", plugin_id); // exactly this build, recorded in the piece ``` Which binary loads changes the sound, so it belongs in the piece rather than in a machine-wide setting that would make the same code play differently in two places. With only one format installed there is nothing to say. A bundle the database has never seen — or one that changed on disk since it was recorded — is scanned right then, and your code waits for it: normally a moment, at most the scan timeout. The result is remembered, so it is a once-per-bundle cost. Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#a-name-is-resolved-where-you-write-it Previous: explanation/audio/06-the-plugin-database#the-database-maintains-itself Next: explanation/audio/06-the-plugin-database#scanning-is-isolated --- The Plugin Database > A skipped plugin comes back when it changes [explanation] A skipped bundle is skipped *as it is on disk*. Updating or reinstalling the plugin is enough to bring it back: the next ordinary sweep sees a new build and opens it. Retrying the same build — after a crash that was really the machine running out of memory, say — is an explicit act, one bundle at a time or all of them with a forced sweep. Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#a-skipped-plugin-comes-back-when-it-changes Previous: explanation/audio/06-the-plugin-database#a-timeout-is-provisional Next: explanation/audio/06-the-plugin-database#related --- The Plugin Database > A timeout is provisional [explanation] A bundle that goes 30 seconds without finishing is a weaker case than a crash. It might be hanging; it might equally be a plugin on a cold network volume, a machine that was thrashing, or an antivirus scanning the file for the first time. So the scan process is killed and the sweep carries on, but the verdict is **provisional**: the next ordinary sweep opens the bundle again, and only after three timeouts in a row on the same build is it skipped. A plugin that was merely unlucky comes back with nothing asked of you. Time that resonon spent suspended doesn't count. Stopping a scan with `Ctrl-Z`, or putting the machine to sleep mid-sweep, does not spend a plugin's budget, so it can't cost a working plugin its place. Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#a-timeout-is-provisional Previous: explanation/audio/06-the-plugin-database#scanning-is-isolated Next: explanation/audio/06-the-plugin-database#a-skipped-plugin-comes-back-when-it-changes --- The Plugin Database > Related [explanation] - [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/) — scan, load, dial, save and retry - [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/) — why plugin folders are preferences - [Plugins in the stdlib reference](/docs/reference/stdlib/audio/#plugins) — `Effect`, `Instrument`, `plugin_scan` Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#related Previous: explanation/audio/06-the-plugin-database#a-skipped-plugin-comes-back-when-it-changes --- The Plugin Database > Scanning is isolated [explanation] A plugin can crash while merely being loaded. So each bundle is opened in a separate process, and a crash takes down that process instead of your session. A bundle that crashes or fails to load is recorded and skipped from then on, so it can't break later scans — which also means it doesn't appear in `plugin_scan()` or resolve in `Effect()`. Setting `RESONON_SUBPROCESS_SCAN=0` scans inside resonon itself, which is useful for debugging a plugin — you see it fail in place, with a stack trace. It is exactly the isolation described here turned off, so a bad bundle then takes the session down with it. Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#scanning-is-isolated Previous: explanation/audio/06-the-plugin-database#a-name-is-resolved-where-you-write-it Next: explanation/audio/06-the-plugin-database#a-timeout-is-provisional --- The Plugin Database > The database maintains itself [explanation] Every run that starts the audio engine — running a file, the REPL, a server — sweeps the CLAP and VST3 folders in the background and opens only bundles that are new or have changed since last time. The sweep after installing one plugin costs one plugin, not your whole folder, so you rarely think about it. The folders swept are the standard ones for your OS, `CLAP_PATH` and `VST3_PATH`, and every `[folders] plugins` entry in `~/.resonon/preferences.toml` ([Plugin folders](/docs/reference/setup/03-home-and-search-paths/#plugin-folders)). Those entries are read before the sweep starts, so a folder of your own is swept from the first run. That is the reason the folder list is data rather than a function call: a call runs only once a session is executing code, which is after the sweep it needed to reach. Scanning runs third-party code, and you may prefer to say when that happens. Automatic sweeping can be switched off — see [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/#turn-off-automatic-scanning). A plugin named by path or filename still resolves without any sweep; only lookup by display name depends on the database. Page: explanation/audio/06-the-plugin-database URL: https://resonon.org/docs/explanation/audio/06-the-plugin-database/#the-database-maintains-itself Next: explanation/audio/06-the-plugin-database#a-name-is-resolved-where-you-write-it --- Latency Compensation [explanation] Latency has several sources, and compensating one does not remove the others. The aim is to keep musical events aligned while reporting the delay that remains between a performer and the sound. Sections: - explanation/audio/07-latency-compensation#processing-paths-must-arrive-together | Processing paths must arrive together - explanation/audio/07-latency-compensation#device-delay-remains-part-of-monitoring | Device delay remains part of monitoring - explanation/audio/07-latency-compensation#a-recording-is-placed-against-what-you-heard | A recording is placed against what you heard Page: explanation/audio/07-latency-compensation URL: https://resonon.org/docs/explanation/audio/07-latency-compensation/ --- Latency Compensation > A recording is placed against what you heard [explanation] A take arrives after the output you played along with and the input path you recorded through. Recording compensation accounts for the measured round trip and graph compensation, plus the rig's `recording_offset_ms` residual. It changes the reference into the captured audio, retaining all captured frames. [Recording and Latency](/docs/explanation/audio/05-recording-and-latency/) explains that placement in detail. External gear needs its own timing information. A returning audio track's `.set_delay(ms)` declares the hardware round trip for live alignment; a file render has no hardware round trip and omits that delay. MIDI output alignment likewise concerns when a hardware instrument's sound reaches the mix, not just when its MIDI message leaves the computer. The controls belong to the path they correct. A late recording is not a reason to shift every MIDI track, and a slow effect is not a reason to change the interface's recording residual. See [Compensate for Outboard Gear](/docs/how-to/audio/16-compensate-for-outboard-gear/), [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/) and [audio_latency](/docs/reference/stdlib/audio/#audio_latency). Page: explanation/audio/07-latency-compensation URL: https://resonon.org/docs/explanation/audio/07-latency-compensation/#a-recording-is-placed-against-what-you-heard Previous: explanation/audio/07-latency-compensation#device-delay-remains-part-of-monitoring --- Latency Compensation > Device delay remains part of monitoring [explanation] Input and output also take time in buffers and converters. Increasing the block size can give the engine more time to finish, but increases the delay you hear when monitoring a performance. PDC aligns graph paths without making this device round trip disappear. `audio_latency()` separates the buffer, graph compensation and device timing. Where available, device timestamps measure delays a buffer-size estimate alone misses. A reported requested buffer size would be misleading here, so the diagnostics use the size the device actually runs at. Page: explanation/audio/07-latency-compensation URL: https://resonon.org/docs/explanation/audio/07-latency-compensation/#device-delay-remains-part-of-monitoring Previous: explanation/audio/07-latency-compensation#processing-paths-must-arrive-together Next: explanation/audio/07-latency-compensation#a-recording-is-placed-against-what-you-heard --- Latency Compensation > Processing paths must arrive together [explanation] An instrument or effect may take time to produce its output. Resonon accounts for reported plugin latency across processing paths and adds compensation delay to shorter paths. A track through a slow processor can then remain aligned with a faster track. That is plugin delay compensation, or PDC. It waits for the slower path; it cannot make that path finish earlier. A custom effect must declare its processing latency for this accounting to include it. A creative delay's echo time is part of its sound and is not automatically a processing-latency declaration. Page: explanation/audio/07-latency-compensation URL: https://resonon.org/docs/explanation/audio/07-latency-compensation/#processing-paths-must-arrive-together Next: explanation/audio/07-latency-compensation#device-delay-remains-part-of-monitoring --- Voices [explanation] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: A `dsp instrument` describes what *one* note sounds like. `render` takes one note's pitch, velocity and gate, and returns one sample. Playing a chord, or a note that rings into the next one, needs several of those at once — and that is what voices are. Sections: - explanation/dsp/01-voices#one-note-one-voice | One note, one voice - explanation/dsp/01-voices#a-voice-starts-fresh | A voice starts fresh - explanation/dsp/01-voices#parameters-are-shared | Parameters are shared - explanation/dsp/01-voices#release-and-running-out | Release, and running out - explanation/dsp/01-voices#the-pitch-is-a-number | The pitch is a number - explanation/dsp/01-voices#related | Related Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/ --- Voices > A voice starts fresh [explanation] A note-on sets a voice's state back to the initial values in the declarations, and clears its buffers. A new note therefore starts from a known point — an oscillator at phase `0`, an envelope at `0` — whatever the voice played before. Without that, a note's attack would depend on which note happened to use the voice last. In the current version this applies to plain `state` in an instrument as well: it behaves like `voice state`. State shared by all voices — for a global LFO or a cross-voice effect — is meant to come later, and a plain `state` is where it will go. Use `voice state` for anything that belongs to one note. Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#a-voice-starts-fresh Previous: explanation/dsp/01-voices#one-note-one-voice Next: explanation/dsp/01-voices#parameters-are-shared --- Voices > One note, one voice [explanation] An instrument has 16 voices. Each is a complete, independent copy of the instrument's running state: its own `voice state`, its own buffers. When a note starts, it gets a voice; `render` runs once per sample for every voice that is sounding, and the voices are summed into the track. So the code you write never deals with polyphony. `phase` in a sine oscillator is simply *the* phase; that there are sixteen of them, one per voice, is the engine's business. This is the same split as in a hardware polysynth, where every voice card holds the same circuit. Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#one-note-one-voice Next: explanation/dsp/01-voices#a-voice-starts-fresh --- Voices > Parameters are shared [explanation] A `param` is a knob on the instrument, not on a note, so every voice reads the same value. Turning the cutoff moves it for every note that is sounding, as on any synth. Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#parameters-are-shared Previous: explanation/dsp/01-voices#a-voice-starts-fresh Next: explanation/dsp/01-voices#release-and-running-out --- Voices > Related [explanation] - [Your First Instrument](/docs/tutorials/dsp/02-your-first-instrument/) — voices in use - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/#dsp-instrument) — the `render` signature and the voice rules - [Play Microtonal and MPE](/docs/how-to/midi/07-play-microtonal-and-mpe/) — fractional pitches from patterns Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#related Previous: explanation/dsp/01-voices#the-pitch-is-a-number --- Voices > Release, and running out [explanation] After note-off, `gate` drops to `0`, but the voice is not freed yet: `render` keeps running so the envelope you wrote can fade the note out. The voice is freed when its output has stayed below −120 dBFS for 64 samples in a row. That is why a release tail rings as long as your envelope makes it, with no release time to declare. A new note takes the first free voice. When all 16 are busy, the engine steals the quietest one — the voice whose loss is least audible, usually a tail that has almost faded. Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#release-and-running-out Previous: explanation/dsp/01-voices#parameters-are-shared Next: explanation/dsp/01-voices#the-pitch-is-a-number --- Voices > The pitch is a number [explanation] `note` is a MIDI note number, but it is an ordinary number, not a key index: it can be fractional. `__native("mtof", 61.5)` is a quarter-tone above C♯4. A scale with fractional steps reaches `render` exactly, with no rounding to semitones on the way. Page: explanation/dsp/01-voices URL: https://resonon.org/docs/explanation/dsp/01-voices/#the-pitch-is-a-number Previous: explanation/dsp/01-voices#release-and-running-out Next: explanation/dsp/01-voices#related --- The Audio-Thread Contract [explanation] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: A `dsp` block runs on the audio thread. That thread has to hand the sound card a buffer every few milliseconds, and a late buffer is a click that everyone hears. It may therefore never wait, never allocate, never touch the disk, and never do an unbounded amount of work. The language of a `dsp` block is built so that the code you write in it keeps those rules without your having to think about them. Sections: - explanation/dsp/02-the-audio-thread-contract#the-block-is-compiled-not-interpreted | The block is compiled, not interpreted - explanation/dsp/02-the-audio-thread-contract#one-sample-at-a-time | One sample at a time - explanation/dsp/02-the-audio-thread-contract#state-is-declared-up-front | State is declared up front - explanation/dsp/02-the-audio-thread-contract#every-if-has-an-else | Every if has an else - explanation/dsp/02-the-audio-thread-contract#a-parameter-steps-unless-told-to-glide | A parameter steps unless told to glide - explanation/dsp/02-the-audio-thread-contract#latency | Latency - explanation/dsp/02-the-audio-thread-contract#related | Related Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/ --- The Audio-Thread Contract > A parameter steps unless told to glide [explanation] A value set on a `param` applies at once. For many parameters that is what you want; for a gain or a cutoff, a jump from one value to another is a step in the signal, heard as a click or a zipper. Adding `smooth ms` to a `param` makes set values glide there over `ms` milliseconds. It is a choice per parameter, not a blanket rule, because what is right for a gain is wrong for a step count. A signal bound to a parameter is never smoothed: it already moves per sample, and smoothing it would change its shape. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#a-parameter-steps-unless-told-to-glide Previous: explanation/dsp/02-the-audio-thread-contract#every-if-has-an-else Next: explanation/dsp/02-the-audio-thread-contract#latency --- The Audio-Thread Contract > Every if has an else [explanation] In a `dsp` block, an `if` without `else` is an error. Every sample must produce a value on every path; a branch that could leave a variable unset for one sample would leave a hole in the audio. The same rule makes `if` usable as an expression: `let gain = if level > t { t / level } else { 1.0 };`. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#every-if-has-an-else Previous: explanation/dsp/02-the-audio-thread-contract#state-is-declared-up-front Next: explanation/dsp/02-the-audio-thread-contract#a-parameter-steps-unless-told-to-glide --- The Audio-Thread Contract > Latency [explanation] Some processing can only react to a sample after it has seen later ones: a lookahead limiter delays its output so its gain is down before a peak comes out. That delay has to be the same everywhere in the mix, or the tracks drift apart. The engine lines them up — it delays the other paths by what each one adds — but only for delays it knows about. The engine knows the delay of the graph it builds from your block. It cannot know the delay your code creates by reading a buffer late, because that is a fact about your algorithm, not about the graph. So you declare it: `latency: 512;` adds 512 samples to what the engine computes for the block. It is a fixed number because the engine's compensation is planned for the whole graph at once, not re-planned sample by sample. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#latency Previous: explanation/dsp/02-the-audio-thread-contract#a-parameter-steps-unless-told-to-glide Next: explanation/dsp/02-the-audio-thread-contract#related --- The Audio-Thread Contract > One sample at a time [explanation] `process` and `render` run once per sample. Every value in the block may change on every sample, and modulation reaches a parameter per sample too. A block can hold a feedback path — a filter, a delay with feedback, two oscillators modulating each other — and it is exact to the sample, because nothing is computed a block ahead. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#one-sample-at-a-time Previous: explanation/dsp/02-the-audio-thread-contract#the-block-is-compiled-not-interpreted Next: explanation/dsp/02-the-audio-thread-contract#state-is-declared-up-front --- The Audio-Thread Contract > Related [explanation] - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) — every declaration - [Declare Latency](/docs/how-to/dsp/02-declare-latency/) — latency in practice - [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) — compensation across the whole graph Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#related Previous: explanation/dsp/02-the-audio-thread-contract#latency --- The Audio-Thread Contract > State is declared up front [explanation] Everything a block remembers between samples is declared: `state` for numbers, `buffer` for arrays. The engine knows the whole memory of a block before the first sample, allocates it once, off the audio thread, and never again. A `buffer` has a fixed size for the same reason — a delay line that grew while playing would have to allocate. Its index wraps around, so a buffer is a circular delay line with no bounds to check. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#state-is-declared-up-front Previous: explanation/dsp/02-the-audio-thread-contract#one-sample-at-a-time Next: explanation/dsp/02-the-audio-thread-contract#every-if-has-an-else --- The Audio-Thread Contract > The block is compiled, not interpreted [explanation] When you run a `dsp effect` definition, resonon compiles it into the audio graph. Nothing of the interpreter — its values, its garbage, its locks — reaches the audio thread. Helpers, `dsp fn`s and object methods are inlined when the block is compiled, so splitting code into functions costs nothing per sample. It is also why a `dsp` block is its own small language rather than all of resonon: only what can run in bounded time without allocating is in it. Page: explanation/dsp/02-the-audio-thread-contract URL: https://resonon.org/docs/explanation/dsp/02-the-audio-thread-contract/#the-block-is-compiled-not-interpreted Next: explanation/dsp/02-the-audio-thread-contract#one-sample-at-a-time --- Editing DSP While It Plays [explanation] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: A `dsp` block is code you can change while you hear it. Running an edited `dsp effect` or `dsp instrument` does not stop the transport or rebuild the track: the new code takes over the running instance. This page explains how, and where that stops. Sections: - explanation/dsp/03-editing-dsp-while-it-plays#the-new-code-is-crossfaded-in | The new code is crossfaded in - explanation/dsp/03-editing-dsp-while-it-plays#what-carries-over | What carries over - explanation/dsp/03-editing-dsp-while-it-plays#what-cant-carry-over | What can't carry over - explanation/dsp/03-editing-dsp-while-it-plays#the-placement-line-owns-the-slot-the-body-owns-the-code | The placement line owns the slot, the body owns the code - explanation/dsp/03-editing-dsp-while-it-plays#related | Related Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/ --- Editing DSP While It Plays > Related [explanation] - [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/#change-it-while-it-plays) — an edit while it plays, step by step - [Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/) — how a re-run finds what is already there - [Patterns, Tracks & Effects](/docs/tutorials/getting-started/03-patterns-tracks-effects/) — the select-and-run loop Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/#related Previous: explanation/dsp/03-editing-dsp-while-it-plays#the-placement-line-owns-the-slot-the-body-owns-the-code --- Editing DSP While It Plays > The new code is crossfaded in [explanation] When you run an edited body, resonon compiles it and crossfades the running instance into it over 10 ms — short enough to feel instant, long enough not to click. Every live instance of that block takes the edit, wherever it sits in the graph. Selecting just the `dsp effect { … }` block is enough; running the whole scene applies the same edit once. For an instrument, the notes that are sounding carry over into the new version and are crossfaded with it, so an edit in the middle of a note doesn't cut it. Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/#the-new-code-is-crossfaded-in Next: explanation/dsp/03-editing-dsp-while-it-plays#what-carries-over --- Editing DSP While It Plays > The placement line owns the slot, the body owns the code [explanation] That split is deliberate. A bare edit to a body should never throw away the knob positions, modulation and state you have built up in a set, so it only ever changes code. Replacing an instance is a bigger gesture, and it belongs to the line that placed it. It follows from how placement works in general: a constructor like `Crush("crush")` or `Synth()` only *describes* an effect or instrument, and `.set_effects()` or `.set_instrument()` is what builds it (see [A constructor is a description](/docs/explanation/audio/02-descriptions-and-slots/#a-constructor-is-a-description)). Running the whole block again, placement line included, re-attaches to what is already running, so nothing is compiled or loaded twice. Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/#the-placement-line-owns-the-slot-the-body-owns-the-code Previous: explanation/dsp/03-editing-dsp-while-it-plays#what-cant-carry-over Next: explanation/dsp/03-editing-dsp-while-it-plays#related --- Editing DSP While It Plays > What can't carry over [explanation] Two kinds of edit leave the old values with nowhere to go: - changing the **parameter set** — adding, removing or renaming a `param`; - changing an effect's **inputs and outputs**. What happens then depends on what you ran. Running only the body **leaves the running instance alone** and warns you. Running the placement line — `track.set_effects(…)` or `track.set_instrument(…)` — **rebuilds** the slot from the source's defaults, audible as a restart rather than a fade; a replaced instrument fades out over 10 ms instead of clicking. Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/#what-cant-carry-over Previous: explanation/dsp/03-editing-dsp-while-it-plays#what-carries-over Next: explanation/dsp/03-editing-dsp-while-it-plays#the-placement-line-owns-the-slot-the-body-owns-the-code --- Editing DSP While It Plays > What carries over [explanation] The slot is not torn down, so everything attached to it stays: - **Parameter values.** A knob you turned stays where you put it. The default in the source seeds a new instance; it does not reset a live one. - **Modulation.** Signals and automation bound to its parameters keep running. - **Connections.** An effect's sidechain inputs stay connected. - **State, by name.** A `state` or `voice state` in the new code continues from the value it had under the same name in the old code. One that you add starts at its initial value. Page: explanation/dsp/03-editing-dsp-while-it-plays URL: https://resonon.org/docs/explanation/dsp/03-editing-dsp-while-it-plays/#what-carries-over Previous: explanation/dsp/03-editing-dsp-while-it-plays#the-new-code-is-crossfaded-in Next: explanation/dsp/03-editing-dsp-while-it-plays#what-cant-carry-over --- Native Extensions: Safety & Threading [explanation] A native extension is Rust code loaded into the resonon process. It is fast and can reach anything the process can, which is also why its limits are strict. This page is about those limits and the reasons for them. Sections: - explanation/dsp/04-native-extension-safety-and-threading#it-computes-it-does-not-process-audio | It computes; it does not process audio - explanation/dsp/04-native-extension-safety-and-threading#it-is-trusted-code | It is trusted code - explanation/dsp/04-native-extension-safety-and-threading#panics-stop-at-the-boundary | Panics stop at the boundary - explanation/dsp/04-native-extension-safety-and-threading#handles-belong-to-their-extension | Handles belong to their extension - explanation/dsp/04-native-extension-safety-and-threading#one-lock-per-class | One lock per class - explanation/dsp/04-native-extension-safety-and-threading#memory-is-handed-over-not-shared | Memory is handed over, not shared - explanation/dsp/04-native-extension-safety-and-threading#related | Related Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/ --- Native Extensions: Safety & Threading > Handles belong to their extension [explanation] An `ext_class` instance reaches resonon as an opaque handle that points into the loaded library. That is why a handle means nothing to another extension — passing it there is an error, not a lookup of some unrelated object — and why `reload_ext` refuses to unload an extension while any of its objects is alive: the handles would point at nothing. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#handles-belong-to-their-extension Previous: explanation/dsp/04-native-extension-safety-and-threading#panics-stop-at-the-boundary Next: explanation/dsp/04-native-extension-safety-and-threading#one-lock-per-class --- Native Extensions: Safety & Threading > It computes; it does not process audio [explanation] An extension function runs synchronously on the interpreter thread — the thread that runs your code — and never on the audio thread. What crosses its boundary is numbers, booleans, strings and arrays of numbers: there is no buffer, block or channel type. That split is deliberate. The audio thread has a deadline every few milliseconds and may not wait, allocate or touch the filesystem; arbitrary Rust behind an FFI call can do all three. So an extension computes things — a wavetable, a tuning, a pattern — and the audio path is written as a `dsp` block, which the engine compiles into its graph under the audio thread's rules (see [The Audio-Thread Contract](/docs/explanation/dsp/02-the-audio-thread-contract/)). Loading is lazy: the first call into an extension opens its library, which allocates and reads the disk — on the interpreter thread, where that is allowed. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#it-computes-it-does-not-process-audio Next: explanation/dsp/04-native-extension-safety-and-threading#it-is-trusted-code --- Native Extensions: Safety & Threading > It is trusted code [explanation] Extensions are not sandboxed. Loading one runs its code with the process's rights — even `resonon pkg inspect` loads an extension to list its functions. Install extensions you trust, as you would a plugin. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#it-is-trusted-code Previous: explanation/dsp/04-native-extension-safety-and-threading#it-computes-it-does-not-process-audio Next: explanation/dsp/04-native-extension-safety-and-threading#panics-stop-at-the-boundary --- Native Extensions: Safety & Threading > Memory is handed over, not shared [explanation] Strings and arrays cross the boundary as copies, so neither side keeps a reference into memory the other owns. The value is handed over; what the extension keeps stays its own. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#memory-is-handed-over-not-shared Previous: explanation/dsp/04-native-extension-safety-and-threading#one-lock-per-class Next: explanation/dsp/04-native-extension-safety-and-threading#related --- Native Extensions: Safety & Threading > One lock per class [explanation] Each class has one lock that covers all its instances, so two calls into a class never race. The price is that a long-running method holds up every other call into the same class, from any object — and every call runs on the interpreter thread, so it holds up the code you run too. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#one-lock-per-class Previous: explanation/dsp/04-native-extension-safety-and-threading#handles-belong-to-their-extension Next: explanation/dsp/04-native-extension-safety-and-threading#memory-is-handed-over-not-shared --- Native Extensions: Safety & Threading > Panics stop at the boundary [explanation] A panic may not unwind across an `extern "C"` boundary: when one escapes, the process aborts, and the host cannot catch it. VST3, CLAP and AU impose the same rule on plugins. So the functions that `ext_fn`, `ext_new` and `ext_method` generate catch the panic inside your library, before it reaches the boundary, and hand it over as a resonon error with your panic message. Code that crosses the boundary without them has to do the same itself — see [the boundary rules](/docs/reference/dsp/02-native-extensions/#boundary-rules). Returning an error is still the better failure: a panic in the middle of a method can leave that object half-updated. Other objects are not affected. Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#panics-stop-at-the-boundary Previous: explanation/dsp/04-native-extension-safety-and-threading#it-is-trusted-code Next: explanation/dsp/04-native-extension-safety-and-threading#handles-belong-to-their-extension --- Native Extensions: Safety & Threading > Related [explanation] - [Ship a Native Extension](/docs/how-to/dsp/05-ship-a-native-extension/) — writing and publishing one - [Native Extensions](/docs/reference/dsp/02-native-extensions/) — macros, types, boundary rules and library lookup Page: explanation/dsp/04-native-extension-safety-and-threading URL: https://resonon.org/docs/explanation/dsp/04-native-extension-safety-and-threading/#related Previous: explanation/dsp/04-native-extension-safety-and-threading#memory-is-handed-over-not-shared --- Values & Sharing [explanation] A few choices about values shape how resonon code behaves: which values are shared, how strict the types are, and what an annotation promises. Each follows from the same aim — code you can select and run in any order, without being surprised by what it does. Sections: - explanation/language/01-values-and-sharing#containers-share-primitives-copy | Containers share, primitives copy - explanation/language/01-values-and-sharing#changing-in-place-or-returning-a-new-value | Changing in place, or returning a new value - explanation/language/01-values-and-sharing#types-are-strict | Types are strict - explanation/language/01-values-and-sharing#an-annotation-is-a-promise-that-holds | An annotation is a promise that holds - explanation/language/01-values-and-sharing#next-steps | Next Steps Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/ --- Values & Sharing > An annotation is a promise that holds [explanation] A type annotation (`fn f(x: Number) -> Number`) is a contract, and it holds at every boundary it guards: a value that does not fit is an error where it crosses, not a wrong result three functions later. The editor reads the same annotation for signatures, hover and completion. You never have to write types. Unannotated code stays dynamic: a name without a type can hold whatever the moment needs while you are performing. Each operation still checks the types it needs. Annotate where a shape is fixed — function parameters and returns, class fields — and where a variable should keep one: `let x: T` checks every later write to `x`. A contract guards a boundary, not every alias of a value. If an `Array` is shared with unannotated code, that code can still change its contents. Passing it to another annotated parameter checks the contents again. The annotation does not copy or freeze the array. A class can deliberately accept another type through a declared `from` conversion. For example, a `Note` annotation accepts a MIDI number. Such conversions happen where a type is asked for; operators and collection elements keep their own rules. See [Type annotations](/docs/reference/language/01-values-and-types/#type-annotations) for the complete boundary and conversion rules. Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/#an-annotation-is-a-promise-that-holds Previous: explanation/language/01-values-and-sharing#types-are-strict Next: explanation/language/01-values-and-sharing#next-steps --- Values & Sharing > Changing in place, or returning a new value [explanation] A class method can change `this`, or it can return a new instance and leave `this` alone: ```resonon class Counter { let count; fn new(n) { this.count = n; } fn increment() { this.count += 1; } // changes in place fn incremented() { return Counter(this.count + 1); } // returns a new one } let c = Counter(0); let alias = c; c.increment(); assert alias.count == 1; // the alias sees the change let d = c.incremented().incremented(); assert c.count == 1; // c is untouched print(d.count); // 3 ``` Both are legitimate; the class you write decides. Patterns always take the second form: every pattern method returns a new pattern, which is why one motif can feed any number of variations (see [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#transforms-wrap-they-dont-edit)). Returning new values makes chains like `c.incremented().incremented()` safe to write, because no link in the chain changes something another name is holding. Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/#changing-in-place-or-returning-a-new-value Previous: explanation/language/01-values-and-sharing#containers-share-primitives-copy Next: explanation/language/01-values-and-sharing#types-are-strict --- Values & Sharing > Containers share, primitives copy [explanation] Assigning a **container** — an array, a dict or a class instance — does not copy it. Both names then refer to the same data, and a change through one is seen through the other. Passing a container to a function works the same way: ```resonon let a = #[1, 2, 3]; let b = a; b.push(99); assert a.length() == 4; // a sees the change fn append_high(arr) { arr.push(C5); } let melody = #[C4, E4, G4]; append_high(melody); assert melody.length() == 4; // the caller's array changed print(melody); ``` This is the rule the rest of a session relies on. Tracks, instruments, effects, MIDI tracks and visuals are shared handles too: `let lead = drums;` gives the same track a second name, it does not build a second track. A DAW works the same way — a track is one object however many places refer to it — and if assignment copied, a helper function that configured a track would configure a copy that nobody hears. When you do want an independent copy, say so with `.clone()`: ```resonon let a = #[1, 2, 3]; let b = a.clone(); b.push(99); assert a.length() == 3; // unchanged print(b); ``` A value that can be copied this way is `Clone`: arrays, dicts, tuples, sections and timelines, and every class that says `implements Clone` and defines `clone()`. A copy clones each value inside it that is `Clone` too, and shares the rest: an array of tracks copies the array, not the tracks. Tracks, devices, patterns and iterators have no `clone()`, because two names for one track are one track. **Primitives** — Numbers, Strings, Booleans, Notes and `NUL` — are always copied, so there is nothing to share. Strings and tuples cannot be changed at all: every string method returns a new string, and a tuple has no `push` or element assignment. A value that cannot change behaves the same whether it is shared or copied. Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/#containers-share-primitives-copy Next: explanation/language/01-values-and-sharing#changing-in-place-or-returning-a-new-value --- Values & Sharing > Next Steps [explanation] - [Values & Types](/docs/reference/language/01-values-and-types/) — every literal and the truthiness rules - [Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/) — how names resolve in a running session Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/#next-steps Previous: explanation/language/01-values-and-sharing#an-annotation-is-a-promise-that-holds --- Values & Sharing > Types are strict [explanation] Resonon does not quietly convert one type into another. `5 + "5"` concatenates because one side is a String, but `C4 + C4`, `true && 0` or `NUL + 1` are type errors, not a best guess. The cross-type rules that exist are few and each has a musical reason: a Note compares with a Number by MIDI value (`C4 == 60`), `+` and `-` transpose a pitch, and `*` and `/` scale its frequency. They are listed in the [type-compatibility table](/docs/reference/language/03-operators/#type-compatibility). The same thinking separates **conditions** from **truthiness**. An `if`, a match guard or an `assert` needs a real Boolean, so `if count { }` is an error rather than a silent test for zero — you write what you mean, `if count > 0`. Only where a callback's answer decides whether to keep an element (`.filter()`, `.find()`, `.any()`, `.all()`) does truthiness apply, and there only `false` and `NUL` are falsy. `0`, `""` and `#[]` are real values, and treating them as "nothing" is a classic source of dropped notes. `NUL` means "no value", and it stays that way. It does not propagate through arithmetic the way SQL's `NULL` does: using it as an operand is an error at the line that did it, not a `NUL` that surfaces three functions later. Reading a variable that was never defined is an error too, so a typo shows up where you made it. Page: explanation/language/01-values-and-sharing URL: https://resonon.org/docs/explanation/language/01-values-and-sharing/#types-are-strict Previous: explanation/language/01-values-and-sharing#changing-in-place-or-returning-a-new-value Next: explanation/language/01-values-and-sharing#an-annotation-is-a-promise-that-holds --- Names & Live Editing [explanation] In a live session you don't run a program once. You select a line here and a block there, in any order, while the music plays (see [The Evaluation Model](/docs/explanation/running/02-the-evaluation-model/)). The rules for names are built for that: a name means what you last executed for it, and what a piece of code means depends on what it says and on the session's current state — never on who called it. Sections: - explanation/language/02-names-and-live-editing#the-last-thing-you-executed-wins | The last thing you executed wins - explanation/language/02-names-and-live-editing#a-function-sees-the-session-not-its-caller | A function sees the session, not its caller - explanation/language/02-names-and-live-editing#session-lookups-are-live | Session lookups are live - explanation/language/02-names-and-live-editing#a-closure-freezes-what-it-captures | A closure freezes what it captures - explanation/language/02-names-and-live-editing#a-playing-pattern-follows-your-edits | A playing pattern follows your edits - explanation/language/02-names-and-live-editing#one-definition-per-name | One definition per name - explanation/language/02-names-and-live-editing#definitions-belong-to-the-file | Definitions belong to the file - explanation/language/02-names-and-live-editing#the-standard-library-sits-underneath | The standard library sits underneath - explanation/language/02-names-and-live-editing#a-module-keeps-to-itself | A module keeps to itself - explanation/language/02-names-and-live-editing#editing-a-module-reaches-the-session | Editing a module reaches the session - explanation/language/02-names-and-live-editing#next-steps | Next Steps Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/ --- Names & Live Editing > A closure freezes what it captures [explanation] Sometimes you want the opposite: a function that remembers a value as it was. That is what a closure — a `fn(…) { … }` value — is for. It captures the variables it refers to, by value, at the moment it is created: ```resonon fn make_adder(n) { return fn(x) { return x + n; }; // n is captured now } let add5 = make_adder(5); assert add5(3) == 8; print("frozen"); ``` What a closure freezes is the values it reads. A function it *calls* is looked up when the closure runs, as in a named `fn`, so redefining that function reaches closures that already exist: ```resonon let f = fn() { return g(); }; fn g() { return 1; } assert f() == 1; print("late"); ``` Run `fn g() { return 2; }` later in the session and `f()` returns 2. Reach for a named function or a session value when behaviour should follow the session, and for a closure's captured values when it should hold on to one. The same idea is why [pattern generators](/docs/explanation/patterns/02-how-patterns-work/#determinism-and-seekability) freeze what they capture: a stream that changed when an unrelated variable did could not replay the same cycle twice. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#a-closure-freezes-what-it-captures Previous: explanation/language/02-names-and-live-editing#session-lookups-are-live Next: explanation/language/02-names-and-live-editing#a-playing-pattern-follows-your-edits --- Names & Live Editing > A function sees the session, not its caller [explanation] A named `fn` looks up any name that isn't its own parameter or local in the **session**, when it is called. A caller's local variables never leak into it, or into a class method: ```resonon let tempo = 120; fn beat_ms() { return 60000 / tempo; } fn play(tempo) { // this tempo is local to play return beat_ms(); // beat_ms still reads the session's tempo } assert play(999) == 500; print(beat_ms()); ``` This keeps each function readable on its own: to know what `beat_ms` does, read its body and the session names it uses. If lookups followed the call chain instead, the same line would do different things depending on which function you selected and ran it from — exactly the uncertainty select-and-execute cannot afford. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#a-function-sees-the-session-not-its-caller Previous: explanation/language/02-names-and-live-editing#the-last-thing-you-executed-wins Next: explanation/language/02-names-and-live-editing#session-lookups-are-live --- Names & Live Editing > A module keeps to itself [explanation] A module's code sees its own top-level names and the standard library, never the session that imports it. A library behaves the same in every piece that uses it, and a `let` you happen to write in your piece cannot change what it does. What a module needs from you, it takes as arguments. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#a-module-keeps-to-itself Previous: explanation/language/02-names-and-live-editing#the-standard-library-sits-underneath Next: explanation/language/02-names-and-live-editing#editing-a-module-reaches-the-session --- Names & Live Editing > A playing pattern follows your edits [explanation] A function you give a pattern — `p.map(fn(n) { … })`, `.map_with_timing(…)`, or a class's `query(cycle)` — is a closure like any other. The values it reads are frozen when the pattern is made. The functions it calls are looked up each time the pattern computes a cycle: ```resonon let melody = [C4 E4 G4].map(fn(n) { return lift(n); }); fn lift(n) { return n + 12; } print("follows"); ``` While `melody` plays, run `fn lift(n) { return n + 7; }` and it plays a fifth up instead, from the next cycle it computes after that line has run. You don't re-run the line that made the pattern. So a playing pattern can also break: run a `lift` that calls a function that doesn't exist, and the callback fails each time it runs. A failing `map` callback plays its notes unchanged, and a failing `query` rests. Either way the error is printed, once per run however often it fails, and printed again after your next run if it is still failing: ```text A playing pattern's map callback failed: Undefined function 'h' at song.non:1:21 | 1 | fn lift(n) { return h(n); } | ^^^^ in the map callback: | 4 | let melody = [C4 E4 G4].map(fn(n) { return lift(n); }); | ^^^^^^^^^^^^^^^^^^^ ``` It quotes the code as it was run, because by the time a pattern computes a cycle you may have moved those lines. For the same reason the error is not underlined in the editor. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#a-playing-pattern-follows-your-edits Previous: explanation/language/02-names-and-live-editing#a-closure-freezes-what-it-captures Next: explanation/language/02-names-and-live-editing#one-definition-per-name --- Names & Live Editing > Definitions belong to the file [explanation] `fn`, `class`, `enum` and `dsp` definitions sit at the top level. A definition names something for the whole file, so it is written where the whole file can see it; a helper that belongs to one place is a closure bound with `let`. A definition exists from the line that defines it, so a call written above a `fn` fails as undefined — unless an earlier run already defined it, which is the session remembering. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#definitions-belong-to-the-file Previous: explanation/language/02-names-and-live-editing#one-definition-per-name Next: explanation/language/02-names-and-live-editing#the-standard-library-sits-underneath --- Names & Live Editing > Editing a module reaches the session [explanation] A `use` evaluates a module when its source, or the source of anything it imports, differs from what the session last evaluated. So you edit a library file, run your `use` line again, and the new definitions are there — there is no reload gesture to remember. And when nothing changed, nothing runs again: a module that creates a track at its top level creates it once, not on every unrelated execution. Freshness follows the imports, so editing a module that another one imports refreshes both. `RESET;` is the full reload, for when you want everything evaluated from scratch. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#editing-a-module-reaches-the-session Previous: explanation/language/02-names-and-live-editing#a-module-keeps-to-itself Next: explanation/language/02-names-and-live-editing#next-steps --- Names & Live Editing > Next Steps [explanation] - [Variables & Scope](/docs/reference/language/02-variables-and-scope/) — the rules, in brief - [Modules](/docs/reference/language/09-modules/#when-a-module-is-evaluated) — module evaluation in the reference Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#next-steps Previous: explanation/language/02-names-and-live-editing#editing-a-module-reaches-the-session --- Names & Live Editing > One definition per name [explanation] Within one piece of source you run, a name has one definition. Two `fn greet`s, a `fn tempo` beside a `let tempo`, a `use` and a `dsp effect` both binding `Delay`, or two methods of one name in a class are an error, and nothing in that source runs. Arity never chooses between functions; a parameter that may be left out gets a default value. The reason is the same predictability. If `tempo` could be both a value and a function, or `greet` could mean two bodies depending on how many arguments you passed, then reading a line would not tell you what it does. Refusing the whole source, rather than running up to the clash, means an execution never half-applies. Running a binding again *later* is different, and it is the point of live coding: execute a new `fn greet` and it replaces the old one from the next call on, while everything else keeps playing. The rule is about one piece of source contradicting itself, not about changing your mind. The editor follows the same line. Until you evaluate anything, it is in **File Mode** (offline): the file is the piece of source, so a name it defines twice is marked. From your first evaluation it is in **Live Mode** (online): the file is where you write selections, and a second `fn greet` further down is the next version of `greet`, not a mistake. The status bar shows the mode; see [Live Mode and File Mode](/docs/reference/running/01-vscode-extension/#live-mode-and-file-mode). Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#one-definition-per-name Previous: explanation/language/02-names-and-live-editing#a-playing-pattern-follows-your-edits Next: explanation/language/02-names-and-live-editing#definitions-belong-to-the-file --- Names & Live Editing > Session lookups are live [explanation] Because the lookup happens at call time, changing a session name changes every function that reads it. You don't redefine the functions: ```resonon let tempo = 120; fn beat_ms() { return 60000 / tempo; } tempo = 150; assert beat_ms() == 400; // picks up the new value print("live"); ``` This is what live coding leans on. Tweak a value, run that one line, and the instrument functions built on it follow. Redefining a function works the same way: every function that calls it gets the new version from its next call. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#session-lookups-are-live Previous: explanation/language/02-names-and-live-editing#a-function-sees-the-session-not-its-caller Next: explanation/language/02-names-and-live-editing#a-closure-freezes-what-it-captures --- Names & Live Editing > The last thing you executed wins [explanation] The session has one namespace for everything you bind at the top level: `let`s, `fn`, `class`, `enum` and `dsp` definitions, and the names a `use` brings in. There is no ranking between them. Execute `fn Delay(…)`, then `use "std/effects" { Delay };`, and `Delay` is the effect; execute the `fn` again and it is the function again. A call and a plain mention of the name always agree, because they look in the same place. That is the only rule you need while performing: to know what a name means, remember what you ran last. A hidden precedence — definitions over imports, say — would make the line you just executed silently do nothing. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#the-last-thing-you-executed-wins Next: explanation/language/02-names-and-live-editing#a-function-sees-the-session-not-its-caller --- Names & Live Editing > The standard library sits underneath [explanation] The standard library is a layer below the session. Any of its names can be bound in the session — `fn clamp`, say — and from then on your code gets yours. The standard library itself never sees the session: its functions keep calling each other, so `let round = 0;` cannot break a function that rounds inside. Overriding a name is a decision about your code, and only about your code. Page: explanation/language/02-names-and-live-editing URL: https://resonon.org/docs/explanation/language/02-names-and-live-editing/#the-standard-library-sits-underneath Previous: explanation/language/02-names-and-live-editing#definitions-belong-to-the-file Next: explanation/language/02-names-and-live-editing#a-module-keeps-to-itself --- Lazy Iteration [explanation] An array's `.map()` builds a new array straight away. An iterator's `.map()` does nothing yet: it returns a new iterator that will map values when something asks for them. That difference — **eager** versus **lazy** — is what lets iterators work on sequences that are large, or that never end. Sections: - explanation/language/03-lazy-iteration#a-pipeline-that-runs-when-you-pull | A pipeline that runs when you pull - explanation/language/03-lazy-iteration#single-use | Single use - explanation/language/03-lazy-iteration#why-a-pattern-iterator-never-ends | Why a pattern iterator never ends - explanation/language/03-lazy-iteration#next-steps | Next Steps Page: explanation/language/03-lazy-iteration URL: https://resonon.org/docs/explanation/language/03-lazy-iteration/ --- Lazy Iteration > A pipeline that runs when you pull [explanation] An iterator is pull-based. Methods like `filter`, `map`, `take` and `skip` each wrap the iterator in front of them and return immediately. Only a consuming method — `collect`, `count`, `fold`, `find`, `next` and the rest — pulls values through the chain, one at a time: ```resonon let result = #[1, 2, 3, 4, 5, 6, 7, 8] .iter() .filter(fn(x) { return x % 2 == 0; }) // nothing runs yet .map(fn(x) { return x * 10; }) // nothing runs yet .collect(); // now every stage runs, value by value print(result); // [20, 40, 60, 80] ``` No intermediate array is built between `filter` and `map`. Each value goes through every stage before the next one starts, and a consuming method that has its answer stops pulling: `find` stops at the first match, `any` at the first `true`. Page: explanation/language/03-lazy-iteration URL: https://resonon.org/docs/explanation/language/03-lazy-iteration/#a-pipeline-that-runs-when-you-pull Next: explanation/language/03-lazy-iteration#single-use --- Lazy Iteration > Next Steps [explanation] - [Collections & Iterators](/docs/reference/language/05-collections-and-iterators/#iterators) — iterator sources and method groups - [Iterator methods](/docs/reference/stdlib/core/#iterator) — every method, with its signature Page: explanation/language/03-lazy-iteration URL: https://resonon.org/docs/explanation/language/03-lazy-iteration/#next-steps Previous: explanation/language/03-lazy-iteration#why-a-pattern-iterator-never-ends --- Lazy Iteration > Single use [explanation] An iterator is a position in a sequence, not the sequence itself. Once a value has been pulled, it is gone; an exhausted iterator returns `NUL` from `next()` and yields nothing more. Calling `collect()` twice on one iterator gives you the elements, then an empty array. To go over the data again, ask the source for a new iterator with `.iter()`. The source is unchanged, because iterating never modifies it. Page: explanation/language/03-lazy-iteration URL: https://resonon.org/docs/explanation/language/03-lazy-iteration/#single-use Previous: explanation/language/03-lazy-iteration#a-pipeline-that-runs-when-you-pull Next: explanation/language/03-lazy-iteration#why-a-pattern-iterator-never-ends --- Lazy Iteration > Why a pattern iterator never ends [explanation] A pattern [is a query over an endless stream of cycles](/docs/explanation/patterns/02-how-patterns-work/), so an iterator over its events never runs out. Laziness is what makes that workable: `.take(8)` caps the sequence, and everything after it sees exactly eight events. ```resonon let notes = [C4 E4 G4].iter() .take(6) .map(fn(e) { return e.note(); }) .collect(); print(notes); // [60, 64, 67, 60, 64, 67] ``` The flip side is that a consuming method on an uncapped pattern iterator — `collect`, `count`, `last`, `fold` — waits for an end that never comes. Put `.take(n)` first, every time. Page: explanation/language/03-lazy-iteration URL: https://resonon.org/docs/explanation/language/03-lazy-iteration/#why-a-pattern-iterator-never-ends Previous: explanation/language/03-lazy-iteration#single-use Next: explanation/language/03-lazy-iteration#next-steps --- The Error Model [explanation] A live evaluation changes a session that may already be playing. Understanding where evaluation stops tells you what to inspect after a failure and what is safe to run again. Sections: - explanation/language/04-the-error-model#syntax-is-checked-before-the-selection-runs | Syntax is checked before the selection runs - explanation/language/04-the-error-model#runtime-evaluation-proceeds-statement-by-statement | Runtime evaluation proceeds statement by statement - explanation/language/04-the-error-model#warnings-preserve-usable-work | Warnings preserve usable work Page: explanation/language/04-the-error-model URL: https://resonon.org/docs/explanation/language/04-the-error-model/ --- The Error Model > Runtime evaluation proceeds statement by statement [explanation] A runtime error stops evaluation at the failing statement. Earlier statements may already have bound variables, created tracks or changed routing. Evaluation is not a transaction, so there is no automatic rollback of those changes. An operation's own failure behavior determines whether it changed anything before reporting the error. That is why correcting the offending statement is often preferable to rebuilding the whole rig. Re-running the larger selection also runs its earlier actions again: a printed message prints again, and a registered callback can be registered again. Naming a track consistently gives you its existing identity, but does not make every action in a selection repeatable. Page: explanation/language/04-the-error-model URL: https://resonon.org/docs/explanation/language/04-the-error-model/#runtime-evaluation-proceeds-statement-by-statement Previous: explanation/language/04-the-error-model#syntax-is-checked-before-the-selection-runs Next: explanation/language/04-the-error-model#warnings-preserve-usable-work --- The Error Model > Syntax is checked before the selection runs [explanation] A parse error or a repeated definition within one file or selection prevents that whole evaluation from running. An incomplete expression at the end cannot leave the first half of that selection applied. The session that existed before the evaluation remains available. The boundary is the text you evaluated. A correct earlier selection is already part of the session; a later selection's syntax error does not undo it. Page: explanation/language/04-the-error-model URL: https://resonon.org/docs/explanation/language/04-the-error-model/#syntax-is-checked-before-the-selection-runs Next: explanation/language/04-the-error-model#runtime-evaluation-proceeds-statement-by-statement --- The Error Model > Warnings preserve usable work [explanation] A warning reports a condition while letting evaluation continue. For example, a project that targets an older resonon version is reported, and the piece still runs. This makes the condition visible while leaving working music available. Editor diagnostics found before evaluation describe the source without running it. Runtime messages describe what actually happened in the session. A clean Problems panel therefore does not prove that hardware exists or that a plugin will load. A failed file run exits with status `1`. In a live session, read the error, inspect the current state and send a correction. `RESET;` explicitly discards that state when you choose to rebuild. [Errors and Warnings](/docs/reference/language/10-errors-and-warnings/) lists the messages; [Debug a Session](/docs/how-to/running/08-debug-a-session/) gives the recovery steps. Page: explanation/language/04-the-error-model URL: https://resonon.org/docs/explanation/language/04-the-error-model/#warnings-preserve-usable-work Previous: explanation/language/04-the-error-model#runtime-evaluation-proceeds-statement-by-statement --- Module Identity [explanation] A module can export definitions and also execute top-level code that creates values or tracks. Its identity matters because importing a helper should not repeatedly rebuild those objects. Sections: - explanation/language/05-module-identity#one-session-reuses-unchanged-source | One session reuses unchanged source - explanation/language/05-module-identity#each-evaluation-sees-one-version | Each evaluation sees one version - explanation/language/05-module-identity#reset-starts-a-new-module-lifetime | Reset starts a new module lifetime Page: explanation/language/05-module-identity URL: https://resonon.org/docs/explanation/language/05-module-identity/ --- Module Identity > Each evaluation sees one version [explanation] Within one execution a module has one version, however often it is imported. A dependency reached through two import paths cannot change halfway through that execution because one import happens later. Circular imports are refused because neither side can finish constructing the exports the other needs. Reloading source does not rewrite every value you previously derived from it. A pattern already sent to a track remains that pattern until you send its replacement. A closure or generator may also hold captured values. Re-evaluate the consuming lines when you want the new definitions to reach the music. Page: explanation/language/05-module-identity URL: https://resonon.org/docs/explanation/language/05-module-identity/#each-evaluation-sees-one-version Previous: explanation/language/05-module-identity#one-session-reuses-unchanged-source Next: explanation/language/05-module-identity#reset-starts-a-new-module-lifetime --- Module Identity > One session reuses unchanged source [explanation] A `use` resolves a file and obtains the session's evaluated module. If neither that source nor anything it imports changed, the existing result is reused. Two aliases reaching the same module therefore do not mean two independent copies of its top-level state. Saving a change to the module, or one of its dependencies, makes a later evaluation of `use` re-evaluate it. This is source-based reuse: re-running the import alone is not an instruction to start an unchanged module from scratch. Page: explanation/language/05-module-identity URL: https://resonon.org/docs/explanation/language/05-module-identity/#one-session-reuses-unchanged-source Next: explanation/language/05-module-identity#each-evaluation-sees-one-version --- Module Identity > Reset starts a new module lifetime [explanation] `RESET;` clears the session's modules as well as its variables and tracks. The next import evaluates the module afresh. Keeping reusable definitions in modules and the rig's assembly in the main piece makes this rebuilding boundary easier to understand. [Modules](/docs/reference/language/09-modules/) specifies resolution and exports; [Split a Piece into Modules](/docs/how-to/language/02-split-a-piece-into-modules/) shows an edit and reload. Page: explanation/language/05-module-identity URL: https://resonon.org/docs/explanation/language/05-module-identity/#reset-starts-a-new-module-lifetime Previous: explanation/language/05-module-identity#each-evaluation-sees-one-version --- The Class Model [explanation] A class groups fields and methods into a value you can pass around. It is useful for a musical object whose behavior needs several related values: a motif builder, a configuration, or a script pattern. Sections: - explanation/language/06-the-class-model#instances-carry-shared-state | Instances carry shared state - explanation/language/06-the-class-model#annotations-describe-contracts | Annotations describe contracts - explanation/language/06-the-class-model#playing-captures-a-pattern | Playing captures a pattern Page: explanation/language/06-the-class-model URL: https://resonon.org/docs/explanation/language/06-the-class-model/ --- The Class Model > Annotations describe contracts [explanation] A field or function annotation is a contract, and it holds: every write to a typed field is checked, and so is each argument and return of an annotated function. When an instance is made, a typed field that cannot be NUL must be set by `new`. A class can declare a `from` conversion for values it deliberately accepts; otherwise a value must already fit the annotation. See [Conversions](/docs/reference/language/07-classes/#conversions). Resonon classes have no inheritance, static members or private fields. Reuse comes from interfaces with default methods, composing values and calling helper functions; module-level `private` limits what a module exports. Page: explanation/language/06-the-class-model URL: https://resonon.org/docs/explanation/language/06-the-class-model/#annotations-describe-contracts Previous: explanation/language/06-the-class-model#instances-carry-shared-state Next: explanation/language/06-the-class-model#playing-captures-a-pattern --- The Class Model > Instances carry shared state [explanation] Calling the class runs its constructor and creates an instance. Assigning that instance to another name shares it; calling a method that changes `this` changes the instance both names see. This lets a helper configure the object its caller will use. ```resonon class Phrase { let root; fn new(root) { this.root = root; } fn transpose(amount) { this.root = this.root + amount; } fn notes() { return #[this.root, this.root + 7]; } } let phrase = Phrase(60); let alias = phrase; phrase.transpose(12); assert alias.root == 72; print(alias.notes()); ``` Methods can instead return new objects to preserve the original. A class that implements `Clone` defines `clone()`, which gives an independent copy when shared mutation is not the intended behavior. The class decides what its copy is: the engine does not invent one for it. The difference is a choice made by the method, not something inferred from its name. Page: explanation/language/06-the-class-model URL: https://resonon.org/docs/explanation/language/06-the-class-model/#instances-carry-shared-state Next: explanation/language/06-the-class-model#annotations-describe-contracts --- The Class Model > Playing captures a pattern [explanation] An instance of a class that implements `Pattern` is a script pattern. Sending it to a track, or transforming it with a combinator such as `.fast()`, captures its fields for playback. Changing the original instance later does not change that playing snapshot; send the instance again to replace the pattern. This separates editing an object from launching its musical result at a cycle boundary. [Classes](/docs/reference/language/07-classes/) specifies the syntax; [Script Patterns](/docs/reference/patterns/02-script-patterns/) specifies the query contract. Page: explanation/language/06-the-class-model URL: https://resonon.org/docs/explanation/language/06-the-class-model/#playing-captures-a-pattern Previous: explanation/language/06-the-class-model#annotations-describe-contracts --- MIDI Tracks & Time [explanation] A MIDI track is a channel on the mixer that sends notes instead of sound. This page explains how a track keeps its identity while you edit, and when the values it sends are decided. Sections: - explanation/midi/01-midi-tracks-and-time#a-track-is-its-name | A track is its name - explanation/midi/01-midi-tracks-and-time#ports-and-aliases-separate-the-rig-from-the-piece | Ports and aliases separate the rig from the piece - explanation/midi/01-midi-tracks-and-time#every-track-shares-one-cycle | Every track shares one cycle - explanation/midi/01-midi-tracks-and-time#velocity-is-read-when-the-note-fires | Velocity is read when the note fires - explanation/midi/01-midi-tracks-and-time#a-cc-lane-is-a-knob-or-a-timeline | A CC lane is a knob or a timeline - explanation/midi/01-midi-tracks-and-time#an-export-renders-it-does-not-sample | An export renders, it does not sample - explanation/midi/01-midi-tracks-and-time#related | Related Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/ --- MIDI Tracks & Time > A CC lane is a knob or a timeline [explanation] A CC lane fed a signal behaves like a knob wired to the synth. The audio engine sends the value the signal holds *now*, a set number of times a second and only when it changes, whether the transport is running or not — so a controller remapped onto a synth keeps working with the music stopped. A CC lane fed a pattern is part of the music instead. Its values are events on the timeline, played with the notes, and only while the transport runs. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#a-cc-lane-is-a-knob-or-a-timeline Previous: explanation/midi/01-midi-tracks-and-time#velocity-is-read-when-the-note-fires Next: explanation/midi/01-midi-tracks-and-time#an-export-renders-it-does-not-sample --- MIDI Tracks & Time > A track is its name [explanation] `session.create_midi_track("bass")` makes the track, once: a name that exists is an error. `session.midi_track("bass")` returns that track, with everything set on it — output, input, velocity, MPE, tuning, key, CC lanes — intact. That is what lets you re-run a line while the music plays: you talk to the track that is already there, without a gap and without a second one stacking up. Two tracks need two names, the way two tracks in a DAW do. A new track has no output, like a MIDI track in Live with "MIDI To" set to "No Output". `bass >> MidiOutput("synth", 2)` routes it, the same `>>` that picks an audio track's output; run `bass >> MidiOutput("synth", 3)` and the track moves to channel 3 from the next cycle, its pattern, CC and input thru with it. `bass >> session.nowhere` sets it back to no output. The session owns every track. A track stays until it is deleted with `session.delete_track("x")`, also when no variable holds it. A deleted track stops playing, its input stops coming through, and its name is free. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#a-track-is-its-name Next: explanation/midi/01-midi-tracks-and-time#ports-and-aliases-separate-the-rig-from-the-piece --- MIDI Tracks & Time > An export renders, it does not sample [explanation] A file has no gate to read a signal at, so `midi_export()` runs the signals across the exported span, the way a bounce runs the audio graph. Each velocity is taken at its own note and each CC value at its own moment, so a filtered LFO writes the curve you hear rather than one flat value. A signal can only be advanced by one owner at a time. So while an export with signals runs, it owns the engine and playback pauses. An export with none — plain patterns, fixed CC values — has nothing to run and never interrupts playback. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#an-export-renders-it-does-not-sample Previous: explanation/midi/01-midi-tracks-and-time#a-cc-lane-is-a-knob-or-a-timeline Next: explanation/midi/01-midi-tracks-and-time#related --- MIDI Tracks & Time > Every track shares one cycle [explanation] MIDI tracks and audio tracks run on the same cycle clock. A pattern on one track and a pattern on another start together and stay together, however long either is, and a pattern sent mid-cycle waits for the same boundary on every track. There is nothing to synchronise, because there is only one clock. [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) describes it. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#every-track-shares-one-cycle Previous: explanation/midi/01-midi-tracks-and-time#ports-and-aliases-separate-the-rig-from-the-piece Next: explanation/midi/01-midi-tracks-and-time#velocity-is-read-when-the-note-fires --- MIDI Tracks & Time > Ports and aliases separate the rig from the piece [explanation] A track's output names a destination alias, such as `"synth"`, while preferences map that alias to a port on this machine. The piece can keep the same destination name when another rig has a different device name. Channels still select parts within that destination; channel 2 on one port is not channel 2 on every port. Outputs and inputs are separate declarations because sending to a synth and listening to a keyboard are separate connections. The ordered preference entries also carry facts about each device, such as whether its absence is expected. A missing device keeps its alias so the track's intent stays visible rather than silently moving to another instrument. Applying a preferences reload looks for the declared ports again. Connecting a cable alone does not yet refresh them. The file's mapping wins on reload, including a mapping to a device that is currently absent. [How Preferences Are Applied](/docs/explanation/setup/02-how-preferences-are-applied/#midi-ports-are-entries-not-a-map) explains the lifecycle; [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/) shows the declarations. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#ports-and-aliases-separate-the-rig-from-the-piece Previous: explanation/midi/01-midi-tracks-and-time#a-track-is-its-name Next: explanation/midi/01-midi-tracks-and-time#every-track-shares-one-cycle --- MIDI Tracks & Time > Related [explanation] - [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/) — tracks, channels, ports and velocity - [Send CC Automation](/docs/how-to/midi/04-send-cc-automation/) — signal and pattern lanes - [Export MIDI](/docs/how-to/midi/08-export-midi/) — write tracks to a file Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#related Previous: explanation/midi/01-midi-tracks-and-time#an-export-renders-it-does-not-sample --- MIDI Tracks & Time > Velocity is read when the note fires [explanation] A velocity pattern gives each note the value of the step it starts in. A velocity signal is read at the moment the note fires, the way a hardware sequencer reads a velocity CV when its gate opens. Nothing is asked about the future, so any signal works — a smoothed one, a `dsp signal`, an envelope — and a slow envelope shapes four notes across a cycle rather than stamping all four with one value. A signal that is a pure function of time lands on the gate exactly; one that carries state is read to within one internal block, a few milliseconds. A signal never produces velocity 0. In MIDI, a note-on at velocity 0 *is* a note-off, so a signal at the bottom of its range gives 1, the quietest velocity MIDI has. A note that carries its own `^` velocity keeps it, whatever the track's velocity is. Page: explanation/midi/01-midi-tracks-and-time URL: https://resonon.org/docs/explanation/midi/01-midi-tracks-and-time/#velocity-is-read-when-the-note-fires Previous: explanation/midi/01-midi-tracks-and-time#every-track-shares-one-cycle Next: explanation/midi/01-midi-tracks-and-time#a-cc-lane-is-a-knob-or-a-timeline --- Monitoring & Thru [explanation] A MIDI track with an input can pass what you play on to its own output — MIDI thru. This page explains what decides whether it does, and what happens to the notes on the way. Sections: - explanation/midi/02-monitoring-and-thru#the-monitor-decides-what-you-hear | The monitor decides what you hear - explanation/midi/02-monitoring-and-thru#played-notes-follow-the-track | Played notes follow the track - explanation/midi/02-monitoring-and-thru#played-notes-are-not-delayed | Played notes are not delayed - explanation/midi/02-monitoring-and-thru#a-feedback-loop-is-caught | A feedback loop is caught - explanation/midi/02-monitoring-and-thru#every-input-feeds-cc | Every input feeds Cc() - explanation/midi/02-monitoring-and-thru#disconnecting-leaves-nothing-hanging | Disconnecting leaves nothing hanging - explanation/midi/02-monitoring-and-thru#related | Related Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/ --- Monitoring & Thru > A feedback loop is caught [explanation] An input and an output on the same virtual port form a loop: every note passed through arrives back at the input and is passed through again. Resonon watches the event rate, and when it runs away — thousands of events in a fraction of a second — it suspends thru, prints a warning, and tries again a second later. The session keeps playing. To avoid loops, use separate ports for input and output. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#a-feedback-loop-is-caught Previous: explanation/midi/02-monitoring-and-thru#played-notes-are-not-delayed Next: explanation/midi/02-monitoring-and-thru#every-input-feeds-cc --- Monitoring & Thru > Disconnecting leaves nothing hanging [explanation] When an input is disconnected, every track that was passing it through sends all-notes-off. Pulling a controller mid-performance doesn't leave a held note ringing. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#disconnecting-leaves-nothing-hanging Previous: explanation/midi/02-monitoring-and-thru#every-input-feeds-cc Next: explanation/midi/02-monitoring-and-thru#related --- Monitoring & Thru > Every input feeds Cc() [explanation] CC messages from every connected input are captured, whether or not a track uses that input, and `Cc()` reads the latest value. The value is a single number updated without a lock, so the audio thread can read it in every block. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#every-input-feeds-cc Previous: explanation/midi/02-monitoring-and-thru#a-feedback-loop-is-caught Next: explanation/midi/02-monitoring-and-thru#disconnecting-leaves-nothing-hanging --- Monitoring & Thru > Played notes are not delayed [explanation] Resonon sends pattern notes early, by the time the audio takes to reach your speakers, so hardware lands with the mix ([Clock & Alignment](/docs/explanation/midi/03-clock-and-alignment/)). A note you play is the other way round: it is a keypress happening now, and delaying it to line up with the audio buffer would only make the instrument feel late. So played notes get the port's own trim, and nothing else. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#played-notes-are-not-delayed Previous: explanation/midi/02-monitoring-and-thru#played-notes-follow-the-track Next: explanation/midi/02-monitoring-and-thru#a-feedback-loop-is-caught --- Monitoring & Thru > Played notes follow the track [explanation] A note passed through leaves on the track's output port and the track's channel, not the channel it arrived on. A keyboard sending on channel 1 into a channel-5 track plays channel 5. The track, not the keyboard, decides where its notes go — the same as for the notes of its pattern — so moving a track to another synth moves what you play on it too. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#played-notes-follow-the-track Previous: explanation/midi/02-monitoring-and-thru#the-monitor-decides-what-you-hear Next: explanation/midi/02-monitoring-and-thru#played-notes-are-not-delayed --- Monitoring & Thru > Related [explanation] - [Play Through from a Keyboard](/docs/how-to/midi/02-play-through-from-a-keyboard/) — route and monitor an input - [Map a Controller](/docs/how-to/midi/03-map-a-controller/) — read CC as a signal Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#related Previous: explanation/midi/02-monitoring-and-thru#disconnecting-leaves-nothing-hanging --- Monitoring & Thru > The monitor decides what you hear [explanation] Monitoring is a track setting, as it is in a DAW. `Monitor.off`, the default, takes nothing from the input to the output: the input is connected but silent. `Monitor.input` passes everything through. `Monitor.auto` passes the input through while the track is not playing its own material, as Live's Auto does: when the transport is stopped, or when the track has no pattern. While the track plays its pattern, the input is silent, and a key you were holding as it started is still released. The default is off because an input you didn't ask to hear should stay silent: connecting a keyboard never makes a track start playing it. Page: explanation/midi/02-monitoring-and-thru URL: https://resonon.org/docs/explanation/midi/02-monitoring-and-thru/#the-monitor-decides-what-you-hear Next: explanation/midi/02-monitoring-and-thru#played-notes-follow-the-track --- Clock & Alignment [explanation] MIDI leaves resonon for gear that has its own timing: a DAW, a drum machine, a CV interface, a synth with its own latency. This page explains how resonon shares its clock with that gear, and how it times what it sends so it lands with the audio. Sections: - explanation/midi/03-clock-and-alignment#lead-or-follow-never-both | Lead or follow, never both - explanation/midi/03-clock-and-alignment#a-port-opts-in-to-clock | A port opts in to clock - explanation/midi/03-clock-and-alignment#joining-in-the-middle | Joining in the middle - explanation/midi/03-clock-and-alignment#following-a-clock | Following a clock - explanation/midi/03-clock-and-alignment#midi-lands-with-the-audio | MIDI lands with the audio - explanation/midi/03-clock-and-alignment#related | Related Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/ --- Clock & Alignment > A port opts in to clock [explanation] Sending clock takes two switches: `set_midi_clock_send(true)` for the session, and `send_clock = true` on each port that should receive it. Ports don't receive clock unless they ask for it, so adding a port to a rig never starts driving a device that was meant to run on its own clock. Which devices take clock is a fact about the rig, not about the piece, so it is written in the port's entry in `~/.resonon/preferences.toml`, beside the port, rather than in code ([The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/)). Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#a-port-opts-in-to-clock Previous: explanation/midi/03-clock-and-alignment#lead-or-follow-never-both Next: explanation/midi/03-clock-and-alignment#joining-in-the-middle --- Clock & Alignment > Following a clock [explanation] MIDI clock is 24 ticks per quarter note, and every tick arrives with some timing noise. A follower estimates the tempo from all of them, with a filter that measures the port's own noise: a clean source is followed quickly and precisely, a jittery one quietly. A tempo *jump* — a DAW switching tempo — is recognised as a jump and taken within a few ticks. A nudge or a ramp is followed within a bar or two. Start restarts from the top, Stop pauses and Continue resumes. A song position sent before Continue is honoured exactly, to the sixteenth, as Live does. As MIDI asks of a receiver, playback starts on the first tick after Start or Continue, at the moment that tick was stamped, not when resonon got round to reading it. The first notes can sound a few milliseconds late, but the beat they play on is the source's. From then on, every tick measures how far the play head is from the source. That difference is not corrected by moving the play head, which would be heard as a jump. Instead the play head runs up to half a percent faster or slower until it is back on the source's beat. Half a percent can't be heard, even on a tempo-synced delay. A buffer's worth of drift, say after a dropout, is gone in two or three seconds. Ticks that arrive late or never arrive are filtered out before they reach the measurement. What lines up with the source is what you hear. Audio takes time to reach your speakers: the buffer, the converter, and the delay of any plugin with lookahead. So the play head runs that far ahead of the source's ticks, and beat 1 is heard on the source's first tick, not one output latency after it. The figure is measured on every buffer. Insert a lookahead limiter while following and the play head is steered onto the new figure in the same way, with no jump. That leaves the source's own delay: a drum machine whose sound comes out a few milliseconds after the clock it sends. That is a fact about the device, so it is the input port's `clock_trim_ms`: positive plays resonon later against that clock, negative earlier. A `SEEK` while following is yours: resonon keeps it, lines it up with the nearest tick, and doesn't pull it back to where the source thinks the song is. `midi_clock_report()` shows the measured phase error, how hard the play head is being steered, and the output delay and trim it is held ahead by. Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#following-a-clock Previous: explanation/midi/03-clock-and-alignment#joining-in-the-middle Next: explanation/midi/03-clock-and-alignment#midi-lands-with-the-audio --- Clock & Alignment > Joining in the middle [explanation] A port that starts receiving clock while the music plays — because clock was turned on, or because the port opted in — is sent the current position and Continue, so it picks up where resonon is rather than from the top. A `SEEK` while playing does the same for every port: Stop, the new position, and Continue, where the play head lands. The ticks that follow sit on the same grid as the notes. Gear that divides clock down to an analogue pulse needs exactly that to land on the beat. A port that stops receiving clock is sent Stop, rather than left waiting for ticks that no longer come. Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#joining-in-the-middle Previous: explanation/midi/03-clock-and-alignment#a-port-opts-in-to-clock Next: explanation/midi/03-clock-and-alignment#following-a-clock --- Clock & Alignment > Lead or follow, never both [explanation] A session either sends clock and is the tempo's source, or follows a clock from elsewhere. Doing both would mean two sources for one tempo, so turning one on turns the other off. Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#lead-or-follow-never-both Next: explanation/midi/03-clock-and-alignment#a-port-opts-in-to-clock --- Clock & Alignment > MIDI lands with the audio [explanation] Audio takes time to reach your speakers: the buffer, the converter, and the delay of any plugin with lookahead. A note sent the moment it is scheduled would sound early against the mix. So every note, CC value and clock tick is timestamped for the moment the audio it belongs with reaches the converter, plugin delay included. Inserting a lookahead limiter does not shift your hardware against the mix. That leaves what differs from device to device: one synth speaks a little later than another, and some gear settles on clock differently than on notes. Those corrections belong to the device, so they sit in its port entry, as `trim_ms` and `clock_trim_ms`, and stay with the port for as long as the entry does. The automatic part can be turned off with `set_midi_latency(MidiLatency.manual)`, leaving only the trims. That setting is about what resonon sends: a follower lines up what you hear either way. Notes you play through a track never get the automatic part ([Monitoring & Thru](/docs/explanation/midi/02-monitoring-and-thru/#played-notes-are-not-delayed)). Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#midi-lands-with-the-audio Previous: explanation/midi/03-clock-and-alignment#following-a-clock Next: explanation/midi/03-clock-and-alignment#related --- Clock & Alignment > Related [explanation] - [Sync to a MIDI Clock](/docs/how-to/midi/05-sync-to-a-midi-clock/) — send or follow clock - [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/) — read the offset and trim a device - [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) — the same timing, for audio input Page: explanation/midi/03-clock-and-alignment URL: https://resonon.org/docs/explanation/midi/03-clock-and-alignment/#related Previous: explanation/midi/03-clock-and-alignment#midi-lands-with-the-audio --- Cycles & Time [explanation] Resonon measures musical time in **cycles**. A cycle is one repeating window — think of it as a bar of music. A pattern doesn't carry a tempo or a list of timestamps; it describes *what happens within one cycle*, and the runtime repeats that cycle forever. Put four notes in a pattern and they're quarter-notes; put eight and they're eighths. This page is the mental model for how that window is sized, how the clock advances it, and why your live edits always land in time. Sections: - explanation/patterns/01-cycles-and-time#cycles-beats--bpm | Cycles, Beats & BPM - explanation/patterns/01-cycles-and-time#the-scheduler-advances-cycles | The Scheduler Advances Cycles - explanation/patterns/01-cycles-and-time#quantized-swaps | Quantized Swaps - explanation/patterns/01-cycles-and-time#code-that-runs-every-cycle | Code That Runs Every Cycle - explanation/patterns/01-cycles-and-time#related | Related Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/ --- Cycles & Time > Code That Runs Every Cycle [explanation] The same boundary is where code can run. A callback registered with [`on_cycle`](/docs/reference/stdlib/generative/#on_cycle) runs once per cycle, on the interpreter thread, just before that cycle is needed — so it can compute the next pattern from the cycle number. Whatever it sends is quantized like any other edit, and lands on the cycle it was computed for. [Change a Pattern Every Cycle](/docs/how-to/patterns/06-change-a-pattern-every-cycle/) shows how. Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/#code-that-runs-every-cycle Previous: explanation/patterns/01-cycles-and-time#quantized-swaps Next: explanation/patterns/01-cycles-and-time#related --- Cycles & Time > Cycles, Beats & BPM [explanation] A cycle is divided into **beats**. The two tempo controls are the cycle's beats and its speed: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } set_bpm(120); // 120 BPM, 4 beats per cycle (the default) let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; PLAY; ``` A cycle is a number of beats, so its length is plain arithmetic. By default that's **120 BPM at 4 beats per cycle**, so one cycle lasts 2 seconds and the four hits above fall one per beat, half a second apart. Add a fifth element and the cycle still lasts 2 seconds — every event simply gets a thinner slice. The cycle is the fixed frame; the pattern decides how to fill it. Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/#cycles-beats--bpm Next: explanation/patterns/01-cycles-and-time#the-scheduler-advances-cycles --- Cycles & Time > Quantized Swaps [explanation] This is the property that makes live coding feel musical rather than chaotic. When you re-send a pattern to a track that's already playing: ```resonon parse-only drums << [bd bd sd bd]; ``` the swap does **not** happen the instant you press execute. It's *quantized* — held until the start of the next cycle, then applied cleanly on the downbeat. Your edit lands in time no matter when you trigger it mid-cycle, so the groove never tears. This is automatic and applies to every pattern update; there's no mid-cycle swap to opt into. It is the same idea as launch quantization in a clip-launching DAW: an edit is queued and fires on the next bar. Because every edit waits for the same boundary, you can evaluate whenever you like — a new pattern, a new layer on another track — and trust it to land on the downbeat, in time with everything already playing. :::note Quantization is to the cycle boundary specifically. If you want a change to take effect *now*, you're really asking to shorten the wait — execute just before the boundary, or work with shorter cycles. ::: Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/#quantized-swaps Previous: explanation/patterns/01-cycles-and-time#the-scheduler-advances-cycles Next: explanation/patterns/01-cycles-and-time#code-that-runs-every-cycle --- Cycles & Time > Related [explanation] - [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/) — how events divide a cycle - [Events & Notes](/docs/explanation/patterns/03-events-and-notes/) — what fills each slice - [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) — what the scheduler drives - [Patterns, Tracks & Effects](/docs/tutorials/getting-started/03-patterns-tracks-effects/) — hearing swaps land on the cycle Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/#related Previous: explanation/patterns/01-cycles-and-time#code-that-runs-every-cycle --- Cycles & Time > The Scheduler Advances Cycles [explanation] Patterns are timeless on their own — `[bd sd bd sd]` is the same description whether you play it fast or slow. What turns that description into sound at a tempo is the **scheduler**: it walks wall-clock time forward, and each time enough real time has elapsed for one cycle, it advances the cycle counter and queries every playing pattern for that cycle's events. ```txt cycle 0 cycle 1 cycle 2 ┌──────────┐ ┌──────────┐ ┌──────────┐ │ bd sd … │ │ bd sd … │ │ bd sd … │ ← pattern queried per cycle └──────────┘ └──────────┘ └──────────┘ 0s 2s 4s 6s ← wall-clock at 120/4 ``` So tempo isn't baked into your patterns — it's the rate at which the scheduler consumes them. Change `set_bpm` and the same patterns simply stream by faster or slower. Page: explanation/patterns/01-cycles-and-time URL: https://resonon.org/docs/explanation/patterns/01-cycles-and-time/#the-scheduler-advances-cycles Previous: explanation/patterns/01-cycles-and-time#cycles-beats--bpm Next: explanation/patterns/01-cycles-and-time#quantized-swaps --- How Patterns Work [explanation] A pattern in resonon is not a list of notes stored somewhere. It is a description that answers one question: *what plays in this cycle?* Everything else about patterns follows from that. It is why transforms cost nothing until playback, why the order of a chain matters, why microtiming is measured in steps, and why generators give the same result on every playback. Sections: - explanation/patterns/02-how-patterns-work#a-pattern-is-a-query-not-a-recording | A pattern is a query, not a recording - explanation/patterns/02-how-patterns-work#transforms-wrap-they-dont-edit | Transforms wrap, they don't edit - explanation/patterns/02-how-patterns-work#timing-moves | Timing moves - explanation/patterns/02-how-patterns-work#determinism-and-seekability | Determinism and seekability - explanation/patterns/02-how-patterns-work#next-steps | Next Steps Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/ --- How Patterns Work > A pattern is a query, not a recording [explanation] Think of a pattern as a recipe, not a recording. When the transport runs, the scheduler asks each pattern for the events of one cycle at a time: - **On demand.** Only the cycle being played is computed. - **Stateless.** Each query is independent, so any cycle can be asked for, in any order. - **Infinite by default.** A pattern repeats forever without storing anything that grows. Time is counted in ticks, 46,126,080 to the cycle, the way a sequencer counts in pulses. Every subdivision up to 16 and every binary one down to 1/1024 is a whole number of ticks, so a five-element sequence divides the cycle into exact fifths, and nothing drifts over hours of playback. A tick is far shorter than a sample, so anything finer simply sits on the nearest one. Resonon's pattern model is inspired by [TidalCycles](https://tidalcycles.org/) and its functional approach to time. Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/#a-pattern-is-a-query-not-a-recording Next: explanation/patterns/02-how-patterns-work#transforms-wrap-they-dont-edit --- How Patterns Work > Determinism and seekability [explanation] Because any cycle can be asked for at any time, a pattern must give the same answer every time it is asked about the same cycle. Resonon keeps to that even where a pattern appears random: - **Seeded randomness.** `rand(seed)` and `choose(seed, …)` return the same value for the same seed. A generator seeded with the cycle number makes a different choice each cycle, and the same choice on every playback. - **Hashed variation.** `.degrade()` and `.humanize()` derive their "random" decisions from a hash of each event's position. The same pattern drops the same hits and jitters the same way on every run. - **Replayed state.** A generator whose state carries from cycle to cycle, like a [stream](/docs/reference/stdlib/generative/#stream), a [Markov chain](/docs/reference/stdlib/generative/#markov) or a [script pattern](/docs/reference/patterns/02-script-patterns/), has no live state that could drift. To answer for cycle *N*, it replays every step from cycle 0. ```resonon use "std/generative" { markov }; let chain = markov(3, #[#[0.5,0.5,0.0],#[0.0,0.5,0.5],#[0.5,0.0,0.5]], 0); assert chain.query(20) == chain.query(20), "the same cycle gives the same state"; print("deterministic"); ``` This is what makes loops, restarts and seeking behave. Stop at cycle 40, seek back to cycle 12, and you hear exactly what played at cycle 12 the first time. The cost is that finding cycle *N* replays *N* steps (O(N)). Each step is cheap, so for musical ranges — hundreds to a few thousand cycles — you won't notice it. Two things follow from replaying. A generator's function captures the variables it refers to when the generator is created, so changing them afterwards does not change the generator. And a script pattern's fields are captured when the instance is sent to a track, so later changes to the original instance don't reach the playing pattern. `rand_true()` and `choose_true()` are the deliberate exception. They are unseeded and break seekability, so use them only when you want a result that is different every time. Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/#determinism-and-seekability Previous: explanation/patterns/02-how-patterns-work#timing-moves Next: explanation/patterns/02-how-patterns-work#next-steps --- How Patterns Work > Next Steps [explanation] - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — how the scheduler advances cycles - [Polymeter & Euclidean Rhythm](/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/) — how phasing meters and euclidean rhythms place their onsets - [Pattern methods](/docs/reference/stdlib/patterns/) — every transform, with its signature Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/#next-steps Previous: explanation/patterns/02-how-patterns-work#determinism-and-seekability --- How Patterns Work > Timing moves [explanation] The microtiming methods (`.nudge()`, `.swing()`, `.humanize()`) move events off the grid. Every amount is a fraction of a slot, not an absolute time, so the feel follows the tempo. Swing is a property of the grid, not of the events. `.swing(amount, grid)` cuts the cycle into `grid` slots and takes them in pairs. It leaves the first of each pair on the grid and delays the second by the amount, so the pair splits the time between them in the ratio `1 + amount` to `1 - amount`. At `0.33` that is two to one, the triplet shuffle of an MPC; at `0.5` it is three to one, a dotted note and the note after it. What plays in a slot doesn't matter: in a stack, the kick on the beat stays and the hat on the off-beat moves. A note between two grid lines moves with its pair, by the amount times its distance to the nearer edge of the pair, so notes never pass each other. `.nudge()` and `.humanize()` work on each event's own **step**, the slot the event occupies, so `humanize(0.1)` loosens a four-step pattern and a sixteen-step one by the same feel. The methods move notes in time. They don't change their length: - A shifted note keeps its full duration, so it may overlap its neighbour or sustain past the end of the cycle. Small overlaps sound natural. - An event pushed outside the cycle is clamped to the cycle boundary. No event is dropped. - A zero amount, or an empty offset list, passes events through unchanged. When you chain these methods, each one sees the events the previous one already moved. That is why `.humanize()` goes last: jitter applied before a swing moves the positions the swing is measured from. Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/#timing-moves Previous: explanation/patterns/02-how-patterns-work#transforms-wrap-they-dont-edit Next: explanation/patterns/02-how-patterns-work#determinism-and-seekability --- How Patterns Work > Transforms wrap, they don't edit [explanation] `.fast(2)`, `.reverse()` and the other pattern methods don't change any stored notes, because there are none. Each one returns a **new** pattern that wraps the one it was called on and changes how that pattern is queried. The original is never touched. It is like non-destructive editing in a DAW: the source clip stays as it was, and the edits stack on top. Two consequences follow. First, you can derive as many variations from one motif as you like, and none of them affects the others. Second, the order of a chain changes the result, because each method wraps everything to its left: ```resonon print([C4 D4].concat([E4]).reverse().describe()); // reverses all three notes print([C4 D4].reverse().concat([E4]).describe()); // reverses only [C4 D4] ``` `.describe()` prints that nesting. Read its output inside-out: `Transpose(7, Reverse(Sequence[3]))` is a three-note sequence, reversed, then transposed. The innermost term is the source, and each wrapper is one method you applied. Page: explanation/patterns/02-how-patterns-work URL: https://resonon.org/docs/explanation/patterns/02-how-patterns-work/#transforms-wrap-they-dont-edit Previous: explanation/patterns/02-how-patterns-work#a-pattern-is-a-query-not-a-recording Next: explanation/patterns/02-how-patterns-work#timing-moves --- Events & Notes [explanation] A pattern doesn't store sound, and it doesn't store a list of notes either. It answers a question: *what plays, and when?* The answer comes back as a stream of **events**. Understanding what an event actually carries — and how the note, chord, and degree literals you write become events — is the mental model that ties patterns, keys, and instruments together. Sections: - explanation/patterns/03-events-and-notes#what-an-event-is | What an Event Is - explanation/patterns/03-events-and-notes#what-a-note-carries | What a Note Carries - explanation/patterns/03-events-and-notes#velocity-is-optional | Velocity Is Optional - explanation/patterns/03-events-and-notes#chords-are-stacks | Chords Are Stacks - explanation/patterns/03-events-and-notes#degrees-stay-abstract-until-keyed | Degrees Stay Abstract Until Keyed - explanation/patterns/03-events-and-notes#from-event-to-sound | From Event to Sound - explanation/patterns/03-events-and-notes#related | Related Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/ --- Events & Notes > Chords Are Stacks [explanation] A chord literal like `C4:maj` or `^1:min7` is not one event with three pitches — it expands into a **stack of single-pitch events that all share the same span**. They sound simultaneous because their time windows are identical. This is why a chord behaves exactly like writing the notes with commas: `[C4:maj]` and `[C4, E4, G4]` produce the same three overlapping events. The chord qualities (`maj`, `min7`, `sus4`, …) are listed in [Scales, Chords & Intervals](/docs/reference/patterns/03-scales-chords-intervals/#chord-qualities). Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#chords-are-stacks Previous: explanation/patterns/03-events-and-notes#velocity-is-optional Next: explanation/patterns/03-events-and-notes#degrees-stay-abstract-until-keyed --- Events & Notes > Degrees Stay Abstract Until Keyed [explanation] A scale degree like `^1` or `^-2` is deliberately *unresolved*. It carries a degree number, not a pitch — `^1` doesn't know whether it's C or F♯ until you give it a key. You anchor it in one of two ways: - **Per pattern** with `.in_key(key)`. - **Per track** with `track.set_key(...)`, after which every degree on that track resolves automatically and absolute notes are quantized into the scale. This late binding is the whole point: write a melody once in degrees, then change the key under it and the same pattern transposes and re-harmonizes itself. A `Key` is a `Scale` rooted at a note; both, along with diatonic chords on degrees (`^1:`), are put to work in [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/). Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#degrees-stay-abstract-until-keyed Previous: explanation/patterns/03-events-and-notes#chords-are-stacks Next: explanation/patterns/03-events-and-notes#from-event-to-sound --- Events & Notes > From Event to Sound [explanation] When the scheduler queries a pattern, it gets these events and turns each one into output at its destination: - On a **MIDI track**, an event becomes a note-on at the span's start and a note-off at its end. A fractional pitch adds a pitch-bend message. - On an **audio track**, an event triggers a voice on the loaded instrument — a sampler hit, a plugin note, or a DSP voice — gated by the same span. Either way, the span's end is what releases the note. The event is the contract; the instrument decides how to make it audible. Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#from-event-to-sound Previous: explanation/patterns/03-events-and-notes#degrees-stay-abstract-until-keyed Next: explanation/patterns/03-events-and-notes#related --- Events & Notes > Related [explanation] - [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) — degrees, keys, chords, and scales - [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/) — how events divide a cycle - [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/) — every literal and modifier - [Pattern Methods](/docs/reference/stdlib/patterns/) — `in_key`, `quantize`, and transforms - [MIDI](/docs/reference/stdlib/midi/) — sending events to MIDI gear - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — the timing side of the model Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#related Previous: explanation/patterns/03-events-and-notes#from-event-to-sound --- Events & Notes > Velocity Is Optional [explanation] An event carries a velocity only if you wrote one — `C4^120`. One without asks its track, so the same pattern plays softer on a track set softer, while a written accent always wins. The velocity belongs to the note when it is part of the phrase, and to the track when it is part of the mix. Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#velocity-is-optional Previous: explanation/patterns/03-events-and-notes#what-a-note-carries Next: explanation/patterns/03-events-and-notes#chords-are-stacks --- Events & Notes > What a Note Carries [explanation] Strip an event down and you find three pieces of information: - **Pitch** — what to play - **Velocity** — how hard (optional; falls back to the track default) - **Span** — when it starts and ends The interesting part is *pitch*, because resonon accepts several kinds and resolves them at different times: | You write | Kind | Resolves to | | --- | --- | --- | | `C4`, `f#3`, `Bb2` | Note name | A MIDI pitch | | `60`, `67` | Number | A MIDI pitch (the number *is* the note) | | `bd`, `sd`, `hh` | Sample | A named hit on the track's sampler | | `^1`, `^5`, `^-2` | Scale degree | A pitch, *once anchored to a key* | | `C4:maj`, `^1:min7` | Chord | Several simultaneous pitches | Note names and plain numbers are the same thing under the hood: `C4` *is* `60`, so the two styles mix freely in one pattern. The mapping is in [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/). Pitches are **fractional**, not just integers: `60.5` is a quarter-tone above `C4`. That's how resonon plays microtonal scales — a non-integer pitch is rendered via pitch bend when a track has [`set_tuning()` or `set_mpe()`](/docs/reference/stdlib/audio/) enabled. Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#what-a-note-carries Previous: explanation/patterns/03-events-and-notes#what-an-event-is Next: explanation/patterns/03-events-and-notes#velocity-is-optional --- Events & Notes > What an Event Is [explanation] An event is a **value over a span of time**. The span is a half-open window `[start, end)`: the event begins at `start` and releases at `end`. That window is everything time-related about the event — when a note sounds and how long it holds are the *same fact*. There's no separate "duration" field; the gate is the span. When you write `[C4 D4 E4 F4]`, querying one cycle hands back four events, each a note value over one quarter of the cycle. Add a fifth note and every span shrinks to fit — the events divide the cycle, as covered in [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/). Page: explanation/patterns/03-events-and-notes URL: https://resonon.org/docs/explanation/patterns/03-events-and-notes/#what-an-event-is Next: explanation/patterns/03-events-and-notes#what-a-note-carries --- Polymeter & Euclidean Rhythm [explanation] Two parts of mini-notation *generate* rhythm rather than spell it out note by note. This page explains how each one arrives at its onsets. **Polymetric patterns** let groups of different lengths cycle at different rates, phasing against each other like Steve Reich loops. **Euclidean rhythms** distribute hits as evenly as possible across steps, producing many of the world's classic rhythmic cells from two numbers. Sections: - explanation/patterns/04-polymeter-and-euclidean-rhythm#polymetric-patterns | Polymetric Patterns - explanation/patterns/04-polymeter-and-euclidean-rhythm#the-n-subdivision | The %N Subdivision - explanation/patterns/04-polymeter-and-euclidean-rhythm#multiple-groups-shared-grid | Multiple Groups: Shared Grid - explanation/patterns/04-polymeter-and-euclidean-rhythm#polymetric--vs-parallel- | Polymetric {} vs Parallel ,] - explanation/patterns/04-polymeter-and-euclidean-rhythm#euclidean-rhythms | Euclidean Rhythms - explanation/patterns/04-polymeter-and-euclidean-rhythm#rotation | Rotation - explanation/patterns/04-polymeter-and-euclidean-rhythm#next-steps | Next Steps Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/ --- Polymeter & Euclidean Rhythm > Euclidean Rhythms [explanation] Give the euclidean algorithm a number of **hits** and a number of **steps**, and it spaces the hits as evenly as possible. Three hits over eight steps: ```txt x . . x . . x . ``` That's the Cuban *tresillo* — the 3+3+2 cell underneath son, reggaeton, EDM, and half of pop music. Many traditional cells fall out of this one algorithm; the cinquillo, for one, is five hits over eight steps. Written inline as `bd(3,8)`, an element sounds on the hit positions and rests on the others, all inside its own slot — so a euclidean element is still one element of its sequence. Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#euclidean-rhythms Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#polymetric--vs-parallel- Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#rotation --- Polymeter & Euclidean Rhythm > Multiple Groups: Shared Grid [explanation] Comma-separated groups inside `{...}` are the heart of polymetric writing. All groups land on the **same onset grid**, but each group's content cycles at its own rate: ```resonon let poly = {C4 E4 G4, F4 A4}; ``` Without an explicit `%N`, N defaults to the **first group's length** — here 3. Each group is sped up by its own N/L factor so every voice produces exactly N onsets per cycle: ```txt time 0 1/3 2/3 │ 1 4/3 5/3 voice 1 C4 E4 G4 │ C4 E4 G4 voice 2 F4 A4 F4 │ A4 F4 A4 ``` Voice 1 repeats identically every cycle. Voice 2's two-note content takes only 2/3 of a cycle per pass, so it drifts one position per cycle and realigns with voice 1 every 2 cycles. That slow churn of two loops sliding past each other is the polymetric sound. An explicit `%N` sets the grid density for all groups at once: ```resonon let dense = {C4 D4 E4, F4 G4}%6; // 6 onsets/cycle; factors 2 and 3 ``` Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#multiple-groups-shared-grid Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#the-n-subdivision Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#polymetric--vs-parallel- --- Polymeter & Euclidean Rhythm > Next Steps [explanation] - [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/) — the query model underneath every pattern - [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/#polymetric-groups) — `{}`, `%N` and `(k,n,r)`, with their step and rotation tables - [Write Polymetric and Euclidean Rhythms](/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/) — the recipes - [Add Swing and Human Feel](/docs/how-to/patterns/02-add-swing-and-human-feel/) — move the onsets off the grid Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#next-steps Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#rotation --- Polymeter & Euclidean Rhythm > Polymetric {} vs Parallel ,] [explanation] Both layer voices, but they divide time differently. In a parallel group `[a b c, d e]`, each voice divides the cycle by its own length: three onsets against two, a rhythmic cross within every cycle. In a polymetric group `{a b c, d e}`, both voices share one grid of three onsets, and what differs is the content: the two-note voice runs out early and wraps, so the voices line up differently from one cycle to the next. Parallel groups cross rhythms; polymetric groups phase melodies. Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#polymetric--vs-parallel- Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#multiple-groups-shared-grid Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#euclidean-rhythms --- Polymeter & Euclidean Rhythm > Polymetric Patterns [explanation] Curly braces `{...}` give each element one **step**. Without a subdivision modifier, one step equals one full cycle: ```resonon let slow = {C4 D4 E4}; // One note per cycle — spans 3 cycles let fast = [C4 D4 E4]; // All three notes in one cycle ``` Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#polymetric-patterns Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#the-n-subdivision --- Polymeter & Euclidean Rhythm > Rotation [explanation] A third parameter rotates the hit pattern, wrapping around: the same spacing, starting from a different point in it. Because a rotation keeps the spacing and moves only the downbeat, rotations of one cell played together interlock: each fills gaps the others leave. The rhythm and its content are separate. `euclid()` takes a whole pattern as the source and deals its events onto the hits in order, so the same rhythm can carry a melody — and the order in which a rhythm and a speed change are applied decides which of the two gets faster. Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#rotation Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#euclidean-rhythms Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#next-steps --- Polymeter & Euclidean Rhythm > The %N Subdivision [explanation] `%N` packs N steps into each cycle. A group of L elements then runs at N/L times the speed of one pass per cycle: `{C4 D4 E4}%3` is the same as `[C4 D4 E4]`, and `{C4 D4 E4}%6` plays it twice a cycle. When N and L don't divide evenly, the content **wraps** — and this is where it gets musical. `{C4 D4}%3` has factor 3/2: three onsets per cycle at 0, 1/3, 2/3, but only two notes of content. Cycle 0 plays C4 D4 C4; cycle 1 picks up where it left off with D4 C4 D4. The content shifts by one position each cycle, phasing against the meter until it realigns after L cycles. :::note The N/L ratio is kept exact — `{C4 D4}%3` runs at exactly 3/2 speed, and the phase always realigns precisely. ::: Page: explanation/patterns/04-polymeter-and-euclidean-rhythm URL: https://resonon.org/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/#the-n-subdivision Previous: explanation/patterns/04-polymeter-and-euclidean-rhythm#polymetric-patterns Next: explanation/patterns/04-polymeter-and-euclidean-rhythm#multiple-groups-shared-grid --- Theory and Microtonality [explanation] Scale-relative writing keeps a motif's relationships intact when you change its key. Microtonal writing uses the same model with intervals between the usual semitones. Sections: - explanation/patterns/05-theory-and-microtonality#a-scale-is-an-interval-set-and-a-key-has-a-root | A scale is an interval set and a key has a root - explanation/patterns/05-theory-and-microtonality#fractional-semitones-retain-pitch-detail | Fractional semitones retain pitch detail Page: explanation/patterns/05-theory-and-microtonality URL: https://resonon.org/docs/explanation/patterns/05-theory-and-microtonality/ --- Theory and Microtonality > A scale is an interval set and a key has a root [explanation] A `Scale` describes ordered intervals without an absolute root. A `Key` places that scale at a note. Degree 1 is the root, and higher degrees walk through the scale rather than adding chromatic semitones. Thus a fifth-degree motif can retain its role when its key changes. ```resonon let major = Key(C4, "major"); let minor = Key(C4, "minor"); print(major.degree(3)); print(minor.degree(3)); ``` A track key resolves degree events and quantizes absolute notes onto its scale. This is a musical choice: an out-of-scale note may move when the track has a key. Use absolute pitches without that quantization when their precise chromatic placement is intended. Diatonic chords choose notes from the key. An explicit chord quality chooses its interval recipe, so a quality such as `min7` and a diatonic seventh chord are different requests. Page: explanation/patterns/05-theory-and-microtonality URL: https://resonon.org/docs/explanation/patterns/05-theory-and-microtonality/#a-scale-is-an-interval-set-and-a-key-has-a-root Next: explanation/patterns/05-theory-and-microtonality#fractional-semitones-retain-pitch-detail --- Theory and Microtonality > Fractional semitones retain pitch detail [explanation] Custom scales can contain fractional semitones. Their repeat period defaults to the twelve-semitone octave; a custom period changes where the interval set repeats. A Scala tuning supplies an interval set from a file. These choices describe pitch relationships without requiring twelve equal steps. An instrument still determines how that pitch is realized. MIDI note numbers identify semitones, so microtonal output uses pitch bend around a nearby MIDI note. With ordinary channel-wide bend, overlapping notes share the bend and can affect one another. MPE gives each note a member channel so its pitch bend can be independent. The receiving synth's mode and bend range must match. [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) and [Play Microtonal and MPE](/docs/how-to/midi/07-play-microtonal-and-mpe/) show the actions. [Theory](/docs/reference/stdlib/theory/) specifies the values and methods. Page: explanation/patterns/05-theory-and-microtonality URL: https://resonon.org/docs/explanation/patterns/05-theory-and-microtonality/#fractional-semitones-retain-pitch-detail Previous: explanation/patterns/05-theory-and-microtonality#a-scale-is-an-interval-set-and-a-key-has-a-root --- Randomness and Seeding [explanation] Randomness can describe a repeatable composition or a decision made anew on each performance. The choice determines whether restarting or seeking brings back the same musical result. Sections: - explanation/patterns/06-randomness-and-seeding#a-seed-identifies-a-repeatable-choice | A seed identifies a repeatable choice - explanation/patterns/06-randomness-and-seeding#pattern-variation-belongs-to-musical-position | Pattern variation belongs to musical position - explanation/patterns/06-randomness-and-seeding#unseeded-choices-are-a-performance-decision | Unseeded choices are a performance decision Page: explanation/patterns/06-randomness-and-seeding URL: https://resonon.org/docs/explanation/patterns/06-randomness-and-seeding/ --- Randomness and Seeding > A seed identifies a repeatable choice [explanation] The seeded helpers in `std/random` return the same result for the same seed and arguments. A constant seed therefore repeats one choice. Using the cycle number as the seed varies that choice between cycles while preserving it when the same cycle is visited again. ```resonon use "std/random" { choose }; let candidates = #[60, 64, 67, 71]; assert choose(8, candidates) == choose(8, candidates); print(choose(8, candidates)); ``` Repeatability depends on the inputs too. Editing the candidate notes, weights or generator changes the composition even when the seed is unchanged. Independent musical parts can use deliberately different seed expressions instead of all drawing from the same cycle seed. Page: explanation/patterns/06-randomness-and-seeding URL: https://resonon.org/docs/explanation/patterns/06-randomness-and-seeding/#a-seed-identifies-a-repeatable-choice Next: explanation/patterns/06-randomness-and-seeding#pattern-variation-belongs-to-musical-position --- Randomness and Seeding > Pattern variation belongs to musical position [explanation] Transforms such as `.degrade()` and `.humanize()` derive variation from event positions, so the same position gives the same variation. Stateful generators replay their progression to answer queries at a later cycle. These mechanisms let the scheduler revisit musical positions without letting the act of querying change the music. A custom query should preserve that property when repeatable playback matters. Unseeded random calls or mutable state outside the query can make the answer depend on evaluation order. Page: explanation/patterns/06-randomness-and-seeding URL: https://resonon.org/docs/explanation/patterns/06-randomness-and-seeding/#pattern-variation-belongs-to-musical-position Previous: explanation/patterns/06-randomness-and-seeding#a-seed-identifies-a-repeatable-choice Next: explanation/patterns/06-randomness-and-seeding#unseeded-choices-are-a-performance-decision --- Randomness and Seeding > Unseeded choices are a performance decision [explanation] `rand_true()` and `choose_true()` choose anew on each call. Re-running setup can therefore produce a different result; invoking them inside a callback can produce a different performance at the same cycle. They intentionally give up seekability, and they are appropriate when that variation is the result you want. [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#determinism-and-seekability) explains queries and replay. [Make a Reproducible Random Choice](/docs/how-to/patterns/03-make-a-reproducible-random-choice/) shows seed choices, and [Random](/docs/reference/stdlib/random/) lists the helpers. Page: explanation/patterns/06-randomness-and-seeding URL: https://resonon.org/docs/explanation/patterns/06-randomness-and-seeding/#unseeded-choices-are-a-performance-decision Previous: explanation/patterns/06-randomness-and-seeding#pattern-variation-belongs-to-musical-position --- Two Ways to Run a Piece [explanation] A piece is the code in one project, and there are two ways to run it. **Live**, a session keeps running and you evaluate the piece into it a fragment at a time, hearing each change as you make it. **As a file run**, `resonon run` opens the project without a window, as the editor opens it, evaluates a script in it, writes what it renders to disk, and exits. It is the same language and the same patterns in both, with a different relationship to time — the way one Csound orchestra plays to the speakers or renders to a file. Sections: - explanation/running/01-two-ways-to-run-a-piece#live | Live - explanation/running/01-two-ways-to-run-a-piece#file-run | File run - explanation/running/01-two-ways-to-run-a-piece#what-differs | What differs - explanation/running/01-two-ways-to-run-a-piece#related | Related Page: explanation/running/01-two-ways-to-run-a-piece URL: https://resonon.org/docs/explanation/running/01-two-ways-to-run-a-piece/ --- Two Ways to Run a Piece > File run [explanation] `resonon run` works from any directory inside the project. It opens the project as Open does: it restores the saved session, calls `fn setup()` and runs the top level of the entry file. Then it evaluates the script you name, in that session, and exits: ```bash resonon run scripts/bounce.non ``` The script can use the names that the top level of the entry file defines. There is no session to grow: the saved session, the entry file and the script are the program, so a render is reproducible from them. It writes files only where it asks to — audio where it calls `render()`, which runs the audio graph faster than real time, and MIDI where it calls `midi_export()`. In a project you also play live, put a render in a script. The top level of the entry file runs again on each Open and each Run File Live, so a render there runs each time too. A file run is how you bounce a piece: a finished mix or stems for a DAW or a collaborator, a render in a script, a check in CI. A render needs no audio device. The transport statements run in a file run as they do live, but the run ends after the last statement, and playback with it, so a file run is not a way to listen. Page: explanation/running/01-two-ways-to-run-a-piece URL: https://resonon.org/docs/explanation/running/01-two-ways-to-run-a-piece/#file-run Previous: explanation/running/01-two-ways-to-run-a-piece#live Next: explanation/running/01-two-ways-to-run-a-piece#what-differs --- Two Ways to Run a Piece > Live [explanation] A [server](/docs/explanation/running/03-sessions-and-servers/) holds a session, and you send it code from VSCode or the REPL. Playback runs in real time, you drive it with the [transport](/docs/reference/running/02-transport/), and [a new pattern lands on the next cycle](/docs/explanation/patterns/01-cycles-and-time/#quantized-swaps), so edits stay in time. The session remembers everything evaluated into it, so the piece grows by evaluation ([The Evaluation Model](/docs/explanation/running/02-the-evaluation-model/)). Opening the project runs its entry file (`src/main.non`): `fn setup()`, then the top level. Run Selection Live adds the selection to the session. Run File Live adds the whole entry file again, without `setup()`. Reset Project opens the project again from its files. [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle) says when each part runs. Live is how you hear a piece: performing, composing by ear, exploring, playing an arrangement through. Recording a take, clocking hardware and playing through outboard gear all happen here, because they happen in real time. Page: explanation/running/01-two-ways-to-run-a-piece URL: https://resonon.org/docs/explanation/running/01-two-ways-to-run-a-piece/#live Next: explanation/running/01-two-ways-to-run-a-piece#file-run --- Two Ways to Run a Piece > Related [explanation] - [The Evaluation Model](/docs/explanation/running/02-the-evaluation-model/) — what a live evaluation does - [File Runs](/docs/reference/running/03-file-runs/) — what `resonon run` opens, and its exit status - [Render a Project](/docs/how-to/running/02-render-a-project/) — `render()`, stems, and where files land Page: explanation/running/01-two-ways-to-run-a-piece URL: https://resonon.org/docs/explanation/running/01-two-ways-to-run-a-piece/#related Previous: explanation/running/01-two-ways-to-run-a-piece#what-differs --- Two Ways to Run a Piece > What differs [explanation] | | Live | File run | | --- | --- | --- | | **How you run it** | A server, with VSCode or the REPL | `resonon run [script]` | | **Session** | Lasts across evaluations | Runs once, then exits | | **Time** | Real time | Faster than real time, inside `render()` | | **Output** | Sound, on the audio interface and MIDI ports | WAV, PNG and MIDI files | | **Suits** | Performing, composing by ear, recording | Bouncing, scripts, CI | A render is made from the session's audio graph, so it leaves out what exists only in real time: MIDI tracks, tracks sent to hardware outputs, live inputs, and the round trip through outboard gear. [What a render contains](/docs/reference/audio/01-levels-and-files/#what-a-render-contains) lists it all. `render()` is not only for file runs. Evaluated in a live session, it bounces the session as it stands; live output pauses while it runs. Page: explanation/running/01-two-ways-to-run-a-piece URL: https://resonon.org/docs/explanation/running/01-two-ways-to-run-a-piece/#what-differs Previous: explanation/running/01-two-ways-to-run-a-piece#file-run Next: explanation/running/01-two-ways-to-run-a-piece#related --- The Evaluation Model [explanation] Live, you keep a **session** alive and grow it — evaluating a line here, a block there, each fragment landing in a runtime that remembers everything you've run so far. If you've used a DAW, the session is your project: you don't rebuild it each time you touch a fader, you adjust the thing that's already playing. This page is the mental model for how code becomes a living session. The other way to run a piece, a file run that renders it and exits, is in [Two Ways to Run a Piece](/docs/explanation/running/01-two-ways-to-run-a-piece/). Sections: - explanation/running/02-the-evaluation-model#the-session-remembers | The Session Remembers - explanation/running/02-the-evaluation-model#one-runtime-many-fragments | One Runtime, Many Fragments - explanation/running/02-the-evaluation-model#transport--reset | Transport & Reset - explanation/running/02-the-evaluation-model#related | Related Page: explanation/running/02-the-evaluation-model URL: https://resonon.org/docs/explanation/running/02-the-evaluation-model/ --- The Evaluation Model > One Runtime, Many Fragments [explanation] Whether you select lines in VSCode, type into the REPL or connect from several machines at once, every fragment goes to one long-lived runtime. Evaluating code live never starts a program; it *evaluates a fragment against the live session*. The editor is only a client — the session lives in a server process, which is why it survives a window reload ([Sessions & Servers](/docs/explanation/running/03-sessions-and-servers/)). Page: explanation/running/02-the-evaluation-model URL: https://resonon.org/docs/explanation/running/02-the-evaluation-model/#one-runtime-many-fragments Previous: explanation/running/02-the-evaluation-model#the-session-remembers Next: explanation/running/02-the-evaluation-model#transport--reset --- The Evaluation Model > Related [explanation] - [Sessions & Servers](/docs/explanation/running/03-sessions-and-servers/) — where the runtime lives - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — when your changes actually take effect - [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/) — the loop, hands-on Page: explanation/running/02-the-evaluation-model URL: https://resonon.org/docs/explanation/running/02-the-evaluation-model/#related Previous: explanation/running/02-the-evaluation-model#transport--reset --- The Evaluation Model > The Session Remembers [explanation] When a fragment finishes, nothing it made is torn down. A track it created stays loaded, stays playing and stays bound to its name, so the next fragment can simply talk to it — send it a new pattern, turn a parameter — without declaring anything again. That persistence, the runtime holding your variables, tracks, instruments and effects between evaluations, is the whole foundation of live coding in resonon. It is also why re-running a line is safe. A track, a device on a track and a pattern slot are each identified by name, so running the line that made them again addresses what is already there instead of stacking a copy — see [Descriptions & Slots](/docs/explanation/audio/02-descriptions-and-slots/). Names in the language work the same way: running a `let` again in a later evaluation rebinds the name, which is what lets you re-run a block you edited ([Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/)). Page: explanation/running/02-the-evaluation-model URL: https://resonon.org/docs/explanation/running/02-the-evaluation-model/#the-session-remembers Next: explanation/running/02-the-evaluation-model#one-runtime-many-fragments --- The Evaluation Model > Transport & Reset [explanation] The transport is session-wide: `PLAY`, `PAUSE` and `STOP` move one play head for every track, and none of them touches the session. `STOP` returns to the start and lets tails ring out, the way it does in a DAW; your tracks, instruments and variables are all still there, ready to play again. What each statement does exactly is in [Transport](/docs/reference/running/02-transport/). `RESET` is the heavy one. It clears the **entire session** — every variable, track, instrument, and effect — and tears down the scheduler, leaving you a blank runtime. It's the live-coding equivalent of closing the project and opening an empty one: the right move when a session has drifted somewhere you can't easily edit your way out of. Page: explanation/running/02-the-evaluation-model URL: https://resonon.org/docs/explanation/running/02-the-evaluation-model/#transport--reset Previous: explanation/running/02-the-evaluation-model#one-runtime-many-fragments Next: explanation/running/02-the-evaluation-model#related --- Sessions & Servers [explanation] When you live-code, the music is not in your editor. It is in a **server**: a resonon process that holds the session — every variable, track, instrument and pattern — and makes the sound. The editor is a client that sends it code. This page explains why it is built that way, and what follows. Sections: - explanation/running/03-sessions-and-servers#the-session-outlives-each-evaluation | The session outlives each evaluation - explanation/running/03-sessions-and-servers#several-clients-one-session | Several clients, one session - explanation/running/03-sessions-and-servers#a-session-runs-one-version-of-the-language | A session runs one version of the language - explanation/running/03-sessions-and-servers#typed-session-commands | Typed session commands - explanation/running/03-sessions-and-servers#related | Related Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/ --- Sessions & Servers > A session runs one version of the language [explanation] A project pins the version of resonon it is written in, in its `resonon.toml`. The language server follows that pin per project, so two projects on different versions can be open side by side, each checked in its own language. A live server can't: it runs one version, the one pinned by the project it was started from. Code from a project that needs a newer version is refused rather than run in the wrong language. The server is never restarted to fit, because restarting would stop what is playing — the editor offers the restart, and it is yours to take. Code written for an older version runs, with a warning the first time. Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/#a-session-runs-one-version-of-the-language Previous: explanation/running/03-sessions-and-servers#several-clients-one-session Next: explanation/running/03-sessions-and-servers#typed-session-commands --- Sessions & Servers > Related [explanation] - [Patterns, Tracks & Effects](/docs/tutorials/getting-started/03-patterns-tracks-effects/) — the loop, hands-on - [Run a Shared Server](/docs/how-to/running/01-run-a-shared-server/) — start, protect and join a server - [The Evaluation Model](/docs/explanation/running/02-the-evaluation-model/) — what one evaluation does - [Two Ways to Run a Piece](/docs/explanation/running/01-two-ways-to-run-a-piece/) — live, or a file run that renders Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/#related Previous: explanation/running/03-sessions-and-servers#typed-session-commands --- Sessions & Servers > Several clients, one session [explanation] A server has one session, and every client connected to it works in that session. A track one person defines is there for everyone else to send patterns to. There is one runtime and one transport, so two performers are playing the same piece, not two pieces at once. That one model covers several ways of working: performers sharing a set, a teacher and a room working in one session, or one person with two windows — rehearsed code in one, experiments in the other. Display names and the output filter exist because, in a shared session, output needs an author. A server binds to loopback by default, which limits direct network exposure. Local programs remain trusted. Explicit `--host` binding enables network access without authentication or encryption; see [Network](/docs/reference/running/06-network/#trust-and-access) for the trust limits. Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/#several-clients-one-session Previous: explanation/running/03-sessions-and-servers#the-session-outlives-each-evaluation Next: explanation/running/03-sessions-and-servers#a-session-runs-one-version-of-the-language --- Sessions & Servers > The session outlives each evaluation [explanation] Each evaluation runs against the same session, so what one evaluation defines is there for the next. That is what makes building a piece up line by line possible: you define a track once and then keep talking to it while the music plays. Keeping the session in its own process also means the editor can come and go. Reload the window, reconnect, or connect from a terminal view: the music keeps playing, because nothing that plays it lived in the editor. Most of the time you never see the server. The first evaluation in VSCode starts a local one if none is known, and the session starts empty. Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/#the-session-outlives-each-evaluation Next: explanation/running/03-sessions-and-servers#several-clients-one-session --- Sessions & Servers > Typed session commands [explanation] Clients can send a `command` message instead of generating source code. Each message has a UUID `id` and a typed `command`. For example: ```json {"type":"command","id":"00000000-0000-0000-0000-000000000001","command":{"kind":"set_parameter","track":"lead","slot":"filter","parameter":"Cutoff","value":1200}} ``` Track names and device slot names are the stable session addresses. Use `master` for the master bus and `instrument` for a track's instrument slot. Values use the same units as code: volume in decibels, pan from -1 to 1, send amount as linear gain, and parameters in their native range. Commands cover volume, pan, mute, solo, sends, parameters, play, stop, seek (in cycles), and plugin windows. They run on the interpreter thread in the same queue as code and call the same methods. The last write executed wins. Errors and completion messages carry the command's request ID. Subscribe to the `session` topic for the session document. Its first `state_snapshot` contains `snapshot` (the document uses linear gain for volume), `revision`, and `writers` (the last writer of each changed object path). Each following `state_update` contains the next revision, request ID, origin (`"code"` or a client UUID object), and `changes`. A change has a `path` array of literal object keys and a `value`; an absent `value` removes the key. Device arrays retain their numeric positions while slot order is unchanged; other array edits replace the array as a whole. Apply every revision in order. A connection that loses updates closes; reconnect and subscribe again for a fresh baseline. Meters and the playhead remain on their separate high-rate topics. A continuous edit starts with `begin_gesture` and ends with `end_gesture`, both carrying the same `gesture` UUID. One gesture can be active per connection. Its edits and boundaries carry that UUID in session updates; disconnect closes an active gesture. Clients should send at most 60 edits per second and always send the final value before ending. The server accepts up to 240 edits per second per connection and explicitly rejects excess edits, without coalescing or reordering accepted writes. Retry a rejected final value before sending the end boundary. The UI edits between two gesture boundaries are one undo step. Code evaluations do not create undo steps, including changes made before an error. Correct the code and run it again. `undo` and `redo` restore document state across all clients, including track and device creation or deletion. They do not rewind variables, functions, callbacks, source text, transport moves, saves or window layout. Callback writes do not create steps. `RESET` and the `open_project` command (Open and Reset Project) start a new history; history is not saved. The `run_file` command (Run File Live) does not create an undo step. See [The session and your code](/docs/explanation/running/05-session-document/). Page: explanation/running/03-sessions-and-servers URL: https://resonon.org/docs/explanation/running/03-sessions-and-servers/#typed-session-commands Previous: explanation/running/03-sessions-and-servers#a-session-runs-one-version-of-the-language Next: explanation/running/03-sessions-and-servers#related --- Transport and Session [explanation] The transport answers where the music is playing. The session holds the rig that can play it. Keeping those lifetimes separate lets you stop a piece, preserve its sound design, and start again without loading everything anew. Sections: - explanation/running/04-transport-and-session#one-play-head-for-the-piece | One play head for the piece - explanation/running/04-transport-and-session#stopping-notes-leaves-tails | Stopping notes leaves tails - explanation/running/04-transport-and-session#reset-discards-the-rig | Reset discards the rig Page: explanation/running/04-transport-and-session URL: https://resonon.org/docs/explanation/running/04-transport-and-session/ --- Transport and Session > One play head for the piece [explanation] Audio and MIDI tracks share the transport's cycle position. Pause holds that position; stop returns it to the start; seek chooses another cycle. Patterns describe events at that musical position, so seeking does not require playing every earlier note first. The audio device also has a frame counter used to date captured audio. Musical position can jump while that device clock advances. A recording and an arrangement need both coordinates to place a take correctly across seeks and restarts. Page: explanation/running/04-transport-and-session URL: https://resonon.org/docs/explanation/running/04-transport-and-session/#one-play-head-for-the-piece Next: explanation/running/04-transport-and-session#stopping-notes-leaves-tails --- Transport and Session > Reset discards the rig [explanation] Reset removes variables, tracks, instruments and effects and starts an empty session. It is a rebuilding boundary rather than another way to move the play head. Saving source and plugin state makes the rig reproducible after that boundary. Recording has its own ending too. `RECORD;` starts playback and armed recording; `STOP;` ends the take, while `PAUSE;` does not. Treat stopping a take and discarding a session as separate decisions. [Transport](/docs/reference/running/02-transport/) specifies each statement; [Perform Live](/docs/how-to/running/10-perform-live/) puts these choices into a set. Page: explanation/running/04-transport-and-session URL: https://resonon.org/docs/explanation/running/04-transport-and-session/#reset-discards-the-rig Previous: explanation/running/04-transport-and-session#stopping-notes-leaves-tails --- Transport and Session > Stopping notes leaves tails [explanation] Pause and stop release sounding notes, but a delay or reverb can still contain sound. Letting that tail finish preserves the musical ending. A stopped play head therefore does not imply an empty effect or absolute silence. Three stops in a row request panic: the sound is cut and instruments and effects are flushed, but the tracks and patterns remain loaded. Panic is recovery within the same rig. Page: explanation/running/04-transport-and-session URL: https://resonon.org/docs/explanation/running/04-transport-and-session/#stopping-notes-leaves-tails Previous: explanation/running/04-transport-and-session#one-play-head-for-the-piece Next: explanation/running/04-transport-and-session#reset-discards-the-rig --- The session and your code [explanation] The session document describes the state of a musical session. It records tracks, device chains, routing, mixer values and arrangement bindings. Code remains an editor of that state. The mixer and routing streams use this same document model. Saving writes the document into the project. Opening restores a session from it, then runs the project's entry file; see [The entry file's lifecycle](#the-entry-files-lifecycle) and [Save and open a session](/docs/how-to/running/12-save-and-open-a-session/). Sections: - explanation/running/05-session-document#what-belongs-to-the-project | What belongs to the project - explanation/running/05-session-document#what-stays-in-code | What stays in code - explanation/running/05-session-document#the-entry-files-lifecycle | The entry file's lifecycle - explanation/running/05-session-document#three-ways-to-run-code | Three ways to run code - explanation/running/05-session-document#why-opening-runs-code | Why opening runs code - explanation/running/05-session-document#undo-ui-edits | Undo UI edits - explanation/running/05-session-document#names-and-identity | Names and identity - explanation/running/05-session-document#text-files-and-plugin-state | Text files and plugin state - explanation/running/05-session-document#opening-a-document | Opening a document - explanation/running/05-session-document#restoring-live-state | Restoring live state Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/ --- The session and your code > Names and identity [explanation] A track's name identifies it across code, files and clients. An effect's slot name identifies it within that track's chain. The instrument has one address per track. A lane is identified by its named section or timeline, track and target; a layer adds its name to that address. A bound timeline held outside the top-level namespace is addressed by its track in `track_timelines`. None of these needs an unrelated generated ID. Recorded objects that have no code name can introduce their own stable IDs with their editing model. Numeric audio IDs only connect a live streaming snapshot to meter readings. They are separate metadata and can change between processes without changing the saved session. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#names-and-identity Previous: explanation/running/05-session-document#undo-ui-edits Next: explanation/running/05-session-document#text-files-and-plugin-state --- The session and your code > Opening a document [explanation] Opening rebuilds what the document can describe on its own: tracks, mixer, routing, tempo, built-in effects, samplers and plugins with their state. Built-in effects use their standard-library definition identity. Samplers restore their kit and sample references. What only code can define waits for it. A custom `dsp` device keeps its slot as a placeholder with its saved parameters, and a section or timeline stays in the document. When code places a device of the same identity in that slot, the new instance takes the saved values first. A plugin that is not installed keeps its slot and state the same way. Placeholders are presentation, not document state: the saved entry is written back unchanged. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#opening-a-document Previous: explanation/running/05-session-document#text-files-and-plugin-state Next: explanation/running/05-session-document#restoring-live-state --- The session and your code > Restoring live state [explanation] Session restoration changes only the values, connections and objects that differ from the target document. Unchanged devices keep their live instances and keep playing. When a removed object is retained in memory, restoration reuses that instance and its pattern bindings before attempting to rebuild a device from saved state. Retained objects are released on the control thread. Restoring live state preserves playback and the playhead position. Opening a project first resets the session, then restores its document and saved position, then runs the entry file. The project format does not store retained runtime objects. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#restoring-live-state Previous: explanation/running/05-session-document#opening-a-document --- The session and your code > Text files and plugin state [explanation] The format uses TOML. The project’s `session/` directory contains `session.toml` for transport, master, arrangement and the ordered track index. Each track has its own file in `tracks/`. Editing one track changes its file without changing the index. For a track named `drums`, the file is `tracks/drums.toml`. Names use reversible UTF-8 percent escaping for uppercase letters and punctuation. This avoids path separators and name collisions on case-insensitive filesystems. The original name remains the key in the track index. Maps use deterministic key order. Chains, mixer order, layers and entries retain musical or authoring order. Text encoding adds no timestamps or process IDs. Serializing a document, reading it and serializing it again produces identical text files. Unknown fields, duplicate identities, missing references and invalid numeric values are errors rather than silently discarded state. Opaque plugin state is raw binary in `state/`. A device's `state` field references its sidecar. Explicit session capture gathers those bytes; ordinary streaming updates never call plugin save functions. Unsupported CLAP state extensions leave the state reference absent. A supported plugin whose state capture fails reports an error. Capture validates that every sidecar is referenced exactly once. Sample and kit paths inside the project root are project-relative. External references retain absolute paths. Neither text encoding nor decoding copies media or executes code. Filesystem installation, restoration and missing-media handling belong to the save/open operation. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#text-files-and-plugin-state Previous: explanation/running/05-session-document#names-and-identity Next: explanation/running/05-session-document#opening-a-document --- The session and your code > The entry file's lifecycle [explanation] The entry file is `src/main.non`, or the file `entry` names in [`resonon.toml`](/docs/reference/setup/04-resonon-toml/#package). It has three parts, and each part runs at a different time: | Part | It runs on | Use it for | | --- | --- | --- | | `fn setup()` | Open and Reset Project, and when your code calls `setup();` | Tracks, with `session.create_track(name)`, and settings that need no variable, such as `set_bpm(120);` | | The top level | Open, Reset Project and each Run File Live | Imports, definitions, `session.track(name)`, instruments, effects and patterns | | `fn teardown()` | Reset Project, `RESET`, opening another project, and closing or quitting | What the engine cannot undo: hardware MIDI state, OSC, external files | `setup()` and `teardown()` are optional. Resonon calls them as it calls any other function, and gives them no other special treatment. `main()` has no special meaning: nothing calls it. An entry file that defines `main()` and does not call it gets the [`main_not_called`](/docs/reference/language/10-errors-and-warnings/) warning. Open and Reset Project do these steps in this order: 1. Call `teardown()` of the current session, if it defines one. Resonon reports a failing `teardown()`. The failure does not stop the reset. 2. Reset the session, as `RESET` does. 3. Restore the saved session document from `session/`, if the project has one. 4. Bind the function definitions and `use` imports of the entry file. 5. Call `setup()`, if the entry file defines it. 6. Run the rest of the top level, in order. The transport stays stopped. Nothing plays until you press Play or Space. The undo history starts again. The session owns every track: a track stays until it is deleted with `session.delete_track(name)`, also when no variable holds it. For example: ```resonon use "std/instruments" { Sampler, Kit }; // Set up the piece. It runs when the project opens and on Reset Project. // Create each track here, once: a name that exists is an error. fn setup() { set_bpm(120); session.create_track("drums"); } // The rest of the file runs after setup(), and again on each file run. // session.track() looks up a track that setup() created. let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("TR-909"))); drums << [bd _ bd _, _ sd _ sd, ch*8]; ``` `session.create_track(name)` makes a track, and a name that exists is an error: create each track once, in `setup()`. `session.track(name)` finds a track that exists, so the top level can run again on each file run. Explicit setters still write their values, so omit setters for settings you want to keep from the saved session. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#the-entry-files-lifecycle Previous: explanation/running/05-session-document#what-stays-in-code Next: explanation/running/05-session-document#three-ways-to-run-code --- The session and your code > Three ways to run code [explanation] | Action | What it runs | What it keeps | Undo | | --- | --- | --- | --- | | **Run Selection Live** | The selection, or the current line | The running session | No undo step | | **Run File Live** | The whole entry file, without `setup()` | The running session, the transport and the mixer | No undo step | | **Reset Project** | The open sequence above | Only what the project's files hold | A new history | Run Selection Live is **Command-Enter**. Run File Live is **Command-Shift-Enter**. It saves the edited files first. A changed pattern starts on the next cycle. Correct a wrong run in code and run it again; session undo does not undo code execution. Reset Project has no default key. Before it resets, it asks in two cases: - The session has changes since the last save, from UI edits or code. A reset loses those changes. - Tracks were renamed in the session after the code named them. Reset Project offers to update the old track names in the code. Saving the session marks it as saved. A save is not an undo step. The keys and commands in each editor are in [VSCode Extension](/docs/reference/running/01-vscode-extension/), [Neovim](/docs/reference/running/07-neovim/), [Edit code in the window](/docs/how-to/running/15-edit-code-in-the-window/) and [Command Line](/docs/reference/setup/01-cli/). Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#three-ways-to-run-code Previous: explanation/running/05-session-document#the-entry-files-lifecycle Next: explanation/running/05-session-document#why-opening-runs-code --- The session and your code > Undo UI edits [explanation] Code evaluations do not create session undo steps, including changes made before an evaluation fails. Correct the code and run it again. Every UI gesture is one step: a fader drag, a track deletion or a device move. **Command-Z** undoes the latest step; **Command-Shift-Z** redoes it, including while the code editor has focus. Use **Control-Z** and **Control-Shift-Z** for code text undo and redo. Single-line fields keep Command-Z for their own text. All connected clients share the session history. Undo restores document state: tracks, devices, routing, mixer settings and arrangement. Retained tracks and devices bring their runtime bindings back. Existing tracks keep the patterns most recently assigned by code. Newer code writes take precedence over older UI edits. Undo does not rewind source text, variables, functions, callbacks, generator state, transport playback or position, window layout, saved files or external effects. A variable can therefore still refer to an object that undo removed; look up the current named track before making another edit. Callback activity is not an undo step. `RESET`, Open and Reset Project clear history; saving does not store it. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#undo-ui-edits Previous: explanation/running/05-session-document#why-opening-runs-code Next: explanation/running/05-session-document#names-and-identity --- The session and your code > What belongs to the project [explanation] The document contains: - Track names, kinds, colours and order; outputs, sends, volume, pan, mute and solo. - Master volume, pan, output channels and effect chain. - Devices in chain order, identified by slot name, backend and device identity. CLAP IDs and VST3 class IDs identify plugins. Display names are labels. - Instrument identity, parameter target values, sampler kit and sample references. - Tempo, beats per cycle, time signature when representable, and transport position. - Named sections and timelines, their lengths, lane targets and layer order. Positions and durations use integer ticks: 46,126,080 ticks per cycle. Saving and reading a third of a cycle therefore preserves its position exactly. The current language derives meter from beats per cycle, using the same spelling as MIDI export. Some cycle lengths cannot be represented as a time signature; those omit the signature and retain their exact beats-per-cycle value. Meters, CPU readings, connected device names, numeric engine IDs and the play state are transient. They do not belong in the document. Opening a document must not start playback. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#what-belongs-to-the-project Next: explanation/running/05-session-document#what-stays-in-code --- The session and your code > What stays in code [explanation] Patterns can contain generators and closures. A document stores their lane bindings and spans, not their contents. Evaluating the corresponding code reattaches the pattern through the same named track and arrangement binding. A document alone cannot reconstruct a generative pattern or a custom DSP body. The session is the document. Code and the UI edit the same tracks, devices and arrangement. Creating a track in the Mixer does not require a matching declaration in the source. After saving, you can remove the code that created it. A chain statement explicitly replaces that chain; evaluating unrelated code leaves it alone. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#what-stays-in-code Previous: explanation/running/05-session-document#what-belongs-to-the-project Next: explanation/running/05-session-document#the-entry-files-lifecycle --- The session and your code > Why opening runs code [explanation] A project that opens without its code is not the piece. Its patterns are silent, and the names its top level defines are undefined, so a selection that uses them fails. The open sequence runs the code, so the opened project plays as its files describe it, when you press Play. A reset loses the changes since the last save. A key next to Command-Enter is too easy to press by mistake for that. So Command-Shift-Enter adds to the running session, and Reset Project is a menu command that asks first. Page: explanation/running/05-session-document URL: https://resonon.org/docs/explanation/running/05-session-document/#why-opening-runs-code Previous: explanation/running/05-session-document#three-ways-to-run-code Next: explanation/running/05-session-document#undo-ui-edits --- The Machine and the Piece [explanation] Where a setting lives follows from what kind of fact it is, and there are only three kinds: | What it is | Where it goes | Travels with the project? | | ---------- | ------------- | ------------------------- | | **A fact about this machine** — which audio interface, which MIDI ports, where your kits and plugins are | `~/.resonon/preferences.toml` | No — and it must not | | **A fact about this piece** — which packages it draws on, which kits came from outside it | `resonon.toml` in the project | Yes | | **An operational knob** — CI, headless rendering, benchmarks | A CLI flag, an environment variable, or a VSCode setting | n/a | That is the split every DAW makes between its Preferences and its project folder. Live has one Preferences dialog; so does resonon, and it is a file. The rule underneath it: **a setting anything outside the running session needs to know is data.** The editor, `resonon collect`, `resonon kits list` and the plugin scan all need to know where your content is, and none of them runs your code. A folder named by a function call only exists while something is running that call, so everything else was guessing. Sections: - explanation/setup/01-machine-and-piece#preferences-are-a-file | Preferences are a file - explanation/setup/01-machine-and-piece#what-belongs-in-the-piece-instead | What belongs in the piece instead - explanation/setup/01-machine-and-piece#what-is-a-call-not-a-setting | What is a call, not a setting - explanation/setup/01-machine-and-piece#related | Related Page: explanation/setup/01-machine-and-piece URL: https://resonon.org/docs/explanation/setup/01-machine-and-piece/ --- The Machine and the Piece > Preferences are a file [explanation] ``` ~/.resonon/preferences.toml ``` Read before any of your code runs, so the device comes up right the first time rather than coming up wrong and being reopened. Every key it takes is listed in [Preferences](/docs/reference/setup/02-preferences/). Your piece then holds channel numbers and kit names only, so it travels: ```resonon no-check // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("vocals"); } set_project_title("my_song"); set_bpm(120); session.master >> Output(0, 1); let vocals = session.track("vocals"); vocals.set_input(0); ``` Omit the file entirely and resonon uses the system default devices at their own sample rate and block size — a script that never mentions audio still makes sound and still records. `resonon setup` is the Preferences dialog, in the terminal. It exists so that an interface is chosen from what this machine has rather than typed from memory — but what it produces is the same file you could write by hand, with your comments and key order kept. Neither door is the real one; the file is. [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) shows both. Page: explanation/setup/01-machine-and-piece URL: https://resonon.org/docs/explanation/setup/01-machine-and-piece/#preferences-are-a-file Next: explanation/setup/01-machine-and-piece#what-belongs-in-the-piece-instead --- The Machine and the Piece > Related [explanation] - [How Preferences Are Applied](/docs/explanation/setup/02-how-preferences-are-applied/) — why a bad key or a missing device cannot take a session down - [Search Paths & Portability](/docs/explanation/setup/03-search-paths-and-portability/) — how content is found, and what travels with a project - [Startup & the Environment](/docs/explanation/setup/04-startup-and-the-environment/) — the operational knobs - [Preferences](/docs/reference/setup/02-preferences/) — every key in `preferences.toml` - [resonon.toml](/docs/reference/setup/04-resonon-toml/) — the project manifest - [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) — `resonon setup`, folders and `reload_preferences()` Page: explanation/setup/01-machine-and-piece URL: https://resonon.org/docs/explanation/setup/01-machine-and-piece/#related Previous: explanation/setup/01-machine-and-piece#what-is-a-call-not-a-setting --- The Machine and the Piece > What belongs in the piece instead [explanation] Device names are a fact about your machine: `"Focusrite Scarlett 2i2"` is true of one rig and meaningless on another. Channel numbers are a fact about your piece: `drums.set_input(2, 3)` means "the third and fourth inputs", and that survives moving to a different rig. So channel routing stays in the music: | Setting | Call | | ------- | ---- | | Master output channels | `session.master >> Output(0, 1)` | | Per-track output channels | `drums >> Output(2, 3)` | | Per-track input channels | `drums.set_input(2, 3)` | Page: explanation/setup/01-machine-and-piece URL: https://resonon.org/docs/explanation/setup/01-machine-and-piece/#what-belongs-in-the-piece-instead Previous: explanation/setup/01-machine-and-piece#preferences-are-a-file Next: explanation/setup/01-machine-and-piece#what-is-a-call-not-a-setting --- The Machine and the Piece > What is a call, not a setting [explanation] Three things, and they are the three things Live keeps as buttons rather than as fields: | Call | What it does | | ---- | ------------ | | `plugin_scan()` | Rescan the plugin folders now. | | `plugin_rescan(path)` | Re-open one bundle, whatever the database says. | | `reload_preferences()` | Put the file in force. | `resonon setup` is a gesture too, and the same one Live's Preferences dialog is: you open it, you change something, you close it. It writes the file; `reload_preferences()` is what puts a change in force in a session that is already playing. They are actions — things you *do* at a moment — rather than settings, which are things that are *true* until you change them. That is the whole test. Page: explanation/setup/01-machine-and-piece URL: https://resonon.org/docs/explanation/setup/01-machine-and-piece/#what-is-a-call-not-a-setting Previous: explanation/setup/01-machine-and-piece#what-belongs-in-the-piece-instead Next: explanation/setup/01-machine-and-piece#related --- How Preferences Are Applied [explanation] [Preferences](/docs/explanation/setup/01-machine-and-piece/) are a file, and a file can ask for things this machine cannot give. This page explains how resonon applies it so that a bad line cannot cost you a session — at startup, or while one is playing. Sections: - explanation/setup/02-how-preferences-are-applied#a-key-nobody-can-honour-costs-only-itself | A key nobody can honour costs only itself - explanation/setup/02-how-preferences-are-applied#a-device-you-named-is-a-device-you-get-or-none | A device you named is a device you get, or none - explanation/setup/02-how-preferences-are-applied#block-size-and-rate-are-reported-not-assumed | Block size and rate are reported, not assumed - explanation/setup/02-how-preferences-are-applied#midi-ports-are-entries-not-a-map | MIDI ports are entries, not a map - explanation/setup/02-how-preferences-are-applied#a-change-waits-to-be-applied | A change waits to be applied - explanation/setup/02-how-preferences-are-applied#related | Related Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/ --- How Preferences Are Applied > A change waits to be applied [explanation] Editing the file changes nothing on its own. Nothing watches it, deliberately: a stray editor save should not be able to reopen your audio device under a take. `reload_preferences()` is the gesture that applies it — the same act as clicking in Live's Preferences dialog, for a file that changed underneath you. Applying is built so that it cannot hurt a session that is playing: - **It applies only differences**, so calling it on an unchanged file costs nothing and makes no gap in the sound. - **A file that will not parse changes nothing.** The whole file is read before anything is touched, so it cannot half-apply. - **Past that, a key nobody can honour costs only itself.** A missing MIDI port does not cost you your buffer size. - **A take is left alone.** While one is recording, the `[audio]` section is not touched: the recording offset trims the head of the take, and a new rate would stitch two devices into one. It covers every setting in the file, the folder lists included, for the same reason: a search list that moved because a file was saved could move mid-take. Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#a-change-waits-to-be-applied Previous: explanation/setup/02-how-preferences-are-applied#midi-ports-are-entries-not-a-map Next: explanation/setup/02-how-preferences-are-applied#related --- How Preferences Are Applied > A device you named is a device you get, or none [explanation] The one key that is never traded for something else is the hardware. Name an interface that is not connected and resonon **waits for it**: nothing plays, the message says which device it is waiting for, and no other device is opened in its place. ``` Warning: /Users/you/.resonon/preferences.toml asks for audio this machine cannot give: `[audio] output` "Scarlett 2i2" — is not connected, so it is what this session is waiting for rather than something else to open in its place. Connect it and press play; this machine has: MacBook Pro Speakers Everything else in the file is applied. ``` Plug it in and press play: PLAY is what opens the device, so there is nothing to restart and nothing to edit. The same holds for an interface unplugged mid-session — playback stops, resonon says so, and play picks it up again when it is back. This is the one place resonon refuses to be helpful on your behalf. Silently moving a session onto the laptop speakers is how a monitored microphone ends up in a feedback loop, and a rig you pinned to its converters is a rig that should stay there. `[audio] input` follows the same rule in its own half: a microphone that is not connected leaves capture closed rather than opening the built-in one, and playback is untouched. Preferences are never rewritten for you. An interface you unplug keeps its name in the file, so plugging it back in is all it takes. Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#a-device-you-named-is-a-device-you-get-or-none Previous: explanation/setup/02-how-preferences-are-applied#a-key-nobody-can-honour-costs-only-itself Next: explanation/setup/02-how-preferences-are-applied#block-size-and-rate-are-reported-not-assumed --- How Preferences Are Applied > A key nobody can honour costs only itself [explanation] A rate this interface cannot run, a block size out of range, a folder that does not exist: each is named, dropped, and the rest of the file is applied. A rig with none of it right still comes up and runs. ``` Warning: /Users/you/.resonon/preferences.toml asks for audio this machine cannot give: `[audio] sample_rate` 192000 — the device does not run at that rate; it does 44100, 48000, 96000 Everything else in the file is applied. ``` Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#a-key-nobody-can-honour-costs-only-itself Next: explanation/setup/02-how-preferences-are-applied#a-device-you-named-is-a-device-you-get-or-none --- How Preferences Are Applied > Block size and rate are reported, not assumed [explanation] A backend is free to ignore a fixed block size — WASAPI in shared mode always does, CoreAudio may clamp — and a rig that believes it is running at 128 frames while the device hands it 512 is a rig whose owner is debugging the wrong thing. So resonon reports the size the device settled on. `sample_rate` is the whole session's, not the output's alone. Left unset, resonon picks a rate the devices you named for `input` and `output` can both run at — which is how a pair like AirPods, whose microphone only does 24 kHz, works without being configured. Set it and your rate stands: an input that cannot join is refused rather than allowed to move the session. Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#block-size-and-rate-are-reported-not-assumed Previous: explanation/setup/02-how-preferences-are-applied#a-device-you-named-is-a-device-you-get-or-none Next: explanation/setup/02-how-preferences-are-applied#midi-ports-are-entries-not-a-map --- How Preferences Are Applied > MIDI ports are entries, not a map [explanation] `[[midi.outputs]]` and `[[midi.inputs]]` are arrays of tables rather than an `alias = "port"` map, for two reasons: the order is meaningful, and `optional` is a fact about one entry rather than about the table — as is how an output's device is driven, its trims and whether it takes clock. An absent device keeps its alias, so a piece pointed at it stays valid and says what is missing. Nothing notices a device being plugged in or pulled out on its own yet — `reload_preferences()` is the gesture that looks again. Moving an alias to another port and reloading moves it there even when the new one is not plugged in: the file wins, and the missing device is reported as missing rather than the old one being kept. A port declared here and not plugged in stays on `resonon setup`'s list and stays selected: unplugging a synth is not a decision to stop using it. Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#midi-ports-are-entries-not-a-map Previous: explanation/setup/02-how-preferences-are-applied#block-size-and-rate-are-reported-not-assumed Next: explanation/setup/02-how-preferences-are-applied#a-change-waits-to-be-applied --- How Preferences Are Applied > Related [explanation] - [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/) — what belongs in preferences at all - [Preferences](/docs/reference/setup/02-preferences/) — every key in `preferences.toml` - [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) — `resonon setup`, folders and `reload_preferences()` - [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/) — when the device does not come up Page: explanation/setup/02-how-preferences-are-applied URL: https://resonon.org/docs/explanation/setup/02-how-preferences-are-applied/#related Previous: explanation/setup/02-how-preferences-are-applied#a-change-waits-to-be-applied --- Search Paths & Portability [explanation] A piece reaches for content — kits, modules, samples, plugins — and the same source should sound the same on every machine it is opened on. This page explains how resonon finds that content so that this machine's folders can help a piece without being able to change it. Sections: - explanation/setup/03-search-paths-and-portability#folders-are-a-list-you-can-take-things-out-of | Folders are a list you can take things out of - explanation/setup/03-search-paths-and-portability#search-paths-add-they-never-replace | Search paths add, they never replace - explanation/setup/03-search-paths-and-portability#modules-are-never-found-on-this-machine | Modules are never found on this machine - explanation/setup/03-search-paths-and-portability#a-sample-is-a-path-a-kit-is-a-name | A sample is a path, a kit is a name - explanation/setup/03-search-paths-and-portability#what-travels-with-a-project | What travels with a project - explanation/setup/03-search-paths-and-portability#related | Related Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/ --- Search Paths & Portability > A sample is a path, a kit is a name [explanation] **Sample files are not searched for at all.** `Sample("kick.wav")` is a path, not a name: it resolves relative to the `.non` file that names it — the way `use` and `load_file` do — and an absolute path is taken as given. There is no list, so a sample either sits where your piece says it sits or it does not exist, and no folder anyone adds can change which file a piece plays. A kit is the other kind of thing: `Kit("808")` is a name, and a name is what gets looked up in the search order. To reach one hit out of a kit, go through the kit rather than through a path that happens to land inside one: ```resonon no-check Sampler(Kit("CR-78")).sample("bd") ``` `"bd"` is the name the kit gives that sound, not the name of a file inside it — which is the point: the kit decides what its sounds are called, so a piece written against it keeps working when the kit's files are renamed or replaced. A kit found through a `[folders] kits` entry is still outside the project, and still says so: naming the folder makes the kit load, it does not make the piece portable. `resonon collect` is what brings one in. Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#a-sample-is-a-path-a-kit-is-a-name Previous: explanation/setup/03-search-paths-and-portability#modules-are-never-found-on-this-machine Next: explanation/setup/03-search-paths-and-portability#what-travels-with-a-project --- Search Paths & Portability > Folders are a list you can take things out of [explanation] `resonon setup` has a page for each folder list, and `resonon config kits` / `plugins` edit them without opening the file. The list is the truth, so taking an entry out takes it out of the search — something a list that only ever grew could never say. **Only `~` is expanded.** A stored path read by the CLI, by the language server and by a CI shell would name a different folder in each if it could name an environment variable or be relative, which is the whole problem preferences exist to fix. `$NAME` still works in `export()` and `plugin_rescan()`, which are gestures inside one running process. Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#folders-are-a-list-you-can-take-things-out-of Next: explanation/setup/03-search-paths-and-portability#search-paths-add-they-never-replace --- Search Paths & Portability > Modules are never found on this machine [explanation] **There is no machine-wide module path, and no setting that adds one.** A module is reachable because this project's `resonon.toml` declares the package it lives in and `resonon install` put it in `dependencies/`, or because a `use` names it by a relative path — never because of anything on this machine. A piece depends on nothing it has not recorded, so the same source resolves the same way everywhere. [Modules](/docs/reference/language/09-modules/#resolving-a-use-path) lists how a `use` path resolves. Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#modules-are-never-found-on-this-machine Previous: explanation/setup/03-search-paths-and-portability#search-paths-add-they-never-replace Next: explanation/setup/03-search-paths-and-portability#a-sample-is-a-path-a-kit-is-a-name --- Search Paths & Portability > Related [explanation] - [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/) — the `~/.resonon` layout and the search order - [resonon.toml](/docs/reference/setup/04-resonon-toml/) — `[dependencies]` and `[local]` - [Modules](/docs/reference/language/09-modules/) — how a `use` resolves - [Share a Project](/docs/how-to/setup/05-share-a-project/) — making a project travel - [The Plugin Database](/docs/explanation/audio/06-the-plugin-database/) — how plugin folders are swept Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#related Previous: explanation/setup/03-search-paths-and-portability#what-travels-with-a-project --- Search Paths & Portability > Search paths add, they never replace [explanation] A folder you name is searched **in addition to** the built-in ones. Naming a kit folder of your own never takes the standard ones away, so adding one cannot make the bundled kits disappear. The order — the project, then this machine's folders, then the resonon home — is listed in [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/#search-order). The project comes first so that a project defines itself: a folder your rig happens to have cannot change what somebody else's project resolves, and the same source sounds the same on every machine. Your own folders still shadow the installed ones, which is where shadowing is useful. This is also why a folder list is safely data. It is additive, and ranked below the project's own content, so it cannot change how a portable piece sounds — only whether a piece that was already reaching outside itself finds what it was reaching for. `resonon config paths` prints the resolved list, and the editor resolves modules through the same one, so a `use` that works when you run a file also hovers, jumps and completes. Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#search-paths-add-they-never-replace Previous: explanation/setup/03-search-paths-and-portability#folders-are-a-list-you-can-take-things-out-of Next: explanation/setup/03-search-paths-and-portability#modules-are-never-found-on-this-machine --- Search Paths & Portability > What travels with a project [explanation] A project's code always travels. The sounds it reaches for travel only if they come from somewhere that exists on the other machine too: | Where the kit lives | Travels? | Why | | --- | --- | --- | | `/kits/` | Yes | It is inside the project. | | A package in `/dependencies/` | Yes | `resonon.toml` names it, and `resonon install` fetches it again. | | The kits that ship with resonon | Yes | They are wherever this version of resonon is installed. | | `~/.resonon/kits/`, or a `[folders] kits` entry | No | They are on this machine only. | A kit travels as a unit because nothing in it points outside it: every path a `kit.toml` names is relative and stays under the kit's `samples/`. That is what lets a kit be copied into a project, by hand or with `resonon collect`, and still play. A kit that pointed at `/Users/you/samples/kick.wav` would work on your machine and silently fall apart on anyone else's, so resonon refuses to load one. The last row is the trap Ableton's *Collect All and Save* exists for: a user library is a good place to keep sounds and a bad thing to depend on silently. So resonon says so, once per kit, and offers two answers — bring the kit into the project with `resonon collect`, or record under `[local]` that the project needs it from outside. `[local]` is the counterpart of `[dependencies]`: the things a project draws on that have **no upstream**. That is why an entry never gains a `source`. The moment a kit has somewhere to be fetched from, it is a package and belongs in `[dependencies]`, with a lock file and an installer — so there is no second package system hiding in `[local]`. And the entry says where a kit came from, not where it is now, which is why collecting a kit satisfies its entry rather than removing it. Nothing ever removes an entry for you. A `Kit(…)` name can be computed, and a live-coded piece runs whatever you evaluate next, so no reading of the source and no record of one session can prove a kit is no longer used. Page: explanation/setup/03-search-paths-and-portability URL: https://resonon.org/docs/explanation/setup/03-search-paths-and-portability/#what-travels-with-a-project Previous: explanation/setup/03-search-paths-and-portability#a-sample-is-a-path-a-kit-is-a-name Next: explanation/setup/03-search-paths-and-portability#related --- Startup & the Environment [explanation] Some things are not settings about your music at all. They exist for continuous integration, headless rendering — a [file run](/docs/reference/running/03-file-runs/) that renders needs no audio device and opens no window — and benchmarking. They are resolved once at startup before any audio engine exists, and so they are flags and environment variables rather than data. Every knob, its flag and VSCode setting, and the rules they share are listed in [Environment Variables](/docs/reference/setup/01-cli/#environment-variables). Sections: - explanation/setup/04-startup-and-the-environment#a-value-resonon-cannot-read-stops-it-starting | A value resonon cannot read stops it starting - explanation/setup/04-startup-and-the-environment#a-location-is-ignored-rather-than-fatal | A location is ignored rather than fatal - explanation/setup/04-startup-and-the-environment#locations-are-settled-once | Locations are settled once - explanation/setup/04-startup-and-the-environment#startup-checks-before-it-claims-anything | Startup checks before it claims anything - explanation/setup/04-startup-and-the-environment#related | Related Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/ --- Startup & the Environment > A location is ignored rather than fatal [explanation] `RESONON_HOME` and `RESONON_STDLIB_PATH` are the exception to that rule, because they name a **location** rather than a value. A location has a safe default to fall back to, and the very command you would run to find out what went wrong prints it — so an unusable one is **ignored, the default stands, and the startup says so**, rather than leaving you unable to start at all over a stale line in a shell profile. An env typo must not be able to cost you a set. **Both must be absolute**, and that is the load-bearing half: everything below the home hangs off it and the whole standard library hangs off the other, so a relative value would be a different library for every directory you happened to start in — the terminal in `~/songs`, the editor's language server at your workspace root, a render launched from the Finder. Past that they differ, and the difference is between a folder resonon **makes** and one it only **reads** — the same split Live draws between its Library and a Place. A home that is not there yet is how a second rig is set up; a standard library that is not there is not a standard library. Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/#a-location-is-ignored-rather-than-fatal Previous: explanation/setup/04-startup-and-the-environment#a-value-resonon-cannot-read-stops-it-starting Next: explanation/setup/04-startup-and-the-environment#locations-are-settled-once --- Startup & the Environment > A value resonon cannot read stops it starting [explanation] There is no fallback here that would not be a lie: a benchmark that quietly ran serial because of a typo is worse than one that refused to run at all. It is the same answer the flag spelling already gave — `--multicore=ture` has always been a usage error — and the environment spelling is not the more forgiving of the two. Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/#a-value-resonon-cannot-read-stops-it-starting Next: explanation/setup/04-startup-and-the-environment#a-location-is-ignored-rather-than-fatal --- Startup & the Environment > Locations are settled once [explanation] Both are settled **once, when the process starts**, and the answer is kept for as long as it runs — so the home cannot move under a running session because something appeared or went away on disk. It is the same trade Live makes: it works out where its Library is at launch, gives you the default when it cannot use the one it was told about, and does not run a set on a Library it already knows it cannot write to. Either way, `resonon config paths` prints the directory that was actually taken — and tags the standard library line with `RESONON_STDLIB_PATH` only when the variable was applied, so it cannot claim an override that was refused. Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/#locations-are-settled-once Previous: explanation/setup/04-startup-and-the-environment#a-location-is-ignored-rather-than-fatal Next: explanation/setup/04-startup-and-the-environment#startup-checks-before-it-claims-anything --- Startup & the Environment > Related [explanation] - [Environment Variables](/docs/reference/setup/01-cli/#environment-variables) — every knob and its flag - [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/) — the `~/.resonon` layout - [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/) — where the other kinds of setting live Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/#related Previous: explanation/setup/04-startup-and-the-environment#startup-checks-before-it-claims-anything --- Startup & the Environment > Startup checks before it claims anything [explanation] Startup reads `~/.resonon/preferences.toml` before the command branches, so `resonon config paths` and the plugin scan see the same folders a session does, and `resonon setup` edits the file that was just read without opening an audio device of its own. It resolves the project before the audio device, so a piece that belongs to no project — or one written for a newer resonon — says so without first claiming an interface and putting a window on screen. The steps are listed under [Startup Sequence](/docs/reference/setup/01-cli/#startup-sequence). Page: explanation/setup/04-startup-and-the-environment URL: https://resonon.org/docs/explanation/setup/04-startup-and-the-environment/#startup-checks-before-it-claims-anything Previous: explanation/setup/04-startup-and-the-environment#locations-are-settled-once Next: explanation/setup/04-startup-and-the-environment#related --- Projects Packages and Pinning [explanation] A piece needs more than a source file: it needs the library code and language version that give that source its meaning. A project records those choices so opening the piece on another machine can reproduce them. Sections: - explanation/setup/05-projects-packages-and-pinning#the-project-is-the-unit-that-travels | The project is the unit that travels - explanation/setup/05-projects-packages-and-pinning#the-manifest-and-lock-file-answer-different-questions | The manifest and lock file answer different questions - explanation/setup/05-projects-packages-and-pinning#the-runtime-version-is-part-of-the-piece | The runtime version is part of the piece Page: explanation/setup/05-projects-packages-and-pinning URL: https://resonon.org/docs/explanation/setup/05-projects-packages-and-pinning/ --- Projects Packages and Pinning > The manifest and lock file answer different questions [explanation] The manifest declares the dependencies you chose, including a tag when you want to pin one. The lock file records the exact commits installed. An untagged dependency's upstream can move while the locked commit stays fixed, so another installation can reproduce the chosen code instead of silently taking today's upstream. Updating is an explicit decision to fetch again and record the result. Keeping `resonon.lock` with the source makes that decision travel with the piece. The installed dependency is still checked against the lock when imported; a mismatch is reported so local changes do not masquerade as the locked version. Page: explanation/setup/05-projects-packages-and-pinning URL: https://resonon.org/docs/explanation/setup/05-projects-packages-and-pinning/#the-manifest-and-lock-file-answer-different-questions Previous: explanation/setup/05-projects-packages-and-pinning#the-project-is-the-unit-that-travels Next: explanation/setup/05-projects-packages-and-pinning#the-runtime-version-is-part-of-the-piece --- Projects Packages and Pinning > The project is the unit that travels [explanation] `resonon.toml` marks the project root. Source lives under `src/`, collected kits under `kits/`, and installed packages under `dependencies/`. Resolving from the project means a shell's working directory or a machine-wide library cannot silently substitute a different module. A package is reusable project content with `src/lib.non` as its entry point. A piece imports the package's exported definitions; its manifest records where to fetch the package. Content with no upstream to fetch, such as a kit from a personal library, belongs in `[local]` and may need to be collected into the project before sharing. Page: explanation/setup/05-projects-packages-and-pinning URL: https://resonon.org/docs/explanation/setup/05-projects-packages-and-pinning/#the-project-is-the-unit-that-travels Next: explanation/setup/05-projects-packages-and-pinning#the-manifest-and-lock-file-answer-different-questions --- Projects Packages and Pinning > The runtime version is part of the piece [explanation] The `resonon` pin selects a major and minor language version; patches within it are interchangeable. The launcher chooses an installed runtime for that pin. It does not download one implicitly. The editor's language server also follows the project version, while a live server runs the version it started with. A project requiring a newer minor than the running server is refused because its source may need syntax or behavior that server lacks. An older project can run on a newer server with a warning, so the change in runtime is visible. Upgrading the manifest is a decision to try the piece under the newer version, not evidence that it has already been checked there. An unknown manifest key is reported without discarding the valid settings. A typo should be visible without taking down an otherwise usable project; malformed TOML, which cannot be read, stops the command before it proceeds. [resonon.toml](/docs/reference/setup/04-resonon-toml/) and [resonon.lock](/docs/reference/setup/07-resonon-lock/) specify the fields. For the actions, see [Install a Package](/docs/how-to/setup/03-install-a-package/) and [Share a Project](/docs/how-to/setup/05-share-a-project/). Page: explanation/setup/05-projects-packages-and-pinning URL: https://resonon.org/docs/explanation/setup/05-projects-packages-and-pinning/#the-runtime-version-is-part-of-the-piece Previous: explanation/setup/05-projects-packages-and-pinning#the-manifest-and-lock-file-answer-different-questions --- The Visual Graph [explanation] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: A visual in resonon is a node in a graph, whether it is a shader you wrote or a ready-made operator like `gfx.Blur`. Nodes are wired with the same two operators that route audio, and the graph is turned into a sequence of GPU passes every time it changes. This page explains the rules of that graph and why they are shaped the way they are. Sections: - explanation/visuals/01-the-visual-graph#a-name-is-an-operator | A name is an operator - explanation/visuals/01-the-visual-graph#two-wiring-rules | Two wiring rules - explanation/visuals/01-the-visual-graph#a-shared-node-renders-once | A shared node renders once - explanation/visuals/01-the-visual-graph#feedback-reads-the-previous-frame | Feedback reads the previous frame - explanation/visuals/01-the-visual-graph#the-graph-changes-as-a-whole | The graph changes as a whole - explanation/visuals/01-the-visual-graph#related | Related Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/ --- The Visual Graph > A name is an operator [explanation] Every visual is made with a name: `gfx.Blur("soft")`, `gfx.load_shader("plasma", "shaders/plasma.glsl")`. The name is its identity for the whole session. The first time a name is used, the operator is built; after that, the same name hands back the same operator. This is what makes a visual editable while it plays. Load an edited `plasma.glsl` again and the operator already on screen takes the new source — its wiring and its bound uniforms stay, because nothing about *which* operator it is has changed. It is the same idea as a track: running `session.track("drums")` again gives you the drums, not a second drum track. Two consequences follow: - A name outlives the variable holding it. Rebind `soft` to something else, and `gfx.Blur("soft")` still has its size when you come back to it. Only a Reset forgets names. - Using a name for a different kind of operator — `gfx.Edge("soft")` after `gfx.Blur("soft")` — replaces it. The new operator starts with no inputs and no bindings, and whatever read from the old one reads from the new one. A helper that builds nodes with fixed names would hand every caller the same nodes, so a helper takes the names as arguments. Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#a-name-is-an-operator Next: explanation/visuals/01-the-visual-graph#two-wiring-rules --- The Visual Graph > A shared node renders once [explanation] A node used by several consumers is one node, not several copies: the graph is de-duplicated by identity. When a `field` feeds two blurs, the noise is drawn once per frame and both blurs sample that one result. Fan-out costs nothing beyond the consumers themselves. Within a frame the graph is acyclic: every edge points from a node drawn earlier to one drawn later. That is what lets the whole graph be drawn in one ordered pass list. Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#a-shared-node-renders-once Previous: explanation/visuals/01-the-visual-graph#two-wiring-rules Next: explanation/visuals/01-the-visual-graph#feedback-reads-the-previous-frame --- The Visual Graph > Feedback reads the previous frame [explanation] A graph that fed its own output back in would be a cycle, and a cycle has no drawing order. Feedback breaks the cycle in time instead: `gfx.feedback(seed, fn(prev) { … })` gives the graph inside it `prev`, the output of the *previous* frame. A trail has no previous frame on its first frame, so `prev` is the seed's frame then. This is TouchDesigner's Feedback TOP: the seed is its input, and the node the closure returns is its Target TOP. The seed is drawn in the current frame like any other node, so it must not depend on the loop it seeds. The renderer keeps two buffers for the node the closure returns: it draws into one while `prev` reads the other, then swaps them. That swap is the only thing feedback adds — everything inside the closure is an ordinary acyclic graph. `gfx.feedback` has no name of its own, because `prev` is not an operator: the buffer pair belongs to the named node the closure returns. Because the buffers belong to a name, a trail survives your edits. Editing that operator's shader, rewiring it, or inserting an operator upstream keeps the trail flowing. It also carries across a section cut when the next section draws the same name. When a section's screen lane stops drawing the operator — over a gap, or in a section without it — the trail holds still and goes on from there when the operator is drawn again, as an uncooked TouchDesigner TOP keeps its image. It starts over from the seed when the name becomes another kind of operator, when the operator is no longer routed to `screen` at all, when the render size or `screen.quality` changes, when the visuals window closes, and on a Reset. To start a trail over on purpose, call `reset()` on that operator: on the next frame `look.reset()` makes `prev` the seed's frame, like the Reset pulse on a TouchDesigner Feedback TOP. Nothing else in the graph changes and nothing recompiles, and the trail builds again from the seed. Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#feedback-reads-the-previous-frame Previous: explanation/visuals/01-the-visual-graph#a-shared-node-renders-once Next: explanation/visuals/01-the-visual-graph#the-graph-changes-as-a-whole --- The Visual Graph > Related [explanation] - [Build an Operator Graph](/docs/how-to/visuals/03-build-an-operator-graph/) — the graph in practice - [Visuals & the Audio Engine](/docs/explanation/visuals/02-visuals-and-the-audio-engine/) — how the pictures keep time with the music - [`std/visuals`](/docs/reference/stdlib/visuals/) — every operator Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#related Previous: explanation/visuals/01-the-visual-graph#the-graph-changes-as-a-whole --- The Visual Graph > The graph changes as a whole [explanation] Every edit to a visual that reaches `screen` — a bind, a new edge, a rewire — takes effect when the block you ran finishes. Only the block's end state is drawn or checked, so a block may pass through a half-wired graph on its way to a complete one. An edit that would break the graph — a cycle outside `gfx.feedback`, say — keeps the last good picture on screen. The error is shown on the block that caused it and stays until a later block fixes the graph. Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#the-graph-changes-as-a-whole Previous: explanation/visuals/01-the-visual-graph#feedback-reads-the-previous-frame Next: explanation/visuals/01-the-visual-graph#related --- The Visual Graph > Two wiring rules [explanation] **`>>` fills the main input.** `a >> b` feeds `a` into `b`'s primary input — the sampler `iChannel0` — and evaluates to `b`. So `a >> b >> c` reads left to right, a chain is itself a value, and `>> screen` at the end puts the result on the display. `>>` never changes `a`: the upstream node can be wired into any number of other places. **`<<` binds anything else, by name.** What it binds depends on the value on its right: - a node becomes a texture input — the second input of `Composite`, the displacement field of `Displace`; - a number, a signal, a meter feed or a short array becomes a uniform. These are the same two operators as in the audio graph — `>>` routes, `<<` sets — and they mean the same there: a track `>>` a bus, a parameter `<<` a signal. Page: explanation/visuals/01-the-visual-graph URL: https://resonon.org/docs/explanation/visuals/01-the-visual-graph/#two-wiring-rules Previous: explanation/visuals/01-the-visual-graph#a-name-is-an-operator Next: explanation/visuals/01-the-visual-graph#a-shared-node-renders-once --- Visuals & the Audio Engine [explanation] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: Visuals are driven by the same session as the music, but they never run on the audio thread. The audio has a deadline every few milliseconds; a frame has sixteen. Everything on this page follows from keeping those two apart while keeping them in time. Sections: - explanation/visuals/02-visuals-and-the-audio-engine#time-comes-from-the-playhead | Time comes from the playhead - explanation/visuals/02-visuals-and-the-audio-engine#bound-values-are-sampled-once-per-frame | Bound values are sampled once per frame - explanation/visuals/02-visuals-and-the-audio-engine#an-analyzer-runs-only-while-it-is-used | An analyzer runs only while it is used - explanation/visuals/02-visuals-and-the-audio-engine#a-shader-error-cant-stop-the-music | A shader error can't stop the music - explanation/visuals/02-visuals-and-the-audio-engine#related | Related Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/ --- Visuals & the Audio Engine > A shader error can't stop the music [explanation] A shader is compiled by the renderer, away from the audio. When it fails to compile, the audio plays on and the last shader that compiled keeps drawing. With a visuals window open, the GLSL error is sent back to the editor as a diagnostic, and it clears when the corrected shader compiles. With no window open nothing is drawn live, so nothing is compiled and no error is reported until one opens — or until `render(screen)` or `screen.snap()` draws the picture to a file. The diagnostic is placed where you can fix it. A shader loaded from a `.glsl` file is marked in that file, on the line you wrote — the changes the engine makes to reach the GPU never shift it. A shader built from a string has no file of its own, so its error is marked on the `>> screen` line, with the line number inside the string in the message. Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/#a-shader-error-cant-stop-the-music Previous: explanation/visuals/02-visuals-and-the-audio-engine#an-analyzer-runs-only-while-it-is-used Next: explanation/visuals/02-visuals-and-the-audio-engine#related --- Visuals & the Audio Engine > An analyzer runs only while it is used [explanation] A spectrum needs an FFT of the channel, and an FFT is real work. So an analyzer runs on a channel only while that channel's `.fft`, or a band of it, is bound to a visual that reaches the screen. A channel no visual looks at costs nothing. One channel has one analyzer, however it is read. Binding `session.master.fft` and `session.master.fft.smooth(120)` to two uniforms still runs one FFT; each different smoothing is its own texture, computed from that one analysis. `.band` reads the analysis before any smoothing, which is why a band is smoothed after it is taken. Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/#an-analyzer-runs-only-while-it-is-used Previous: explanation/visuals/02-visuals-and-the-audio-engine#bound-values-are-sampled-once-per-frame Next: explanation/visuals/02-visuals-and-the-audio-engine#a-shader-error-cant-stop-the-music --- Visuals & the Audio Engine > Bound values are sampled once per frame [explanation] A uniform bound to a signal or a meter feed is read once for each frame the renderer draws, outside the audio thread. The audio engine does not know how many visuals read it, or how often. Binding a signal to a shader costs the audio nothing. The feeds a shader reads are levels, and levels are spiky: a peak that lasts a few milliseconds jumps from one frame to the next. That is why the feeds have `.smooth`, applied on the visuals' side of the fence — the same attack-and-release idea as a meter's ballistics. Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/#bound-values-are-sampled-once-per-frame Previous: explanation/visuals/02-visuals-and-the-audio-engine#time-comes-from-the-playhead Next: explanation/visuals/02-visuals-and-the-audio-engine#an-analyzer-runs-only-while-it-is-used --- Visuals & the Audio Engine > Related [explanation] - [The Visual Graph](/docs/explanation/visuals/01-the-visual-graph/) — names, wiring and feedback - [Bind Audio to a Shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/) — the feeds in practice - [Signals & Time](/docs/explanation/audio/03-signals-and-time/) — the transport that drives both Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/#related Previous: explanation/visuals/02-visuals-and-the-audio-engine#a-shader-error-cant-stop-the-music --- Visuals & the Audio Engine > Time comes from the playhead [explanation] The built-in uniforms `iTime`, `iCycle` and `iBeat` are the playhead's position, the same one the notes play from — not the GPU's clock, and not wall time. `iTime` is the position in seconds, `iCycle` in cycles and `iBeat` in beats. A shader therefore moves in step with the audio it is shown with. They do what the transport does: a pause holds them, a seek moves them, a stop rewinds them to 0. A tempo change bends `iCycle` and `iBeat` rather than making them jump. A signal bound to a uniform is read at the same position, and so is the span a sequenced screen lane shows. Page: explanation/visuals/02-visuals-and-the-audio-engine URL: https://resonon.org/docs/explanation/visuals/02-visuals-and-the-audio-engine/#time-comes-from-the-playhead Next: explanation/visuals/02-visuals-and-the-audio-engine#bound-values-are-sampled-once-per-frame --- feedback [function] fn feedback(seed: Visual, build: Function) -> Visual Builds a feedback group: TouchDesigner's Feedback TOP, with the group output as its Target TOP. The closure is called with `prev` and returns the group output. `prev` is the output's previous frame, except on the output's first frame and on the frame after a `reset()`, when it is the seed's current frame. Wire `prev` into a slot (e.g. `d.parameter("by") << prev`) to close the loop; the renderer realizes it as a ping-pong buffer. Route the result with `>> screen`. Parameters: seed: Visual — what `prev` is until the output has a frame of its own build: Function — `fn(prev) { ... }`, returning the group's output Visual Returns: Visual — the group output, routable with `>>` and reusable for fan-out Examples: `feedback(Noise("seed"), fn(prev) { let d = Displace("warp"); d.parameter("by") << prev; return Noise("field") >> d; })` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#feedback --- filter [function] fn filter(array: Array, func: Function) -> Array Selects elements from an array that satisfy a predicate. Parameters: array: Array — the array to filter func: Function — returns truthy/falsy for each element Returns: Array — a new array of matching elements Examples: `filter([1, 2, 3, 4], fn(x) { x > 2; })` returns `[3, 4]` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#filter-1 --- fold [function] fn fold(array: Array, initial: Any, func: Function) -> Any Reduces an array to a single value using an accumulator function. Parameters: array: Array — the array to reduce initial: Any — starting value for the accumulator func: Function — takes (accumulator, element), returns new accumulator Returns: Any — the final accumulated value Examples: `fold([1, 2, 3], 0, fn(acc, x) { acc + x; })` returns `6` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#fold --- format [function] fn format(value: Any) -> String Returns canonical source text for a value. Beat times use exact fractions when a short decimal cannot represent them. Unsupported values report `format(): has no source form`. Parameters: value: Any — value to write as source Returns: String — source text ```resonon assert format(note(C4, 1/3, 1)) == "note(C4, 1/3, 1)"; ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#format-2 --- hostname [function] fn hostname() -> String Returns this machine's hostname. Intended for per-machine branching in a piece — one file can clock the studio rig on the studio machine and something else everywhere else. Returns: String — the hostname Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#hostname --- Play Samples [guide] `Sampler` plays a kit as a drum machine: each name in a pattern triggers its own one-shot sample. `SamplerMelodic` plays one sample across the keyboard. Both, and `Kit`, are in `std/instruments`. Every method is listed in the [instruments reference](/docs/reference/stdlib/instruments/). Sections: - how-to/audio/01-play-samples#play-a-drum-kit | Play a drum kit - how-to/audio/01-play-samples#see-what-a-kit-contains | See what a kit contains - how-to/audio/01-play-samples#trigger-samples-by-midi-number | Trigger samples by MIDI number - how-to/audio/01-play-samples#shape-one-hit | Shape one hit - how-to/audio/01-play-samples#shape-every-hit-of-a-pad | Shape every hit of a pad - how-to/audio/01-play-samples#play-melodies-from-a-sample | Play melodies from a sample - how-to/audio/01-play-samples#set-a-melodic-envelope | Set a melodic envelope - how-to/audio/01-play-samples#related | Related Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/ --- Play Samples > Play a drum kit [guide] Put a `Sampler` with a kit on a track, and name the kit's samples in a pattern: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd _ bd _, _ sd _ sd, hh*8]; PLAY; ``` The bundled kits include **CR-78**, **TR-808** and **TR-909** for drums and **keys** for melodic sampling. Your own kits are folders of `.wav` files under `kits/`, optionally with a [`kit.toml`](/docs/reference/setup/05-kit-toml/). Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#play-a-drum-kit Next: how-to/audio/01-play-samples#see-what-a-kit-contains --- Play Samples > Play melodies from a sample [guide] `SamplerMelodic(Kit(...))` loads the kit's `default_sample` and maps it across the keyboard. Note names play as a melody, and a comma stacks voices: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << [C4 E4 G4 C5, C3 _ G3 _]; PLAY; ``` A kit with only one sample needs no `default_sample`. A missing sample, a missing root note, or a multi-sample kit with no default is an error when the kit loads. To load another sample from the kit, name it: ```resonon use "std/instruments" { SamplerMelodic, Kit }; let keys = SamplerMelodic(Kit("keys")); keys.load_sample("sound2"); ``` `SamplerMelodic()` with no kit is an empty sampler; load content into it later with `.load_kit()` or `.load_sample()`. On a melodic sampler, a hit's `.pitch(n)` is relative to the note you played: `C4.pitch(12)` sounds at C5. Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#play-melodies-from-a-sample Previous: how-to/audio/01-play-samples#shape-every-hit-of-a-pad Next: how-to/audio/01-play-samples#set-a-melodic-envelope --- Play Samples > Related [guide] - [Your First Groove](/docs/tutorials/patterns/02-your-first-groove/) — rests, subdivision and stacking - [Instruments](/docs/reference/stdlib/instruments/) — every sampler method - [kit.toml](/docs/reference/setup/05-kit-toml/) — the kit manifest Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#related Previous: how-to/audio/01-play-samples#set-a-melodic-envelope --- Play Samples > See what a kit contains [guide] `show()` prints a kit's samples, with the MIDI note each one is mapped to: ```resonon use "std/instruments" { Kit }; show(Kit("CR-78")); ``` Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#see-what-a-kit-contains Previous: how-to/audio/01-play-samples#play-a-drum-kit Next: how-to/audio/01-play-samples#trigger-samples-by-midi-number --- Play Samples > Set a melodic envelope [guide] `.set_envelope(attack, decay, sustain, release)` shapes how every note swells and fades. The three times are in milliseconds; sustain is a level from `0` to `1`: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); let keys = SamplerMelodic(Kit("keys")); lead.set_instrument(keys); keys.set_envelope(10, 100, 1.0, 200); lead << [C3 E3 G3 C4]; PLAY; ``` A fast attack and short release give a plucked note; a slow attack and long release turn the same sample into a pad. Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#set-a-melodic-envelope Previous: how-to/audio/01-play-samples#play-melodies-from-a-sample Next: how-to/audio/01-play-samples#related --- Play Samples > Shape every hit of a pad [guide] To change a sample for every hit — its gain, pan, envelope, slice points or reverse — set a parameter on its slot. Put the sampler on the track first; a slot names something inside a live sampler: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); let kit = Sampler(Kit("CR-78")); drums.set_instrument(kit); kit.slot("bd").parameter("gain") << 0.8; drums << [bd sd bd sd]; PLAY; ``` A slot parameter takes a signal too — see [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/). Remapping a sample to another note and choke groups are on the same `Sampler` value; see [`set_note`](/docs/reference/stdlib/instruments/#set_note) and [`set_choke_group`](/docs/reference/stdlib/instruments/#set_choke_group). Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#shape-every-hit-of-a-pad Previous: how-to/audio/01-play-samples#shape-one-hit Next: how-to/audio/01-play-samples#play-melodies-from-a-sample --- Play Samples > Shape one hit [guide] Attach a method to a sample name in the pattern and only that hit changes. `.vel()` sets velocity (`0`–`1`), `.pitch()` transposes in semitones, `.pan()` places the hit (`-1`–`1`), and `.gain()` scales its level — past `1` if you need it: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd.vel(1.0) sd.vel(0.4) bd.gain(1.4).pitch(-2) sd.pan(0.5)]; PLAY; ``` A hit's `.pan()` and `.gain()` apply on top of the pad's own settings: pan adds to the pad's pan, and gain multiplies the pad's gain. Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#shape-one-hit Previous: how-to/audio/01-play-samples#trigger-samples-by-midi-number Next: how-to/audio/01-play-samples#shape-every-hit-of-a-pad --- Play Samples > Trigger samples by MIDI number [guide] Every sample is mapped to a note, so a number triggers it too. Names and numbers mix in one pattern: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [36 42 38 42]; // kick, hat, snare, hat drums << [bd 42 sd 42]; PLAY; ``` Page: how-to/audio/01-play-samples URL: https://resonon.org/docs/how-to/audio/01-play-samples/#trigger-samples-by-midi-number Previous: how-to/audio/01-play-samples#see-what-a-kit-contains Next: how-to/audio/01-play-samples#shape-one-hit --- Build an Effect Chain [guide] The built-in effects are in `std/effects`; each one's arguments are in the [effects reference](/docs/reference/stdlib/effects/). Third-party effects are loaded with `Effect()` — see [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/). Every effect's first argument is its **slot name**, which identifies it in the chain. Sections: - how-to/audio/02-build-an-effect-chain#put-effects-on-a-track | Put effects on a track - how-to/audio/02-build-an-effect-chain#change-the-chain-while-it-plays | Change the chain while it plays - how-to/audio/02-build-an-effect-chain#set-an-effects-parameters | Set an effect's parameters - how-to/audio/02-build-an-effect-chain#clear-the-chain | Clear the chain - how-to/audio/02-build-an-effect-chain#related | Related Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/ --- Build an Effect Chain > Change the chain while it plays [guide] Edit the list and run the `set_effects` line again. Effects whose names are still in the list keep running; new names are added, missing names are removed, and moved names are reordered: ```resonon continue drums.set_effects(#[Filter("highpass", FilterType.highpass, 120), Delay("delay", 0.25, 0.5), Filter("lowpass", FilterType.lowpass, 800, 3.0)]); ``` The arguments you give are written to the effect that is already in the chain, so changing `Filter("lowpass", FilterType.lowpass, 800, 3.0)` to `Filter("lowpass", FilterType.lowpass, 2000, 3.0)` and re-running moves the cutoff. Arguments you leave out are not written, and keep whatever value the effect has now. Giving a name to a different kind of effect replaces it with a new one. Two effects on one track can't share a name. Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/#change-the-chain-while-it-plays Previous: how-to/audio/02-build-an-effect-chain#put-effects-on-a-track Next: how-to/audio/02-build-an-effect-chain#set-an-effects-parameters --- Build an Effect Chain > Clear the chain [guide] An empty list removes every effect: ```resonon continue drums.set_effects(#[]); ``` Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/#clear-the-chain Previous: how-to/audio/02-build-an-effect-chain#set-an-effects-parameters Next: how-to/audio/02-build-an-effect-chain#related --- Build an Effect Chain > Put effects on a track [guide] `set_effects` sets the track's whole chain, as a list. The signal runs through it in list order: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Delay, Filter, FilterType }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; drums.set_effects(#[Delay("delay", 0.25, 0.5), Filter("lowpass", FilterType.lowpass, 800, 3.0)]); // delay, then filter PLAY; ``` `show(drums)` prints the chain in order. Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/#put-effects-on-a-track Next: how-to/audio/02-build-an-effect-chain#change-the-chain-while-it-plays --- Build an Effect Chain > Related [guide] - [Effects](/docs/reference/stdlib/effects/) — every built-in effect and its arguments - [Descriptions & Slots](/docs/explanation/audio/02-descriptions-and-slots/) — why a chain keeps its effects across a re-run - [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/) — write your own effect Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/#related Previous: how-to/audio/02-build-an-effect-chain#clear-the-chain --- Build an Effect Chain > Set an effect's parameters [guide] Keep a handle to the effect, put it on the track, then set parameters through the handle: ```resonon use "std/effects" { Delay }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); let echo = Delay("delay", 0.25, 0.5); drums.set_effects(#[echo]); echo.set_parameter("Time", 0.4); // method form, chainable echo.parameter("Time") << 0.15; // operator form ``` The `<<` form also takes a signal, so the parameter moves — see [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/). Setting a parameter before `set_effects` is fine: the value is applied when the effect is built. Reading one — `parameter`, `parameters()` — needs the effect on a track first. Page: how-to/audio/02-build-an-effect-chain URL: https://resonon.org/docs/how-to/audio/02-build-an-effect-chain/#set-an-effects-parameters Previous: how-to/audio/02-build-an-effect-chain#change-the-chain-while-it-plays Next: how-to/audio/02-build-an-effect-chain#clear-the-chain --- Use a Plugin [guide] `Effect(slot, name)` names an effect plugin and `Instrument(name)` an instrument plugin. Placing it on a track with `set_effects` or `set_instrument` loads it. Every method is in the [audio reference](/docs/reference/stdlib/audio/#plugins). [The Plugin Database](/docs/explanation/audio/06-the-plugin-database/) explains scanning. Sections: - how-to/audio/03-use-a-plugin#load-an-effect-plugin | Load an effect plugin - how-to/audio/03-use-a-plugin#load-an-instrument-plugin | Load an instrument plugin - how-to/audio/03-use-a-plugin#find-what-is-installed | Find what is installed - how-to/audio/03-use-a-plugin#set-and-modulate-parameters | Set and modulate parameters - how-to/audio/03-use-a-plugin#open-the-plugins-editor | Open the plugin's editor - how-to/audio/03-use-a-plugin#save-and-load-a-plugins-state | Save and load a plugin's state - how-to/audio/03-use-a-plugin#bring-back-a-skipped-plugin | Bring back a skipped plugin - how-to/audio/03-use-a-plugin#turn-off-automatic-scanning | Turn off automatic scanning - how-to/audio/03-use-a-plugin#related | Related Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/ --- Use a Plugin > Bring back a skipped plugin [guide] A plugin that crashed or timed out while being scanned is skipped. Updating or reinstalling it brings it back by itself. To retry the same build: - Run the constructor that failed, and take the **Retry** quick fix on its line. - Or run **RESONON: Retry Skipped Plugins...** in VSCode to see every skipped plugin and pick what to retry. - Or retry one bundle in code or from a terminal: ```resonon parse-only plugin_rescan("~/Library/Audio/Plug-Ins/VST3/Whatever.vst3"); ``` ```bash resonon plugin rescan ~/Library/Audio/Plug-Ins/VST3/Whatever.vst3 resonon plugin list # what is skipped, and why ``` `plugin_scan(force: true)` — **RESONON: Rescan Plugins (Full)**, `resonon plugin scan --force` — re-opens every bundle, which takes as long as a first scan. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#bring-back-a-skipped-plugin Previous: how-to/audio/03-use-a-plugin#save-and-load-a-plugins-state Next: how-to/audio/03-use-a-plugin#turn-off-automatic-scanning --- Use a Plugin > Find what is installed [guide] `plugin_scan()` sweeps your plugin folders and returns what it found: ```resonon parse-only let plugins = plugin_scan(); print(plugins); // a table print(plugins.filter("reverb")); // by name ``` In VSCode, run **RESONON: Rescan Plugins**; in a terminal, `resonon plugin scan`. To add a folder of your own, run `resonon config plugins add `, then `reload_preferences()`. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#find-what-is-installed Previous: how-to/audio/03-use-a-plugin#load-an-instrument-plugin Next: how-to/audio/03-use-a-plugin#set-and-modulate-parameters --- Use a Plugin > Load an effect plugin [guide] Name the plugin, place it, then dial it: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Reverb }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let reverb = Reverb("reverb"); drums.set_effects(#[reverb]); reverb.set_parameter("Room", 0.8); PLAY; ``` `Reverb`, `PlateReverb`, `Sampler` and `SamplerMelodic` are built-in devices. They load directly from the application and need no scan. A plugin can be named by display name, by filename in your plugin folders, or by full path. When one bundle holds several plugins, or you have a CLAP and a VST3 build of the same plugin, add the plugin ID to say which one: ```resonon parse-only let shimmer = Effect("shimmer", "Valhalla Shimmer"); let custom = Effect("custom", "/path/to/plugin.clap"); let chorus = Effect("chorus", "Multi-FX", "com.vendor.multi-fx.chorus"); ``` Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#load-an-effect-plugin Next: how-to/audio/03-use-a-plugin#load-an-instrument-plugin --- Use a Plugin > Load an instrument plugin [guide] A plugin instrument goes on a track like any other instrument: ```resonon parse-only // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_instrument(Instrument("Surge XT")); lead << [C4 E4 G4 C5]; ``` Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#load-an-instrument-plugin Previous: how-to/audio/03-use-a-plugin#load-an-effect-plugin Next: how-to/audio/03-use-a-plugin#find-what-is-installed --- Use a Plugin > Open the plugin's editor [guide] ```resonon parse-only // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); let synth = Instrument("Surge XT"); lead.set_instrument(synth); if synth.supports_gui() { synth.show_gui(); } ``` `.hide_gui()` closes it. The built-in reverbs have no editor. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#open-the-plugins-editor Previous: how-to/audio/03-use-a-plugin#set-and-modulate-parameters Next: how-to/audio/03-use-a-plugin#save-and-load-a-plugins-state --- Use a Plugin > Related [guide] - [Audio: Plugins](/docs/reference/stdlib/audio/#plugins) — `Effect`, `Instrument` and their methods - [The Plugin Database](/docs/explanation/audio/06-the-plugin-database/) — scanning, isolation and skipped plugins - [Build an Effect Chain](/docs/how-to/audio/02-build-an-effect-chain/) — chains of built-in and plugin effects Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#related Previous: how-to/audio/03-use-a-plugin#turn-off-automatic-scanning --- Use a Plugin > Save and load a plugin's state [guide] `.save_state(path)` writes the plugin's full state to a file; `.load_state(path)` reads it into another instance. Saving needs the plugin on a track. Loading can come before placement: ```resonon parse-only // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); session.create_track("backing"); } let lead = session.track("lead"); let synth = Instrument("Surge XT"); lead.set_instrument(synth); synth.save_state("presets/my_lead.preset"); let backing = session.track("backing"); let synth2 = Instrument("Surge XT"); synth2.load_state("presets/my_lead.preset"); backing.set_instrument(synth2); ``` A state file only loads into the plugin that wrote it. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#save-and-load-a-plugins-state Previous: how-to/audio/03-use-a-plugin#open-the-plugins-editor Next: how-to/audio/03-use-a-plugin#bring-back-a-skipped-plugin --- Use a Plugin > Set and modulate parameters [guide] `.parameters()` returns every parameter with its range, default and current value, and `print` shows it as a table; a substring filters the list. `set_parameter` sets a value and chains, and `parameter` hands back the parameter itself: read it with `.get()`, set it as `0`–`1` across its range with `.set_norm()`, or modulate it with `<<`: ```resonon use "std/signals" { Sine }; use "std/effects" { Reverb }; let reverb = Reverb("reverb"); session.master.set_effects(#[reverb]); print(reverb.parameters("room")); reverb.set_parameter("Room", 0.8) .set_parameter("Damp", 0.4); show(reverb.parameter("Room").get()); reverb.parameter("Mix") << 0.4; reverb.parameter("Room") << Sine(0.2).range(0.3, 0.9); ``` Values set before `set_effects` are applied when the plugin is built; reading needs it on a track. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#set-and-modulate-parameters Previous: how-to/audio/03-use-a-plugin#find-what-is-installed Next: how-to/audio/03-use-a-plugin#open-the-plugins-editor --- Use a Plugin > Turn off automatic scanning [guide] Uncheck `resonon.plugins.autoScan` in VSCode, pass `--plugin-auto-scan=false`, or set `RESONON_PLUGIN_AUTO_SCAN=0` ([environment variables](/docs/reference/setup/01-cli/#environment-variables)). Plugins named by path or filename still load. Page: how-to/audio/03-use-a-plugin URL: https://resonon.org/docs/how-to/audio/03-use-a-plugin/#turn-off-automatic-scanning Previous: how-to/audio/03-use-a-plugin#bring-back-a-skipped-plugin Next: how-to/audio/03-use-a-plugin#related --- Group Tracks on a Bus [guide] A track has one **output**, `session.master` unless you change it. Point several tracks' outputs at one track, and that track is the group's bus. [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) explains the model. Sections: - how-to/audio/04-group-tracks-on-a-bus#route-the-tracks-into-a-bus | Route the tracks into a bus - how-to/audio/04-group-tracks-on-a-bus#take-a-track-out-of-the-group | Take a track out of the group - how-to/audio/04-group-tracks-on-a-bus#delete-a-bus | Delete a bus - how-to/audio/04-group-tracks-on-a-bus#related | Related Page: how-to/audio/04-group-tracks-on-a-bus URL: https://resonon.org/docs/how-to/audio/04-group-tracks-on-a-bus/ --- Group Tracks on a Bus > Delete a bus [guide] ```resonon continue drum_bus.delete(); ``` The tracks that output to the bus now output to [`session.nowhere`](/docs/explanation/audio/01-the-audio-graph/) — Live's **Sends Only** — and stop sounding until you route them again (`kick >> session.master;`). Nothing is rerouted for you. Sends into the bus are removed and sidechain inputs it fed are unwired; the console names every track this touched. Page: how-to/audio/04-group-tracks-on-a-bus URL: https://resonon.org/docs/how-to/audio/04-group-tracks-on-a-bus/#delete-a-bus Previous: how-to/audio/04-group-tracks-on-a-bus#take-a-track-out-of-the-group Next: how-to/audio/04-group-tracks-on-a-bus#related --- Group Tracks on a Bus > Related [guide] - [Audio: Routing & sends](/docs/reference/stdlib/audio/#routing--sends) — sends and the other routing methods - [Share an Effect with a Send](/docs/how-to/audio/05-share-an-effect-with-a-send/) — add a copy of a track to a bus instead of moving it - [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) — outputs, sends, gain and dependency order Page: how-to/audio/04-group-tracks-on-a-bus URL: https://resonon.org/docs/how-to/audio/04-group-tracks-on-a-bus/#related Previous: how-to/audio/04-group-tracks-on-a-bus#delete-a-bus --- Group Tracks on a Bus > Route the tracks into a bus [guide] Make the bus, give it the effects the group shares, and set each track's output with `>>`: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drum_bus"); session.create_track("kick"); session.create_track("snare"); } let drum_bus = session.track("drum_bus").set_effects(#[Filter("lowpass", FilterType.lowpass, 4000)]); let kick = session.track("kick").set_instrument(Sampler(Kit("CR-78"))); let snare = session.track("snare").set_instrument(Sampler(Kit("CR-78"))); kick >> drum_bus; snare >> drum_bus; kick << [bd*4]; snare << [_ sd _ sd]; PLAY; ``` The bus reaches `session.master` by itself, so the group has one fader: `drum_bus.volume`. `>>` chains hops, so `kick >> drum_bus >> session.master` routes a track and its bus in one line. Page: how-to/audio/04-group-tracks-on-a-bus URL: https://resonon.org/docs/how-to/audio/04-group-tracks-on-a-bus/#route-the-tracks-into-a-bus Next: how-to/audio/04-group-tracks-on-a-bus#take-a-track-out-of-the-group --- Group Tracks on a Bus > Take a track out of the group [guide] Route it back to `session.master`: ```resonon continue snare >> session.master; ``` Page: how-to/audio/04-group-tracks-on-a-bus URL: https://resonon.org/docs/how-to/audio/04-group-tracks-on-a-bus/#take-a-track-out-of-the-group Previous: how-to/audio/04-group-tracks-on-a-bus#route-the-tracks-into-a-bus Next: how-to/audio/04-group-tracks-on-a-bus#delete-a-bus --- Share an Effect with a Send [guide] A **send** adds a copy of a track to another track, at a level of its own, while the track keeps playing to its output. Put the shared effect on a return track and send to it. [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) explains the model. Sections: - how-to/audio/05-share-an-effect-with-a-send#send-a-track-to-a-return | Send a track to a return - how-to/audio/05-share-an-effect-with-a-send#change-the-send-level | Change the send level - how-to/audio/05-share-an-effect-with-a-send#automate-the-send-level | Automate the send level - how-to/audio/05-share-an-effect-with-a-send#related | Related Page: how-to/audio/05-share-an-effect-with-a-send URL: https://resonon.org/docs/how-to/audio/05-share-an-effect-with-a-send/ --- Share an Effect with a Send > Automate the send level [guide] Send a signal or a pattern to the send: ```resonon continue perc.send(delay_bus) << automation(#[0, 0.3], #[8, 0.8]); ``` `set_send` takes one as well, in place of the number: `perc.set_send(delay_bus, [0.2 0.6])`. Page: how-to/audio/05-share-an-effect-with-a-send URL: https://resonon.org/docs/how-to/audio/05-share-an-effect-with-a-send/#automate-the-send-level Previous: how-to/audio/05-share-an-effect-with-a-send#change-the-send-level Next: how-to/audio/05-share-an-effect-with-a-send#related --- Share an Effect with a Send > Change the send level [guide] Address a send that already exists with `send(dest)`: ```resonon continue perc.send(delay_bus).set(0.5); ``` Page: how-to/audio/05-share-an-effect-with-a-send URL: https://resonon.org/docs/how-to/audio/05-share-an-effect-with-a-send/#change-the-send-level Previous: how-to/audio/05-share-an-effect-with-a-send#send-a-track-to-a-return Next: how-to/audio/05-share-an-effect-with-a-send#automate-the-send-level --- Share an Effect with a Send > Related [guide] - [Audio: Routing & sends](/docs/reference/stdlib/audio/#routing--sends) — `set_send`, `send` and the send methods - [Blend Dry and Wet](/docs/how-to/audio/06-blend-dry-and-wet/) — trade the dry signal against the send - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — breakpoints and curve shapes Page: how-to/audio/05-share-an-effect-with-a-send URL: https://resonon.org/docs/how-to/audio/05-share-an-effect-with-a-send/#related Previous: how-to/audio/05-share-an-effect-with-a-send#automate-the-send-level --- Share an Effect with a Send > Send a track to a return [guide] Put the effect on a track of its own, then send each source to it with `set_send(dest, amount)`: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Delay }; use "std/signals" { automation }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("delay_bus"); session.create_track("perc"); } let delay_bus = session.track("delay_bus"); delay_bus.set_effects(#[Delay("delay", 0.3, 0.5).set_parameter("Mix", 1.0)]); let perc = session.track("perc"); perc.set_instrument(Sampler(Kit("CR-78"))); perc << [rs _ cl _]; perc.set_send(delay_bus, 0.3); PLAY; ``` The delay on a return is fully wet (`Mix` 1.0): the source track already plays the dry signal. The amount runs from `0` to `1`. Send the other tracks the same way; one track can send to several returns, each at its own level. Page: how-to/audio/05-share-an-effect-with-a-send URL: https://resonon.org/docs/how-to/audio/05-share-an-effect-with-a-send/#send-a-track-to-a-return Next: how-to/audio/05-share-an-effect-with-a-send#change-the-send-level --- Blend Dry and Wet [guide] Send the track to the effect bus, and send it to its own output with the complementary amount. A send to the track's own output sets the level of the dry signal instead of adding a copy. Sections: - how-to/audio/06-blend-dry-and-wet#set-the-blend | Set the blend - how-to/audio/06-blend-dry-and-wet#go-fully-wet | Go fully wet - how-to/audio/06-blend-dry-and-wet#related | Related Page: how-to/audio/06-blend-dry-and-wet URL: https://resonon.org/docs/how-to/audio/06-blend-dry-and-wet/ --- Blend Dry and Wet > Go fully wet [guide] To hear only the effect, route the track to `session.nowhere` — Live's **Sends Only**. The track leaves the mix and its sends keep feeding their buses: ```resonon continue drums >> session.nowhere; drums.set_send(wet_bus, 1.0); // all of it through the reverb ``` `drums >> session.master;` puts the dry signal back, at 100%. Page: how-to/audio/06-blend-dry-and-wet URL: https://resonon.org/docs/how-to/audio/06-blend-dry-and-wet/#go-fully-wet Previous: how-to/audio/06-blend-dry-and-wet#set-the-blend Next: how-to/audio/06-blend-dry-and-wet#related --- Blend Dry and Wet > Related [guide] - [Share an Effect with a Send](/docs/how-to/audio/05-share-an-effect-with-a-send/) — sends, and changing their level - [The Audio Graph](/docs/explanation/audio/01-the-audio-graph/) — outputs, sends and gain Page: how-to/audio/06-blend-dry-and-wet URL: https://resonon.org/docs/how-to/audio/06-blend-dry-and-wet/#related Previous: how-to/audio/06-blend-dry-and-wet#go-fully-wet --- Blend Dry and Wet > Set the blend [guide] ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Reverb }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("wet"); session.create_track("drums"); } let wet_bus = session.track("wet"); wet_bus.set_effects(#[Reverb("reverb", 0.9, 0.2)]); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; drums.set_send(wet_bus, 0.7); // 70% through the reverb drums.set_send(session.master, 0.3); // 30% dry PLAY; ``` For a constant-power crossfade, use `amount.sqrt()` for one side and `(1.0 - amount).sqrt()` for the other. :::caution Setting the output with `>>` puts the dry level back to 100%. Set the route first and the levels second. ::: Page: how-to/audio/06-blend-dry-and-wet URL: https://resonon.org/docs/how-to/audio/06-blend-dry-and-wet/#set-the-blend Next: how-to/audio/06-blend-dry-and-wet#go-fully-wet --- Duck with a Sidechain [guide] A compressor with a sidechain input listens to one signal and turns down another. Put the compressor on the track that should duck, and feed the track it should duck under into its sidechain port with `connect_input`. Sections: - how-to/audio/07-duck-with-a-sidechain#connect-the-sidechain | Connect the sidechain - how-to/audio/07-duck-with-a-sidechain#find-the-port-name | Find the port name - how-to/audio/07-duck-with-a-sidechain#if-the-plugin-reloads | If the plugin reloads - how-to/audio/07-duck-with-a-sidechain#related | Related Page: how-to/audio/07-duck-with-a-sidechain URL: https://resonon.org/docs/how-to/audio/07-duck-with-a-sidechain/ --- Duck with a Sidechain > Connect the sidechain [guide] Place the compressor first — the port belongs to the effect on the track — then connect the source to its port: ```resonon parse-only use "std/instruments" { Sampler, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("kick"); session.create_track("bass"); } let kick = session.track("kick"); kick.set_instrument(Sampler(Kit("CR-78"))); kick << [bd*4]; let bass = session.track("bass"); bass.set_instrument(Instrument("Surge XT")); bass << [C2 _ C2 G1]; let comp = Effect("comp", "TDR Molot GE"); bass.set_effects(#[comp]); comp.connect_input("Sidechain", kick); PLAY; ``` Then turn on the compressor's own sidechain or external-key switch, and set its threshold, ratio and release by ear. The kick reaches the port only; it is not mixed into the bass. Page: how-to/audio/07-duck-with-a-sidechain URL: https://resonon.org/docs/how-to/audio/07-duck-with-a-sidechain/#connect-the-sidechain Next: how-to/audio/07-duck-with-a-sidechain#find-the-port-name --- Duck with a Sidechain > Find the port name [guide] The port name is the plugin's own, matched exactly: MCompressor and TDR Molot GE say `"Sidechain"`, Shadow Hills `"Stereo Aux In"`, FETish `"Aux"`. A name the plugin doesn't have is an error that ends with the ones it does — `Available ports: …` — so connecting with a guess shows you the list. Page: how-to/audio/07-duck-with-a-sidechain URL: https://resonon.org/docs/how-to/audio/07-duck-with-a-sidechain/#find-the-port-name Previous: how-to/audio/07-duck-with-a-sidechain#connect-the-sidechain Next: how-to/audio/07-duck-with-a-sidechain#if-the-plugin-reloads --- Duck with a Sidechain > If the plugin reloads [guide] A connection to a port that disappears — the plugin reloaded, or changed its buses — comes back when the plugin offers the port again. You don't connect it again. Page: how-to/audio/07-duck-with-a-sidechain URL: https://resonon.org/docs/how-to/audio/07-duck-with-a-sidechain/#if-the-plugin-reloads Previous: how-to/audio/07-duck-with-a-sidechain#find-the-port-name Next: how-to/audio/07-duck-with-a-sidechain#related --- Duck with a Sidechain > Related [guide] - [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/) — load and set up the compressor - [Sidechain a Custom Effect](/docs/how-to/dsp/01-sidechain-a-custom-effect/) — a `dsp effect` with a sidechain input of its own - [Audio: Plugins](/docs/reference/stdlib/audio/#plugins) — `connect_input` Page: how-to/audio/07-duck-with-a-sidechain URL: https://resonon.org/docs/how-to/audio/07-duck-with-a-sidechain/#related Previous: how-to/audio/07-duck-with-a-sidechain#if-the-plugin-reloads --- Send a Track to Hardware Outputs [guide] `Output` names channels of the audio interface, counting from 0: two for a stereo pair, one for mono. The interface itself is set in [preferences](/docs/reference/setup/02-preferences/), or in the app with **Output Device** on the **Audio** tab of the [Preferences window](/docs/how-to/setup/07-use-the-preferences-window/). Sections: - how-to/audio/08-send-a-track-to-hardware-outputs#route-a-track-to-interface-channels | Route a track to interface channels - how-to/audio/08-send-a-track-to-hardware-outputs#route-the-whole-mix | Route the whole mix - how-to/audio/08-send-a-track-to-hardware-outputs#bring-a-track-back-into-the-mix | Bring a track back into the mix - how-to/audio/08-send-a-track-to-hardware-outputs#related | Related Page: how-to/audio/08-send-a-track-to-hardware-outputs URL: https://resonon.org/docs/how-to/audio/08-send-a-track-to-hardware-outputs/ --- Send a Track to Hardware Outputs > Bring a track back into the mix [guide] ```resonon parse-only click >> session.master; ``` Page: how-to/audio/08-send-a-track-to-hardware-outputs URL: https://resonon.org/docs/how-to/audio/08-send-a-track-to-hardware-outputs/#bring-a-track-back-into-the-mix Previous: how-to/audio/08-send-a-track-to-hardware-outputs#route-the-whole-mix Next: how-to/audio/08-send-a-track-to-hardware-outputs#related --- Send a Track to Hardware Outputs > Related [guide] - [Audio: Routing & sends](/docs/reference/stdlib/audio/#routing--sends) — `Output` and the routing methods - [Preferences](/docs/reference/setup/02-preferences/) — the `[audio]` output device Page: how-to/audio/08-send-a-track-to-hardware-outputs URL: https://resonon.org/docs/how-to/audio/08-send-a-track-to-hardware-outputs/#related Previous: how-to/audio/08-send-a-track-to-hardware-outputs#bring-a-track-back-into-the-mix --- Send a Track to Hardware Outputs > Route a track to interface channels [guide] Route the track to an `Output` with `>>`. It replaces the track's route to `session.master`, so the track leaves the mix: ```resonon parse-only // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("click"); session.create_track("cue"); } let click = session.track("click"); let cue = session.track("cue"); click >> Output(2, 3); // the click on channels 2 and 3, not in the mix cue >> Output(4); // mono, on channel 4 ``` A channel the interface doesn't have is an error. A track routed to an `Output` is not in a render's `master.wav` either; `render(click, n)` writes it on its own. Page: how-to/audio/08-send-a-track-to-hardware-outputs URL: https://resonon.org/docs/how-to/audio/08-send-a-track-to-hardware-outputs/#route-a-track-to-interface-channels Next: how-to/audio/08-send-a-track-to-hardware-outputs#route-the-whole-mix --- Send a Track to Hardware Outputs > Route the whole mix [guide] `session.master` takes an `Output` too: ```resonon parse-only session.master >> Output(2, 3); // the whole mix on channels 2 and 3 ``` Page: how-to/audio/08-send-a-track-to-hardware-outputs URL: https://resonon.org/docs/how-to/audio/08-send-a-track-to-hardware-outputs/#route-the-whole-mix Previous: how-to/audio/08-send-a-track-to-hardware-outputs#route-a-track-to-interface-channels Next: how-to/audio/08-send-a-track-to-hardware-outputs#bring-a-track-back-into-the-mix --- Sweep a Parameter with an LFO [guide] Anything you set with `<<` — an effect parameter, a track's `volume` or `pan`, a send level — takes a signal as well as a number. The LFOs are in `std/signals`. [Signals & Time](/docs/explanation/audio/03-signals-and-time/) explains how a signal keeps time. Sections: - how-to/audio/09-sweep-a-parameter-with-an-lfo#bind-an-lfo-to-the-parameter | Bind an LFO to the parameter - how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-speed | Set the speed - how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-range | Set the range - how-to/audio/09-sweep-a-parameter-with-an-lfo#shape-the-sweep | Shape the sweep - how-to/audio/09-sweep-a-parameter-with-an-lfo#keep-the-phase-when-you-change-the-speed | Keep the phase when you change the speed - how-to/audio/09-sweep-a-parameter-with-an-lfo#lock-two-parameters-together | Lock two parameters together - how-to/audio/09-sweep-a-parameter-with-an-lfo#related | Related Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/ --- Sweep a Parameter with an LFO > Bind an LFO to the parameter [guide] Put the effect on the track, then send a signal to its parameter: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType, Delay }; use "std/signals" { Sine, Sine2, Tri }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let filter = Filter("lowpass", FilterType.lowpass, 800); let delay = Delay("delay", 0.25, 0.4); drums.set_effects(#[filter, delay]); filter.parameter("Cutoff") << Sine(1).range_exp(400, 4000); PLAY; ``` For pan, take a bipolar LFO — `Sine2`, `Tri2`, `Saw2` or `Square2` — which swings from `-1` to `1`: ```resonon continue drums.pan << Sine2(0.5); ``` Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#bind-an-lfo-to-the-parameter Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-speed --- Sweep a Parameter with an LFO > Keep the phase when you change the speed [guide] Binding a signal restarts it at the next cycle boundary. To change an LFO's speed without its phase jumping, put it on the global clock with `.continuous()`: ```resonon continue filter.parameter("Cutoff") << Sine(2).set_timebase(seconds(1)).range(200, 4000).continuous(); ``` To restart it on a grid instead, give `.set_retrigger()` the period: `.set_retrigger(cycles(1))` on every cycle, `.set_retrigger(beats(1))` on every beat, `.set_retrigger(note_value(1, 8).dotted())` every dotted eighth. Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#keep-the-phase-when-you-change-the-speed Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#shape-the-sweep Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#lock-two-parameters-together --- Sweep a Parameter with an LFO > Lock two parameters together [guide] Bind one signal to both, and they move in phase. Two separate signals drift independently: ```resonon continue let lfo = Sine(0.5).range(0.1, 0.4); delay.parameter("Time") << lfo; delay.parameter("Feedback") << lfo; ``` Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#lock-two-parameters-together Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#keep-the-phase-when-you-change-the-speed Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#related --- Sweep a Parameter with an LFO > Related [guide] - [Signals](/docs/reference/stdlib/signals/) — every LFO and signal method - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — a shape you place in time instead of a loop - [Write a Modulation Source](/docs/how-to/dsp/04-write-a-modulation-source/) — an LFO of your own - [Map a Controller](/docs/how-to/midi/03-map-a-controller/) — drive a parameter from a controller Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#related Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#lock-two-parameters-together --- Sweep a Parameter with an LFO > Set the range [guide] `.range(min, max)` maps linearly. For cutoff, and anything else you hear as pitch, use `.range_exp(min, max)`, so the sweep spends equal time in each octave: ```resonon continue filter.parameter("Cutoff") << Sine(1).range(200, 4000); // midpoint ~2100 Hz filter.parameter("Cutoff") << Sine(1).range_exp(200, 4000); // midpoint ~894 Hz ``` Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#set-the-range Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-speed Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#shape-the-sweep --- Sweep a Parameter with an LFO > Set the speed [guide] The argument is sweeps per cycle, so the LFO follows the tempo: `Sine(4)` sweeps four times a cycle, `Sine(0.25)` once every four cycles. To count in another unit, give the LFO a timebase. A note value keeps it synced to the tempo: ```resonon continue filter.parameter("Cutoff") << Sine(1).set_timebase(note_value(1, 8).dotted()).range_exp(200, 4000); // a dotted eighth filter.parameter("Cutoff") << Tri(1).set_timebase(note_value(1, 4).triplet()).range_exp(200, 4000); // a quarter triplet filter.parameter("Cutoff") << Sine(1).set_timebase(cycles(2)).range_exp(200, 4000); // two bars ``` Seconds free it from the tempo, like switching an LFO's sync off: ```resonon continue filter.parameter("Cutoff") << Sine(2).set_timebase(seconds(1)).range_exp(200, 4000); // 2 Hz delay.parameter("Time") << Sine(1).set_timebase(seconds(0.5)).range(0.1, 0.4); // a 0.5 s period ``` Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#set-the-speed Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#bind-an-lfo-to-the-parameter Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-range --- Sweep a Parameter with an LFO > Shape the sweep [guide] Add, scale and invert LFOs with arithmetic: ```resonon continue filter.parameter("Cutoff") << (Sine(1) + Tri(3) * 0.5).range_exp(200, 8000); delay.parameter("Feedback") << Sine(4) * 0.2 + 0.5; // a small wobble around 0.5 filter.parameter("Cutoff") << (-Sine(1)).range(200, 4000); // inverted ``` Page: how-to/audio/09-sweep-a-parameter-with-an-lfo URL: https://resonon.org/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/#shape-the-sweep Previous: how-to/audio/09-sweep-a-parameter-with-an-lfo#set-the-range Next: how-to/audio/09-sweep-a-parameter-with-an-lfo#keep-the-phase-when-you-change-the-speed --- Step a Parameter Through Values [guide] A parameter takes a pattern or a stepped signal as well as a number, and holds each value for its step. [Signals & Time](/docs/explanation/audio/03-signals-and-time/) explains how a signal keeps time. Sections: - how-to/audio/10-step-a-parameter-through-values#send-the-values-as-a-pattern | Send the values as a pattern - how-to/audio/10-step-a-parameter-through-values#smooth-the-jumps | Smooth the jumps - how-to/audio/10-step-a-parameter-through-values#related | Related Page: how-to/audio/10-step-a-parameter-through-values URL: https://resonon.org/docs/how-to/audio/10-step-a-parameter-through-values/ --- Step a Parameter Through Values > Related [guide] - [Signals](/docs/reference/stdlib/signals/) — `signal`, `.smooth()` and the other signal methods - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — continuous movement - [Transform a Pattern](/docs/how-to/patterns/01-transform-a-pattern/) — change the steps from cycle to cycle Page: how-to/audio/10-step-a-parameter-through-values URL: https://resonon.org/docs/how-to/audio/10-step-a-parameter-through-values/#related Previous: how-to/audio/10-step-a-parameter-through-values#smooth-the-jumps --- Step a Parameter Through Values > Send the values as a pattern [guide] Write the values as a pattern, one per step: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Delay }; use "std/signals" { signal }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let delay = Delay("delay", 0.25, 0.4); drums.set_effects(#[delay]); delay.parameter("Feedback") << [0.1 0.3 0.5 0.3]; drums.volume << [-6 0 -6 0]; PLAY; ``` The pattern plays exactly as it would on a track. A nested step keeps its place in the cycle, `<...>` takes one turn per cycle, and a transform such as `.degrade()` changes the steps every cycle: ```resonon continue delay.parameter("Feedback") << [0.1 <0.3 [0.5 0.6]>]; ``` A rest leaves the parameter where the last step put it, so `[0.1 _ 0.5 _]` moves twice per cycle. Before the first step has played, the parameter already has its value. Where two events overlap, the one that started last holds. For values you compute, `signal(#[...])` steps through an array, dividing the cycle evenly among them: ```resonon continue delay.parameter("Time") << signal(#[0.1, 0.2, 0.35, 0.15]); ``` Page: how-to/audio/10-step-a-parameter-through-values URL: https://resonon.org/docs/how-to/audio/10-step-a-parameter-through-values/#send-the-values-as-a-pattern Next: how-to/audio/10-step-a-parameter-through-values#smooth-the-jumps --- Step a Parameter Through Values > Smooth the jumps [guide] A jump can click or zipper. `.smooth(ms)` on a signal rounds off each jump; a longer time rounds it more: ```resonon continue delay.parameter("Time") << signal(#[0.1, 0.2, 0.35, 0.15]).smooth(10); ``` Start around 10 ms, and raise it until the clicks go. Page: how-to/audio/10-step-a-parameter-through-values URL: https://resonon.org/docs/how-to/audio/10-step-a-parameter-through-values/#smooth-the-jumps Previous: how-to/audio/10-step-a-parameter-through-values#send-the-values-as-a-pattern Next: how-to/audio/10-step-a-parameter-through-values#related --- Draw an Automation Curve [guide] `automation()` is a curve through breakpoints, placed in cycles; `signal_ramp()` is a straight line. Both are in `std/signals`, and either can drive anything you set with `<<`. [Signals & Time](/docs/explanation/audio/03-signals-and-time/) explains how a signal keeps time. Sections: - how-to/audio/11-draw-an-automation-curve#place-the-breakpoints | Place the breakpoints - how-to/audio/11-draw-an-automation-curve#shape-each-segment | Shape each segment - how-to/audio/11-draw-an-automation-curve#draw-a-straight-ramp | Draw a straight ramp - how-to/audio/11-draw-an-automation-curve#related | Related Page: how-to/audio/11-draw-an-automation-curve URL: https://resonon.org/docs/how-to/audio/11-draw-an-automation-curve/ --- Draw an Automation Curve > Draw a straight ramp [guide] `signal_ramp(start, end)` rises in a line over one cycle and repeats; a third argument stretches it over several cycles: ```resonon continue filter.parameter("Cutoff") << signal_ramp(0, 1, 4).range_exp(200, 4000); ``` Running the line again restarts the ramp at the next cycle boundary. Page: how-to/audio/11-draw-an-automation-curve URL: https://resonon.org/docs/how-to/audio/11-draw-an-automation-curve/#draw-a-straight-ramp Previous: how-to/audio/11-draw-an-automation-curve#shape-each-segment Next: how-to/audio/11-draw-an-automation-curve#related --- Draw an Automation Curve > Place the breakpoints [guide] Give `automation()` `#[time, value]` breakpoints, with the time in cycles: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; use "std/signals" { automation, signal_ramp }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let filter = Filter("lowpass", FilterType.lowpass, 800); drums.set_effects(#[filter]); let sweep = automation(#[0, 0.0], #[2, 1.0], #[4, 0.3], #[6, 0.0]); filter.parameter("Cutoff") << sweep.range_exp(200, 4000); PLAY; ``` The first value holds before the first breakpoint, and the last after the last one. Breakpoint times are counted in the signal's timebase: for times in seconds, add `.set_timebase(seconds(1))`; for beats, `.set_timebase(beats(1))`. Page: how-to/audio/11-draw-an-automation-curve URL: https://resonon.org/docs/how-to/audio/11-draw-an-automation-curve/#place-the-breakpoints Next: how-to/audio/11-draw-an-automation-curve#shape-each-segment --- Draw an Automation Curve > Related [guide] - [Signals](/docs/reference/stdlib/signals/#automation) — `automation` and `signal_ramp` - [Curve](/docs/reference/stdlib/audio/#curve) and [Bezier](/docs/reference/stdlib/audio/#bezier) — the segment shapes - [Automate a Song](/docs/how-to/audio/19-automate-a-song/) — place automation at a point in a song - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — a shape that loops Page: how-to/audio/11-draw-an-automation-curve URL: https://resonon.org/docs/how-to/audio/11-draw-an-automation-curve/#related Previous: how-to/audio/11-draw-an-automation-curve#draw-a-straight-ramp --- Draw an Automation Curve > Shape each segment [guide] A third element sets the curve of the segment that starts at that breakpoint: ```resonon continue let shaped = automation( #[0, 0.0, Curve.smooth], #[2, 1.0, Curve.ease_out], #[4, 0.3, Curve.step], #[6, 0.0] ); filter.parameter("Cutoff") << shaped.range_exp(200, 4000); ``` The shapes are the variants of [`Curve`](/docs/reference/stdlib/audio/#curve). For a shape of your own, give a [`Bezier`](/docs/reference/stdlib/audio/#bezier): `#[0, 0.0, Bezier(0.3, 1.6, 0.7, 1)]` rises past its target and settles back. Page: how-to/audio/11-draw-an-automation-curve URL: https://resonon.org/docs/how-to/audio/11-draw-an-automation-curve/#shape-each-segment Previous: how-to/audio/11-draw-an-automation-curve#place-the-breakpoints Next: how-to/audio/11-draw-an-automation-curve#draw-a-straight-ramp --- Record a Take [guide] A track records from its input when it is armed and the transport is recording. Every method is in the [audio reference](/docs/reference/stdlib/audio/#recording--input). [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) explains the timing model. Sections: - how-to/audio/12-record-a-take#choose-the-input-device | Choose the input device - how-to/audio/12-record-a-take#route-an-input-to-the-track | Route an input to the track - how-to/audio/12-record-a-take#arm-and-monitor-the-track | Arm and monitor the track - how-to/audio/12-record-a-take#record | Record - how-to/audio/12-record-a-take#save-the-take | Save the take - how-to/audio/12-record-a-take#record-several-tracks-at-once | Record several tracks at once - how-to/audio/12-record-a-take#related | Related Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/ --- Record a Take > Arm and monitor the track [guide] `.arm()` readies the track to record. `.set_monitor()` sets whether you hear the input: `Monitor.input` always, `Monitor.auto` while the track is armed or recording, `Monitor.off` never. Track with `Monitor.auto`: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("mic"); } let mic = session.track("mic"); mic.set_input(0); mic.set_monitor(Monitor.auto); mic.arm(); ``` Set `.set_input()` before `.set_monitor()`: choosing an input turns monitoring off. Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#arm-and-monitor-the-track Previous: how-to/audio/12-record-a-take#route-an-input-to-the-track Next: how-to/audio/12-record-a-take#record --- Record a Take > Choose the input device [guide] Set the interface in `~/.resonon/preferences.toml`: ```toml [audio] input = "Focusrite Scarlett 2i2" ``` The name matches exactly, then as a case-insensitive substring; with no `input`, the system default is used. Run `reload_preferences()` to apply the change without restarting. It is refused while a take is being recorded. To see the names and channel counts, list the input devices: ```resonon for d in audio_input_devices() { print(d["name"] + " (" + d["channels"] + " inputs)"); } ``` Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#choose-the-input-device Next: how-to/audio/12-record-a-take#route-an-input-to-the-track --- Record a Take > Record [guide] ```resonon parse-only RECORD; // ... play or sing ... STOP; ``` `RECORD` starts playback and records every armed track. `STOP` ends the take, returns to the start, and leaves the track armed for another pass. `PAUSE` halts the transport without ending the take. Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#record Previous: how-to/audio/12-record-a-take#arm-and-monitor-the-track Next: how-to/audio/12-record-a-take#save-the-take --- Record a Take > Record several tracks at once [guide] Arm each one. `RECORD` records them all, each into its own take: ```resonon no-check // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("vocals"); session.create_track("guitar"); } let vocals = session.track("vocals").set_input(0).set_monitor(Monitor.auto).arm(); let guitar = session.track("guitar").set_input(1).set_monitor(Monitor.auto).arm(); RECORD; // ... perform ... STOP; let vocal_take = vocals.take(); let guitar_take = guitar.take(); ``` `.disarm()` stands a track down. Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#record-several-tracks-at-once Previous: how-to/audio/12-record-a-take#save-the-take Next: how-to/audio/12-record-a-take#related --- Record a Take > Related [guide] - [Audio: Recording & input](/docs/reference/stdlib/audio/#recording--input) — every recording method - [Punch In and Out](/docs/how-to/audio/13-punch-in-and-out/) — record only part of the song - [Correct Recording Latency](/docs/how-to/audio/15-correct-recording-latency/) — when takes land early or late - [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) — clocks, sample rates and how a take is placed Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#related Previous: how-to/audio/12-record-a-take#record-several-tracks-at-once --- Record a Take > Route an input to the track [guide] `.set_input()` takes channel numbers of the input device, counting from 0 — one for mono, two for a stereo pair: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("vocals"); } let vocals = session.track("vocals"); vocals.set_input(0); ``` ```resonon no-check // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("keys"); } let keys = session.track("keys"); keys.set_input(2, 3); ``` A channel the device doesn't have is an error that names the device and its channel count. Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#route-an-input-to-the-track Previous: how-to/audio/12-record-a-take#choose-the-input-device Next: how-to/audio/12-record-a-take#arm-and-monitor-the-track --- Record a Take > Save the take [guide] Every pass is kept. `.take()` returns the oldest one not yet collected, as an `AudioClip`, or `NUL` when none is left: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("mic"); } let mic = session.track("mic"); mic.set_input(0).arm(); RECORD; STOP; let take = mic.take(); if take != NUL { show(take.duration()); // seconds show(take.position()); // the cycle it was performed from take.save("vocals.wav"); } ``` A take is recorded in real time, in a live session: evaluate `RECORD` and `STOP` as you play. Run in one go, with nothing in between — a file run, or one selection holding both — there is no take, and `.take()` returns `NUL`. `.save(path)` on the track writes its recording straight to a WAV instead. Page: how-to/audio/12-record-a-take URL: https://resonon.org/docs/how-to/audio/12-record-a-take/#save-the-take Previous: how-to/audio/12-record-a-take#record Next: how-to/audio/12-record-a-take#record-several-tracks-at-once --- Punch In and Out [guide] Punch points limit recording to a window of cycles; playback runs from wherever it starts. [Record a Take](/docs/how-to/audio/12-record-a-take/) covers arming and collecting takes. Sections: - how-to/audio/13-punch-in-and-out#set-the-window | Set the window - how-to/audio/13-punch-in-and-out#punch-in-or-out-only | Punch in or out only - how-to/audio/13-punch-in-and-out#punch-the-same-window-again | Punch the same window again - how-to/audio/13-punch-in-and-out#remove-the-punch-points | Remove the punch points - how-to/audio/13-punch-in-and-out#related | Related Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/ --- Punch In and Out > Punch in or out only [guide] `.punch_in(cycle)` starts recording at a cycle and doesn't stop; `.punch_out(cycle)` records from now and stops at a cycle. Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/#punch-in-or-out-only Previous: how-to/audio/13-punch-in-and-out#set-the-window Next: how-to/audio/13-punch-in-and-out#punch-the-same-window-again --- Punch In and Out > Punch the same window again [guide] The points stay set across passes: run `RECORD` again for another take of the same window, and collect each with `.take()`. Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/#punch-the-same-window-again Previous: how-to/audio/13-punch-in-and-out#punch-in-or-out-only Next: how-to/audio/13-punch-in-and-out#remove-the-punch-points --- Punch In and Out > Related [guide] - [Audio: Recording & input](/docs/reference/stdlib/audio/#punch-recording) — the punch methods - [Record a Take](/docs/how-to/audio/12-record-a-take/) — arm, record and save Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/#related Previous: how-to/audio/13-punch-in-and-out#remove-the-punch-points --- Punch In and Out > Remove the punch points [guide] `.clear_punch()` removes them, and the track records whenever the transport does. `.is_punched()` says whether any are set. Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/#remove-the-punch-points Previous: how-to/audio/13-punch-in-and-out#punch-the-same-window-again Next: how-to/audio/13-punch-in-and-out#related --- Punch In and Out > Set the window [guide] `.punch(in, out)` records from cycle `in` up to cycle `out`: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("rec"); } let rec = session.track("rec"); rec.set_input(0).arm(); rec.punch(4, 12); // records cycles 4 to 11 RECORD; ``` Punch points land on cycle boundaries. The window is recorded in a live session, as the play head passes it; a file run ends before it gets there. Page: how-to/audio/13-punch-in-and-out URL: https://resonon.org/docs/how-to/audio/13-punch-in-and-out/#set-the-window Next: how-to/audio/13-punch-in-and-out#punch-in-or-out-only --- Process a Live Input [guide] A monitored input runs through its track's effect chain and sends, like any other track. Sections: - how-to/audio/14-process-a-live-input#monitor-the-input-through-effects | Monitor the input through effects - how-to/audio/14-process-a-live-input#related | Related Page: how-to/audio/14-process-a-live-input URL: https://resonon.org/docs/how-to/audio/14-process-a-live-input/ --- Process a Live Input > Monitor the input through effects [guide] Route the input, give the track its effects and sends, and monitor it: ```resonon use "std/effects" { Reverb, Filter, FilterType }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("reverb_bus"); session.create_track("vocals"); } let reverb_bus = session.track("reverb_bus").set_effects(#[Reverb("reverb", 0.5, 0.7)]); let vox = session.track("vocals"); vox.set_input(0); vox.set_effects(#[Filter("highpass", FilterType.highpass, 120)]); vox.set_monitor(Monitor.input); vox.set_send(reverb_bus, 0.4); ``` `Monitor.input` monitors whether or not the track is armed. Set `.set_input()` before `.set_monitor()`: choosing an input turns monitoring off. The input is heard live; in a render it is silent. If what you hear lags what you play, lower `[audio] buffer_size` — see [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/#the-audio-crackles-or-reacts-late). Page: how-to/audio/14-process-a-live-input URL: https://resonon.org/docs/how-to/audio/14-process-a-live-input/#monitor-the-input-through-effects Next: how-to/audio/14-process-a-live-input#related --- Process a Live Input > Related [guide] - [Record a Take](/docs/how-to/audio/12-record-a-take/) — choose the device and route an input - [Build an Effect Chain](/docs/how-to/audio/02-build-an-effect-chain/) — the effects on a track Page: how-to/audio/14-process-a-live-input URL: https://resonon.org/docs/how-to/audio/14-process-a-live-input/#related Previous: how-to/audio/14-process-a-live-input#monitor-the-input-through-effects --- Correct Recording Latency [guide] Resonon measures the round trip through the interface and moves each take back by it, so a take lines up with what you heard while you played. Correct it by hand only when takes still land early or late. [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) explains the model. Sections: - how-to/audio/15-correct-recording-latency#check-the-correction | Check the correction - how-to/audio/15-correct-recording-latency#measure-the-error | Measure the error - how-to/audio/15-correct-recording-latency#set-the-offset | Set the offset - how-to/audio/15-correct-recording-latency#related | Related Page: how-to/audio/15-correct-recording-latency URL: https://resonon.org/docs/how-to/audio/15-correct-recording-latency/ --- Correct Recording Latency > Check the correction [guide] `audio_latency()` reports what is in force; its keys are listed under [`audio_latency`](/docs/reference/stdlib/audio/#audio_latency): ```resonon let lat = audio_latency(); show(lat["record_compensation_ms"]); // what a take is corrected by show(lat["output_ms"]); show(lat["input_ms"]); ``` A smaller `[audio] buffer_size` shortens the round trip. Page: how-to/audio/15-correct-recording-latency URL: https://resonon.org/docs/how-to/audio/15-correct-recording-latency/#check-the-correction Next: how-to/audio/15-correct-recording-latency#measure-the-error --- Correct Recording Latency > Measure the error [guide] 1. Loop an output of the interface back into an input with a cable. 2. Play a click, and record it through the loop. 3. Compare where the recorded click lands with the click you played. The difference is the error. Page: how-to/audio/15-correct-recording-latency URL: https://resonon.org/docs/how-to/audio/15-correct-recording-latency/#measure-the-error Previous: how-to/audio/15-correct-recording-latency#check-the-correction Next: how-to/audio/15-correct-recording-latency#set-the-offset --- Correct Recording Latency > Related [guide] - [Preferences](/docs/reference/setup/02-preferences/) — `recording_offset_ms` and the other `[audio]` keys - [Compensate for Outboard Gear](/docs/how-to/audio/16-compensate-for-outboard-gear/) — a track that runs through hardware - [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) — clocks, sample rates and how a take is placed Page: how-to/audio/15-correct-recording-latency URL: https://resonon.org/docs/how-to/audio/15-correct-recording-latency/#related Previous: how-to/audio/15-correct-recording-latency#set-the-offset --- Correct Recording Latency > Set the offset [guide] In the app, type the error in **Recording Offset** on the **Audio** tab of the [Preferences window](/docs/how-to/setup/07-use-the-preferences-window/). It is in force at once. Or put the error in `~/.resonon/preferences.toml`, then run `reload_preferences()`: ```toml [audio] recording_offset_ms = 2.5 # takes arrive 2.5 ms later than measured ``` Positive means takes arrive later than measured, so each take starts further in; negative is for an interface that overstates its latency. Values beyond ±500 ms are refused. `recording_offset()` reads back what is in force: ```resonon show(recording_offset()); ``` Page: how-to/audio/15-correct-recording-latency URL: https://resonon.org/docs/how-to/audio/15-correct-recording-latency/#set-the-offset Previous: how-to/audio/15-correct-recording-latency#measure-the-error Next: how-to/audio/15-correct-recording-latency#related --- Compensate for Outboard Gear [guide] A track that leaves the interface, runs through a hardware processor and comes back in arrives late by the hardware's round trip. Tell resonon how late, and it delays the other tracks to match. Sections: - how-to/audio/16-compensate-for-outboard-gear#set-the-round-trip | Set the round trip - how-to/audio/16-compensate-for-outboard-gear#related | Related Page: how-to/audio/16-compensate-for-outboard-gear URL: https://resonon.org/docs/how-to/audio/16-compensate-for-outboard-gear/ --- Compensate for Outboard Gear > Related [guide] - [Audio: Recording & input](/docs/reference/stdlib/audio/#recording--input) — `delay` and `delay` - [Correct Recording Latency](/docs/how-to/audio/15-correct-recording-latency/) — the interface's own latency - [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/) — a MIDI device that is early or late Page: how-to/audio/16-compensate-for-outboard-gear URL: https://resonon.org/docs/how-to/audio/16-compensate-for-outboard-gear/#related Previous: how-to/audio/16-compensate-for-outboard-gear#set-the-round-trip --- Compensate for Outboard Gear > Set the round trip [guide] Give the returning track the round trip in milliseconds with `.set_delay(ms)`: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("guitar"); } let guitar = session.track("guitar"); guitar.set_delay(8); show(guitar.delay()); ``` The delay is for playing live. A render has no round trip through the hardware, and does not apply it. Page: how-to/audio/16-compensate-for-outboard-gear URL: https://resonon.org/docs/how-to/audio/16-compensate-for-outboard-gear/#set-the-round-trip Next: how-to/audio/16-compensate-for-outboard-gear#related --- Arrange a Song from Sections [guide] A **section** holds every track's lane for a stretch of the song; `arrange()` puts sections in sequence. Every method is in the [audio reference](/docs/reference/stdlib/audio/#sections). [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) explains how sections, lanes and layers relate. For a guided first song, see [Arrange a Song](/docs/tutorials/getting-started/05-arrange-a-song/). Sections: - how-to/audio/17-arrange-a-song-from-sections#write-a-section | Write a section - how-to/audio/17-arrange-a-song-from-sections#write-a-variation | Write a variation - how-to/audio/17-arrange-a-song-from-sections#sequence-the-sections | Sequence the sections - how-to/audio/17-arrange-a-song-from-sections#play-the-song | Play the song - how-to/audio/17-arrange-a-song-from-sections#check-what-it-will-play | Check what it will play - how-to/audio/17-arrange-a-song-from-sections#related | Related Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/ --- Arrange a Song from Sections > Check what it will play [guide] `show(song)` prints every lane as it will play — one row per stretch, with the layer that wins it: ```resonon continue show(song); ``` `song[drums].entries()` lists what you wrote on a lane instead, and flags writes that are completely hidden as `masked`. Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#check-what-it-will-play Previous: how-to/audio/17-arrange-a-song-from-sections#play-the-song Next: how-to/audio/17-arrange-a-song-from-sections#related --- Arrange a Song from Sections > Play the song [guide] `song.play()` starts the song from the top and plays it once through: ```resonon continue song.play(); ``` Every lane edit you make afterwards is heard while it plays; you don't call `play()` again. Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#play-the-song Previous: how-to/audio/17-arrange-a-song-from-sections#sequence-the-sections Next: how-to/audio/17-arrange-a-song-from-sections#check-what-it-will-play --- Arrange a Song from Sections > Related [guide] - [Audio: Sections](/docs/reference/stdlib/audio/#sections) — every section and lane method - [Add Fills to a Song](/docs/how-to/audio/18-add-fills-to-a-song/) — punch fills over the sections - [Automate a Song](/docs/how-to/audio/19-automate-a-song/) — volume, pan and effect automation per section - [Render a Project](/docs/how-to/running/02-render-a-project/) — bounce the song to disk Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#related Previous: how-to/audio/17-arrange-a-song-from-sections#check-what-it-will-play --- Arrange a Song from Sections > Sequence the sections [guide] `arrange(#[...])` plays its elements back to back. `elem * n` repeats one, and an arrangement can be an element of another: ```resonon continue let song = arrange(#[verse * 2, chorus]); // verse 0–16, chorus 16–24 ``` Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#sequence-the-sections Previous: how-to/audio/17-arrange-a-song-from-sections#write-a-variation Next: how-to/audio/17-arrange-a-song-from-sections#play-the-song --- Arrange a Song from Sections > Write a section [guide] `section(length)` makes a section `length` cycles long. Index it with a track and send the lane a pattern: ```resonon use "std/instruments" { Sampler, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("bass"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let bass = session.track("bass"); bass.set_instrument(Sampler(Kit("CR-78"))); let verse = section(8); verse[drums] << [bd bd sd bd]; verse[bass] << [c2 _ g1 _]; ``` `verse[drums].at(start, duration) << pattern` places a pattern inside the lane instead of covering the whole section. Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#write-a-section Next: how-to/audio/17-arrange-a-song-from-sections#write-a-variation --- Arrange a Song from Sections > Write a variation [guide] `.clone()` copies a section, every lane included. Change the copy: ```resonon continue let chorus = verse.clone(); chorus[drums] << [bd sd bd sd]; ``` Page: how-to/audio/17-arrange-a-song-from-sections URL: https://resonon.org/docs/how-to/audio/17-arrange-a-song-from-sections/#write-a-variation Previous: how-to/audio/17-arrange-a-song-from-sections#write-a-section Next: how-to/audio/17-arrange-a-song-from-sections#sequence-the-sections --- Add Fills to a Song [guide] A fill is written at a position on the song's lane. It masks what is underneath, across section boundaries too, and the part underneath resumes in its own place when the fill ends. [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) explains masking and layers. Sections: - how-to/audio/18-add-fills-to-a-song#punch-a-fill | Punch a fill - how-to/audio/18-add-fills-to-a-song#remove-a-fill | Remove a fill - how-to/audio/18-add-fills-to-a-song#group-fills-on-a-layer | Group fills on a layer - how-to/audio/18-add-fills-to-a-song#related | Related Page: how-to/audio/18-add-fills-to-a-song URL: https://resonon.org/docs/how-to/audio/18-add-fills-to-a-song/ --- Add Fills to a Song > Group fills on a layer [guide] Write fills to a named layer, and mute or unmute them together: ```resonon continue song[drums].layer("fills").at(7, 1) << [hh hh hh hh]; song[drums].layer("fills").at(15, 1) << [hh hh hh hh]; song[drums].layer("fills").mute(); song[drums].layer("fills").unmute(); ``` A muted layer goes quiet at the next cycle boundary. `.layer("fills").clear()` removes the layer's writes, `.clear()` on the lane removes everything above the structure, and `.set_layer_order(#[...])` sets the stack from bottom to top. Page: how-to/audio/18-add-fills-to-a-song URL: https://resonon.org/docs/how-to/audio/18-add-fills-to-a-song/#group-fills-on-a-layer Previous: how-to/audio/18-add-fills-to-a-song#remove-a-fill Next: how-to/audio/18-add-fills-to-a-song#related --- Add Fills to a Song > Punch a fill [guide] Write to a position with `.at(start, duration)`, in cycles from the start of the song: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let verse = section(8); verse[drums] << [bd bd sd bd]; let chorus = verse.clone(); chorus[drums] << [bd sd bd sd]; let song = arrange(#[verse, chorus]); song[drums].at(6, 4) << [cp cp]; ``` Running an `.at()` line again with a different length reshapes that same fill. Rewriting the whole lane changes the structure underneath and keeps the fill: ```resonon continue song[drums] << [bd _ sd _]; ``` Page: how-to/audio/18-add-fills-to-a-song URL: https://resonon.org/docs/how-to/audio/18-add-fills-to-a-song/#punch-a-fill Next: how-to/audio/18-add-fills-to-a-song#remove-a-fill --- Add Fills to a Song > Related [guide] - [Audio: Sections](/docs/reference/stdlib/audio/#sections) — lanes, positions and layers - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — the song the fills go on - [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) — masks, layers and when an edit lands Page: how-to/audio/18-add-fills-to-a-song URL: https://resonon.org/docs/how-to/audio/18-add-fills-to-a-song/#related Previous: how-to/audio/18-add-fills-to-a-song#group-fills-on-a-layer --- Add Fills to a Song > Remove a fill [guide] `.clear()` on the position removes it: ```resonon continue song[drums].at(6, 4).clear(); ``` Page: how-to/audio/18-add-fills-to-a-song URL: https://resonon.org/docs/how-to/audio/18-add-fills-to-a-song/#remove-a-fill Previous: how-to/audio/18-add-fills-to-a-song#punch-a-fill Next: how-to/audio/18-add-fills-to-a-song#group-fills-on-a-layer --- Automate a Song [guide] A track's `volume`, `pan` and effect parameters are lanes of a section or song, like its notes. [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) explains lanes. Sections: - how-to/audio/19-automate-a-song#automate-a-section | Automate a section - how-to/audio/19-automate-a-song#automate-at-a-position-in-the-song | Automate at a position in the song - how-to/audio/19-automate-a-song#related | Related Page: how-to/audio/19-automate-a-song URL: https://resonon.org/docs/how-to/audio/19-automate-a-song/ --- Automate a Song > Automate a section [guide] Index the section with the track, and send the parameter a value or a signal: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; use "std/signals" { automation }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums.set_effects(#[Filter("lowpass", FilterType.lowpass, 800)]); let verse = section(8); verse[drums] << [bd bd sd bd]; verse[drums].volume << -6; let chorus = verse.clone(); chorus[drums].volume << 0; let song = arrange(#[verse, chorus]); ``` An effect parameter is addressed by the effect's slot name: `verse[drums].effect("lowpass").parameter("Cutoff")`. Page: how-to/audio/19-automate-a-song URL: https://resonon.org/docs/how-to/audio/19-automate-a-song/#automate-a-section Next: how-to/audio/19-automate-a-song#automate-at-a-position-in-the-song --- Automate a Song > Automate at a position in the song [guide] Write to a position on the song's lane, in cycles from the start of the song: ```resonon continue song[drums].volume.at(8, 8) << automation().at(0, -24).at(8, 0); // the chorus swells in ``` The automation's own times count from the start of the position. Page: how-to/audio/19-automate-a-song URL: https://resonon.org/docs/how-to/audio/19-automate-a-song/#automate-at-a-position-in-the-song Previous: how-to/audio/19-automate-a-song#automate-a-section Next: how-to/audio/19-automate-a-song#related --- Automate a Song > Related [guide] - [Audio: Sections](/docs/reference/stdlib/audio/#sections) — section lanes and parameters - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — breakpoints and curve shapes - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — the song being automated Page: how-to/audio/19-automate-a-song URL: https://resonon.org/docs/how-to/audio/19-automate-a-song/#related Previous: how-to/audio/19-automate-a-song#automate-at-a-position-in-the-song --- Arrange a Track on a Timeline [guide] A **timeline** is one lane on its own: patterns placed at positions, looping at its end. Use one to arrange a single track without writing sections. Sections: - how-to/audio/20-arrange-a-track-on-a-timeline#place-the-patterns | Place the patterns - how-to/audio/20-arrange-a-track-on-a-timeline#change-it-while-it-plays | Change it while it plays - how-to/audio/20-arrange-a-track-on-a-timeline#related | Related Page: how-to/audio/20-arrange-a-track-on-a-timeline URL: https://resonon.org/docs/how-to/audio/20-arrange-a-track-on-a-timeline/ --- Arrange a Track on a Timeline > Change it while it plays [guide] Write to the timeline again; the track follows. A timeline has the same layer methods as a section's lane — see [Add Fills to a Song](/docs/how-to/audio/18-add-fills-to-a-song/#group-fills-on-a-layer). Page: how-to/audio/20-arrange-a-track-on-a-timeline URL: https://resonon.org/docs/how-to/audio/20-arrange-a-track-on-a-timeline/#change-it-while-it-plays Previous: how-to/audio/20-arrange-a-track-on-a-timeline#place-the-patterns Next: how-to/audio/20-arrange-a-track-on-a-timeline#related --- Arrange a Track on a Timeline > Place the patterns [guide] `timeline(length)` makes a timeline `length` cycles long. Place patterns with `.at(start, duration)`, then send the timeline to the track: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let t = timeline(16); t.at(0, 8) << [bd _ sd _]; t.at(8, 4) << [bd*4]; t.at(14.5, 1.5) << [cp cp]; // positions need not be whole cycles drums << t; PLAY; ``` Cycles no pattern covers are silent. Page: how-to/audio/20-arrange-a-track-on-a-timeline URL: https://resonon.org/docs/how-to/audio/20-arrange-a-track-on-a-timeline/#place-the-patterns Next: how-to/audio/20-arrange-a-track-on-a-timeline#change-it-while-it-plays --- Arrange a Track on a Timeline > Related [guide] - [Audio: Timelines](/docs/reference/stdlib/audio/#timelines) — every timeline and layer method - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — every track at once Page: how-to/audio/20-arrange-a-track-on-a-timeline URL: https://resonon.org/docs/how-to/audio/20-arrange-a-track-on-a-timeline/#related Previous: how-to/audio/20-arrange-a-track-on-a-timeline#change-it-while-it-plays --- Fix Audio Problems [guide] Find the message or the symptom, then work through the fix. Quoted blocks are what resonon prints. Device settings live in `~/.resonon/preferences.toml` — see [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/). In the app, change them on the **Audio** tab of the [Preferences window](/docs/how-to/setup/07-use-the-preferences-window/) instead: a change there is in force at once, so you do not run `reload_preferences()`. Sections: - how-to/audio/21-fix-audio-problems#no-output-device | No output device - how-to/audio/21-fix-audio-problems#the-stream-does-not-start | The stream does not start - how-to/audio/21-fix-audio-problems#input-and-output-disagree-on-the-sample-rate | Input and output disagree on the sample rate - how-to/audio/21-fix-audio-problems#the-audio-crackles-or-reacts-late | The audio crackles, or reacts late - how-to/audio/21-fix-audio-problems#a-sample-file-is-not-found | A sample file is not found - how-to/audio/21-fix-audio-problems#a-sample-does-not-load | A sample does not load - how-to/audio/21-fix-audio-problems#a-kit-does-not-load | A kit does not load - how-to/audio/21-fix-audio-problems#a-name-is-not-in-the-kit | A name is not in the kit - how-to/audio/21-fix-audio-problems#a-melodic-sample-has-no-root-note | A melodic sample has no root note - how-to/audio/21-fix-audio-problems#a-track-plays-somewhere-unexpected | A track plays somewhere unexpected - how-to/audio/21-fix-audio-problems#a-modulated-parameter-clicks | A modulated parameter clicks - how-to/audio/21-fix-audio-problems#related | Related Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/ --- Fix Audio Problems > A kit does not load [guide] > **Failed to parse kit.toml: TOML parse error at line 1, column 5 …** 1. Fix the line the message names — usually a missing comma, quote or bracket. 2. Check that every sample path in `kit.toml` points to a WAV file that exists. Without a `kit.toml`, files named like General MIDI drums (`bd`, `sd`, `hh`, …) get those notes, and the other files get notes counting up from C2. Every key: [kit.toml](/docs/reference/setup/05-kit-toml/). Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-kit-does-not-load Previous: how-to/audio/21-fix-audio-problems#a-sample-does-not-load Next: how-to/audio/21-fix-audio-problems#a-name-is-not-in-the-kit --- Fix Audio Problems > A melodic sample has no root note [guide] > **Sample 'piano' has no root note; add root to kit.toml or pass one to .load_sample()** A melodic sampler needs to know which note the sample plays, to pitch it. 1. Set `root` for the sample in the kit's `kit.toml`, or 2. pass it when you load the sample: `keys.load_sample("piano", C4)`. `load_sample` takes the sample's name in the kit, not a file path. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-melodic-sample-has-no-root-note Previous: how-to/audio/21-fix-audio-problems#a-name-is-not-in-the-kit Next: how-to/audio/21-fix-audio-problems#a-track-plays-somewhere-unexpected --- Fix Audio Problems > A modulated parameter clicks [guide] A signal that jumps — steps, a controller's 128 values — makes a parameter it drives click. Smooth it with `.smooth(ms)`: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Delay }; use "std/signals" { signal }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let delay = Delay("delay", 0.25, 0.4); drums.set_effects(#[delay]); delay.parameter("Time") << signal([0.1 0.2 0.35 0.15]).smooth(10); ``` How much to smooth depends on the parameter; see [Step a Parameter Through Values](/docs/how-to/audio/10-step-a-parameter-through-values/). Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-modulated-parameter-clicks Previous: how-to/audio/21-fix-audio-problems#a-track-plays-somewhere-unexpected Next: how-to/audio/21-fix-audio-problems#related --- Fix Audio Problems > A name is not in the kit [guide] > **Sample 'clap' not found in kit 'CR-78'. Available: ["bd", "rs", "sd", …]** The kit loaded, but it has no sound by that name. Use a name from the list, or add the sound to the kit's `kit.toml`. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-name-is-not-in-the-kit Previous: how-to/audio/21-fix-audio-problems#a-kit-does-not-load Next: how-to/audio/21-fix-audio-problems#a-melodic-sample-has-no-root-note --- Fix Audio Problems > A sample does not load [guide] > **Failed to load sample: …** The file was found, but it is not a WAV file resonon can read. 1. Resonon reads WAV only. Convert MP3, OGG and FLAC files to WAV. 2. Check the file opens in another app. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-sample-does-not-load Previous: how-to/audio/21-fix-audio-problems#a-sample-file-is-not-found Next: how-to/audio/21-fix-audio-problems#a-kit-does-not-load --- Fix Audio Problems > A sample file is not found [guide] > **Sample file 'kick.wav' not found.** > **Looked for: /Users/you/song/src/kick.wav** `Sample("…")` takes a path, and the message names the only place resonon looked. 1. The path is relative to the `.non` file that names it, not to the folder you started resonon in. A piece in `src/` that says `Sample("kick.wav")` needs `src/kick.wav`. 2. `../` and absolute paths work. A sample outside the project does not travel with it. 3. A kit folder does not help: kit folders are searched for `Kit("…")` names, never for `Sample` paths. 4. For one sound out of a kit, name it as the kit does: `Sampler(Kit("CR-78")).sample("bd")`. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-sample-file-is-not-found Previous: how-to/audio/21-fix-audio-problems#the-audio-crackles-or-reacts-late Next: how-to/audio/21-fix-audio-problems#a-sample-does-not-load --- Fix Audio Problems > A track plays somewhere unexpected [guide] A track is silent, doubled, or heard through the wrong effects: its output or a send is not what you think. 1. Print the routing — every track, the ones you name, or one track: ```resonon parse-only routing_report(); routing_report(drums, bass); drums.routing_report(); ``` 2. Put a track back to its default — output on `session.master`, no sends — with `reset_routing()`, then route it again. It chains: ```resonon parse-only drums.reset_routing().set_send(reverb_bus, 0.5); ``` Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#a-track-plays-somewhere-unexpected Previous: how-to/audio/21-fix-audio-problems#a-melodic-sample-has-no-root-note Next: how-to/audio/21-fix-audio-problems#a-modulated-parameter-clicks --- Fix Audio Problems > Input and output disagree on the sample rate [guide] > **This session runs at 48000 Hz, which Scarlett 2i2 cannot. It reports 44100 Hz; see > audio_input_devices(). `[audio] sample_rate` is holding the session at 48000 Hz. Scarlett 2i2 and > MacBook Pro Speakers both run at 44100 Hz: remove that line to let the session take a rate they > share, or set it to 44100.** A session has one sample rate. Resonon picks one that both devices can run, so this appears only when they share none, or when `[audio] sample_rate` sets one the input cannot run. Playback still works; recording and monitoring are off. 1. Remove `[audio] sample_rate`, and let resonon choose a rate the two share. Or set the rate the message names. 2. Or name an output device in `[audio] output` that shares a rate with the input. 3. Run `reload_preferences()`. To see what each device can run: ```resonon print(audio_input_devices()); // each device's sample_rates and buffer_frames print(audio_output_devices()); ``` Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#input-and-output-disagree-on-the-sample-rate Previous: how-to/audio/21-fix-audio-problems#the-stream-does-not-start Next: how-to/audio/21-fix-audio-problems#the-audio-crackles-or-reacts-late --- Fix Audio Problems > No output device [guide] > **No audio output device found** 1. Check that the system has an output device and that it is turned on. On macOS, open **Audio MIDI Setup** and look for it there. 2. Close any app that holds the device for itself. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#no-output-device Next: how-to/audio/21-fix-audio-problems#the-stream-does-not-start --- Fix Audio Problems > Related [guide] - [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) — choose the device, rate and block size - [Preferences](/docs/reference/setup/02-preferences/#audio) — every `[audio]` key - [Play Samples](/docs/how-to/audio/01-play-samples/) — kits, samples and melodic samplers - [Fix Plugin Problems](/docs/how-to/audio/22-fix-plugin-problems/) — plugins that are not found or do not load Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#related Previous: how-to/audio/21-fix-audio-problems#a-modulated-parameter-clicks --- Fix Audio Problems > The audio crackles, or reacts late [guide] The block size is the trade. A smaller one reacts sooner and leaves less time to compute each block; too small, and blocks are late and crackle. 1. Measure the load: ```resonon print(audio_cpu_load()); // load and peak, from 0.0 to 1.0 ``` A `load` near `1.0` means the blocks are too short for the work. 2. Crackles: raise `[audio] buffer_size`. Late reaction: lower it. 128 and 256 are the usual starting points. ```toml [audio] buffer_size = 256 ``` 3. Run `reload_preferences()` and listen again. A size the device does not take is refused, and the message names the range it takes. ```resonon print(audio_buffer_size()); // the size the device delivers now print(audio_latency()); // buffer_ms, device_ms and the rest ``` Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#the-audio-crackles-or-reacts-late Previous: how-to/audio/21-fix-audio-problems#input-and-output-disagree-on-the-sample-rate Next: how-to/audio/21-fix-audio-problems#a-sample-file-is-not-found --- Fix Audio Problems > The stream does not start [guide] > **Failed to build stream: …** / **Failed to start stream: …** 1. Close other audio apps: DAWs, browser tabs that play audio. 2. Check that the device can run the sample rate in `[audio] sample_rate`. 3. Name another device in `[audio] output`. 4. Run `reload_preferences()` after the change, or restart. Page: how-to/audio/21-fix-audio-problems URL: https://resonon.org/docs/how-to/audio/21-fix-audio-problems/#the-stream-does-not-start Previous: how-to/audio/21-fix-audio-problems#no-output-device Next: how-to/audio/21-fix-audio-problems#input-and-output-disagree-on-the-sample-rate --- Fix Plugin Problems [guide] Find the message or the symptom, then work through the fix. Quoted blocks are what resonon prints. How scanning works and how to find what is installed: [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/). Sections: - how-to/audio/22-fix-plugin-problems#a-plugin-is-not-found | A plugin is not found - how-to/audio/22-fix-plugin-problems#a-plugin-was-skipped-after-a-crash | A plugin was skipped after a crash - how-to/audio/22-fix-plugin-problems#a-plugin-did-not-finish-loading-in-time | A plugin did not finish loading in time - how-to/audio/22-fix-plugin-problems#a-plugin-is-listed-but-will-not-load | A plugin is listed, but will not load - how-to/audio/22-fix-plugin-problems#a-plugin-is-built-for-another-architecture | A plugin is built for another architecture - how-to/audio/22-fix-plugin-problems#a-plugin-has-no-gui | A plugin has no GUI - how-to/audio/22-fix-plugin-problems#the-plugin-database-is-empty | The plugin database is empty - how-to/audio/22-fix-plugin-problems#related | Related Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/ --- Fix Plugin Problems > A plugin did not finish loading in time [guide] > **plugin '/…/Foo.vst3' did not finish loading within 30s — the plugin appears to hang on load** The bundle went quiet rather than crashing. A slow network volume, a busy machine or a virus scanner opening the file for the first time all look the same. 1. Usually, do nothing. The next sweep tries it again; only three timeouts in a row set it aside, and the message says which attempt this was. 2. To try it now, use the **Retry Foo.vst3** quick fix, or run `plugin_rescan('/…/Foo.vst3')`. 3. The 30 seconds count only time resonon was running, so suspending or sleeping the machine does not cause it. 4. After three timeouts it is treated like a crash: see the section above. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-did-not-finish-loading-in-time Previous: how-to/audio/22-fix-plugin-problems#a-plugin-was-skipped-after-a-crash Next: how-to/audio/22-fix-plugin-problems#a-plugin-is-listed-but-will-not-load --- Fix Plugin Problems > A plugin has no GUI [guide] > **plugin does not support the CLAP GUI extension** Not every plugin has a GUI, and the plugins that come with resonon have none. 1. List its parameters with `.parameters()`, once it is on a track with `.set_effects()` or `.set_instrument()`. 2. Set them with `.set_parameter(name, value)`. 3. For a third-party plugin that should have a GUI, update it. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-has-no-gui Previous: how-to/audio/22-fix-plugin-problems#a-plugin-is-built-for-another-architecture Next: how-to/audio/22-fix-plugin-problems#the-plugin-database-is-empty --- Fix Plugin Problems > A plugin is built for another architecture [guide] > **built for x86_64, but resonon is arm64 — a plugin cannot be loaded across architectures** A VST3 or CLAP plugin loads into resonon's own process, and no system bridges that across architectures. Install a build of the plugin for resonon's architecture. A DAW may open the same plugin as an Audio Unit, which macOS can run in a separate process; VST3 and CLAP have no such bridge. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-is-built-for-another-architecture Previous: how-to/audio/22-fix-plugin-problems#a-plugin-is-listed-but-will-not-load Next: how-to/audio/22-fix-plugin-problems#a-plugin-has-no-gui --- Fix Plugin Problems > A plugin is listed, but will not load [guide] 1. Read the reason in the error. A bundle that will not open reports what the system said, with the paths the loader tried — usually enough to name a missing library. 2. Reinstall the plugin, in case the file is damaged. 3. Check the vendor's notes for libraries the plugin needs. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-is-listed-but-will-not-load Previous: how-to/audio/22-fix-plugin-problems#a-plugin-did-not-finish-loading-in-time Next: how-to/audio/22-fix-plugin-problems#a-plugin-is-built-for-another-architecture --- Fix Plugin Problems > A plugin is not found [guide] The error ends with a tip that says what the plugin database knows. > **Tip: the plugin database was last updated 3 days ago. If you installed this plugin since, run > `plugin_scan()` to pick it up.** 1. Run `plugin_scan()`, or **RESONON: Rescan Plugins**. Resonon also sweeps the plugin folders in the background every time it starts, so this is only needed for a plugin installed during a session. > **Tip: the plugin database is up to date, so this plugin does not appear to be installed. Check > the name, or run `plugin_scan()` after installing it.** 1. Check the name against `resonon plugin list`. 2. Check that the plugin is in a plugin folder: the standard folders for your OS, `CLAP_PATH` and `VST3_PATH`, or a folder you added with `resonon config plugins add "/path/to/plugins"` ([Plugin folders](/docs/reference/setup/03-home-and-search-paths/#plugin-folders)). Run `reload_preferences()` after adding a folder, and the plugins in it are found without a restart. 3. `resonon plugin scan` lists every folder it sweeps, and marks the ones that do not exist. 4. `resonon plugin list` also lists bundles that were **skipped**: one that crashed or hung while loading is set aside, and is never found by name. See the next two sections. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-is-not-found Next: how-to/audio/22-fix-plugin-problems#a-plugin-was-skipped-after-a-crash --- Fix Plugin Problems > A plugin was skipped after a crash [guide] > **plugin '/…/Foo.vst3' crashed the scan worker while loading** The bundle crashed the separate process that opens plugins during a scan, so it was set aside. 1. Update or reinstall the plugin. The next sweep tries a bundle again once it changes on disk. 2. To try the same build again — the crash may have been the machine's, not the plugin's — use the **Retry Foo.vst3** quick fix on the underlined call, or run `plugin_rescan('/…/Foo.vst3')`, or `resonon plugin rescan '/…/Foo.vst3'` in a terminal. 3. To see every skipped bundle and retry some of them, run **RESONON: Retry Skipped Plugins...** and tick the ones you want. 4. To open every bundle again, run `plugin_scan(force: true)`, **RESONON: Rescan Plugins (Full)** or `resonon plugin scan --force`. This is a full scan, and takes as long. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#a-plugin-was-skipped-after-a-crash Previous: how-to/audio/22-fix-plugin-problems#a-plugin-is-not-found Next: how-to/audio/22-fix-plugin-problems#a-plugin-did-not-finish-loading-in-time --- Fix Plugin Problems > Related [guide] - [Use a Plugin](/docs/how-to/audio/03-use-a-plugin/) — load, scan and control plugins - [The Plugin Database](/docs/explanation/audio/06-the-plugin-database/) — why plugins are scanned out of process - [VSCode Extension](/docs/reference/running/01-vscode-extension/#views-plugins-and-preferences) — the plugin commands Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#related Previous: how-to/audio/22-fix-plugin-problems#the-plugin-database-is-empty --- Fix Plugin Problems > The plugin database is empty [guide] > **No plugins in the database. It is normally built automatically in the background; run > `resonon plugin scan` to build it now.** 1. Run `resonon plugin scan`, or `plugin_scan()` in a session. 2. If it stays empty, check that automatic scanning is on: the VSCode setting `resonon.plugins.autoScan`, the `--plugin-auto-scan` flag and the `RESONON_PLUGIN_AUTO_SCAN` variable ([Environment Variables](/docs/reference/setup/01-cli/#environment-variables)). 3. After an upgrade, the database is rebuilt from nothing; it fills as the first sweep finishes. Page: how-to/audio/22-fix-plugin-problems URL: https://resonon.org/docs/how-to/audio/22-fix-plugin-problems/#the-plugin-database-is-empty Previous: how-to/audio/22-fix-plugin-problems#a-plugin-has-no-gui Next: how-to/audio/22-fix-plugin-problems#related --- Monitor Levels and Routing [guide] Use a connected live session for the editor views. Start playback, then inspect the mix before changing gain or routing. Sections: - how-to/audio/23-monitor-levels-and-routing#check-the-levels | Check the levels - how-to/audio/23-monitor-levels-and-routing#trace-the-route | Trace the route - how-to/audio/23-monitor-levels-and-routing#scope-a-modulation-signal | Scope a modulation signal Page: how-to/audio/23-monitor-levels-and-routing URL: https://resonon.org/docs/how-to/audio/23-monitor-levels-and-routing/ --- Monitor Levels and Routing > Check the levels [guide] 1. In VSCode, run **RESONON: Open Resonon Window** from the command palette. 2. Watch each track and the master through the loudest section. If levels are too high, reduce the contributing track's volume, then check the master again. 3. Evaluate a fader change against an existing track: ```resonon parse-only drums.volume << -6; ``` Volumes are in dB; `0` is unity. Keep room for tracks summing together and for later effects. You can also drag the fader in the Mixer; code reads the same value. For a running server, open its window with the editor commands or `window_show()`. From a terminal, `resonon app` starts its own session and main window. See [Use the Mixer](/docs/how-to/running/13-use-the-mixer/). Page: how-to/audio/23-monitor-levels-and-routing URL: https://resonon.org/docs/how-to/audio/23-monitor-levels-and-routing/#check-the-levels Next: how-to/audio/23-monitor-levels-and-routing#trace-the-route --- Monitor Levels and Routing > Scope a modulation signal [guide] Register the signal, then open the scope window with [`scope_show()`](/docs/reference/stdlib/audio/#scope_show): ```resonon parse-only use "std/signals" { Sine }; let movement = Sine(0.5).range(-1, 1); scope(movement, "pan movement"); PLAY; scope_show(length: cycles(4)); ``` Evaluate this in the live session. Each lane spans its signal's own range unless you give `min` and `max`. Give `length` enough time for one full period of a slow signal: `Sine(0.5)` takes two cycles. To change the view, call `scope_show()` again. To keep a picture of the scope, or to look at it without opening the window, [`scope_snap("scope.png")`](/docs/reference/stdlib/audio/#scope_snap) writes it to a PNG; it takes the same `min`, `max` and `length`. The terminal scope (**RESONON: Open Scope**) shows the same lanes; adjust its time and vertical ranges with the [scope keys](/docs/reference/running/05-terminal-views/#scope). `drums.rms` and `drums.peak` are MeterFeed values for binding to visuals; printing them does not read a numeric meter. Use the mixer to watch levels, or [bind a feed to a shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/). Page: how-to/audio/23-monitor-levels-and-routing URL: https://resonon.org/docs/how-to/audio/23-monitor-levels-and-routing/#scope-a-modulation-signal Previous: how-to/audio/23-monitor-levels-and-routing#trace-the-route --- Monitor Levels and Routing > Trace the route [guide] Run **RESONON: Open Routing**, select the track and press `Enter`. Check its instrument, effect order, output and sends. To print routing in the console instead: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); routing_report(drums); ``` Use `routing_report()` without arguments for the whole graph. If a track is silent, follow its output through any buses to master or to the intended hardware channels. Page: how-to/audio/23-monitor-levels-and-routing URL: https://resonon.org/docs/how-to/audio/23-monitor-levels-and-routing/#trace-the-route Previous: how-to/audio/23-monitor-levels-and-routing#check-the-levels Next: how-to/audio/23-monitor-levels-and-routing#scope-a-modulation-signal --- Improve Playback Performance [guide] Measure the same demanding section before and after each change. Keep the audio device, sample rate and block size fixed while comparing. Sections: - how-to/audio/24-improve-playback-performance#read-audio-load-during-playback | Read audio load during playback - how-to/audio/24-improve-playback-performance#compare-multicore-rendering | Compare multicore rendering - how-to/audio/24-improve-playback-performance#reduce-work-and-measure-again | Reduce work and measure again Page: how-to/audio/24-improve-playback-performance URL: https://resonon.org/docs/how-to/audio/24-improve-playback-performance/ --- Improve Playback Performance > Compare multicore rendering [guide] Save the source and plugin state, then compare fresh servers from the project directory: ```sh resonon --multicore=false server ``` Stop that server before starting the alternative: ```sh resonon --multicore=true server ``` Reconnect VSCode, evaluate the same piece and measure the same section. Check for inherited `RESONON_PARALLEL` in your shell: it overrides the flag. Keep the mode that gives this piece more reliable playback. Small sessions may gain nothing from multicore rendering. Page: how-to/audio/24-improve-playback-performance URL: https://resonon.org/docs/how-to/audio/24-improve-playback-performance/#compare-multicore-rendering Previous: how-to/audio/24-improve-playback-performance#read-audio-load-during-playback Next: how-to/audio/24-improve-playback-performance#reduce-work-and-measure-again --- Improve Playback Performance > Read audio load during playback [guide] In a live session, start the piece, let it reach the section you want to test, then evaluate: ```resonon let cpu = audio_cpu_load(); print(cpu); ``` `load` is smoothed audio callback load, and `peak` is its recent peak. A value of `1` means the callback used its whole available time. This is audio deadline usage, not the operating system's process CPU percentage. Leave margin for the loudest or busiest part of the piece. Page: how-to/audio/24-improve-playback-performance URL: https://resonon.org/docs/how-to/audio/24-improve-playback-performance/#read-audio-load-during-playback Next: how-to/audio/24-improve-playback-performance#compare-multicore-rendering --- Improve Playback Performance > Reduce work and measure again [guide] Simplify the busiest instrument or effect chain one change at a time. For a common reverb, try [sharing an effect with a send](/docs/how-to/audio/05-share-an-effect-with-a-send/) if that gives the sound you want. For visuals, reduce `screen.set_quality()` and compare again. If the live device still misses deadlines, try a larger supported `[audio] buffer_size` in preferences and apply it with `reload_preferences()` while no take is recording. Expect more monitoring latency; inspect `audio_latency()` after the change. See [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/) for device checks and [Command Line](/docs/reference/setup/01-cli/#options) for the flags. Page: how-to/audio/24-improve-playback-performance URL: https://resonon.org/docs/how-to/audio/24-improve-playback-performance/#reduce-work-and-measure-again Previous: how-to/audio/24-improve-playback-performance#compare-multicore-rendering --- Sidechain a Custom Effect [guide] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: An effect has one stereo input unless it declares its inputs. Declare a second one, and feed another track into it with `connect_input`. Sections: - how-to/dsp/01-sidechain-a-custom-effect#duck-one-track-with-another | Duck one track with another - how-to/dsp/01-sidechain-a-custom-effect#write-a-mono-effect | Write a mono effect - how-to/dsp/01-sidechain-a-custom-effect#related | Related Page: how-to/dsp/01-sidechain-a-custom-effect URL: https://resonon.org/docs/how-to/dsp/01-sidechain-a-custom-effect/ --- Sidechain a Custom Effect > Duck one track with another [guide] Declare the inputs and the output. `process` takes one argument per channel, in the order the inputs are declared — a stereo input gives two, a mono input one: ```resonon use "std/instruments" { Sampler, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("pad"); } dsp effect Ducker { input main: stereo; input sidechain: mono; output: stereo; param threshold: 0.3 range(0, 1); param ratio: 4.0 range(1, 20); state env: 0.0; fn process(main_l, main_r, sc) -> (out_l, out_r) { let over = __native("max", __native("abs", sc) - threshold, 0.0) * (1.0 - 1.0 / ratio); if over > env { env = env + (over - env) * 0.01; } else { env = env + (over - env) * 0.001; } let gain = 1.0 / (1.0 + env); return (main_l * gain, main_r * gain); } } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd _ bd _]; let pad = session.track("pad"); pad.set_instrument(Sampler(Kit("CR-78"))); pad << [cy cy cy cy]; let duck = Ducker("ducker"); pad.set_effects(#[duck]); duck.connect_input("sidechain", drums); PLAY; ``` The pad passes through `main`; the drums arrive on `sidechain` and pull the pad down on every hit. `connect_input` takes the name of a declared `input`, and the effect must be on its track first. The source reaches the input only; it is not mixed into the output. Page: how-to/dsp/01-sidechain-a-custom-effect URL: https://resonon.org/docs/how-to/dsp/01-sidechain-a-custom-effect/#duck-one-track-with-another Next: how-to/dsp/01-sidechain-a-custom-effect#write-a-mono-effect --- Sidechain a Custom Effect > Related [guide] - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/#dsp-effect) — every input and output form - [Duck with a Sidechain](/docs/how-to/audio/07-duck-with-a-sidechain/) — sidechain a plugin effect - [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/) — write an effect from the start Page: how-to/dsp/01-sidechain-a-custom-effect URL: https://resonon.org/docs/how-to/dsp/01-sidechain-a-custom-effect/#related Previous: how-to/dsp/01-sidechain-a-custom-effect#write-a-mono-effect --- Sidechain a Custom Effect > Write a mono effect [guide] Declare one mono input and a mono output, and `process` takes one sample and returns one: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("bass"); } dsp effect MonoGain { input main: mono; output: mono; param level: 1.0 range(0, 2); fn process(input) -> output { return input * level; } } let bass = session.track("bass"); bass.set_instrument(Sampler(Kit("CR-78"))); bass << [bd _ bd _]; bass.set_effects(#[MonoGain("monogain")]); PLAY; ``` Page: how-to/dsp/01-sidechain-a-custom-effect URL: https://resonon.org/docs/how-to/dsp/01-sidechain-a-custom-effect/#write-a-mono-effect Previous: how-to/dsp/01-sidechain-a-custom-effect#duck-one-track-with-another Next: how-to/dsp/01-sidechain-a-custom-effect#related --- Declare Latency [guide] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: An effect that looks ahead — a limiter, a linear-phase filter — outputs each sample some time after it gets it. Declare that delay with `latency:`, in samples, and the engine delays the other paths of the mix by the same amount, so every track stays in time. Sections: - how-to/dsp/02-declare-latency#declare-it-on-an-effect | Declare it on an effect - how-to/dsp/02-declare-latency#declare-it-on-an-instrument | Declare it on an instrument - how-to/dsp/02-declare-latency#get-the-number-right | Get the number right - how-to/dsp/02-declare-latency#related | Related Page: how-to/dsp/02-declare-latency URL: https://resonon.org/docs/how-to/dsp/02-declare-latency/ --- Declare Latency > Declare it on an effect [guide] ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("bass"); } dsp effect LookaheadLimiter { latency: 512; param ceiling: 0.8 range(0.1, 1); param release: 0.0005 range(0.00001, 0.01); buffer buf_l(512); buffer buf_r(512); state wp: 0; state gain: 1.0; state hold: 0; fn process(left, right) -> (out_l, out_r) { // The gain the incoming sample needs, from the louder channel. let peak = __native("max", __native("abs", left), __native("abs", right)); let target = if peak > ceiling { ceiling / peak } else { 1.0 }; // Drop at once, hold until that sample is out, then recover. if target < gain { gain = target; hold = 512.0; } else { if hold > 0.0 { hold = hold - 1.0; } else { gain = gain + (target - gain) * release; } } // Output the sample from 512 samples ago. let delayed_l = buf_l[wp]; let delayed_r = buf_r[wp]; buf_l[wp] = left; buf_r[wp] = right; wp = (wp + 1.0) % 512.0; return (delayed_l * gain, delayed_r * gain); } } let bass = session.track("bass"); bass.set_instrument(Sampler(Kit("CR-78"))); bass << [bd _ bd _]; bass.set_effects(#[LookaheadLimiter("limiter")]); PLAY; ``` The limiter sees each peak 512 samples before it outputs it, so the gain is already down when the peak goes out. The output is 512 samples late, and the block says so. Page: how-to/dsp/02-declare-latency URL: https://resonon.org/docs/how-to/dsp/02-declare-latency/#declare-it-on-an-effect Next: how-to/dsp/02-declare-latency#declare-it-on-an-instrument --- Declare Latency > Declare it on an instrument [guide] The same line goes into a `dsp instrument`: ```resonon parse-only dsp instrument LatentSynth { latency: 256; voice state phase: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { let freq = __native("mtof", note); phase = __native("fract", phase + freq * INV_SR); let sample = __native("sin", phase * TWOPI) * velocity * gate; return (sample, sample); } } ``` Page: how-to/dsp/02-declare-latency URL: https://resonon.org/docs/how-to/dsp/02-declare-latency/#declare-it-on-an-instrument Previous: how-to/dsp/02-declare-latency#declare-it-on-an-effect Next: how-to/dsp/02-declare-latency#get-the-number-right --- Declare Latency > Get the number right [guide] Declare the delay the block adds, and only that. The engine already knows the delay of what it builds for you, and adds your number to it. Without a `latency:` line the block declares `0`. A delay that changes with a parameter can't be declared: `latency:` is a fixed number of samples. Declare the largest one, and pad the shorter settings to it. Page: how-to/dsp/02-declare-latency URL: https://resonon.org/docs/how-to/dsp/02-declare-latency/#get-the-number-right Previous: how-to/dsp/02-declare-latency#declare-it-on-an-instrument Next: how-to/dsp/02-declare-latency#related --- Declare Latency > Related [guide] - [Recording & Latency](/docs/explanation/audio/05-recording-and-latency/) — how the engine compensates delay across the graph - [The Audio-Thread Contract](/docs/explanation/dsp/02-the-audio-thread-contract/#latency) — why latency is declared, not measured - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) — where `latency:` goes Page: how-to/dsp/02-declare-latency URL: https://resonon.org/docs/how-to/dsp/02-declare-latency/#related Previous: how-to/dsp/02-declare-latency#get-the-number-right --- Share DSP Code [guide] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: DSP code is shared in three ways. All three are inlined when the block is compiled, so a call costs nothing at audio rate. Pick the smallest one that does the job: | You need… | Write | | :-- | :-- | | a helper for one block | a `fn` inside that block | | the same pure function in several blocks | a `dsp fn` at the top of the file | | a component with its own state, in several places | a `dsp object` at the top of the file | Sections: - how-to/dsp/03-share-dsp-code#split-a-block-into-helpers | Split a block into helpers - how-to/dsp/03-share-dsp-code#share-a-pure-function | Share a pure function - how-to/dsp/03-share-dsp-code#share-a-component-with-state | Share a component with state - how-to/dsp/03-share-dsp-code#import-dsp-code-from-another-file | Import DSP code from another file - how-to/dsp/03-share-dsp-code#related | Related Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/ --- Share DSP Code > Import DSP code from another file [guide] Put the shared code in a module, and import it into another module with a selective `use`: ```resonon parse-only // filters.non dsp fn softclip(x) -> out { return x / (1.0 + __native("abs", x)); } dsp object OnePole { state prev: 0.0; fn lp(input, coeff) -> out { prev = prev + coeff * (input - prev); return prev; } } ``` ```resonon parse-only // warm.non use "./filters" { softclip, OnePole }; dsp effect Warm { param tone: 0.2 range(0, 1); fn process(input) -> output { let lp = OnePole(); return lp.lp(softclip(input), tone); } } ``` Only a module's `dsp` blocks can call imported DSP code — not the blocks in the file you run or in a selection you execute. To use `softclip` from your piece, import `Warm`, the block that calls it: ```resonon parse-only use "./warm" { Warm }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("bass"); } let bass = session.track("bass"); bass.set_effects(#[Warm("warm")]); ``` Mark a definition `private` to keep it out of the module's exports. Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/#import-dsp-code-from-another-file Previous: how-to/dsp/03-share-dsp-code#share-a-component-with-state Next: how-to/dsp/03-share-dsp-code#related --- Share DSP Code > Related [guide] - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) — the rules for helpers, `dsp fn` and `dsp object` - [Modules](/docs/reference/language/09-modules/) — `use`, selective imports and `private` Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/#related Previous: how-to/dsp/03-share-dsp-code#import-dsp-code-from-another-file --- Share DSP Code > Share a component with state [guide] When the shared code must remember something — a filter's last sample, a delay line — write a `dsp object`. Give it `state` and `buffer` declarations and methods with any names. Each `let x = OnePole()` in a block is a separate copy with its own state, so make one per channel: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } dsp object OnePole { state prev: 0.0; fn lp(input, coeff) -> out { prev = prev + coeff * (input - prev); return prev; } } dsp effect Smooth { param amount: 0.1 range(0.001, 1); fn process(left, right) -> (out_l, out_r) { let lp_l = OnePole(); let lp_r = OnePole(); return (lp_l.lp(left, amount), lp_r.lp(right, amount)); } } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; drums.set_effects(#[Smooth("smooth")]); PLAY; ``` An object has no `param`: its block's params reach it as arguments, like `amount` above. Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/#share-a-component-with-state Previous: how-to/dsp/03-share-dsp-code#share-a-pure-function Next: how-to/dsp/03-share-dsp-code#import-dsp-code-from-another-file --- Share DSP Code > Share a pure function [guide] Move the helper out of the block and prefix it with `dsp`. Every `dsp` block in the file can call it. A `dsp fn` has no `param`, `state` or `buffer`, and returns one value — call it once per channel: ```resonon dsp fn softclip(x) -> out { return x / (1.0 + __native("abs", x)); } dsp effect Saturate { param drive: 2.0 range(1, 10); fn process(left, right) -> (out_l, out_r) { return (softclip(left * drive), softclip(right * drive)); } } dsp instrument ClippedSine { voice state phase: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { phase = __native("fract", phase + __native("mtof", note) * INV_SR); let sample = softclip(__native("sin", phase * TWOPI) * 4.0) * velocity * gate; return (sample, sample); } } ``` Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/#share-a-pure-function Previous: how-to/dsp/03-share-dsp-code#split-a-block-into-helpers Next: how-to/dsp/03-share-dsp-code#share-a-component-with-state --- Share DSP Code > Split a block into helpers [guide] Any `fn` in a block besides `process` or `render` is a helper. It can read and write the block's `param`, `state` and `buffer` names, but only sees its own arguments — pass it what it needs: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } dsp effect SoftClipper { param drive: 2.0 range(1, 10); param mix: 0.5 range(0, 1); fn soft_clip(x) -> out { return x / (1.0 + __native("abs", x)); } fn blend(dry, wet) -> out { return dry * (1.0 - mix) + wet * mix; } fn process(left, right) -> (out_l, out_r) { return (blend(left, soft_clip(left * drive)), blend(right, soft_clip(right * drive))); } } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; drums.set_effects(#[SoftClipper("softclipper")]); PLAY; ``` Page: how-to/dsp/03-share-dsp-code URL: https://resonon.org/docs/how-to/dsp/03-share-dsp-code/#split-a-block-into-helpers Next: how-to/dsp/03-share-dsp-code#share-a-pure-function --- Write a Modulation Source [guide] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: When the built-in LFOs and envelopes don't do what you need, write a `dsp signal`. It is compiled like an effect, returns one value per sample, and binds with `<<` wherever a built-in signal does. Sections: - how-to/dsp/04-write-a-modulation-source#write-a-signal-and-bind-it | Write a signal and bind it - how-to/dsp/04-write-a-modulation-source#give-it-parameters | Give it parameters - how-to/dsp/04-write-a-modulation-source#lock-it-to-the-beat | Lock it to the beat - how-to/dsp/04-write-a-modulation-source#process-another-signal | Process another signal - how-to/dsp/04-write-a-modulation-source#follow-a-midi-controller | Follow a MIDI controller - how-to/dsp/04-write-a-modulation-source#related | Related Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/ --- Write a Modulation Source > Follow a MIDI controller [guide] `cc`, `pitchbend` and `aftertouch` read the live MIDI input: ```resonon dsp signal CcSmooth { range: 0..1 state value: 0.0; fn process() -> out { value = value + (__native("cc", 74) - value) * 0.001; return value; } } ``` This follows CC 74 on any channel, and glides to each new value instead of stepping. To read one channel only, add it after the CC number: `__native("cc", 74, 1)` reads channel 1 (channels are 1–16). Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#follow-a-midi-controller Previous: how-to/dsp/04-write-a-modulation-source#process-another-signal Next: how-to/dsp/04-write-a-modulation-source#related --- Write a Modulation Source > Give it parameters [guide] `param` works as in an effect. A signal's params are the arguments of its constructor: ```resonon dsp signal Wobble { range: 0..1 param speed: 4.0 range(0.1, 40); param depth: 0.5 range(0, 1); state phase: 0.0; fn process() -> out { phase = __native("fract", phase + speed * CPS * INV_SR); return 0.5 + depth * 0.5 * __native("sin", phase * TWOPI); } } let slow = Wobble(0.5); let shallow = Wobble(speed: 8, depth: 0.2); let wobbly = Wobble(Wobble(0.25).range(2, 8)); // speed moved by another signal ``` A param given a signal follows it sample by sample. Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#give-it-parameters Previous: how-to/dsp/04-write-a-modulation-source#write-a-signal-and-bind-it Next: how-to/dsp/04-write-a-modulation-source#lock-it-to-the-beat --- Write a Modulation Source > Lock it to the beat [guide] The clock constants follow the transport, so you don't need a phase of your own. `CYCLE_PHASE` and `BEAT_PHASE` ramp from `0` to `1` over each cycle or beat: ```resonon dsp signal CycleRamp { range: 0..1 fn process() -> out { return CYCLE_PHASE; } } ``` `BEAT_EDGE` and `CYCLE_EDGE` are `1` on the one sample where a beat or cycle starts. Use them to sample and hold — here, a new random value on every beat: ```resonon dsp signal BeatRandom { range: 0..1 state held: 0.0; fn process() -> out { if BEAT_EDGE > 0.0 { held = __native("noise") * 0.5 + 0.5; } else { held = held; } return held; } } ``` Every constant is listed in the [DSP builtins](/docs/reference/stdlib/dsp-builtins/#constants). Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#lock-it-to-the-beat Previous: how-to/dsp/04-write-a-modulation-source#give-it-parameters Next: how-to/dsp/04-write-a-modulation-source#process-another-signal --- Write a Modulation Source > Process another signal [guide] Give `process` arguments, and the signal takes other signals as inputs. They come first in the constructor, before the params: ```resonon use "std/signals" { Sine }; dsp signal Quantize { param steps: 4 range(1, 32); fn process(source) -> out { return __native("round", source * steps) / steps; } } let stepped = Quantize(Sine(2)); // input, positionally let finer = Quantize(source: Sine(2), steps: 16); let still = Quantize(0.5); // a number is a constant signal ``` Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#process-another-signal Previous: how-to/dsp/04-write-a-modulation-source#lock-it-to-the-beat Next: how-to/dsp/04-write-a-modulation-source#follow-a-midi-controller --- Write a Modulation Source > Related [guide] - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — the built-in LFOs, and what a signal can be bound to - [Signals & Time](/docs/explanation/audio/03-signals-and-time/) — when a bound signal starts and restarts - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/#dsp-signal) — everything a `dsp signal` can declare Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#related Previous: how-to/dsp/04-write-a-modulation-source#follow-a-midi-controller --- Write a Modulation Source > Write a signal and bind it [guide] A signal has one entry point, `fn process() -> out`: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } dsp signal Ramp { range: 0..1 state phase: 0.0; fn process() -> out { phase = __native("fract", phase + CPS * INV_SR); return phase; } } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let filter = Filter("lowpass", FilterType.lowpass, 2000); drums.set_effects(#[filter]); filter.parameter("Cutoff") << Ramp().range_exp(300, 4000); PLAY; ``` `phase` moves on by `CPS * INV_SR` in each sample — one whole turn per cycle. `Ramp()` makes an instance, and every signal method works on it: `.range_exp` maps it onto the cutoff. A signal's output is taken to go from `-1` to `1`. `range: 0..1` says this one goes from `0` to `1`, so `.range` and `.range_exp` map the right span. Page: how-to/dsp/04-write-a-modulation-source URL: https://resonon.org/docs/how-to/dsp/04-write-a-modulation-source/#write-a-signal-and-bind-it Next: how-to/dsp/04-write-a-modulation-source#give-it-parameters --- Ship a Native Extension [guide] A native extension is a Rust library that resonon loads and calls like a module. Use one to compute something — a wavetable, a scale, a pattern — that is too slow or impossible in resonon. It runs on the interpreter thread, not the audio thread: audio processing belongs in a [`dsp effect` or `dsp instrument`](/docs/tutorials/dsp/01-your-first-effect/). See [Native Extensions: Safety & Threading](/docs/explanation/dsp/04-native-extension-safety-and-threading/) before you ship one. :::caution[Experimental] The `resonon-ext` crate that extensions build against is not published yet, so a scaffolded project builds only where that crate is reachable. Expect breaking changes until it is published and its ABI is versioned. ::: You need the [Rust toolchain](https://rustup.rs); check it with `cargo --version`. Sections: - how-to/dsp/05-ship-a-native-extension#scaffold-the-project | Scaffold the project - how-to/dsp/05-ship-a-native-extension#expose-functions-and-classes | Expose functions and classes - how-to/dsp/05-ship-a-native-extension#wrap-them-in-libnon | Wrap them in lib.non - how-to/dsp/05-ship-a-native-extension#build-and-use-it | Build and use it - how-to/dsp/05-ship-a-native-extension#reload-it-while-you-work | Reload it while you work - how-to/dsp/05-ship-a-native-extension#publish-prebuilt-binaries | Publish prebuilt binaries - how-to/dsp/05-ship-a-native-extension#related | Related Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/ --- Ship a Native Extension > Build and use it [guide] ```bash resonon build ``` This builds the crate in release mode and copies the library into `bin/`. Import the package by its name; the module is bound under that name with `-` changed to `_`: ```resonon parse-only use "my-ext"; print(my_ext.double(21)); // 42 let s = my_ext.Stepper(#[60, 62, 64, 67]); print(s.next()); // 60 print(s.next()); // 62 ``` Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#build-and-use-it Previous: how-to/dsp/05-ship-a-native-extension#wrap-them-in-libnon Next: how-to/dsp/05-ship-a-native-extension#reload-it-while-you-work --- Ship a Native Extension > Expose functions and classes [guide] In `native/src/lib.rs`, mark each function with `#[ext_fn]`, and list it in `resonon_extension!`: ```rust use resonon_ext::prelude::*; #[ext_fn(doc = "Doubles a number")] fn double(x: f64) -> f64 { x * 2.0 } resonon_extension! { name: "my_ext", functions: [double] } ``` For an object that keeps state, add a class, a constructor and methods. Every constructor and method goes into `functions`, and the class into `classes`: ```rust use resonon_ext::prelude::*; /// A step sequencer that cycles through values. #[ext_class] struct Stepper { values: Vec, index: usize, } #[ext_new(doc = "Create a stepper from an array of values")] fn stepper_new(values: Vec) -> Stepper { Stepper { values, index: 0 } } #[ext_method(Stepper, doc = "Get the next value in the sequence")] fn stepper_next(s: &mut Stepper) -> f64 { if s.values.is_empty() { return 0.0; } let val = s.values[s.index % s.values.len()]; s.index += 1; val } #[ext_method(Stepper, doc = "Read the current step index")] fn stepper_index(s: &Stepper) -> f64 { s.index as f64 } resonon_extension! { name: "my_ext", functions: [stepper_new, stepper_next, stepper_index], classes: [Stepper] } ``` The macros and the types they accept are in the [Native Extensions reference](/docs/reference/dsp/02-native-extensions/). Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#expose-functions-and-classes Previous: how-to/dsp/05-ship-a-native-extension#scaffold-the-project Next: how-to/dsp/05-ship-a-native-extension#wrap-them-in-libnon --- Ship a Native Extension > Publish prebuilt binaries [guide] Build a binary named for your platform, and commit it: ```bash resonon build --dist ``` This writes, for example, `bin/my_ext-macos-aarch64.dylib`. The scaffolded `.gitignore` already ignores the local build and keeps these. Build and commit one per platform you support, then push the repository. When someone runs `resonon pkg install gh:you/my-ext`, resonon builds the extension from source. If that build fails — on a machine without the Rust toolchain, say — the committed binary for their platform is used instead. Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#publish-prebuilt-binaries Previous: how-to/dsp/05-ship-a-native-extension#reload-it-while-you-work Next: how-to/dsp/05-ship-a-native-extension#related --- Ship a Native Extension > Related [guide] - [Native Extensions](/docs/reference/dsp/02-native-extensions/) — macros, types, and where resonon looks for the library - [Publish a Package](/docs/how-to/setup/04-publish-a-package/) — push a package and tag its versions - [Fix Install and Project Problems](/docs/how-to/setup/06-fix-install-and-project-problems/) — a package that is not found or has nothing in it Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#related Previous: how-to/dsp/05-ship-a-native-extension#publish-prebuilt-binaries --- Ship a Native Extension > Reload it while you work [guide] After a change to the Rust code, build again in a terminal, then reload the extension in your session instead of restarting it: ```resonon parse-only reload_ext("my_ext"); ``` The reload fails while any object from the extension is still alive. Reassign or drop the variables that hold them first — `s` above. Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#reload-it-while-you-work Previous: how-to/dsp/05-ship-a-native-extension#build-and-use-it Next: how-to/dsp/05-ship-a-native-extension#publish-prebuilt-binaries --- Ship a Native Extension > Scaffold the project [guide] ```bash resonon new my-ext --native cd my-ext ``` ``` my-ext/ resonon.toml # manifest, with a [native] section src/ lib.non # the resonon-facing API native/ # the Rust crate Cargo.toml src/lib.rs bin/ # built libraries go here ``` Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#scaffold-the-project Next: how-to/dsp/05-ship-a-native-extension#expose-functions-and-classes --- Ship a Native Extension > Wrap them in lib.non [guide] Users don't call Rust directly. `src/lib.non` is an ordinary module whose functions call into the extension with `__ext(extension, function, ...args)`. Each `#[ext_class]` is declared as a [native class](/docs/reference/language/07-classes/#native-classes) of the same name, whose methods pass `this` back to the extension: ```resonon parse-only //! my-ext — custom pattern generators. /// Doubles a number. fn double(x) { return __ext("my_ext", "double", x); } /// A step sequencer that cycles through values. native class Stepper { /// The current step index. let index: Number { return __ext("my_ext", "stepper_index", this); } /// The next value in the sequence. fn next() -> Number { return __ext("my_ext", "stepper_next", this); } } /// Creates a stepper from values. fn Stepper(values) -> Stepper { return __ext("my_ext", "stepper_new", values); } ``` An object the extension returns is a `Stepper` because `lib.non` declares one. An object whose class no `native class` declares is refused with an error. `stepper.index` runs its field body on each read. The body uses an ordinary `#[ext_method]` export; no additional macro or manifest entry is needed. Keep a field body a cheap read. Assigning `stepper.index` is an error; `stepper.next()` remains a method because it advances state. Page: how-to/dsp/05-ship-a-native-extension URL: https://resonon.org/docs/how-to/dsp/05-ship-a-native-extension/#wrap-them-in-libnon Previous: how-to/dsp/05-ship-a-native-extension#expose-functions-and-classes Next: how-to/dsp/05-ship-a-native-extension#build-and-use-it --- Fix Language Errors [guide] Find the message, then work through the fix. Quoted blocks are what resonon prints; most errors name the file, line and column where they happened. Every kind of error is listed in [Errors & Warnings](/docs/reference/language/10-errors-and-warnings/). Sections: - how-to/language/01-fix-language-errors#undefined-function | Undefined function - how-to/language/01-fix-language-errors#type-error | Type error - how-to/language/01-fix-language-errors#wrong-number-of-arguments | Wrong number of arguments - how-to/language/01-fix-language-errors#index-out-of-bounds | Index out of bounds - how-to/language/01-fix-language-errors#a-name-is-defined-twice | A name is defined twice - how-to/language/01-fix-language-errors#a-definition-is-inside-a-function | A definition is inside a function - how-to/language/01-fix-language-errors#related | Related Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/ --- Fix Language Errors > A definition is inside a function [guide] > **Parse error at …/src/main.non:2:5: \`fn\` is a definition, and a definition is written at the top > level of a file. For a local function, bind a closure: let f = fn(x) { ... };** `fn`, `class`, `enum` and `dsp` definitions go at the top level of a file, outside any function, loop or block. 1. Move the definition out, above the code that uses it. 2. Or, for a helper that belongs to one place, bind a closure: ```resonon fn outer() { let inner = fn(x) { return x * 2; }; return inner(21); } print(outer()); ``` Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#a-definition-is-inside-a-function Previous: how-to/language/01-fix-language-errors#a-name-is-defined-twice Next: how-to/language/01-fix-language-errors#related --- Fix Language Errors > A name is defined twice [guide] > **Duplicate definition at …/src/main.non:2:1: fn 'greet' repeats the fn at 1:1.** > **A name has one definition: rename one of them.** Within the code you run, a name has one definition: one `fn`, `class`, `enum` or `dsp` block, not also a `let` or an import, and one method or field of that name in a class. Nothing in that code runs until the repeat is gone. The message names both places. 1. If the two are different things, rename one of them, and its uses. 2. If you meant a second version with more parameters, keep one definition and give the extra parameters default values: ```resonon fn greet(name = "world") { return "hello " + name; } print(greet()); print(greet("band")); ``` 3. If a `use` is one of the two, rename the import with `as`, or import only the names you need: ```resonon no-check use "./a.non" { foo }; use "./b.non" { foo as b_foo }; ``` Or import the module under a name of your own, and reach through it: ```resonon no-check use "./b.non" as b; b.foo(); ``` 4. If you meant to replace the old definition, run the new one on its own. A later run replaces whatever the name meant, an import included; only a repeat within one run is refused. Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#a-name-is-defined-twice Previous: how-to/language/01-fix-language-errors#index-out-of-bounds Next: how-to/language/01-fix-language-errors#a-definition-is-inside-a-function --- Fix Language Errors > Index out of bounds [guide] > **Index out of bounds at …/src/main.non:2:8: index 5 is out of range for length 3** Arrays count from 0, so an array of length 3 has the indices 0, 1 and 2. 1. Check the length with `.length()`. 2. To go round an array, take the index modulo its length: ```resonon let arr = #[10, 20, 30]; for i in range(6) { print(arr[i % arr.length()]); // 10, 20, 30, 10, 20, 30 } ``` Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#index-out-of-bounds Previous: how-to/language/01-fix-language-errors#wrong-number-of-arguments Next: how-to/language/01-fix-language-errors#a-name-is-defined-twice --- Fix Language Errors > Related [guide] - [Modules](/docs/reference/language/09-modules/) — how `use` binds names - [Functions](/docs/reference/language/06-functions/) — parameters and default values - [Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/) — why a name has one definition, and why definitions belong to the file Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#related Previous: how-to/language/01-fix-language-errors#a-definition-is-inside-a-function --- Fix Language Errors > Type error [guide] > **Type error at …/src/main.non:1:13: expected Number, got String** A value of the wrong type reached a function or operator. The column points at it. 1. Check what you passed against the signature. Hover the function in VSCode to see it. 2. A MIDI note is a number or a note name: `60` or `C4`, not `"60"`. 3. The rules for each type: [Values & Types](/docs/reference/language/01-values-and-types/). Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#type-error Previous: how-to/language/01-fix-language-errors#undefined-function Next: how-to/language/01-fix-language-errors#wrong-number-of-arguments --- Fix Language Errors > Undefined function [guide] > **Undefined function 'Delay' at …/src/main.non:3:9** 1. Check the spelling. Names are case-sensitive: `Delay`, not `delay`. 2. Import it. Effects, instruments and signals come from standard-library modules, so name them in a `use` first: ```resonon use "std/effects" { Delay, Reverb }; use "std/instruments" { Sampler, Kit }; use "std/signals" { Sine }; ``` Every module and what it exports is in the [standard library reference](/docs/reference/stdlib/). 3. For a function from your own module, `use` that module — see [Modules](/docs/reference/language/09-modules/). Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#undefined-function Next: how-to/language/01-fix-language-errors#type-error --- Fix Language Errors > Wrong number of arguments [guide] > **Arity mismatch at …/src/main.non:2:2: 'AudioTrack.pan' expects 1 arguments, got 2** Compare the call with the signature the message names. Hover the name in VSCode, or look it up in the [standard library reference](/docs/reference/stdlib/). Page: how-to/language/01-fix-language-errors URL: https://resonon.org/docs/how-to/language/01-fix-language-errors/#wrong-number-of-arguments Previous: how-to/language/01-fix-language-errors#type-error Next: how-to/language/01-fix-language-errors#index-out-of-bounds --- Split a Piece into Modules [guide] Use local modules to share definitions without repeating them in the main piece. Sections: - how-to/language/02-split-a-piece-into-modules#extract-a-pattern-helper | Extract a pattern helper - how-to/language/02-split-a-piece-into-modules#pick-up-an-edit | Pick up an edit - how-to/language/02-split-a-piece-into-modules#keep-imports-unambiguous | Keep imports unambiguous Page: how-to/language/02-split-a-piece-into-modules URL: https://resonon.org/docs/how-to/language/02-split-a-piece-into-modules/ --- Split a Piece into Modules > Extract a pattern helper [guide] Create `src/patterns.non` beside `src/main.non` and save: ```resonon fn kick() { return [bd _ bd _]; } ``` Keep track creation in the main piece for this example. In `src/main.non`, save: ```resonon parse-only use "./patterns" as grooves; use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << grooves.kick(); PLAY; ``` Evaluate the main file in VSCode. The relative import is resolved from the importing file, so both files can move together with the project. Page: how-to/language/02-split-a-piece-into-modules URL: https://resonon.org/docs/how-to/language/02-split-a-piece-into-modules/#extract-a-pattern-helper Next: how-to/language/02-split-a-piece-into-modules#pick-up-an-edit --- Split a Piece into Modules > Keep imports unambiguous [guide] Use a module alias when helpers in different files have the same name. For helpers used only inside the module, add `private` before their definitions. If two modules import each other, move the shared definitions into a third file and import it from both. [Modules](/docs/reference/language/09-modules/) lists the import forms; [Module Identity](/docs/explanation/language/05-module-identity/) explains reuse and reloads. Page: how-to/language/02-split-a-piece-into-modules URL: https://resonon.org/docs/how-to/language/02-split-a-piece-into-modules/#keep-imports-unambiguous Previous: how-to/language/02-split-a-piece-into-modules#pick-up-an-edit --- Split a Piece into Modules > Pick up an edit [guide] Change the returned pattern in `patterns.non` and save it. Re-evaluate the `use` and the line that sends `grooves.kick()` to the track. The edited module is evaluated again, and the new pattern is sent to the existing track. Check the change at the next cycle boundary. Page: how-to/language/02-split-a-piece-into-modules URL: https://resonon.org/docs/how-to/language/02-split-a-piece-into-modules/#pick-up-an-edit Previous: how-to/language/02-split-a-piece-into-modules#extract-a-pattern-helper Next: how-to/language/02-split-a-piece-into-modules#keep-imports-unambiguous --- Send MIDI to a Synth or DAW [guide] A `MidiTrack` plays its pattern out of a MIDI port on one channel, chosen with `>>`. Every method is in the [MIDI reference](/docs/reference/stdlib/midi/#miditrack); the port keys are in [Preferences](/docs/reference/setup/02-preferences/#midioutputs-and-midiinputs). Sections: - how-to/midi/01-send-midi-to-a-synth-or-daw#declare-an-output-port | Declare an output port - how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-pattern-on-a-track | Play a pattern on a track - how-to/midi/01-send-midi-to-a-synth-or-daw#use-several-channels | Use several channels - how-to/midi/01-send-midi-to-a-synth-or-daw#send-tracks-to-different-ports | Send tracks to different ports - how-to/midi/01-send-midi-to-a-synth-or-daw#set-the-velocity | Set the velocity - how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-daw-instrument | Play a DAW instrument - how-to/midi/01-send-midi-to-a-synth-or-daw#check-what-is-connected | Check what is connected - how-to/midi/01-send-midi-to-a-synth-or-daw#related | Related Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/ --- Send MIDI to a Synth or DAW > Check what is connected [guide] ```resonon print(midi_output_ports()); // every output port on the system print(midi_connected()); // {alias: port} for each connected port midi_routing_report(); // ports, tracks and clock, in one summary ``` Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#check-what-is-connected Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-daw-instrument Next: how-to/midi/01-send-midi-to-a-synth-or-daw#related --- Send MIDI to a Synth or DAW > Declare an output port [guide] Ports belong to the machine, so they are declared in `~/.resonon/preferences.toml`, not in the piece. The piece names a port by its alias: ```toml [[midi.outputs]] alias = "synth" port = "IAC Driver Bus 1" ``` `resonon --list-ports` prints a ready-to-paste entry for every attached device, and `resonon setup` writes the entries for you. The port name matches exactly, then as a substring, so `"IAC"` finds `"IAC Driver Bus 1"`. Run `reload_preferences()` to put a change in force without restarting. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#declare-an-output-port Next: how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-pattern-on-a-track --- Send MIDI to a Synth or DAW > Play a DAW instrument [guide] 1. Enable a virtual port. On macOS, open **Audio MIDI Setup**, choose **Window → Show MIDI Studio**, double-click **IAC Driver**, and check **Device is online**. 2. Declare it as an output, as above. 3. In the DAW, enable the port as a MIDI input, create an instrument track, set its MIDI input to the port, and turn on input monitoring. 4. Play a track from resonon. To record it as a MIDI clip, arm the DAW track and record. For several instruments, create one DAW track per channel, all listening to the same port. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#play-a-daw-instrument Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#set-the-velocity Next: how-to/midi/01-send-midi-to-a-synth-or-daw#check-what-is-connected --- Send MIDI to a Synth or DAW > Play a pattern on a track [guide] Create a track, route it to the port with `>>`, and send it a pattern with `<<`: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("lead"); } let lead = session.midi_track("lead"); lead >> MidiOutput("synth"); lead << [C4 E4 G4 E4]; PLAY; ``` The track plays on channel 1 at velocity 100. A new track has no output — Live's "No Output" — so until the `>>` line runs it sends nothing. Send it another pattern at any time; the new one starts on the next cycle. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#play-a-pattern-on-a-track Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#declare-an-output-port Next: how-to/midi/01-send-midi-to-a-synth-or-daw#use-several-channels --- Send MIDI to a Synth or DAW > Related [guide] - [MIDI Tracks & Time](/docs/explanation/midi/01-midi-tracks-and-time/) — a track's name, its lifetime and the shared cycle - [Sync to a MIDI Clock](/docs/how-to/midi/05-sync-to-a-midi-clock/) — lock a DAW's tempo to resonon - [Fix MIDI Problems](/docs/how-to/midi/09-fix-midi-problems/) — no notes, missing ports, stuck notes Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#related Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#check-what-is-connected --- Send MIDI to a Synth or DAW > Send tracks to different ports [guide] Declare a port per destination, each under its own alias: ```toml [[midi.outputs]] alias = "daw" port = "IAC Driver Bus 1" [[midi.outputs]] alias = "synth" port = "Prophet Rev2" optional = true ``` `optional = true` marks gear that is not always plugged in; its absence is expected instead of reported. Route each track to its alias, and move it with another `>>`: ```resonon // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("pad"); session.create_midi_track("lead"); } let pad = session.midi_track("pad"); let lead = session.midi_track("lead"); pad >> MidiOutput("synth"); lead >> MidiOutput("daw", 2); // to the DAW, channel 2 lead >> MidiOutput("synth", 5); // to the synth, channel 5 lead >> session.nowhere; // no output: the track keeps its pattern and sends nothing ``` A track playing a pattern moves to the new port or channel on the next cycle, with its CC and input thru. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#send-tracks-to-different-ports Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#use-several-channels Next: how-to/midi/01-send-midi-to-a-synth-or-daw#set-the-velocity --- Send MIDI to a Synth or DAW > Set the velocity [guide] `.set_velocity()` sets the velocity for every note without a `^` velocity of its own. Give it a number, a pattern, or a signal: ```resonon use "std/signals" { Sine }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("melody"); } let melody = session.midi_track("melody"); melody >> MidiOutput("synth"); melody << [C4^100 D4 E4 F4^50]; melody.set_velocity(80); // fixed melody.set_velocity([100 60 80 120]); // one value per step melody.set_velocity(Sine(0.5).range(60, 127)); // read as each note fires ``` The last call wins. The `^` velocities on `C4` and `F4` always stay. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#set-the-velocity Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#send-tracks-to-different-ports Next: how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-daw-instrument --- Send MIDI to a Synth or DAW > Use several channels [guide] Give `MidiOutput` a channel as its second argument. A multi-timbral synth or a DAW plays each channel with its own sound: ```resonon // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("lead"); session.create_midi_track("bass"); session.create_midi_track("drums"); } let lead = session.midi_track("lead"); let bass = session.midi_track("bass").set_velocity(80); let drums = session.midi_track("drums").set_velocity(110); lead >> MidiOutput("synth", 1); bass >> MidiOutput("synth", 2); drums >> MidiOutput("synth", 10); lead << [E5 D5 C5 D5]; bass << [C3 _ C3 G2]; drums << [C2 _ D2 _]; PLAY; ``` Channel 10 is General MIDI drums. Page: how-to/midi/01-send-midi-to-a-synth-or-daw URL: https://resonon.org/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/#use-several-channels Previous: how-to/midi/01-send-midi-to-a-synth-or-daw#play-a-pattern-on-a-track Next: how-to/midi/01-send-midi-to-a-synth-or-daw#send-tracks-to-different-ports --- Play Through from a Keyboard [guide] A MIDI track can take notes from an input port and pass them on to its own output. Every method is in the [MIDI reference](/docs/reference/stdlib/midi/#set_input); [Monitoring & Thru](/docs/explanation/midi/02-monitoring-and-thru/) explains what happens to the notes on the way. Sections: - how-to/midi/02-play-through-from-a-keyboard#declare-an-input-port | Declare an input port - how-to/midi/02-play-through-from-a-keyboard#play-a-synth-from-the-keyboard | Play a synth from the keyboard - how-to/midi/02-play-through-from-a-keyboard#listen-to-one-channel-or-every-port | Listen to one channel, or every port - how-to/midi/02-play-through-from-a-keyboard#stop-hearing-the-input | Stop hearing the input - how-to/midi/02-play-through-from-a-keyboard#disconnect-the-keyboard | Disconnect the keyboard - how-to/midi/02-play-through-from-a-keyboard#related | Related Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/ --- Play Through from a Keyboard > Declare an input port [guide] Add a `[[midi.inputs]]` entry to `~/.resonon/preferences.toml` and run `reload_preferences()`: ```toml [[midi.inputs]] alias = "kb" port = "KeyStep" optional = true ``` The port name matches exactly, then as a substring: `"KeyStep"` finds `"Arturia KeyStep 37"`. If several ports match, the first wins. `optional = true` is for a controller you don't always have plugged in. `midi_input_ports()` lists what the system offers: ```resonon print(midi_input_ports()); ``` Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#declare-an-input-port Next: how-to/midi/02-play-through-from-a-keyboard#play-a-synth-from-the-keyboard --- Play Through from a Keyboard > Disconnect the keyboard [guide] ```resonon parse-only midi_input_disconnect("kb"); ``` Tracks that were playing it through get an all-notes-off, so nothing hangs. Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#disconnect-the-keyboard Previous: how-to/midi/02-play-through-from-a-keyboard#stop-hearing-the-input Next: how-to/midi/02-play-through-from-a-keyboard#related --- Play Through from a Keyboard > Listen to one channel, or every port [guide] Add a channel to take only that channel from the port. Use `"all"` to take every connected input: ```resonon // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("bass"); session.create_midi_track("omni"); } let bass = session.midi_track("bass").set_input("kb", 1); // channel 1 of "kb" only let omni = session.midi_track("omni").set_input("all"); // every input port ``` A track has one input. Calling `.set_input()` again replaces it. Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#listen-to-one-channel-or-every-port Previous: how-to/midi/02-play-through-from-a-keyboard#play-a-synth-from-the-keyboard Next: how-to/midi/02-play-through-from-a-keyboard#stop-hearing-the-input --- Play Through from a Keyboard > Play a synth from the keyboard [guide] Route the input into a track, turn monitoring on, and route the track's output: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("keys"); } let keys = session.midi_track("keys") .set_input("kb") .set_monitor(Monitor.input); keys >> MidiOutput("synth"); ``` What you play on the keyboard comes out of the `"synth"` port, on the output's channel. Declare that port as in [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/). A track with no output has nowhere to send its input, so nothing comes through until the `>>` line runs. Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#play-a-synth-from-the-keyboard Previous: how-to/midi/02-play-through-from-a-keyboard#declare-an-input-port Next: how-to/midi/02-play-through-from-a-keyboard#listen-to-one-channel-or-every-port --- Play Through from a Keyboard > Related [guide] - [Map a Controller](/docs/how-to/midi/03-map-a-controller/) — use knobs and faders as signals - [Monitoring & Thru](/docs/explanation/midi/02-monitoring-and-thru/) — channel remapping and feedback protection - [Preferences](/docs/reference/setup/02-preferences/#midioutputs-and-midiinputs) — every port key Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#related Previous: how-to/midi/02-play-through-from-a-keyboard#disconnect-the-keyboard --- Play Through from a Keyboard > Stop hearing the input [guide] Set the monitor back to `Monitor.off`, the default: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("keys"); } let keys = session.midi_track("keys").set_input("kb"); keys.set_monitor(Monitor.off); ``` | Mode | What reaches the output | | --- | --- | | `Monitor.off` | Nothing from the input | | `Monitor.input` | Everything from the input | | `Monitor.auto` | Everything from the input while the transport is stopped or the track has no pattern; nothing while the track plays its pattern | Page: how-to/midi/02-play-through-from-a-keyboard URL: https://resonon.org/docs/how-to/midi/02-play-through-from-a-keyboard/#stop-hearing-the-input Previous: how-to/midi/02-play-through-from-a-keyboard#listen-to-one-channel-or-every-port Next: how-to/midi/02-play-through-from-a-keyboard#disconnect-the-keyboard --- Map a Controller [guide] `Cc()` turns a controller's CC messages into a signal from `0` to `1`, which you can send into any parameter. `Cc` and `Cc_learn` are in the [signals reference](/docs/reference/stdlib/signals/#cc). The controller needs an input port — see [Play Through from a Keyboard](/docs/how-to/midi/02-play-through-from-a-keyboard/#declare-an-input-port). Sections: - how-to/midi/03-map-a-controller#read-a-knob | Read a knob - how-to/midi/03-map-a-controller#find-a-knobs-cc-number | Find a knob's CC number - how-to/midi/03-map-a-controller#drive-a-parameter | Drive a parameter - how-to/midi/03-map-a-controller#related | Related Page: how-to/midi/03-map-a-controller URL: https://resonon.org/docs/how-to/midi/03-map-a-controller/ --- Map a Controller > Drive a parameter [guide] Smooth the steps, scale to the parameter's range, and send it with `<<`: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType, Delay }; use "std/signals" { Cc }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let filter = Filter("lowpass", FilterType.lowpass, 2000); let delay = Delay("delay", 0.25, 0.5); drums.set_effects(#[filter, delay]); filter.parameter("Cutoff") << Cc(74).smooth(50).range_exp(200, 8000); delay.parameter("Feedback") << Cc(71).smooth(30).range(0.1, 0.6); drums.volume << Cc(7).range(-60, 0); ``` - `.smooth(ms)` removes the zipper noise of a CC's 128 steps. How much to smooth depends on the parameter; see [Step a Parameter Through Values](/docs/how-to/audio/10-step-a-parameter-through-values/#smooth-the-jumps). - `.range_exp()` suits frequencies, where the ear hears ratios; `.range()` suits linear values. A few CC numbers are near-universal: **1** mod wheel, **7** volume, **10** pan, **11** expression, **64** sustain, **71** resonance, **74** cutoff. Page: how-to/midi/03-map-a-controller URL: https://resonon.org/docs/how-to/midi/03-map-a-controller/#drive-a-parameter Previous: how-to/midi/03-map-a-controller#find-a-knobs-cc-number Next: how-to/midi/03-map-a-controller#related --- Map a Controller > Find a knob's CC number [guide] Run `Cc_learn()` and move the knob within ten seconds: ```resonon parse-only use "std/signals" { Cc_learn }; let knob = Cc_learn(); // Waiting for CC input... (10s timeout) // Learned: Cc(74, 1) ``` It returns a signal bound to that knob and prints the `Cc(...)` call for it. Replace `Cc_learn()` with that call so the script doesn't stop to learn each time. With no CC in ten seconds, it is an error. Page: how-to/midi/03-map-a-controller URL: https://resonon.org/docs/how-to/midi/03-map-a-controller/#find-a-knobs-cc-number Previous: how-to/midi/03-map-a-controller#read-a-knob Next: how-to/midi/03-map-a-controller#drive-a-parameter --- Map a Controller > Read a knob [guide] Give the CC number. Add a channel (1–16) when two controllers send the same number: ```resonon use "std/signals" { Cc }; let cutoff = Cc(74); // CC 74 on any channel let wheel = Cc(1, 1); // CC 1 on channel 1 only ``` Every input port feeds `Cc()`, whether or not a track uses it. Page: how-to/midi/03-map-a-controller URL: https://resonon.org/docs/how-to/midi/03-map-a-controller/#read-a-knob Next: how-to/midi/03-map-a-controller#find-a-knobs-cc-number --- Map a Controller > Related [guide] - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — shape and combine signals - [Send CC Automation](/docs/how-to/midi/04-send-cc-automation/) — send CC out to a synth - [Signals reference](/docs/reference/stdlib/signals/) — `Cc`, `Cc_learn`, `.smooth()`, `.range()` Page: how-to/midi/03-map-a-controller URL: https://resonon.org/docs/how-to/midi/03-map-a-controller/#related Previous: how-to/midi/03-map-a-controller#drive-a-parameter --- Send CC Automation [guide] `.cc(number)` on a MIDI track gives a CC lane. Send it a value, a pattern or a signal with `<<`. The lane is in the [MIDI reference](/docs/reference/stdlib/midi/#cc). Sections: - how-to/midi/04-send-cc-automation#send-a-fixed-value | Send a fixed value - how-to/midi/04-send-cc-automation#send-a-sweep | Send a sweep - how-to/midi/04-send-cc-automation#send-values-in-time-with-the-notes | Send values in time with the notes - how-to/midi/04-send-cc-automation#remap-one-controller-to-another | Remap one controller to another - how-to/midi/04-send-cc-automation#send-a-signal-more-often | Send a signal more often - how-to/midi/04-send-cc-automation#related | Related Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/ --- Send CC Automation > Related [guide] - [Map a Controller](/docs/how-to/midi/03-map-a-controller/) — read a controller's CC as a signal - [MIDI Tracks & Time](/docs/explanation/midi/01-midi-tracks-and-time/) — signal lanes and pattern lanes - [Export MIDI](/docs/how-to/midi/08-export-midi/) — write CC lanes to a file Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#related Previous: how-to/midi/04-send-cc-automation#send-a-signal-more-often --- Send CC Automation > Remap one controller to another [guide] A controller's CC is a signal too, so you can pass it on under another number — here the mod wheel drives the synth's cutoff: ```resonon use "std/signals" { Cc }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("synth"); } let synth = session.midi_track("synth"); synth >> MidiOutput("synth"); synth.cc(74) << Cc(1).range(0, 127); ``` Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#remap-one-controller-to-another Previous: how-to/midi/04-send-cc-automation#send-values-in-time-with-the-notes Next: how-to/midi/04-send-cc-automation#send-a-signal-more-often --- Send CC Automation > Send a fixed value [guide] ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("synth"); } let synth = session.midi_track("synth"); synth >> MidiOutput("synth"); synth.cc(7) << 100; ``` The value is sent once, and again whenever you change it. Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#send-a-fixed-value Next: how-to/midi/04-send-cc-automation#send-a-sweep --- Send CC Automation > Send a signal more often [guide] `.set_send_rate(hz)` changes how often a signal is sent. Higher is smoother, and uses more of the port's bandwidth: ```resonon continue synth.cc(74).set_send_rate(60) << Cc(1).range(0, 127); ``` At most one message is sent per audio buffer, about 90 per second at common settings, so a much higher rate gains nothing. Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#send-a-signal-more-often Previous: how-to/midi/04-send-cc-automation#remap-one-controller-to-another Next: how-to/midi/04-send-cc-automation#related --- Send CC Automation > Send a sweep [guide] Send a signal. Its value is sent 30 times a second, and only when it changes: ```resonon use "std/signals" { Sine }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("synth"); } let synth = session.midi_track("synth"); synth >> MidiOutput("synth"); synth << [C4 E4 G4 C5]; synth.cc(74) << Sine(0.5).range(0, 127); ``` A signal lane keeps sending with the transport stopped, like a knob on the synth would. Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#send-a-sweep Previous: how-to/midi/04-send-cc-automation#send-a-fixed-value Next: how-to/midi/04-send-cc-automation#send-values-in-time-with-the-notes --- Send CC Automation > Send values in time with the notes [guide] Send a pattern. Each value is sent on its step, like a note, and only while the transport runs: ```resonon continue synth.cc(1) << [0 64 127 64]; ``` Page: how-to/midi/04-send-cc-automation URL: https://resonon.org/docs/how-to/midi/04-send-cc-automation/#send-values-in-time-with-the-notes Previous: how-to/midi/04-send-cc-automation#send-a-sweep Next: how-to/midi/04-send-cc-automation#remap-one-controller-to-another --- Sync to a MIDI Clock [guide] Resonon either sends MIDI clock and leads, or follows a clock from elsewhere — one or the other. Clock runs with the transport of a live session; a file run ends, and its clock with it, after its last statement. The functions are in the [MIDI reference](/docs/reference/stdlib/midi/#set_midi_clock_send); [Clock & Alignment](/docs/explanation/midi/03-clock-and-alignment/) explains how both work. Sections: - how-to/midi/05-sync-to-a-midi-clock#set-up-a-virtual-port | Set up a virtual port - how-to/midi/05-sync-to-a-midi-clock#lead-send-clock | Lead: send clock - how-to/midi/05-sync-to-a-midi-clock#follow-take-clock-from-a-daw | Follow: take clock from a DAW - how-to/midi/05-sync-to-a-midi-clock#trim-the-follower | Trim the follower - how-to/midi/05-sync-to-a-midi-clock#check-the-clock | Check the clock - how-to/midi/05-sync-to-a-midi-clock#related | Related Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/ --- Sync to a MIDI Clock > Check the clock [guide] ```resonon midi_clock_report(); // source, tempo, transport, and when following: phase, output delay, trim midi_routing_report(); // the clock mode, and which ports receive clock ``` If a device gets no clock, check that `[clock]` appears next to its port. If the tempo won't lock, check that the source is actually sending clock on the port you follow. Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#check-the-clock Previous: how-to/midi/05-sync-to-a-midi-clock#trim-the-follower Next: how-to/midi/05-sync-to-a-midi-clock#related --- Sync to a MIDI Clock > Follow: take clock from a DAW [guide] 1. Declare the port the clock arrives on as an input: ```toml [[midi.inputs]] alias = "daw" port = "IAC Driver Bus 1" ``` 2. Follow it: ```resonon parse-only set_midi_clock_source("daw"); ``` 3. If the piece sends patterns from [`on_cycle`](/docs/reference/stdlib/generative/#on_cycle) callbacks, run them once for the first cycle — the DAW's start, not `PLAY`, starts the transport: ```resonon parse-only prime_cycles(); ``` 4. Start the DAW. Resonon takes its tempo, and starts, stops and continues with it. Turn it off with `set_midi_clock_source()`. Following turns sending off, and sending turns following off. Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#follow-take-clock-from-a-daw Previous: how-to/midi/05-sync-to-a-midi-clock#lead-send-clock Next: how-to/midi/05-sync-to-a-midi-clock#trim-the-follower --- Sync to a MIDI Clock > Lead: send clock [guide] 1. Mark each port that should receive clock with `send_clock = true` in its entry in `~/.resonon/preferences.toml`, and run `reload_preferences()`: ```toml [[midi.outputs]] alias = "daw" port = "IAC Driver Bus 1" send_clock = true ``` 2. Turn clock on and play: ```resonon set_midi_clock_send(true); set_bpm(120); PLAY; ``` 3. In the DAW, set the transport to follow external MIDI clock from that port. The port receives clock ticks plus Start, Stop and Continue. Ports without `send_clock` get none. `midi_routing_report()` marks each port that receives clock with `[clock]`. You can turn clock on — for everything, or for one more port — while the music plays: the port is sent the current position and picks up in place. `set_midi_clock_send(false)`, or taking `send_clock` out, sends it Stop. Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#lead-send-clock Previous: how-to/midi/05-sync-to-a-midi-clock#set-up-a-virtual-port Next: how-to/midi/05-sync-to-a-midi-clock#follow-take-clock-from-a-daw --- Sync to a MIDI Clock > Related [guide] - [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/) — trim a device that is early or late - [Clock & Alignment](/docs/explanation/midi/03-clock-and-alignment/) — opt-in ports, position and tempo following - [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/) — play a DAW instrument over the same port Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#related Previous: how-to/midi/05-sync-to-a-midi-clock#check-the-clock --- Sync to a MIDI Clock > Set up a virtual port [guide] To sync with a DAW on the same machine, share a virtual port. On macOS, open **Audio MIDI Setup**, choose **Window → Show MIDI Studio**, double-click **IAC Driver** and check **Device is online**. `resonon --list-ports` then shows `IAC Driver Bus 1`. Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#set-up-a-virtual-port Next: how-to/midi/05-sync-to-a-midi-clock#lead-send-clock --- Sync to a MIDI Clock > Trim the follower [guide] Resonon allows for its own output latency and plugin delay, so what you hear lands on the source's clock. If it still sounds early or late against the source — the source's own sound comes out after the clock it sends — add `clock_trim_ms` to the input's entry and run `reload_preferences()`. Positive plays resonon later, negative earlier: ```toml [[midi.inputs]] alias = "drums" port = "TR-8S" clock_trim_ms = 3 # the drum machine sounds 3 ms after its clock ``` The trim can be up to ±500 ms; a value further out is reported and ignored. A reload applies it without closing the port, and the play head moves onto it without a jump. Page: how-to/midi/05-sync-to-a-midi-clock URL: https://resonon.org/docs/how-to/midi/05-sync-to-a-midi-clock/#trim-the-follower Previous: how-to/midi/05-sync-to-a-midi-clock#follow-take-clock-from-a-daw Next: how-to/midi/05-sync-to-a-midi-clock#check-the-clock --- Align Hardware with the Mix [guide] Resonon sends MIDI early by exactly the time its audio takes to reach your speakers, plugin latency included, so hardware lands with the mix without any setup. What is left is each device's own response time, which you trim per port. [Clock & Alignment](/docs/explanation/midi/03-clock-and-alignment/#midi-lands-with-the-audio) explains the model. Sections: - how-to/midi/06-align-hardware-with-the-mix#see-the-offset | See the offset - how-to/midi/06-align-hardware-with-the-mix#trim-a-device | Trim a device - how-to/midi/06-align-hardware-with-the-mix#trim-only-the-clock | Trim only the clock - how-to/midi/06-align-hardware-with-the-mix#use-the-trims-alone | Use the trims alone - how-to/midi/06-align-hardware-with-the-mix#related | Related Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/ --- Align Hardware with the Mix > Related [guide] - [Clock & Alignment](/docs/explanation/midi/03-clock-and-alignment/) — why notes you play through are not delayed - [Sync to a MIDI Clock](/docs/how-to/midi/05-sync-to-a-midi-clock/#trim-the-follower) — send clock to a port, or trim one you follow - [Preferences](/docs/reference/setup/02-preferences/#midioutputs-and-midiinputs) — `trim_ms`, `clock_trim_ms`, `send_clock` Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/#related Previous: how-to/midi/06-align-hardware-with-the-mix#use-the-trims-alone --- Align Hardware with the Mix > See the offset [guide] ```resonon midi_latency_report(); ``` ```txt MIDI output alignment auto audio buffer 512 fr 10.67 ms device + safety 2.10 ms plugin compensation 1536 fr 32.00 ms <- PDC ------------------------------------------ auto offset 44.77 ms port "cv" trim 0.00 clock -2.50 -> 44.77 / 42.27 ms [clock] ``` The last lines show what each port ends up with, for notes and for clock. Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/#see-the-offset Next: how-to/midi/06-align-hardware-with-the-mix#trim-a-device --- Align Hardware with the Mix > Trim a device [guide] Add `trim_ms` to the port's entry in `~/.resonon/preferences.toml` and run `reload_preferences()`. Negative sends earlier, positive later: ```toml [[midi.outputs]] alias = "cv" port = "Eowave Portail" trim_ms = -2.5 # this synth speaks late; send to it earlier ``` A trim moves the port's notes and its clock. It can be up to ±500 ms; a value further out is reported and ignored. Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/#trim-a-device Previous: how-to/midi/06-align-hardware-with-the-mix#see-the-offset Next: how-to/midi/06-align-hardware-with-the-mix#trim-only-the-clock --- Align Hardware with the Mix > Trim only the clock [guide] Some gear settles on clock differently than on notes. `clock_trim_ms` is added to clock and transport messages only, on top of `trim_ms`: ```toml [[midi.outputs]] alias = "cv" port = "Eowave Portail" trim_ms = 0 clock_trim_ms = -2.5 ``` `midi_port_trim("cv")` and `midi_port_clock_trim("cv")` read back what is in force. Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/#trim-only-the-clock Previous: how-to/midi/06-align-hardware-with-the-mix#trim-a-device Next: how-to/midi/06-align-hardware-with-the-mix#use-the-trims-alone --- Align Hardware with the Mix > Use the trims alone [guide] To turn the automatic offset off and keep only the trims: ```resonon set_midi_latency(MidiLatency.manual); set_midi_latency(MidiLatency.auto); // back to the default ``` Page: how-to/midi/06-align-hardware-with-the-mix URL: https://resonon.org/docs/how-to/midi/06-align-hardware-with-the-mix/#use-the-trims-alone Previous: how-to/midi/06-align-hardware-with-the-mix#trim-only-the-clock Next: how-to/midi/06-align-hardware-with-the-mix#related --- Play Microtonal and MPE [guide] A MIDI note number is a semitone. To play between them, a track sends the nearest note plus a pitch bend. Every method here is in the [MIDI reference](/docs/reference/stdlib/midi/#miditrack). Sections: - how-to/midi/07-play-microtonal-and-mpe#give-a-track-a-key | Give a track a key - how-to/midi/07-play-microtonal-and-mpe#play-a-tuning-with-pitch-bend | Play a tuning with pitch bend - how-to/midi/07-play-microtonal-and-mpe#give-each-note-its-own-channel-with-mpe | Give each note its own channel with MPE - how-to/midi/07-play-microtonal-and-mpe#related | Related Page: how-to/midi/07-play-microtonal-and-mpe URL: https://resonon.org/docs/how-to/midi/07-play-microtonal-and-mpe/ --- Play Microtonal and MPE > Give a track a key [guide] `.set_key()` resolves scale degrees sent to the track and pulls absolute notes onto the scale: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("lead"); } let lead = session.midi_track("lead"); lead >> MidiOutput("synth"); lead.set_key(Key(C4, "major")); lead << [^1 ^3 ^5 ^3]; ``` It takes a `Key`, or a scale name or `Scale` plus a root: ```resonon continue lead.set_key("minor", A3); lead.set_key(Scale(#[0, 2, 4, 5, 7, 9, 11]), C4); ``` [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) covers degrees and keys in patterns. Page: how-to/midi/07-play-microtonal-and-mpe URL: https://resonon.org/docs/how-to/midi/07-play-microtonal-and-mpe/#give-a-track-a-key Next: how-to/midi/07-play-microtonal-and-mpe#play-a-tuning-with-pitch-bend --- Play Microtonal and MPE > Give each note its own channel with MPE [guide] `.set_mpe()` spreads notes across member channels, each with its own pitch bend: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("pad"); } let pad = session.midi_track("pad"); pad >> MidiOutput("synth"); pad.set_mpe(); pad << [C4, E4, G4]; ``` Put the synth in MPE mode. Resonon sends the MPE configuration message and each channel's bend range before the first note, so the synth sets itself up. If the synth takes a different bend range, or only some member channels, pass them — the range in semitones, then the lowest and highest member channel: ```resonon continue pad.set_mpe(24); // ±24 semitones pad.set_mpe(48, 2, 9); // member channels 2 to 9 ``` Page: how-to/midi/07-play-microtonal-and-mpe URL: https://resonon.org/docs/how-to/midi/07-play-microtonal-and-mpe/#give-each-note-its-own-channel-with-mpe Previous: how-to/midi/07-play-microtonal-and-mpe#play-a-tuning-with-pitch-bend Next: how-to/midi/07-play-microtonal-and-mpe#related --- Play Microtonal and MPE > Play a tuning with pitch bend [guide] Load a tuning as the key and turn on `.set_tuning()`. A note that falls between semitones is sent as the nearest MIDI note plus a pitch bend: ```resonon parse-only // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("just"); } let just = session.midi_track("just"); just >> MidiOutput("synth"); just.set_tuning(); just.set_key(load_scala("just/5-limit"), C4); just << [^1 ^3 ^5 ^3]; ``` The bend range defaults to ±2 semitones, which every synth understands. If you raise it with `.set_tuning(range)`, set the same range on the synth. One channel has one pitch bend, so overlapping notes bend each other: the channel takes the bend of the newest note, and when that note ends, the bend of the newest note still held. For chords and legato lines, use MPE. Page: how-to/midi/07-play-microtonal-and-mpe URL: https://resonon.org/docs/how-to/midi/07-play-microtonal-and-mpe/#play-a-tuning-with-pitch-bend Previous: how-to/midi/07-play-microtonal-and-mpe#give-a-track-a-key Next: how-to/midi/07-play-microtonal-and-mpe#give-each-note-its-own-channel-with-mpe --- Play Microtonal and MPE > Related [guide] - [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) — degrees and keys in patterns - [Scales, Chords & Intervals](/docs/reference/patterns/03-scales-chords-intervals/) — built-in scales and Scala files - [MIDI reference](/docs/reference/stdlib/midi/#set_tuning) — `.set_tuning()`, `.set_mpe()` and `.set_key()` Page: how-to/midi/07-play-microtonal-and-mpe URL: https://resonon.org/docs/how-to/midi/07-play-microtonal-and-mpe/#related Previous: how-to/midi/07-play-microtonal-and-mpe#give-each-note-its-own-channel-with-mpe --- Export MIDI [guide] `midi_export()` writes notes to a `.mid` file for a DAW or notation software. Its signature, and what the file contains, are in the [audio reference](/docs/reference/stdlib/audio/#midi_export). To bounce sound instead, see [Render a Project](/docs/how-to/running/02-render-a-project/). Sections: - how-to/midi/08-export-midi#export-a-pattern | Export a pattern - how-to/midi/08-export-midi#export-a-track | Export a track - how-to/midi/08-export-midi#export-several-tracks-into-one-file | Export several tracks into one file - how-to/midi/08-export-midi#choose-the-path | Choose the path - how-to/midi/08-export-midi#related | Related Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/ --- Export MIDI > Choose the path [guide] Add a path as the last argument. A relative path is relative to the project, wherever you run from; an absolute path is used as written. Every form returns the path it wrote: ```resonon let path = midi_export([C4 E4 G4 C5], 4, "melody.mid"); print(path); ``` Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/#choose-the-path Previous: how-to/midi/08-export-midi#export-several-tracks-into-one-file Next: how-to/midi/08-export-midi#related --- Export MIDI > Export a pattern [guide] Give the pattern and the number of cycles: ```resonon let melody = [C4^80 E4^110 G4 C5]; midi_export(melody, 4); ``` The file is written to `renders/_<date>_<time>/export.mid` in the project. A note with a `^` velocity keeps it; any other note gets velocity 100. Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/#export-a-pattern Next: how-to/midi/08-export-midi#export-a-track --- <!-- ID: how-to/midi/08-export-midi#export-a-track --> Export MIDI > Export a track [guide] Pass the track instead. Its output's channel (channel 1 for a track with no output), default velocity, velocity modulation and CC lanes go into the file: ```resonon use "std/signals" { Sine }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("bass"); } let bass = session.midi_track("bass").set_velocity(90); bass >> MidiOutput("synth", 2); bass << [C2 E2 G2 C3]; bass.cc(74) << Sine(0.25).range(0, 127); midi_export(bass, 4); ``` The file is named after the track: `bass.mid`. A velocity signal or a signal-driven CC is rendered, not sampled once, so a slow envelope writes the curve you hear. While it renders, the export owns the engine and playback pauses, then resumes. An export with nothing to render — plain patterns and fixed CC values — does not interrupt playback. Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/#export-a-track Previous: how-to/midi/08-export-midi#export-a-pattern Next: how-to/midi/08-export-midi#export-several-tracks-into-one-file --- <!-- ID: how-to/midi/08-export-midi#export-several-tracks-into-one-file --> Export MIDI > Export several tracks into one file [guide] Pass an array of tracks: ```resonon // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("bass"); session.create_midi_track("lead"); } let bass = session.midi_track("bass").set_velocity(80); let lead = session.midi_track("lead").set_velocity(110); bass >> MidiOutput("synth", 1); lead >> MidiOutput("synth", 2); bass << [C2 E2 G2]; lead << [C5 E5 G5 C6]; midi_export(#[bass, lead], 8); ``` Each track becomes its own track in the file. A track in the array with no pattern is skipped and named in the output; a single track with no pattern is an error. Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/#export-several-tracks-into-one-file Previous: how-to/midi/08-export-midi#export-a-track Next: how-to/midi/08-export-midi#choose-the-path --- <!-- ID: how-to/midi/08-export-midi#related --> Export MIDI > Related [guide] - [MIDI Tracks & Time](/docs/explanation/midi/01-midi-tracks-and-time/) — why a velocity signal is rendered - [Render a Project](/docs/how-to/running/02-render-a-project/) — bounce audio instead - [MIDI reference](/docs/reference/stdlib/midi/) — tracks and CC lanes Page: how-to/midi/08-export-midi URL: https://resonon.org/docs/how-to/midi/08-export-midi/#related Previous: how-to/midi/08-export-midi#choose-the-path --- <!-- ID: how-to/midi/09-fix-midi-problems --> Fix MIDI Problems [guide] Find the message or the symptom, then work through the fix. Quoted blocks are what resonon prints. Sections: - how-to/midi/09-fix-midi-problems#no-notes-reach-the-synth-or-daw | No notes reach the synth or DAW - how-to/midi/09-fix-midi-problems#a-port-is-not-found | A port is not found - how-to/midi/09-fix-midi-problems#a-note-hangs | A note hangs - how-to/midi/09-fix-midi-problems#notes-or-clock-arrive-late-or-unevenly | Notes or clock arrive late or unevenly - how-to/midi/09-fix-midi-problems#the-octaves-look-one-off | The octaves look one off - how-to/midi/09-fix-midi-problems#related | Related Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/ --- <!-- ID: how-to/midi/09-fix-midi-problems#a-note-hangs --> Fix MIDI Problems > A note hangs [guide] A note-on was sent, and its note-off never arrived — often after a change in the middle of a note. 1. Press **F5** to play: on start, resonon sends a note-off for every note it left sounding. 2. Press **Shift+F5** three times: the third stop sends a note-off for every note resonon started that is still sounding, then sustain off and all notes off on every channel of every port. This also stops notes played through thru. 3. If the note still hangs, the synth or DAW ignores all notes off or lost the note-off: use its own panic. Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#a-note-hangs Previous: how-to/midi/09-fix-midi-problems#a-port-is-not-found Next: how-to/midi/09-fix-midi-problems#notes-or-clock-arrive-late-or-unevenly --- <!-- ID: how-to/midi/09-fix-midi-problems#a-port-is-not-found --> Fix MIDI Problems > A port is not found [guide] 1. Run `resonon --list-ports`. It prints an entry for each attached device, ready to paste. 2. For a DAW on the same Mac, turn on a virtual port: **Audio MIDI Setup → Window → Show MIDI Studio → IAC Driver → Device is online**. 3. Run `reload_preferences()` after you change the file or plug in the device. Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#a-port-is-not-found Previous: how-to/midi/09-fix-midi-problems#no-notes-reach-the-synth-or-daw Next: how-to/midi/09-fix-midi-problems#a-note-hangs --- <!-- ID: how-to/midi/09-fix-midi-problems#no-notes-reach-the-synth-or-daw --> Fix MIDI Problems > No notes reach the synth or DAW [guide] First check that the track has an output. A new `MidiTrack` has none until `>>` routes it, and `print(bass);` shows `no output`. Route it to a declared alias: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("bass"); } let bass = session.midi_track("bass"); bass >> MidiOutput("synth"); ``` > **MIDI port "synth" is not connected — 3 events dropped. Add a `[[midi.outputs]]` entry with this > alias.** The track was routed to the alias, but the preferences no longer declare it. 1. Declare it in `~/.resonon/preferences.toml` — `resonon setup` picks the port from a list: ```toml [[midi.outputs]] alias = "synth" port = "IAC" ``` 2. Run `reload_preferences()` to open it without restarting. 3. Check what is connected: `print(midi_connected());` prints `{alias: port}` for every open port. > **MIDI port "synth" has no device — 3 events dropped. Run `resonon --list-ports` and check the > port name.** The alias is declared, but no device matches its `port`. Resonon also prints this for every port when it runs with `--no-midi`, which opens no ports on purpose. 1. Run `resonon --list-ports` and compare the names. A port name matches exactly first, then as a substring, so `"IAC"` finds `"IAC Driver Bus 1"`. 2. Plug the device in, then run `reload_preferences()`. The alias stays valid while the device is missing, so the tracks that use it do not need to change. 3. For gear that is not always there, add `optional = true` to its entry: its absence is expected rather than reported. On the DAW side, check that the track's MIDI input is the port, that it is armed or monitoring, and that it has an instrument. Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#no-notes-reach-the-synth-or-daw Next: how-to/midi/09-fix-midi-problems#a-port-is-not-found --- <!-- ID: how-to/midi/09-fix-midi-problems#notes-or-clock-arrive-late-or-unevenly --> Fix MIDI Problems > Notes or clock arrive late or unevenly [guide] A device is behind or ahead of the mix by the same amount every time: trim its port — see [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/). When the timing wobbles, or a device following resonon's clock drifts, trace what is sent: 1. Start the trace, with the transport playing: ```resonon parse-only set_midi_trace(true); ``` 2. Let it play a few bars, then stop the trace. It prints what it captured: ```resonon parse-only set_midi_trace(false); ``` 3. Read the report. Each `NoteOn` line says how far ahead of its time it was sent, or `LATE`. Under `Inter-tick intervals`, the `jitter` line is the spread of the clock's tick spacing. `midi_trace_report()` prints what has been captured so far and keeps recording. Each thread keeps the last few thousand events; past that, the report says how many it dropped. Notes sent `LATE` reached the output after their time: check the load — see [the audio crackles, or reacts late](/docs/how-to/audio/21-fix-audio-problems/#the-audio-crackles-or-reacts-late) and [notes drop out under load](/docs/how-to/patterns/11-fix-timing-problems/#notes-drop-out-under-load). A steady report with a device that still wobbles points at the device or its connection. Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#notes-or-clock-arrive-late-or-unevenly Previous: how-to/midi/09-fix-midi-problems#a-note-hangs Next: how-to/midi/09-fix-midi-problems#the-octaves-look-one-off --- <!-- ID: how-to/midi/09-fix-midi-problems#related --> Fix MIDI Problems > Related [guide] - [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/) — ports, channels and a DAW over a virtual port - [Preferences](/docs/reference/setup/02-preferences/#midioutputs-and-midiinputs) — every port key - [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/) — a device that is early or late Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#related Previous: how-to/midi/09-fix-midi-problems#the-octaves-look-one-off --- <!-- ID: how-to/midi/09-fix-midi-problems#the-octaves-look-one-off --> Fix MIDI Problems > The octaves look one off [guide] Nothing is wrong. Resonon writes `C4` for MIDI note 60; Ableton Live and some other DAWs call the same note `C3`. | Resonon | MIDI note | Ableton Live | | ------- | --------- | ------------ | | `C4` | 60 | C3 | | `A4` | 69 | A3 | | `C5` | 72 | C4 | Page: how-to/midi/09-fix-midi-problems URL: https://resonon.org/docs/how-to/midi/09-fix-midi-problems/#the-octaves-look-one-off Previous: how-to/midi/09-fix-midi-problems#notes-or-clock-arrive-late-or-unevenly Next: how-to/midi/09-fix-midi-problems#related --- <!-- ID: how-to/patterns/01-transform-a-pattern --> Transform a Pattern [guide] Each recipe starts from a pattern you already have and returns a new one. The original is never changed, so you can derive as many variations from one motif as you need. Every method is listed in the [pattern methods reference](/docs/reference/stdlib/patterns/). Sections: - how-to/patterns/01-transform-a-pattern#play-a-phrase-faster-or-slower | Play a phrase faster or slower - how-to/patterns/01-transform-a-pattern#harmonize-a-melody | Harmonize a melody - how-to/patterns/01-transform-a-pattern#turn-a-phrase-into-a-palindrome | Turn a phrase into a palindrome - how-to/patterns/01-transform-a-pattern#thin-out-a-busy-part | Thin out a busy part - how-to/patterns/01-transform-a-pattern#rewrite-every-note | Rewrite every note - how-to/patterns/01-transform-a-pattern#change-notes-by-where-they-fall-in-the-cycle | Change notes by where they fall in the cycle - how-to/patterns/01-transform-a-pattern#find-out-what-a-chain-does | Find out what a chain does Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/ --- <!-- ID: how-to/patterns/01-transform-a-pattern#change-notes-by-where-they-fall-in-the-cycle --> Transform a Pattern > Change notes by where they fall in the cycle [guide] `.map_with_timing(fn)` also passes each note's `start` (`0.0` to `1.0` in the cycle) and its duration. Lift the second half of the cycle up an octave: ```resonon let pat = [C4 D4 E4 F4]; let lifted = pat.map_with_timing(fn(note, start, dur) { if start >= 0.5 { return note + 12; } return note; }); print(lifted.describe()); ``` Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#change-notes-by-where-they-fall-in-the-cycle Previous: how-to/patterns/01-transform-a-pattern#rewrite-every-note Next: how-to/patterns/01-transform-a-pattern#find-out-what-a-chain-does --- <!-- ID: how-to/patterns/01-transform-a-pattern#find-out-what-a-chain-does --> Transform a Pattern > Find out what a chain does [guide] When a chain doesn't sound the way you expect, print `.describe()` and read it inside-out. `.length()` counts the events in one cycle: ```resonon print([C4 D4 E4].reverse().transpose(7).describe()); // => Transpose(7, Reverse(Sequence[3])) print([C4 D4 E4 F4].length()); // => 4 ``` `Transpose(7, Reverse(Sequence[3]))` is a three-note sequence, reversed, then transposed. If the order is not what you meant, reorder the chain. [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#transforms-wrap-they-dont-edit) explains why the order matters. Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#find-out-what-a-chain-does Previous: how-to/patterns/01-transform-a-pattern#change-notes-by-where-they-fall-in-the-cycle --- <!-- ID: how-to/patterns/01-transform-a-pattern#harmonize-a-melody --> Transform a Pattern > Harmonize a melody [guide] Stack the melody against a transposed copy of itself. Four semitones up is a major third: ```resonon let melody = [C4 D4 E4 F4]; print(melody.stack(melody.transpose(4)).describe()); ``` `.transpose()` leaves rests untouched, so a melody with gaps harmonizes cleanly. Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#harmonize-a-melody Previous: how-to/patterns/01-transform-a-pattern#play-a-phrase-faster-or-slower Next: how-to/patterns/01-transform-a-pattern#turn-a-phrase-into-a-palindrome --- <!-- ID: how-to/patterns/01-transform-a-pattern#play-a-phrase-faster-or-slower --> Transform a Pattern > Play a phrase faster or slower [guide] `.fast(n)` plays the pattern `n` times per cycle; `.slow(n)` stretches it across `n` cycles. ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << [C4 E4 G4 C5].reverse().fast(2); // descending, twice per cycle PLAY; ``` `[C4 D4 E4].fast(2)` and the mini-notation `[[C4 D4 E4]*2]` give the same result. Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#play-a-phrase-faster-or-slower Next: how-to/patterns/01-transform-a-pattern#harmonize-a-melody --- <!-- ID: how-to/patterns/01-transform-a-pattern#rewrite-every-note --> Transform a Pattern > Rewrite every note [guide] `.map(fn)` calls your function with each note's MIDI number and plays what it returns: a number replaces the note, an array turns it into a chord, and a pattern substitutes a sub-sequence. Fold a melody into one octave: ```resonon let melody = [C4 D4 E4 F4 G4]; let folded = melody.map(fn(note) { return 60 + (note % 12); }); print(folded.describe()); ``` Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#rewrite-every-note Previous: how-to/patterns/01-transform-a-pattern#thin-out-a-busy-part Next: how-to/patterns/01-transform-a-pattern#change-notes-by-where-they-fall-in-the-cycle --- <!-- ID: how-to/patterns/01-transform-a-pattern#thin-out-a-busy-part --> Transform a Pattern > Thin out a busy part [guide] `.degrade(p)` drops each note with probability `p`. On a stream of hi-hats it adds occasional gaps: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("hats"); } let hats = session.track("hats"); hats.set_instrument(Sampler(Kit("TR-808"))); hats << [ch*8].degrade(0.15); // straight 8ths, about 15% of hits dropped PLAY; ``` The same hits drop on every playback. To change which hits drop, change the pattern. Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#thin-out-a-busy-part Previous: how-to/patterns/01-transform-a-pattern#turn-a-phrase-into-a-palindrome Next: how-to/patterns/01-transform-a-pattern#rewrite-every-note --- <!-- ID: how-to/patterns/01-transform-a-pattern#turn-a-phrase-into-a-palindrome --> Transform a Pattern > Turn a phrase into a palindrome [guide] Append a reversed copy: ```resonon let base = [C4 D4 E4 G4]; print(base.concat(base.reverse()).describe()); ``` `.rotate(n)` is the other reordering: it shifts the notes right by `n` (negative shifts left) and wraps around the ends. Page: how-to/patterns/01-transform-a-pattern URL: https://resonon.org/docs/how-to/patterns/01-transform-a-pattern/#turn-a-phrase-into-a-palindrome Previous: how-to/patterns/01-transform-a-pattern#harmonize-a-melody Next: how-to/patterns/01-transform-a-pattern#thin-out-a-busy-part --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel --> Add Swing and Human Feel [guide] Swing is measured on a grid you name; nudge and humanize are measured on each event's own step. Notes keep their length when they move. [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#timing-moves) explains the model. Sections: - how-to/patterns/02-add-swing-and-human-feel#swing-a-pattern | Swing a pattern - how-to/patterns/02-add-swing-and-human-feel#place-a-groove-by-hand | Place a groove by hand - how-to/patterns/02-add-swing-and-human-feel#add-human-timing | Add human timing - how-to/patterns/02-add-swing-and-human-feel#change-the-groove-from-cycle-to-cycle | Change the groove from cycle to cycle - how-to/patterns/02-add-swing-and-human-feel#combine-swing-and-humanize | Combine swing and humanize - how-to/patterns/02-add-swing-and-human-feel#give-each-layer-its-own-feel | Give each layer its own feel Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/ --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#add-human-timing --> Add Swing and Human Feel > Add human timing [guide] `.humanize(amount)` moves each event by an offset within `±amount` of its step. The offsets differ from event to event but are the same on every playback: ```resonon [bd sd bd sd].humanize(0.1); // ±10% of a step ``` Start around `0.05` and raise it until the part loosens without sounding sloppy. Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#add-human-timing Previous: how-to/patterns/02-add-swing-and-human-feel#place-a-groove-by-hand Next: how-to/patterns/02-add-swing-and-human-feel#change-the-groove-from-cycle-to-cycle --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#change-the-groove-from-cycle-to-cycle --> Add Swing and Human Feel > Change the groove from cycle to cycle [guide] Each method accepts a pattern where it takes an amount, so the groove can alternate: ```resonon [hh*8].swing(<0.25 0.33>, 8); // moderate, then triplet [bd sd bd sd].humanize(<0.05 0.2>); // tight, then loose [bd sd bd sd].nudge(<[0 0.25 0 -0.1] [0 0 0 0]>); // nudged, then straight ``` Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#change-the-groove-from-cycle-to-cycle Previous: how-to/patterns/02-add-swing-and-human-feel#add-human-timing Next: how-to/patterns/02-add-swing-and-human-feel#combine-swing-and-humanize --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#combine-swing-and-humanize --> Add Swing and Human Feel > Combine swing and humanize [guide] Set the groove first, then add the jitter: ```resonon [hh*8].swing(0.25, 8).humanize(0.05); [bd sd bd sd].nudge([0.0, 0.15, 0.0, -0.08]).humanize(0.05); ``` If you humanize first, the swing is measured from positions that have already moved, and the groove blurs. Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#combine-swing-and-humanize Previous: how-to/patterns/02-add-swing-and-human-feel#change-the-groove-from-cycle-to-cycle Next: how-to/patterns/02-add-swing-and-human-feel#give-each-layer-its-own-feel --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#give-each-layer-its-own-feel --> Add Swing and Human Feel > Give each layer its own feel [guide] Put the layers on separate tracks and time each one on its own — here straight kicks, swung and humanized hats, and a late snare: ```resonon use "std/instruments" { Sampler, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("kicks"); session.create_track("hats"); session.create_track("snares"); } let kit = Sampler(Kit("CR-78")); let kicks = session.track("kicks"); kicks.set_instrument(kit); kicks << [bd*4].humanize(0.05); let hats = session.track("hats"); hats.set_instrument(kit); hats << [hh*8].swing(0.2, 8).humanize(0.05); let snares = session.track("snares"); snares.set_instrument(kit); snares << [_ sd _ sd].nudge([0.0, 0.1]); PLAY; ``` Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#give-each-layer-its-own-feel Previous: how-to/patterns/02-add-swing-and-human-feel#combine-swing-and-humanize --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#place-a-groove-by-hand --> Add Swing and Human Feel > Place a groove by hand [guide] `.nudge(offsets)` moves each event by its own amount: `0.0` is on the grid, positive is later, negative is earlier. The offsets are used in order and wrap when there are more events than offsets: ```resonon [bd sd bd sd].nudge([0.0, 0.25, 0.0, -0.1]); // snare 1 late, snare 2 early [bd sd bd sd].nudge([0.0, 0.1]); // [0, 0.1, 0, 0.1] ``` ``` Offsets: 0.0 +0.25 0.0 -0.1 Original: | bd | sd | bd | sd | 0 0.25 0.5 0.75 1.0 Nudged: | bd | sd | bd | sd | 0 0.3125 0.5 0.725 1.0 ``` Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#place-a-groove-by-hand Previous: how-to/patterns/02-add-swing-and-human-feel#swing-a-pattern Next: how-to/patterns/02-add-swing-and-human-feel#add-human-timing --- <!-- ID: how-to/patterns/02-add-swing-and-human-feel#swing-a-pattern --> Add Swing and Human Feel > Swing a pattern [guide] `.swing(amount, grid)` cuts the cycle into `grid` slots and delays every second one, like the swing on a drum machine. `16` swings 16ths, `8` swings 8ths. Whatever plays on the beat stays, so a whole kit swings as one groove: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd*4, _ cp _ cp, hh*16].swing(0.1, 16); PLAY; ``` The kicks and claps sit on the grid's even slots and don't move; the hats on the odd 16ths play late. The amount is a fraction of one slot and runs from `0` to `0.5`. Start low and raise it by ear; `0.33` puts the delayed slots on the triplet — [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#timing-moves) explains why. The grid is an even number of slots per cycle, from 2 to 1024. Page: how-to/patterns/02-add-swing-and-human-feel URL: https://resonon.org/docs/how-to/patterns/02-add-swing-and-human-feel/#swing-a-pattern Next: how-to/patterns/02-add-swing-and-human-feel#place-a-groove-by-hand --- <!-- ID: how-to/patterns/03-make-a-reproducible-random-choice --> Make a Reproducible Random Choice [guide] The functions in [`std/random`](/docs/reference/stdlib/random/) take a seed and return the same result for the same seed, so a piece that uses them plays the same way every time, and after every seek. [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#determinism-and-seekability) explains why. Sections: - how-to/patterns/03-make-a-reproducible-random-choice#pick-one-value | Pick one value - how-to/patterns/03-make-a-reproducible-random-choice#pick-anew-each-cycle | Pick anew each cycle - how-to/patterns/03-make-a-reproducible-random-choice#check-that-it-is-reproducible | Check that it is reproducible - how-to/patterns/03-make-a-reproducible-random-choice#related | Related Page: how-to/patterns/03-make-a-reproducible-random-choice URL: https://resonon.org/docs/how-to/patterns/03-make-a-reproducible-random-choice/ --- <!-- ID: how-to/patterns/03-make-a-reproducible-random-choice#check-that-it-is-reproducible --> Make a Reproducible Random Choice > Check that it is reproducible [guide] Assert that the same seed gives the same value: ```resonon use "std/random" { rand }; assert rand(7) == rand(7), "same seed must give the same value"; print("deterministic"); ``` `rand_true()` and `choose_true()` are unseeded and fail this check on purpose. Use them only when you want a different result on every call. Page: how-to/patterns/03-make-a-reproducible-random-choice URL: https://resonon.org/docs/how-to/patterns/03-make-a-reproducible-random-choice/#check-that-it-is-reproducible Previous: how-to/patterns/03-make-a-reproducible-random-choice#pick-anew-each-cycle Next: how-to/patterns/03-make-a-reproducible-random-choice#related --- <!-- ID: how-to/patterns/03-make-a-reproducible-random-choice#pick-anew-each-cycle --> Make a Reproducible Random Choice > Pick anew each cycle [guide] Seed with the cycle number, inside a [stream](/docs/how-to/patterns/04-generate-a-random-walk/) or an [`on_cycle` callback](/docs/how-to/patterns/06-change-a-pattern-every-cycle/), and the pick changes from cycle to cycle but is the same on every playback: ```resonon use "std/instruments" { SamplerMelodic, Kit }; use "std/random" { choose }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); let notes = #[60, 64, 67, 71]; on_cycle(fn(cycle) { lead << Sequence(#[choose(cycle, notes)]); }); PLAY; ``` Page: how-to/patterns/03-make-a-reproducible-random-choice URL: https://resonon.org/docs/how-to/patterns/03-make-a-reproducible-random-choice/#pick-anew-each-cycle Previous: how-to/patterns/03-make-a-reproducible-random-choice#pick-one-value Next: how-to/patterns/03-make-a-reproducible-random-choice#check-that-it-is-reproducible --- <!-- ID: how-to/patterns/03-make-a-reproducible-random-choice#pick-one-value --> Make a Reproducible Random Choice > Pick one value [guide] `choose(seed, values)` picks one element; `choose_weighted(seed, values, weights)` takes a parallel array of weights: ```resonon use "std/random" { choose, choose_weighted }; let notes = #[C4, E4, G4, B4]; print(choose(0, notes)); // the same element on every run let chords = #[[C4 E4 G4], [F4 A4 C5], [G4 B4 D5]]; let weights = #[3, 1, 1]; // C major three times as likely print(choose_weighted(0, chords, weights)); ``` `rand(seed)` returns a number from `0` to `1` the same way. Change the seed for a different pick. Page: how-to/patterns/03-make-a-reproducible-random-choice URL: https://resonon.org/docs/how-to/patterns/03-make-a-reproducible-random-choice/#pick-one-value Next: how-to/patterns/03-make-a-reproducible-random-choice#pick-anew-each-cycle --- <!-- ID: how-to/patterns/03-make-a-reproducible-random-choice#related --> Make a Reproducible Random Choice > Related [guide] - [Random](/docs/reference/stdlib/random/) — every seeded and unseeded function - [Generate a Random Walk](/docs/how-to/patterns/04-generate-a-random-walk/) — a value that moves from cycle to cycle Page: how-to/patterns/03-make-a-reproducible-random-choice URL: https://resonon.org/docs/how-to/patterns/03-make-a-reproducible-random-choice/#related Previous: how-to/patterns/03-make-a-reproducible-random-choice#check-that-it-is-reproducible --- <!-- ID: how-to/patterns/04-generate-a-random-walk --> Generate a Random Walk [guide] A [stream](/docs/reference/stdlib/generative/#stream) computes each cycle's value from the previous one. Seed its random step with the cycle number, and the walk is the same on every playback. Sections: - how-to/patterns/04-generate-a-random-walk#step-by-a-random-interval | Step by a random interval - how-to/patterns/04-generate-a-random-walk#keep-it-in-a-register | Keep it in a register - how-to/patterns/04-generate-a-random-walk#bias-its-direction | Bias its direction - how-to/patterns/04-generate-a-random-walk#move-a-whole-chord | Move a whole chord - how-to/patterns/04-generate-a-random-walk#related | Related Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/ --- <!-- ID: how-to/patterns/04-generate-a-random-walk#bias-its-direction --> Generate a Random Walk > Bias its direction [guide] Compare `rand(cycle)` with a probability. Here the walk steps up 70% of the time: ```resonon use "std/generative" { stream }; use "std/random" { rand }; let rising = stream(65, fn(prev, cycle) { if (rand(cycle) < 0.7) { return prev + 1; } return prev - 1; }); print(rising.query(3)); ``` Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/#bias-its-direction Previous: how-to/patterns/04-generate-a-random-walk#keep-it-in-a-register Next: how-to/patterns/04-generate-a-random-walk#move-a-whole-chord --- <!-- ID: how-to/patterns/04-generate-a-random-walk#keep-it-in-a-register --> Generate a Random Walk > Keep it in a register [guide] Turn the walk around when it would leave the range: ```resonon use "std/generative" { stream }; use "std/random" { choose }; let bound_steps = #[-3, -1, 1, 3]; let bounded = stream(60, fn(prev, cycle) { let next = prev + choose(cycle, bound_steps); if (next > 72) { return prev - 3; } // too high — turn around if (next < 60) { return prev + 3; } // too low — turn around return next; }); print(bounded.query(8)); ``` Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/#keep-it-in-a-register Previous: how-to/patterns/04-generate-a-random-walk#step-by-a-random-interval Next: how-to/patterns/04-generate-a-random-walk#bias-its-direction --- <!-- ID: how-to/patterns/04-generate-a-random-walk#move-a-whole-chord --> Generate a Random Walk > Move a whole chord [guide] Start the stream from an array, and return an array: ```resonon use "std/generative" { stream }; use "std/random" { choose }; let voicing = stream(#[60, 64, 67], fn(prev, cycle) { let step = choose(cycle, #[-2, 2]); let result = #[]; for note in prev { result.push(note + step); } return result; }); print(voicing.query(2)); ``` Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/#move-a-whole-chord Previous: how-to/patterns/04-generate-a-random-walk#bias-its-direction Next: how-to/patterns/04-generate-a-random-walk#related --- <!-- ID: how-to/patterns/04-generate-a-random-walk#related --> Generate a Random Walk > Related [guide] - [Generative](/docs/reference/stdlib/generative/#stream) — `stream` and its methods - [Make a Reproducible Random Choice](/docs/how-to/patterns/03-make-a-reproducible-random-choice/) — `rand`, `choose` and seeds - [Write a Pattern as a Class](/docs/how-to/patterns/07-write-a-pattern-as-a-class/) — when the logic needs several state variables Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/#related Previous: how-to/patterns/04-generate-a-random-walk#move-a-whole-chord --- <!-- ID: how-to/patterns/04-generate-a-random-walk#step-by-a-random-interval --> Generate a Random Walk > Step by a random interval [guide] Start the stream from a MIDI note, and add a step chosen from a list each cycle: ```resonon use "std/instruments" { SamplerMelodic, Kit }; use "std/generative" { stream }; use "std/random" { choose }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let steps = #[-2, -1, 1, 2]; let walk = stream(64, fn(prev, cycle) { return prev + choose(cycle, steps); }); let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << walk; PLAY; ``` A stream works on MIDI numbers (60 = C4), so you can do arithmetic on the value directly. `walk.query(n)` returns the value at cycle `n`, to check a walk before you play it. Page: how-to/patterns/04-generate-a-random-walk URL: https://resonon.org/docs/how-to/patterns/04-generate-a-random-walk/#step-by-a-random-interval Next: how-to/patterns/04-generate-a-random-walk#keep-it-in-a-register --- <!-- ID: how-to/patterns/05-generate-a-progression-with-a-markov-chain --> Generate a Progression with a Markov Chain [guide] [`markov(states, matrix, start)`](/docs/reference/stdlib/generative/#markov) moves between numbered states. Row *i* of the matrix holds the chances of going from state *i* to each state, and each row sums to `1`. The chain takes the same path on every playback. Sections: - how-to/patterns/05-generate-a-progression-with-a-markov-chain#write-the-chain-and-map-its-states | Write the chain and map its states - how-to/patterns/05-generate-a-progression-with-a-markov-chain#forbid-a-move | Forbid a move - how-to/patterns/05-generate-a-progression-with-a-markov-chain#end-on-a-cadence | End on a cadence - how-to/patterns/05-generate-a-progression-with-a-markov-chain#related | Related Page: how-to/patterns/05-generate-a-progression-with-a-markov-chain URL: https://resonon.org/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/ --- <!-- ID: how-to/patterns/05-generate-a-progression-with-a-markov-chain#end-on-a-cadence --> Generate a Progression with a Markov Chain > End on a cadence [guide] Give the home state a row that points only to itself. Once the chain reaches it, it stays: ```resonon use "std/generative" { markov }; let resolving = markov( 3, #[ #[0.0, 0.7, 0.3], // start: mostly move toward state 1 #[0.0, 0.3, 0.7], // middle: mostly move toward state 2 #[0.0, 0.0, 1.0] // end: stay ], 0 ); print(resolving.query(10)); // settled on state 2 ``` Page: how-to/patterns/05-generate-a-progression-with-a-markov-chain URL: https://resonon.org/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/#end-on-a-cadence Previous: how-to/patterns/05-generate-a-progression-with-a-markov-chain#forbid-a-move Next: how-to/patterns/05-generate-a-progression-with-a-markov-chain#related --- <!-- ID: how-to/patterns/05-generate-a-progression-with-a-markov-chain#forbid-a-move --> Generate a Progression with a Markov Chain > Forbid a move [guide] Set its weight to zero. In the chain above, state 0 never jumps straight to state 2, and state 2 never reaches state 1. Zeros encode the rules of your harmony — for example, to stop a V chord from going directly to a ii. Don't make a whole row zero unless you want the chain to stay stuck in that state. Page: how-to/patterns/05-generate-a-progression-with-a-markov-chain URL: https://resonon.org/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/#forbid-a-move Previous: how-to/patterns/05-generate-a-progression-with-a-markov-chain#write-the-chain-and-map-its-states Next: how-to/patterns/05-generate-a-progression-with-a-markov-chain#end-on-a-cadence --- <!-- ID: how-to/patterns/05-generate-a-progression-with-a-markov-chain#related --> Generate a Progression with a Markov Chain > Related [guide] - [Generative](/docs/reference/stdlib/generative/#markov) — `markov` and its methods - [Write a Pattern as a Class](/docs/how-to/patterns/07-write-a-pattern-as-a-class/) — patterns with state of their own Page: how-to/patterns/05-generate-a-progression-with-a-markov-chain URL: https://resonon.org/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/#related Previous: how-to/patterns/05-generate-a-progression-with-a-markov-chain#end-on-a-cadence --- <!-- ID: how-to/patterns/05-generate-a-progression-with-a-markov-chain#write-the-chain-and-map-its-states --> Generate a Progression with a Markov Chain > Write the chain and map its states [guide] The chain outputs state indices, so map them to notes or chords. A small [script pattern](/docs/how-to/patterns/07-write-a-pattern-as-a-class/) does that: ```resonon use "std/instruments" { SamplerMelodic, Kit }; use "std/generative" { markov }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } class Mapped implements Pattern { let chain; let notes; fn new(chain, notes) { this.chain = chain; this.notes = notes; } fn query(cycle) -> Note | Number | Rest | Array | Pattern? { return this.notes[this.chain.query(cycle)]; } } let three_state = markov( 3, #[ #[0.5, 0.5, 0.0], #[0.0, 0.5, 0.5], #[0.5, 0.0, 0.5] ], 0 ); let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << Mapped(three_state, #[C4, E4, G4]); PLAY; ``` Page: how-to/patterns/05-generate-a-progression-with-a-markov-chain URL: https://resonon.org/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/#write-the-chain-and-map-its-states Next: how-to/patterns/05-generate-a-progression-with-a-markov-chain#forbid-a-move --- <!-- ID: how-to/patterns/06-change-a-pattern-every-cycle --> Change a Pattern Every Cycle [guide] When the next pattern depends on more than one value, compute it in a callback. `on_cycle` runs it once per cycle with the cycle number, and what it sends lands on that cycle. Sections: - how-to/patterns/06-change-a-pattern-every-cycle#send-a-pattern-from-a-callback | Send a pattern from a callback - how-to/patterns/06-change-a-pattern-every-cycle#stop-the-callbacks | Stop the callbacks - how-to/patterns/06-change-a-pattern-every-cycle#start-on-an-external-clock | Start on an external clock - how-to/patterns/06-change-a-pattern-every-cycle#related | Related Page: how-to/patterns/06-change-a-pattern-every-cycle URL: https://resonon.org/docs/how-to/patterns/06-change-a-pattern-every-cycle/ --- <!-- ID: how-to/patterns/06-change-a-pattern-every-cycle#related --> Change a Pattern Every Cycle > Related [guide] - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — when a cycle is computed, and when a change lands - [Generate a Random Walk](/docs/how-to/patterns/04-generate-a-random-walk/) — a value that carries from cycle to cycle Page: how-to/patterns/06-change-a-pattern-every-cycle URL: https://resonon.org/docs/how-to/patterns/06-change-a-pattern-every-cycle/#related Previous: how-to/patterns/06-change-a-pattern-every-cycle#start-on-an-external-clock --- <!-- ID: how-to/patterns/06-change-a-pattern-every-cycle#send-a-pattern-from-a-callback --> Change a Pattern Every Cycle > Send a pattern from a callback [guide] ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); on_cycle(fn(cycle) { let note = 60 + (cycle % 12); // one step up each cycle, then back down lead << Sequence(#[note]); }); PLAY; ``` Seed any random choice with `cycle`, so the result is the same on every playback — see [Make a Reproducible Random Choice](/docs/how-to/patterns/03-make-a-reproducible-random-choice/). Page: how-to/patterns/06-change-a-pattern-every-cycle URL: https://resonon.org/docs/how-to/patterns/06-change-a-pattern-every-cycle/#send-a-pattern-from-a-callback Next: how-to/patterns/06-change-a-pattern-every-cycle#stop-the-callbacks --- <!-- ID: how-to/patterns/06-change-a-pattern-every-cycle#start-on-an-external-clock --> Change a Pattern Every Cycle > Start on an external clock [guide] When resonon follows a MIDI clock, call `prime_cycles()` before the clock starts, so the first cycle is not empty — see [Sync to a MIDI Clock](/docs/how-to/midi/05-sync-to-a-midi-clock/#follow-take-clock-from-a-daw). Page: how-to/patterns/06-change-a-pattern-every-cycle URL: https://resonon.org/docs/how-to/patterns/06-change-a-pattern-every-cycle/#start-on-an-external-clock Previous: how-to/patterns/06-change-a-pattern-every-cycle#stop-the-callbacks Next: how-to/patterns/06-change-a-pattern-every-cycle#related --- <!-- ID: how-to/patterns/06-change-a-pattern-every-cycle#stop-the-callbacks --> Change a Pattern Every Cycle > Stop the callbacks [guide] `off_cycle()` removes every callback. Page: how-to/patterns/06-change-a-pattern-every-cycle URL: https://resonon.org/docs/how-to/patterns/06-change-a-pattern-every-cycle/#stop-the-callbacks Previous: how-to/patterns/06-change-a-pattern-every-cycle#send-a-pattern-from-a-callback Next: how-to/patterns/06-change-a-pattern-every-cycle#start-on-an-external-clock --- <!-- ID: how-to/patterns/07-write-a-pattern-as-a-class --> Write a Pattern as a Class [guide] Write a script pattern when a [stream](/docs/how-to/patterns/04-generate-a-random-walk/) or a [Markov chain](/docs/how-to/patterns/05-generate-a-progression-with-a-markov-chain/) is not enough — when you need several state variables, helper methods, or logic that does not fit one `fn(prev, cycle)`. The contract (what `query()` may return and do) is in the [script pattern reference](/docs/reference/patterns/02-script-patterns/). | | Script pattern | Stream | |:--|:--------------|:-------| | **Defined as** | A class that implements `Pattern` | `stream(init, fn(prev, cycle))` | | **State** | Any number of named fields | A single value (`prev`) | | **Extras** | Helper methods, tables in fields | Closure only | | **Use it for** | Logic with structure or several state variables | Walking one value forward | Sections: - how-to/patterns/07-write-a-pattern-as-a-class#step-through-a-list-of-notes | Step through a list of notes - how-to/patterns/07-write-a-pattern-as-a-class#use-helper-methods-and-lookup-tables | Use helper methods and lookup tables - how-to/patterns/07-write-a-pattern-as-a-class#drive-the-pattern-from-the-cycle-number | Drive the pattern from the cycle number - how-to/patterns/07-write-a-pattern-as-a-class#transform-it-like-any-pattern | Transform it like any pattern Page: how-to/patterns/07-write-a-pattern-as-a-class URL: https://resonon.org/docs/how-to/patterns/07-write-a-pattern-as-a-class/ --- <!-- ID: how-to/patterns/07-write-a-pattern-as-a-class#drive-the-pattern-from-the-cycle-number --> Write a Pattern as a Class > Drive the pattern from the cycle number [guide] You don't always need state. Index a list with `cycle` to play a chord progression: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("pad"); } class ChordProgression implements Pattern { let chords; fn new(chords) { this.chords = chords; } fn query(cycle) -> Note | Number | Rest | Array | Pattern? { return this.chords[cycle % this.chords.length()]; } } let prog = ChordProgression(#[ #[C4, E4, G4], #[D4, F4, A4], #[G4, B4, D5], #[C4, E4, G4], ]); let pad = session.track("pad"); pad.set_instrument(SamplerMelodic(Kit("keys"))); pad << prog; PLAY; ``` An array return plays as a chord. Return a pattern such as `[C4 E4 G4]` to spread notes across the cycle, or `[_]` for a silent cycle. Page: how-to/patterns/07-write-a-pattern-as-a-class URL: https://resonon.org/docs/how-to/patterns/07-write-a-pattern-as-a-class/#drive-the-pattern-from-the-cycle-number Previous: how-to/patterns/07-write-a-pattern-as-a-class#use-helper-methods-and-lookup-tables Next: how-to/patterns/07-write-a-pattern-as-a-class#transform-it-like-any-pattern --- <!-- ID: how-to/patterns/07-write-a-pattern-as-a-class#step-through-a-list-of-notes --> Write a Pattern as a Class > Step through a list of notes [guide] Declare the class `implements Pattern`, give it a `query(cycle)` method that declares what it returns, `-> Note | Number | Rest | Array | Pattern?`, and send an instance to a track. Fields you change in `query()` carry over to the next cycle: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } class Stepper implements Pattern { let notes; let idx; fn new(notes) { this.notes = notes; this.idx = 0; } fn query(cycle) -> Note | Number | Rest | Array | Pattern? { let note = this.notes[this.idx % this.notes.length()]; this.idx = this.idx + 1; return note; } } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << Stepper(#[C4, D4, E4, F4, G4]); PLAY; ``` | Cycle | `this.idx` before | `query()` returns | `this.idx` after | |:------|:-----------------|:-----------------|:----------------| | 0 | 0 | `notes[0]` = C4 | 1 | | 1 | 1 | `notes[1]` = D4 | 2 | | … | … | … | … | | 5 | 5 | `notes[0]` = C4 | 6 | Page: how-to/patterns/07-write-a-pattern-as-a-class URL: https://resonon.org/docs/how-to/patterns/07-write-a-pattern-as-a-class/#step-through-a-list-of-notes Next: how-to/patterns/07-write-a-pattern-as-a-class#use-helper-methods-and-lookup-tables --- <!-- ID: how-to/patterns/07-write-a-pattern-as-a-class#transform-it-like-any-pattern --> Write a Pattern as a Class > Transform it like any pattern [guide] A class that implements `Pattern` has every combinator, and every function that takes a pattern takes it. Each captures the instance's fields as they are at that moment: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } class Rise implements Pattern { let base; fn new(base) { this.base = base; } fn query(cycle) -> Note | Number | Rest | Array | Pattern? { return this.base + cycle % 5; } } let lead = session.track("lead"); lead.set_instrument(SamplerMelodic(Kit("keys"))); lead << Rise(60).fast(2).transpose(12); PLAY; ``` Page: how-to/patterns/07-write-a-pattern-as-a-class URL: https://resonon.org/docs/how-to/patterns/07-write-a-pattern-as-a-class/#transform-it-like-any-pattern Previous: how-to/patterns/07-write-a-pattern-as-a-class#drive-the-pattern-from-the-cycle-number --- <!-- ID: how-to/patterns/07-write-a-pattern-as-a-class#use-helper-methods-and-lookup-tables --> Write a Pattern as a Class > Use helper methods and lookup tables [guide] A script pattern is an ordinary class, so `query()` can call your own methods. Build tables once in `new()`, store them in a field, and read the field in `query()`. This walk clamps itself to a register: ```resonon use "std/random" { choose }; class BoundedWalk implements Pattern { let pos; let lower; let upper; let steps; fn new(start, lower, upper) { this.pos = start; this.lower = lower; this.upper = upper; this.steps = #[-2, -1, 1, 2]; } fn clamp(val) { if val < this.lower { return this.lower; } if val > this.upper { return this.upper; } return val; } fn query(cycle) -> Note | Number | Rest | Array | Pattern? { this.pos = this.clamp(this.pos + choose(cycle, this.steps)); return this.pos; } } let walk = BoundedWalk(60, 48, 72); print(walk.query(0)); print(walk.query(1)); ``` Page: how-to/patterns/07-write-a-pattern-as-a-class URL: https://resonon.org/docs/how-to/patterns/07-write-a-pattern-as-a-class/#use-helper-methods-and-lookup-tables Previous: how-to/patterns/07-write-a-pattern-as-a-class#step-through-a-list-of-notes Next: how-to/patterns/07-write-a-pattern-as-a-class#drive-the-pattern-from-the-cycle-number --- <!-- ID: how-to/patterns/08-write-in-a-key --> Write in a Key [guide] A `Scale` is a set of intervals with no pitch. A `Key` is a scale rooted at a note, and it is what turns degrees into notes. [Events & Notes](/docs/explanation/patterns/03-events-and-notes/#degrees-stay-abstract-until-keyed) explains why degrees stay abstract until a key resolves them. The names these recipes accept are listed in [Scales, Chords & Intervals](/docs/reference/patterns/03-scales-chords-intervals/). Sections: - how-to/patterns/08-write-in-a-key#write-a-melody-in-scale-degrees | Write a melody in scale degrees - how-to/patterns/08-write-in-a-key#set-the-key-for-a-whole-track | Set the key for a whole track - how-to/patterns/08-write-in-a-key#play-the-diatonic-chords-of-a-key | Play the diatonic chords of a key - how-to/patterns/08-write-in-a-key#borrow-a-note-or-chord-from-outside-the-key | Borrow a note or chord from outside the key - how-to/patterns/08-write-in-a-key#write-chords-by-name | Write chords by name - how-to/patterns/08-write-in-a-key#use-a-mode | Use a mode - how-to/patterns/08-write-in-a-key#use-your-own-scale-or-tuning | Use your own scale or tuning - how-to/patterns/08-write-in-a-key#build-material-from-intervals | Build material from intervals Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/ --- <!-- ID: how-to/patterns/08-write-in-a-key#borrow-a-note-or-chord-from-outside-the-key --> Write in a Key > Borrow a note or chord from outside the key [guide] Put `b` or `#` before the degree number to play it a semitone lower or higher — a blue note, a leading tone, a chord from the parallel key. The degree still follows the key: ```resonon let blues = [^1 ^b3 ^3 ^5].in_key(Key(C4, "major")); // the b3 rubs against the 3 let leading = [^5 ^6 ^#7 ^8].in_key(Key(A3, "minor")); // G# leads up to A let borrowed = <^1: ^b6:maj ^b7:maj ^1:>.in_key(Key(C4, "major")); ``` An altered degree has no diatonic chord, so as a chord root it names its quality: `^b6:maj`, not `^b6:`. For a negative degree the accidental comes first: `^b-2`. Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#borrow-a-note-or-chord-from-outside-the-key Previous: how-to/patterns/08-write-in-a-key#play-the-diatonic-chords-of-a-key Next: how-to/patterns/08-write-in-a-key#write-chords-by-name --- <!-- ID: how-to/patterns/08-write-in-a-key#build-material-from-intervals --> Write in a Key > Build material from intervals [guide] `interval(note, name)` returns one note. Collect several to spell a scale or chord that isn't built in: ```resonon let root = C4; let diminished = #[ root, interval(root, "M2"), interval(root, "m3"), interval(root, "P4"), interval(root, "tritone"), interval(root, "m6"), interval(root, "M6"), interval(root, "M7") ]; print(diminished); ``` Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#build-material-from-intervals Previous: how-to/patterns/08-write-in-a-key#use-your-own-scale-or-tuning --- <!-- ID: how-to/patterns/08-write-in-a-key#play-the-diatonic-chords-of-a-key --> Write in a Key > Play the diatonic chords of a key [guide] A trailing `:` on a degree builds the diatonic chord on it; add a quality to override it: ```resonon let cadence = [^1: ^4: ^5: ^1:].in_key(Key(A3, "minor")); let colored = [^1:min7 ^4:min7].in_key(Key(D4, "dorian")); ``` Outside a pattern, ask the key directly: ```resonon let k = Key(C4, "major"); print(k.chord(2)); // [D4, F4, A4] (ii) print(k.chord7(5)); // [G4, B4, D5, F5] (V7) print(k.quantize(C#4)); // C4 ``` Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#play-the-diatonic-chords-of-a-key Previous: how-to/patterns/08-write-in-a-key#set-the-key-for-a-whole-track Next: how-to/patterns/08-write-in-a-key#borrow-a-note-or-chord-from-outside-the-key --- <!-- ID: how-to/patterns/08-write-in-a-key#set-the-key-for-a-whole-track --> Write in a Key > Set the key for a whole track [guide] `track.set_key(...)` resolves every degree sent to the track, and quantizes absolute notes into the scale. It works on `MidiTrack` and `AudioTrack`. Change the key while the track plays and the next cycle is in the new key, degrees and absolute notes alike, with no need to send the pattern again: ```resonon parse-only // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("lead"); } let lead = session.midi_track("lead"); lead >> MidiOutput("synth"); lead.set_key(Key(C4, "minor")); // or lead.set_key("minor", C4) lead << [^1 ^3 ^5]; ``` Change the key and the same degrees follow it. Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#set-the-key-for-a-whole-track Previous: how-to/patterns/08-write-in-a-key#write-a-melody-in-scale-degrees Next: how-to/patterns/08-write-in-a-key#play-the-diatonic-chords-of-a-key --- <!-- ID: how-to/patterns/08-write-in-a-key#use-a-mode --> Write in a Key > Use a mode [guide] Name the mode, or rotate a scale with `.mode(n)`: ```resonon let dorian = Scale("dorian"); let also_dorian = Scale("major").mode(2); // major mode 2 = dorian print(dorian.intervals()); // [0, 2, 3, 5, 7, 9, 10] print(also_dorian.intervals()); // the same print(Key(D4, dorian).notes()); ``` Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#use-a-mode Previous: how-to/patterns/08-write-in-a-key#write-chords-by-name Next: how-to/patterns/08-write-in-a-key#use-your-own-scale-or-tuning --- <!-- ID: how-to/patterns/08-write-in-a-key#use-your-own-scale-or-tuning --> Write in a Key > Use your own scale or tuning [guide] Pass semitone intervals to `Scale()`. They start at `0` and ascend; fractional values are microtonal, and a second argument sets a period other than the octave: ```resonon let neutral = Scale(#[0, 1.5, 3.5, 5, 7, 8.5, 10]); let stretched = Scale(#[0, 2, 4, 5, 7, 9, 11], 19); let k = Key(D4, neutral); print(k.notes()); ``` Load a Scala `.scl` file with `load_scala()`. It looks next to your `.non` file, then in the project's `scales/`, then in `~/.resonon/scales/`, then in the scales shipped with resonon: ```resonon parse-only let just = load_scala("just/5-limit"); let bp = load_scala("bohlen-pierce"); ``` On a MIDI track, fractional pitches play through pitch bend; turn on `track.set_tuning()` or `track.set_mpe()` for the track. Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#use-your-own-scale-or-tuning Previous: how-to/patterns/08-write-in-a-key#use-a-mode Next: how-to/patterns/08-write-in-a-key#build-material-from-intervals --- <!-- ID: how-to/patterns/08-write-in-a-key#write-a-melody-in-scale-degrees --> Write in a Key > Write a melody in scale degrees [guide] Write degrees with `^` inside a pattern and resolve them with `.in_key()`: ```resonon let melody = [^1 ^3 ^5 ^-2].in_key(Key(C4, "major")); print(melody.describe()); ``` `^8` is the root an octave up; `^0` and negative degrees go below the root. Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#write-a-melody-in-scale-degrees Next: how-to/patterns/08-write-in-a-key#set-the-key-for-a-whole-track --- <!-- ID: how-to/patterns/08-write-in-a-key#write-chords-by-name --> Write in a Key > Write chords by name [guide] Write `Root:Quality` in a pattern, and add `~n` for an inversion. `<…>` changes chord each cycle: ```resonon let progression = <D4:min7 G4:7 C4:maj7~1>; // ii–V–I, last chord inverted ``` `chord(root, quality, inversion)` returns the same chord as an array of notes. Positive inversions raise the lowest notes by an octave; negative ones drop the highest: ```resonon print(chord(C4, "major")); // [C4, E4, G4] print(chord(C4, "major", 1)); // [E4, G4, C5] print(chord(C4, "major", -1)); // [G3, C4, E4] ``` To play an array as a chord, wrap it in `Stack()`: `Stack(chord(C4, "min7"))`. Page: how-to/patterns/08-write-in-a-key URL: https://resonon.org/docs/how-to/patterns/08-write-in-a-key/#write-chords-by-name Previous: how-to/patterns/08-write-in-a-key#borrow-a-note-or-chord-from-outside-the-key Next: how-to/patterns/08-write-in-a-key#use-a-mode --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms --> Write Polymetric and Euclidean Rhythms [guide] The syntax is in [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/); how the onsets are placed is in [Polymeter & Euclidean Rhythm](/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/). Sections: - how-to/patterns/09-write-polymetric-and-euclidean-rhythms#phase-two-loops-against-each-other | Phase two loops against each other - how-to/patterns/09-write-polymetric-and-euclidean-rhythms#spread-hits-evenly | Spread hits evenly - how-to/patterns/09-write-polymetric-and-euclidean-rhythms#rotate-and-interlock | Rotate and interlock - how-to/patterns/09-write-polymetric-and-euclidean-rhythms#deal-a-melody-onto-the-hits | Deal a melody onto the hits - how-to/patterns/09-write-polymetric-and-euclidean-rhythms#related | Related Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/ --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#deal-a-melody-onto-the-hits --> Write Polymetric and Euclidean Rhythms > Deal a melody onto the hits [guide] [`euclid()`](/docs/reference/stdlib/patterns/#euclid) takes a whole pattern as the source, and deals its notes onto the hits in order: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("melody"); } let dealt = euclid(3, 8, [C4 E4 G4]); // one note per hit let wrapped = euclid(5, 8, [C4 E4]); // C4 E4 C4 E4 C4 let melody = session.midi_track("melody"); melody >> MidiOutput("synth"); melody << dealt; PLAY; ``` The order of the operations matters. `[C4(3,8)*2]` makes the rhythm first and then plays it twice as fast; `euclid(3, 8, [C4 E4].fast(2))` doubles the source first and then picks the hits from it. Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/#deal-a-melody-onto-the-hits Previous: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#rotate-and-interlock Next: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#related --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#phase-two-loops-against-each-other --> Write Polymetric and Euclidean Rhythms > Phase two loops against each other [guide] Put the loops in curly braces, separated by commas. Every loop plays on the grid of the first one, and a shorter loop drifts against it: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("TR-808"))); drums << {bd sd bd sd, ch ch oh}; // 4-step grid; the 3-hat loop drifts PLAY; ``` Set the grid yourself with `%n` — `n` steps per cycle for every loop: ```resonon continue drums << {bd sd bd sd, ch ch oh}%8; ``` A polymetric group can be one element of a sequence: ```resonon continue drums << [{bd sd bd}%4 cp]; // the group fills the first half ``` Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/#phase-two-loops-against-each-other Next: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#spread-hits-evenly --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#related --> Write Polymetric and Euclidean Rhythms > Related [guide] - [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/) — `{}`, `%n` and `(k,n,r)` - [Polymeter & Euclidean Rhythm](/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/) — how the onsets are placed - [Add Swing and Human Feel](/docs/how-to/patterns/02-add-swing-and-human-feel/) — move the onsets off the grid Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/#related Previous: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#deal-a-melody-onto-the-hits --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#rotate-and-interlock --> Write Polymetric and Euclidean Rhythms > Rotate and interlock [guide] A third number rotates the rhythm by that many steps. Rotations of one rhythm on different sounds interlock: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd(3,8,0), rs(3,8,2), hh(3,8,5)]; PLAY; ``` Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/#rotate-and-interlock Previous: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#spread-hits-evenly Next: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#deal-a-melody-onto-the-hits --- <!-- ID: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#spread-hits-evenly --> Write Polymetric and Euclidean Rhythms > Spread hits evenly [guide] Add `(hits, steps)` to an element: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("TR-808"))); drums << [bd(3,8), ch(7,16), sd(2,16,4)]; PLAY; ``` The element plays on the hits and rests on the other steps, inside its own slot. `bd(3,8)` is the tresillo; the explanation lists more rhythms that two numbers spell. Page: how-to/patterns/09-write-polymetric-and-euclidean-rhythms URL: https://resonon.org/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/#spread-hits-evenly Previous: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#phase-two-loops-against-each-other Next: how-to/patterns/09-write-polymetric-and-euclidean-rhythms#rotate-and-interlock --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays --> List the Notes a Pattern Plays [guide] `notes()` lists what a pattern, timeline, MIDI track, array of MIDI tracks or section plays. It reads the same notes [`midi_export()`](/docs/how-to/midi/08-export-midi/) writes to a file, and plays nothing. Its signature and fields are in the [audio reference](/docs/reference/stdlib/audio/#notes). To see a pattern as a grid instead, use `viz()`. Sections: - how-to/patterns/10-list-the-notes-a-pattern-plays#print-the-notes-as-json | Print the notes as JSON - how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-chord | Check a chord - how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-drum-pattern | Check a drum pattern - how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-track-from-a-later-cycle | List a track from a later cycle - how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-song | List a song - how-to/patterns/10-list-the-notes-a-pattern-plays#use-the-notes-in-code | Use the notes in code - how-to/patterns/10-list-the-notes-a-pattern-plays#write-a-midi-clip-in-beats | Write a MIDI clip in beats - how-to/patterns/10-list-the-notes-a-pattern-plays#related | Related Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/ --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-chord --> List the Notes a Pattern Plays > Check a chord [guide] The notes of a chord start together, lowest first: ```resonon print(to_json(notes([C4:maj _], 1))); ``` ```json [{"channel":1,"duration":0.5,"duration_seconds":1,"name":"C4","note":60,"start":0,"start_seconds":0,"velocity":100},{"channel":1,"duration":0.5,"duration_seconds":1,"name":"E4","note":64,"start":0,"start_seconds":0,"velocity":100},{"channel":1,"duration":0.5,"duration_seconds":1,"name":"G4","note":67,"start":0,"start_seconds":0,"velocity":100}] ``` Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#check-a-chord Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#print-the-notes-as-json Next: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-drum-pattern --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-drum-pattern --> List the Notes a Pattern Plays > Check a drum pattern [guide] A drum hit names its sample in place of a note. It has no channel, because it plays a sample: ```resonon print(to_json(notes([bd _ sd bd^60], 1))); ``` ```json [{"duration":0.25,"duration_seconds":0.5,"sample":"bd","start":0,"start_seconds":0,"velocity":100},{"duration":0.25,"duration_seconds":0.5,"sample":"sd","start":0.5,"start_seconds":1,"velocity":100},{"duration":0.25,"duration_seconds":0.5,"sample":"bd","start":0.75,"start_seconds":1.5,"velocity":60}] ``` Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#check-a-drum-pattern Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-chord Next: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-track-from-a-later-cycle --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-song --> List the Notes a Pattern Plays > List a song [guide] Pass a section, or the song `arrange()` makes from sections, to list every track in it as `.play()` plays it. Each note names its track, and `start` is the position in the song. A drum sampler's notes are the hits of its kit. An audio track has no MIDI channel: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let intro = section(1); intro[drums] << [bd _ _ _]; let groove = section(1); groove[drums] << [bd sd]; let song = arrange(#[intro, groove]); print(to_json(notes(song, 2))); ``` ```json [{"duration":0.25,"duration_seconds":0.5,"sample":"bd","start":0,"start_seconds":0,"track":"drums","velocity":100},{"duration":0.5,"duration_seconds":1,"sample":"bd","start":1,"start_seconds":2,"track":"drums","velocity":100},{"duration":0.5,"duration_seconds":1,"sample":"sd","start":1.5,"start_seconds":3,"track":"drums","velocity":100}] ``` Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#list-a-song Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-track-from-a-later-cycle Next: how-to/patterns/10-list-the-notes-a-pattern-plays#use-the-notes-in-code --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-track-from-a-later-cycle --> List the Notes a Pattern Plays > List a track from a later cycle [guide] Pass a track to get its channel, its default velocity and its key, as it plays them. Each note names the track. Add a start cycle as the last argument: ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_midi_track("bass"); } let bass = session.midi_track("bass").set_velocity(90); bass >> MidiOutput("synth", 2); bass << [C2 _ G2 _]; print(to_json(notes(bass, 1, 1))); ``` ```json [{"channel":2,"duration":0.25,"duration_seconds":0.5,"name":"C2","note":36,"start":1,"start_seconds":2,"track":"bass","velocity":90},{"channel":2,"duration":0.25,"duration_seconds":0.5,"name":"G2","note":43,"start":1.5,"start_seconds":3,"track":"bass","velocity":90}] ``` An array of tracks lists all their notes in one list. A track with a velocity signal is run over the span, as `midi_export()` runs it, so playback pauses while it is listed. CC and pitch bend are not listed. Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#list-a-track-from-a-later-cycle Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-drum-pattern Next: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-song --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#print-the-notes-as-json --> List the Notes a Pattern Plays > Print the notes as JSON [guide] Give the source and the number of cycles, and print the result with `to_json()`: ```resonon print(to_json(notes([C4 [E4 G4]], 1))); ``` The output is one line: ```json [{"channel":1,"duration":0.5,"duration_seconds":1,"name":"C4","note":60,"start":0,"start_seconds":0,"velocity":100},{"channel":1,"duration":0.25,"duration_seconds":0.5,"name":"E4","note":64,"start":0.5,"start_seconds":1,"velocity":100},{"channel":1,"duration":0.25,"duration_seconds":0.5,"name":"G4","note":67,"start":0.75,"start_seconds":1.5,"velocity":100}] ``` `start` and `duration` are in cycles. `start_seconds` and `duration_seconds` are at the current tempo, here 120 BPM. Notes are sorted by start, then pitch, and the keys of each note are in sorted order, so the same piece always prints the same text. Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#print-the-notes-as-json Next: how-to/patterns/10-list-the-notes-a-pattern-plays#check-a-chord --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#related --> List the Notes a Pattern Plays > Related [guide] - [Export MIDI](/docs/how-to/midi/08-export-midi/) — write the same notes to a file - [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) — scale degrees need a key before they are listed Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#related Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#write-a-midi-clip-in-beats --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#use-the-notes-in-code --> List the Notes a Pattern Plays > Use the notes in code [guide] `notes()` returns an Array of Dicts, so a piece can read it directly: ```resonon let listed = notes([C4 E4 G4 C5], 4); print(listed.length()); // 16 print(listed[0]["name"]); // C4 ``` Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#use-the-notes-in-code Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#list-a-song Next: how-to/patterns/10-list-the-notes-a-pattern-plays#write-a-midi-clip-in-beats --- <!-- ID: how-to/patterns/10-list-the-notes-a-pattern-plays#write-a-midi-clip-in-beats --> List the Notes a Pattern Plays > Write a MIDI clip in beats [guide] Use `note()` for positions and lengths in beats. Use `clip()` for a looping pattern. The clip's bars use the current beats per cycle when you create it. Later meter changes keep its stored beat positions and beat length. ```resonon let melody = clip(bars: 2, notes: #[ note(C4, 0, 1/3, 90), note(D4, 1/3, 1/3), note(E4, 2/3, 1/3, muted: true) ]); show(melody); print(to_json(notes(melody, 2))); ``` `show()` lists every authored note in beats, including muted notes. `notes()` lists sounding notes in cycles. A missing velocity uses the track default. A note at or past the clip end stays stored but does not play. A note that extends past the end stops at the end. Page: how-to/patterns/10-list-the-notes-a-pattern-plays URL: https://resonon.org/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/#write-a-midi-clip-in-beats Previous: how-to/patterns/10-list-the-notes-a-pattern-plays#use-the-notes-in-code Next: how-to/patterns/10-list-the-notes-a-pattern-plays#related --- <!-- ID: how-to/patterns/11-fix-timing-problems --> Fix Timing Problems [guide] Find the message or the symptom, then work through the fix. Every timing amount here is a fraction of one step, as in [Add Swing and Human Feel](/docs/how-to/patterns/02-add-swing-and-human-feel/). Sections: - how-to/patterns/11-fix-timing-problems#an-edit-lands-late | An edit lands late - how-to/patterns/11-fix-timing-problems#notes-drop-out-under-load | Notes drop out under load - how-to/patterns/11-fix-timing-problems#events-pile-up-at-the-end-of-the-cycle | Events pile up at the end of the cycle - how-to/patterns/11-fix-timing-problems#swing-moves-only-every-other-slot | Swing moves only every other slot - how-to/patterns/11-fix-timing-problems#swing-doesnt-move-anything | Swing doesn't move anything - how-to/patterns/11-fix-timing-problems#midi-gear-is-early-or-late-against-the-mix | MIDI gear is early or late against the mix - how-to/patterns/11-fix-timing-problems#related | Related Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/ --- <!-- ID: how-to/patterns/11-fix-timing-problems#an-edit-lands-late --> Fix Timing Problems > An edit lands late [guide] A pattern you send to a playing track starts at the next cycle boundary, not when you run the line. That keeps it on the downbeat; there is no way to apply it mid-cycle. 1. Run the line shortly before the boundary. 2. To land a change at a chosen cycle further ahead, write it to a position in an arrangement — see [Add Fills to a Song](/docs/how-to/audio/18-add-fills-to-a-song/). Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#an-edit-lands-late Next: how-to/patterns/11-fix-timing-problems#notes-drop-out-under-load --- <!-- ID: how-to/patterns/11-fix-timing-problems#events-pile-up-at-the-end-of-the-cycle --> Fix Timing Problems > Events pile up at the end of the cycle [guide] `.nudge()`, `.swing()` and `.humanize()` never move an event into the next cycle. An event pushed past the end of the cycle lands on the end, so large offsets can stack several events there. 1. Keep the offsets small: `0.1` is a tenth of a step. 2. Make the offset of the last events of the cycle smaller, or negative. ```resonon [bd sd bd sd].nudge(#[0, 0.1, 0, -0.1]); ``` Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#events-pile-up-at-the-end-of-the-cycle Previous: how-to/patterns/11-fix-timing-problems#notes-drop-out-under-load Next: how-to/patterns/11-fix-timing-problems#swing-moves-only-every-other-slot --- <!-- ID: how-to/patterns/11-fix-timing-problems#midi-gear-is-early-or-late-against-the-mix --> Fix Timing Problems > MIDI gear is early or late against the mix [guide] The pattern is in time, but a synth or drum machine is heard ahead of or behind the audio tracks. Set the port's `trim_ms` — see [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/). Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#midi-gear-is-early-or-late-against-the-mix Previous: how-to/patterns/11-fix-timing-problems#swing-doesnt-move-anything Next: how-to/patterns/11-fix-timing-problems#related --- <!-- ID: how-to/patterns/11-fix-timing-problems#notes-drop-out-under-load --> Fix Timing Problems > Notes drop out under load [guide] > **Pattern query deadline exceeded: 3 scheduling pass(es) truncated since the previous warning > (latest: MIDI, cycle 812, budget … ms). Scheduled output may be incomplete. Simplify expensive > patterns or generators, or reduce scheduling load.** A cycle took too long to compute, and some of its events were not scheduled. 1. Look for a generator that grows with time. A stream, a Markov chain or a script pattern replays every cycle from cycle 0 to answer for the current one, so a costly step function gets slower as the cycle count rises. 2. Make the step function cheaper, or move work that doesn't change out of it and into a `let`. 3. Look for an `on_cycle` callback that does heavy work, and do that work once outside it. Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#notes-drop-out-under-load Previous: how-to/patterns/11-fix-timing-problems#an-edit-lands-late Next: how-to/patterns/11-fix-timing-problems#events-pile-up-at-the-end-of-the-cycle --- <!-- ID: how-to/patterns/11-fix-timing-problems#related --> Fix Timing Problems > Related [guide] - [Add Swing and Human Feel](/docs/how-to/patterns/02-add-swing-and-human-feel/) — nudge, swing and humanize - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/#quantized-swaps) — why an edit waits for the cycle boundary - [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/#timing-moves) — how each timing move measures its amount Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#related Previous: how-to/patterns/11-fix-timing-problems#midi-gear-is-early-or-late-against-the-mix --- <!-- ID: how-to/patterns/11-fix-timing-problems#swing-doesnt-move-anything --> Fix Timing Problems > Swing doesn't move anything [guide] Swing moves only what plays on the odd slots of its grid. A part with nothing there stays straight: the quarter notes of `[bd sd bd sd]` all sit on even 16ths, so `.swing(0.25, 16)` leaves them alone. Match the grid to the part you want to swing: `16` for 16th hats, `8` for 8ths, `4` to swing the `sd` in `[bd sd bd sd]`. Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#swing-doesnt-move-anything Previous: how-to/patterns/11-fix-timing-problems#swing-moves-only-every-other-slot Next: how-to/patterns/11-fix-timing-problems#midi-gear-is-early-or-late-against-the-mix --- <!-- ID: how-to/patterns/11-fix-timing-problems#swing-moves-only-every-other-slot --> Fix Timing Problems > Swing moves only every other slot [guide] That is what swing does: the even slots of its grid stay, and the odd ones play late. To move each event by its own amount, use `.nudge()` with one offset per event: ```resonon [hh hh hh hh].nudge(#[0, 0.2, 0.05, 0.15]); ``` Page: how-to/patterns/11-fix-timing-problems URL: https://resonon.org/docs/how-to/patterns/11-fix-timing-problems/#swing-moves-only-every-other-slot Previous: how-to/patterns/11-fix-timing-problems#events-pile-up-at-the-end-of-the-cycle Next: how-to/patterns/11-fix-timing-problems#swing-doesnt-move-anything --- <!-- ID: how-to/running/01-run-a-shared-server --> Run a Shared Server [guide] A server holds one session; every client connected to it plays into that session. The flags are in the [CLI reference](/docs/reference/setup/01-cli/#resonon-server); [Sessions & Servers](/docs/explanation/running/03-sessions-and-servers/) explains the model. Sections: - how-to/running/01-run-a-shared-server#start-a-server | Start a server - how-to/running/01-run-a-shared-server#share-on-a-network | Share on a network - how-to/running/01-run-a-shared-server#join-from-vscode | Join from VSCode - how-to/running/01-run-a-shared-server#join-from-a-terminal-view | Join from a terminal view - how-to/running/01-run-a-shared-server#tell-who-ran-what | Tell who ran what - how-to/running/01-run-a-shared-server#related | Related Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/ --- <!-- ID: how-to/running/01-run-a-shared-server#join-from-a-terminal-view --> Run a Shared Server > Join from a terminal view [guide] ```bash resonon view routing --host 10.0.0.5 --port 5555 ``` Leave out `--host` and `--port` to pick a discovered server from a list, or press `Tab` to enter an address. The Manual default is `127.0.0.1:5555`. Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#join-from-a-terminal-view Previous: how-to/running/01-run-a-shared-server#join-from-vscode Next: how-to/running/01-run-a-shared-server#tell-who-ran-what --- <!-- ID: how-to/running/01-run-a-shared-server#join-from-vscode --> Run a Shared Server > Join from VSCode [guide] Open the RESONON sidebar. Servers that the extension starts are tracked directly. For another loopback server, choose **Add Server...** and enter `127.0.0.1` and its port. Network-bound servers advertise to editors on the same machine; to join from another machine, add the server's network address and port. With several servers connected, **Set as Active Server** picks the one `Cmd+Enter` evaluates on. Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#join-from-vscode Previous: how-to/running/01-run-a-shared-server#share-on-a-network Next: how-to/running/01-run-a-shared-server#join-from-a-terminal-view --- <!-- ID: how-to/running/01-run-a-shared-server#related --> Run a Shared Server > Related [guide] - [Sessions & Servers](/docs/explanation/running/03-sessions-and-servers/) — one session, many clients - [VSCode Extension](/docs/reference/running/01-vscode-extension/) — every command and setting - [Fix Connection Problems](/docs/how-to/running/05-fix-connection-problems/) — when a connection fails Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#related Previous: how-to/running/01-run-a-shared-server#tell-who-ran-what --- <!-- ID: how-to/running/01-run-a-shared-server#share-on-a-network --> Run a Shared Server > Share on a network [guide] Bind explicitly to a network interface, or to every interface: ```bash resonon server --host 0.0.0.0 --name "studio" ``` The loopback default limits direct network exposure. Local programs remain trusted: any local program that can connect can control the session. Explicit network binding has no authentication or encryption. Anyone who can reach the port can control the session; use only a trusted network. Loopback binding is not a complete security boundary against browser-origin connections. Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#share-on-a-network Previous: how-to/running/01-run-a-shared-server#start-a-server Next: how-to/running/01-run-a-shared-server#join-from-vscode --- <!-- ID: how-to/running/01-run-a-shared-server#start-a-server --> Run a Shared Server > Start a server [guide] ```bash resonon server --name "studio" ``` ```txt [server] Listening on 127.0.0.1:5555 ``` It listens on this machine only, on port 5555. Loopback-only servers do not send discovery beacons. Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#start-a-server Next: how-to/running/01-run-a-shared-server#share-on-a-network --- <!-- ID: how-to/running/01-run-a-shared-server#tell-who-ran-what --> Run a Shared Server > Tell who ran what [guide] Each client has a display name, shown in the status bar and next to its output. Set it with **RESONON: Set Display Name** or the `resonon.client.name` setting; without one, your system user name is used. When several people evaluate at once, **RESONON: Toggle Output Filter (Own / All)** shows only your own output, or everyone's. Page: how-to/running/01-run-a-shared-server URL: https://resonon.org/docs/how-to/running/01-run-a-shared-server/#tell-who-ran-what Previous: how-to/running/01-run-a-shared-server#join-from-a-terminal-view Next: how-to/running/01-run-a-shared-server#related --- <!-- ID: how-to/running/02-render-a-project --> Render a Project [guide] `render()` bounces offline, faster than real time. Put it in the project's `src/main.non` and run `resonon run` in the project folder, or evaluate it in a live session. What it can render, including visuals, is listed under [`render`](/docs/reference/stdlib/audio/#render). Sections: - how-to/running/02-render-a-project#render-stems-and-the-master | Render stems and the master - how-to/running/02-render-a-project#render-only-the-mix-or-one-track | Render only the mix, or one track - how-to/running/02-render-a-project#name-the-output | Name the output - how-to/running/02-render-a-project#find-the-files | Find the files - how-to/running/02-render-a-project#related | Related Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/ --- <!-- ID: how-to/running/02-render-a-project#find-the-files --> Render a Project > Find the files [guide] Each render gets its own folder under `renders/` in the project, named after the title and the time, so renders never overwrite each other. When the render is done, `resonon run` prints the folder: `rendered to <folder>/`. A project with one render: ``` my_piece/ resonon.toml src/main.non renders/ house_beat_2026-09-07_18-00-00/ kicks.wav kicks.wav.json hats.wav hats.wav.json master.wav master.wav.json ``` Beside each WAV, its `.wav.json` holds the tempo it was rendered at. The files are 24-bit, 48 kHz stereo WAV. Live output pauses while a render runs, and a progress bar in the terminal shows the cycle and the time left. The render captures the session as it sounds — instruments, effects, sends and automation. MIDI tracks, hardware outputs and live inputs are not in it: [What a render contains](/docs/reference/audio/01-levels-and-files/#what-a-render-contains). Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/#find-the-files Previous: how-to/running/02-render-a-project#name-the-output Next: how-to/running/02-render-a-project#related --- <!-- ID: how-to/running/02-render-a-project#name-the-output --> Render a Project > Name the output [guide] `set_project_title()` names the output folder; `set_project_artist()` sets the artist. Without a title, the folder is named after the package in `resonon.toml`. ```resonon parse-only set_project_title("House Beat"); set_project_artist("RESONON"); ``` Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/#name-the-output Previous: how-to/running/02-render-a-project#render-only-the-mix-or-one-track Next: how-to/running/02-render-a-project#find-the-files --- <!-- ID: how-to/running/02-render-a-project#related --> Render a Project > Related [guide] - [Audio: render](/docs/reference/stdlib/audio/#render) — every render target - [Render a Song](/docs/how-to/running/03-render-a-song/) — a render as long as the song - [Two Ways to Run a Piece](/docs/explanation/running/01-two-ways-to-run-a-piece/) — when to render - [Export MIDI](/docs/how-to/midi/08-export-midi/) — export notes instead of audio Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/#related Previous: how-to/running/02-render-a-project#find-the-files --- <!-- ID: how-to/running/02-render-a-project#render-only-the-mix-or-one-track --> Render a Project > Render only the mix, or one track [guide] ```resonon continue render(4); // the master mix render(kicks, 4); // one track ``` Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/#render-only-the-mix-or-one-track Previous: how-to/running/02-render-a-project#render-stems-and-the-master Next: how-to/running/02-render-a-project#name-the-output --- <!-- ID: how-to/running/02-render-a-project#render-stems-and-the-master --> Render a Project > Render stems and the master [guide] List the tracks, add `session.master`, and give the number of cycles: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("kicks"); session.create_track("hats"); } set_project_title("House Beat"); let kicks = session.track("kicks"); kicks.set_instrument(Sampler(Kit("CR-78"))); kicks << [bd*4]; kicks.set_effects(#[Filter("lowpass", FilterType.lowpass, 600)]); let hats = session.track("hats"); hats.set_instrument(Sampler(Kit("CR-78"))); hats << [_ hh].fast(4); hats.set_effects(#[Filter("highpass", FilterType.highpass, 3000)]); render(#[kicks, hats, session.master], 4); ``` Each track is written as its own WAV, and `session.master` as the full mix. Page: how-to/running/02-render-a-project URL: https://resonon.org/docs/how-to/running/02-render-a-project/#render-stems-and-the-master Next: how-to/running/02-render-a-project#render-only-the-mix-or-one-track --- <!-- ID: how-to/running/03-render-a-song --> Render a Song [guide] A song made with `arrange()` knows its own length, so the render can be exactly as long as the song. Sections: - how-to/running/03-render-a-song#render-the-song | Render the song - how-to/running/03-render-a-song#render-stems-with-it | Render stems with it - how-to/running/03-render-a-song#keep-the-tail | Keep the tail - how-to/running/03-render-a-song#related | Related Page: how-to/running/03-render-a-song URL: https://resonon.org/docs/how-to/running/03-render-a-song/ --- <!-- ID: how-to/running/03-render-a-song#keep-the-tail --> Render a Song > Keep the tail [guide] The render stops at its last cycle, so a reverb or delay still sounding there is cut. To keep it, render past the end of the song: ```resonon continue render(session.master, song.length() + 2); ``` A song plays nothing after its last cycle, so the extra cycles hold only the tail. Add cycles until the tail has died away. What else a render leaves out is in [What a render contains](/docs/reference/audio/01-levels-and-files/#what-a-render-contains). Page: how-to/running/03-render-a-song URL: https://resonon.org/docs/how-to/running/03-render-a-song/#keep-the-tail Previous: how-to/running/03-render-a-song#render-stems-with-it Next: how-to/running/03-render-a-song#related --- <!-- ID: how-to/running/03-render-a-song#related --> Render a Song > Related [guide] - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — build the song - [Render a Project](/docs/how-to/running/02-render-a-project/) — naming the folder, and where files land - [Arrange a Song](/docs/tutorials/getting-started/05-arrange-a-song/) — the whole path, as a tutorial Page: how-to/running/03-render-a-song URL: https://resonon.org/docs/how-to/running/03-render-a-song/#related Previous: how-to/running/03-render-a-song#keep-the-tail --- <!-- ID: how-to/running/03-render-a-song#render-stems-with-it --> Render a Song > Render stems with it [guide] List the tracks beside `session.master`: ```resonon continue render(#[drums, session.master], song.length()); ``` Each track is written as its own WAV, beside `master.wav`. Page: how-to/running/03-render-a-song URL: https://resonon.org/docs/how-to/running/03-render-a-song/#render-stems-with-it Previous: how-to/running/03-render-a-song#render-the-song Next: how-to/running/03-render-a-song#keep-the-tail --- <!-- ID: how-to/running/03-render-a-song#render-the-song --> Render a Song > Render the song [guide] End the project's `src/main.non` with the song, `song.play()`, and a render as long as the song: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } set_project_title("My Song"); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let verse = section(4); verse[drums] << [bd _ sd _]; let chorus = section(4); chorus[drums] << [bd sd bd sd]; let song = arrange(#[verse * 2, chorus]); song.play(); render(session.master, song.length()); ``` `song.play()` puts the song on its tracks. `render()` plays it from the start, for `song.length()` cycles. In the project folder, run: ```bash resonon run ``` The mix is in `renders/my_song_<date>_<time>/master.wav`. Page: how-to/running/03-render-a-song URL: https://resonon.org/docs/how-to/running/03-render-a-song/#render-the-song Next: how-to/running/03-render-a-song#render-stems-with-it --- <!-- ID: how-to/running/04-render-visuals-to-frames --> Render Visuals to Video [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: `render(screen, n)` renders what is routed to `screen` for `n` cycles. On macOS it writes `screen.mp4`: 60 fps H.264 video with the master mix as AAC audio, using the native hardware encoder. Add `session.master` or a track to the targets to write their WAV files too. On other platforms it writes a PNG frame sequence. Sections: - how-to/running/04-render-visuals-to-frames#render-the-picture-and-the-mix | Render the picture and the mix - how-to/running/04-render-visuals-to-frames#render-without-a-separate-wav | Render without a separate WAV - how-to/running/04-render-visuals-to-frames#find-the-export | Find the export - how-to/running/04-render-visuals-to-frames#render-a-songs-screen-lane | Render a song's screen lane - how-to/running/04-render-visuals-to-frames#related | Related Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/ --- <!-- ID: how-to/running/04-render-visuals-to-frames#find-the-export --> Render Visuals to Video > Find the export [guide] On macOS, the movie is in the render's folder under `renders/`: ```txt renders/ frames_2026-09-30_18-00-00/ master.wav only when master is a target screen.mp4 picture and master mix ``` There are 60 frames a second, at the composition size (1920 × 1080 by default). Set it with `screen.resolution(width, height)` before rendering. H.264 uses 4:2:0 colour with BT.709 tags; both dimensions must be even. An odd dimension errors before audio is bounced or files are written. No PNG frames or external encoder are needed on macOS. Other platforms write `frames/frame_00000.png` onwards. To assemble these into a video with audio, include `session.master` in the targets and run an encoder such as `ffmpeg` in the render folder: ```bash ffmpeg -framerate 60 -i frames/frame_%05d.png -i master.wav -c:v libx264 -pix_fmt yuv420p -c:a aac video.mp4 ``` Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/#find-the-export Previous: how-to/running/04-render-visuals-to-frames#render-without-a-separate-wav Next: how-to/running/04-render-visuals-to-frames#render-a-songs-screen-lane --- <!-- ID: how-to/running/04-render-visuals-to-frames#related --> Render Visuals to Video > Related [guide] - [Render a Project](/docs/how-to/running/02-render-a-project/) — audio only, stems, and naming the folder - [Bind Audio to a Shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/) — levels and spectra on a picture - [Audio: render](/docs/reference/stdlib/audio/#render) — every render target Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/#related Previous: how-to/running/04-render-visuals-to-frames#render-a-songs-screen-lane --- <!-- ID: how-to/running/04-render-visuals-to-frames#render-a-songs-screen-lane --> Render Visuals to Video > Render a song's screen lane [guide] Call `song.play()` to put the arranged screen lane on screen, then render it for the song's length: ```resonon continue let verse = section(1); verse[drums] << [bd sd bd sd]; verse[screen] << field; let chorus = verse.clone(); chorus[screen] << soft; let song = arrange(#[verse, chorus]); song.play(); render(#[session.master, screen], song.length()); ``` The picture changes on the first frame at each span's start. Gaps and frames past the lane's end are black. Feedback trails keep their state across cuts and hold still during gaps, as in the live window. Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/#render-a-songs-screen-lane Previous: how-to/running/04-render-visuals-to-frames#find-the-export Next: how-to/running/04-render-visuals-to-frames#related --- <!-- ID: how-to/running/04-render-visuals-to-frames#render-the-picture-and-the-mix --> Render Visuals to Video > Render the picture and the mix [guide] Route the picture to `screen`, then render `session.master` and `screen` together: ```resonon use "std/instruments" { Sampler, Kit }; use "std/visuals" as gfx; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } set_project_title("Frames"); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let field = gfx.Noise("field"); let soft = gfx.Blur("soft"); soft.parameter("size") << drums.rms.smooth(80).range(1, 40); field >> soft >> screen; render(#[session.master, screen], 1); ``` Then, in the project folder: ```bash resonon run ``` A level or spectrum bound to the picture reads the render's own audio, so the frames move with the mix. No window has to be open. Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/#render-the-picture-and-the-mix Next: how-to/running/04-render-visuals-to-frames#render-without-a-separate-wav --- <!-- ID: how-to/running/04-render-visuals-to-frames#render-without-a-separate-wav --> Render Visuals to Video > Render without a separate WAV [guide] ```resonon continue render(screen, 1); ``` The master mix is included in the macOS MP4. No separate `master.wav` is written. On other platforms, the mix drives the bound levels but is not saved. Page: how-to/running/04-render-visuals-to-frames URL: https://resonon.org/docs/how-to/running/04-render-visuals-to-frames/#render-without-a-separate-wav Previous: how-to/running/04-render-visuals-to-frames#render-the-picture-and-the-mix Next: how-to/running/04-render-visuals-to-frames#find-the-export --- <!-- ID: how-to/running/05-fix-connection-problems --> Fix Connection Problems [guide] Find the message or the symptom, then work through the fix. Quoted blocks are what resonon or the VSCode extension prints; bracketed lines appear in the **RESONON** Output panel. Sections: - how-to/running/05-fix-connection-problems#vscode-cannot-connect | VSCode cannot connect - how-to/running/05-fix-connection-problems#a-server-will-not-start | A server will not start - how-to/running/05-fix-connection-problems#a-server-does-not-appear-in-the-servers-view | A server does not appear in the Servers view - how-to/running/05-fix-connection-problems#the-connection-drops | The connection drops - how-to/running/05-fix-connection-problems#a-server-will-not-play-a-project | A server will not play a project - how-to/running/05-fix-connection-problems#the-extension-and-resonon-disagree-on-the-version | The extension and resonon disagree on the version - how-to/running/05-fix-connection-problems#nothing-appears-in-the-output-panel | Nothing appears in the Output panel - how-to/running/05-fix-connection-problems#related | Related Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/ --- <!-- ID: how-to/running/05-fix-connection-problems#a-server-does-not-appear-in-the-servers-view --> Fix Connection Problems > A server does not appear in the Servers view [guide] The view shows **No servers online.** 1. Check that the server runs, and that its startup line printed. A loopback-only server does not advertise; a server the extension starts is tracked directly. 2. Add it by hand: choose **Add Server...** and enter its host and port. A server added this way stays in the list. 3. In a terminal view, pass `--host` and `--port` to connect without the list. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#a-server-does-not-appear-in-the-servers-view Previous: how-to/running/05-fix-connection-problems#a-server-will-not-start Next: how-to/running/05-fix-connection-problems#the-connection-drops --- <!-- ID: how-to/running/05-fix-connection-problems#a-server-will-not-play-a-project --> Fix Connection Problems > A server will not play a project [guide] > **/songs/techno needs Resonon 0.13.0; this server runs 0.12.1. Restart the server from that > project to play it.** A running server keeps the version it started with, and refuses a project that needs a newer one. 1. Restart the server from inside the project, so the launcher starts the version it pins. For a server the extension started, take the **Restart server for …** button on the message; restarting stops playback. 2. If the message ends with `Install with: resonon version install …`, run that first. `resonon.server.path` pins the extension to one binary, whatever the project pins. Clear it to let the launcher choose. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#a-server-will-not-play-a-project Previous: how-to/running/05-fix-connection-problems#the-connection-drops Next: how-to/running/05-fix-connection-problems#the-extension-and-resonon-disagree-on-the-version --- <!-- ID: how-to/running/05-fix-connection-problems#a-server-will-not-start --> Fix Connection Problems > A server will not start [guide] > **Server error: Address already in use (os error 48)** Another process holds the port — often a server you started earlier. 1. Find it: `lsof -i :5555`. Stop it, or connect to it instead. 2. Or start this one on another port: `resonon server --port 5557`. For a server the extension starts, set `resonon.server.port`. 3. The default host is `127.0.0.1`. To connect from another machine, the server must bind explicitly to its network address with `--host`; see [Run a Shared Server](/docs/how-to/running/01-run-a-shared-server/). > **Failed to start RESONON server: Could not find resonon binary. Set resonon.server.path in > settings or ensure resonon is on your PATH.** 1. Run `resonon --version` in a terminal. If it is not found, install resonon — see [Installation](/docs/tutorials/getting-started/01-installation/). 2. If it is installed somewhere VSCode doesn't look, set `resonon.server.path` to the binary. > **Failed to start RESONON server: Server failed to start within 15 seconds** The server started but never reported that it was listening. Read what it printed in the **RESONON** Output panel, and start it with `resonon server` in a terminal to see the error. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#a-server-will-not-start Previous: how-to/running/05-fix-connection-problems#vscode-cannot-connect Next: how-to/running/05-fix-connection-problems#a-server-does-not-appear-in-the-servers-view --- <!-- ID: how-to/running/05-fix-connection-problems#nothing-appears-in-the-output-panel --> Fix Connection Problems > Nothing appears in the Output panel [guide] 1. Print it: an expression on its own prints nothing. Use `print()` or `put()`. 2. Open the panel with `Cmd+Shift+U`, and pick **RESONON** in its list. 3. Check that the status bar shows a connected server. 4. In a shared session, check the output filter: **RESONON: Toggle Output Filter (Own / All)**. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#nothing-appears-in-the-output-panel Previous: how-to/running/05-fix-connection-problems#the-extension-and-resonon-disagree-on-the-version Next: how-to/running/05-fix-connection-problems#related --- <!-- ID: how-to/running/05-fix-connection-problems#related --> Fix Connection Problems > Related [guide] - [Run a Shared Server](/docs/how-to/running/01-run-a-shared-server/) — hosts, ports and local access - [VSCode Extension](/docs/reference/running/01-vscode-extension/) — every command and setting - [Command Line](/docs/reference/setup/01-cli/#resonon-server) — the server's flags - [Fix Install and Project Problems](/docs/how-to/setup/06-fix-install-and-project-problems/#a-new-feature-seems-missing-after-an-upgrade) — an upgrade that seems to change nothing Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#related Previous: how-to/running/05-fix-connection-problems#nothing-appears-in-the-output-panel --- <!-- ID: how-to/running/05-fix-connection-problems#the-connection-drops --> Fix Connection Problems > The connection drops [guide] > **[Lost connection to studio (10.0.0.5:5555), attempting reconnect...]** The extension tries three times to reconnect to the active server. If all three fail: > **Server "studio" disconnected** 1. Check that the server still runs; restart it if it stopped. 2. Choose **Reconnect**, or **Pick Server** to connect to another. A terminal view does not reconnect: it returns to its connect screen with the reason, where you connect again. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#the-connection-drops Previous: how-to/running/05-fix-connection-problems#a-server-does-not-appear-in-the-servers-view Next: how-to/running/05-fix-connection-problems#a-server-will-not-play-a-project --- <!-- ID: how-to/running/05-fix-connection-problems#the-extension-and-resonon-disagree-on-the-version --> Fix Connection Problems > The extension and resonon disagree on the version [guide] > **RESONON version mismatch: extension 0.12.1, binary 0.11.0. Update to avoid compatibility > issues.** Update whichever is older: take **Download Update**, or update the extension in VSCode. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#the-extension-and-resonon-disagree-on-the-version Previous: how-to/running/05-fix-connection-problems#a-server-will-not-play-a-project Next: how-to/running/05-fix-connection-problems#nothing-appears-in-the-output-panel --- <!-- ID: how-to/running/05-fix-connection-problems#vscode-cannot-connect --> Fix Connection Problems > VSCode cannot connect [guide] > **Not connected to RESONON server. Run 'RESONON: Connect to Server' first.** 1. Check that a server runs: start one with **RESONON: Start Server**, or `resonon server` in a terminal. A server is ready when it prints `[server] Listening on 127.0.0.1:5555`. 2. Check the host and port. `5555` is the default port; a server started with `--port` listens on that one. 3. Check that your firewall lets the connection through to the port. 4. Start the server on the loopback address, to rule the network out: `resonon server --host 127.0.0.1`. Page: how-to/running/05-fix-connection-problems URL: https://resonon.org/docs/how-to/running/05-fix-connection-problems/#vscode-cannot-connect Next: how-to/running/05-fix-connection-problems#a-server-will-not-start --- <!-- ID: how-to/running/06-change-tempo --> Change Tempo [guide] Set the piece's starting tempo before sending patterns to tracks. Tempo is shared by audio and MIDI. Sections: - how-to/running/06-change-tempo#set-a-fixed-tempo | Set a fixed tempo - how-to/running/06-change-tempo#change-tempo-by-cycle-in-a-live-session | Change tempo by cycle in a live session Page: how-to/running/06-change-tempo URL: https://resonon.org/docs/how-to/running/06-change-tempo/ --- <!-- ID: how-to/running/06-change-tempo#change-tempo-by-cycle-in-a-live-session --> Change Tempo > Change tempo by cycle in a live session [guide] Register a callback that chooses the tempo from the current cycle, so seeking to a later cycle chooses that section's tempo too: ```resonon set_bpm(120, 4); on_cycle(fn(cycle) { if cycle < 8 { set_bpm(120, 4); } else { set_bpm(100, 4); } }); PLAY; ``` Play through cycle 8 and check the slower tempo. Then stop, evaluate `SEEK 8;` and play again to check the later section directly. Keep this callback registered only once: before replacing it, run `off_cycle()`, which clears **all** cycle callbacks, then register the callbacks you need again. Resonon has no dedicated tempo-map or tempo-ramp API. This callback is a live-session recipe for cycle-based changes, not an editable tempo lane. For a fixed-tempo file render, put `set_bpm()` before the render call. [Cycles and Time](/docs/explanation/patterns/01-cycles-and-time/) explains the time model; [set_bpm](/docs/reference/stdlib/audio/#set_bpm) and [on_cycle](/docs/reference/stdlib/generative/#on_cycle) give the signatures. Page: how-to/running/06-change-tempo URL: https://resonon.org/docs/how-to/running/06-change-tempo/#change-tempo-by-cycle-in-a-live-session Previous: how-to/running/06-change-tempo#set-a-fixed-tempo --- <!-- ID: how-to/running/06-change-tempo#set-a-fixed-tempo --> Change Tempo > Set a fixed tempo [guide] ```resonon set_bpm(120, 4); ``` This gives four beats per cycle at 120 BPM: a cycle lasts two seconds. Use `set_bpm(90, 3)` for three beats per cycle at 90 BPM. Pass the beats per cycle explicitly when changing meter; omitting it uses four. To change the running tempo without changing project metadata, evaluate: ```resonon set_bpm(128, 4); ``` If the session is following an external MIDI clock, `set_bpm()` is ignored with a message. Return to the internal clock with `set_midi_clock_source()` before setting the tempo yourself. Page: how-to/running/06-change-tempo URL: https://resonon.org/docs/how-to/running/06-change-tempo/#set-a-fixed-tempo Next: how-to/running/06-change-tempo#change-tempo-by-cycle-in-a-live-session --- <!-- ID: how-to/running/08-debug-a-session --> Debug a Session [guide] Keep the session open while you narrow down the problem. Use the console for runtime messages and the editor for the source location. Sections: - how-to/running/08-debug-a-session#find-the-failing-statement | Find the failing statement - how-to/running/08-debug-a-session#inspect-values-and-patterns | Inspect values and patterns - how-to/running/08-debug-a-session#separate-routing-from-playback | Separate routing from playback - how-to/running/08-debug-a-session#recover-deliberately | Recover deliberately Page: how-to/running/08-debug-a-session URL: https://resonon.org/docs/how-to/running/08-debug-a-session/ --- <!-- ID: how-to/running/08-debug-a-session#find-the-failing-statement --> Debug a Session > Find the failing statement [guide] 1. Open **RESONON: Open Console** and the VSCode Problems panel. 2. Evaluate the smallest selection that reproduces the error. Read the first error and its file, line and column. 3. Fix that statement, then evaluate it again. For the common messages, use [Fix Language Errors](/docs/how-to/language/01-fix-language-errors/). After a runtime error, earlier statements may already have changed the session. Inspect those changes before re-running a larger selection. Page: how-to/running/08-debug-a-session URL: https://resonon.org/docs/how-to/running/08-debug-a-session/#find-the-failing-statement Next: how-to/running/08-debug-a-session#inspect-values-and-patterns --- <!-- ID: how-to/running/08-debug-a-session#inspect-values-and-patterns --> Debug a Session > Inspect values and patterns [guide] ```resonon let motif = [C4 E4 G4 E4].fast(2); show(motif); print(motif.describe()); assert type(motif) == "Pattern"; ``` Use `print()` for a value and `show()` for its inspection output. `.describe()` exposes a pattern's transform chain. To inspect a loaded module, evaluate `show(module_alias)` against the alias you imported; compare its exports with the function you meant to call. Page: how-to/running/08-debug-a-session URL: https://resonon.org/docs/how-to/running/08-debug-a-session/#inspect-values-and-patterns Previous: how-to/running/08-debug-a-session#find-the-failing-statement Next: how-to/running/08-debug-a-session#separate-routing-from-playback --- <!-- ID: how-to/running/08-debug-a-session#recover-deliberately --> Debug a Session > Recover deliberately [guide] Use `PAUSE;` to hold your place or `STOP;` to return to the start. If sound needs to be cut, send `STOP;` three times. Use `RESET;` only when you intend to discard the session, then rebuild it from the saved source. The [error model](/docs/explanation/language/04-the-error-model/) explains which changes survive an error. Page: how-to/running/08-debug-a-session URL: https://resonon.org/docs/how-to/running/08-debug-a-session/#recover-deliberately Previous: how-to/running/08-debug-a-session#separate-routing-from-playback --- <!-- ID: how-to/running/08-debug-a-session#separate-routing-from-playback --> Debug a Session > Separate routing from playback [guide] Open the mixer and routing views. Check whether the track has a pattern and instrument, whether transport is playing, and where the track sends its output. Follow [Monitor Levels and Routing](/docs/how-to/audio/23-monitor-levels-and-routing/) for the steps. Use [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/) or [Fix MIDI Problems](/docs/how-to/midi/09-fix-midi-problems/) when the failure is at the device. Page: how-to/running/08-debug-a-session URL: https://resonon.org/docs/how-to/running/08-debug-a-session/#separate-routing-from-playback Previous: how-to/running/08-debug-a-session#inspect-values-and-patterns Next: how-to/running/08-debug-a-session#recover-deliberately --- <!-- ID: how-to/running/09-use-the-repl --> Use the REPL [guide] Use the REPL when you want to try code interactively from a terminal. Sections: - how-to/running/09-use-the-repl#open-the-project-prompt | Open the project prompt - how-to/running/09-use-the-repl#enter-a-small-session | Enter a small session - how-to/running/09-use-the-repl#stop-and-leave | Stop and leave Page: how-to/running/09-use-the-repl URL: https://resonon.org/docs/how-to/running/09-use-the-repl/ --- <!-- ID: how-to/running/09-use-the-repl#enter-a-small-session --> Use the REPL > Enter a small session [guide] Enter each line separately and press `Enter`: ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; PLAY; ``` The prompt retains the variables between lines. Enter `drums << [bd hh sd hh];` to replace the pattern at the next cycle boundary. Use the up arrow to recall and edit a previous line. Keep a function or class definition on one input line; the REPL does not gather multiline input. For larger edits, save code in a project file and evaluate it through VSCode. Page: how-to/running/09-use-the-repl URL: https://resonon.org/docs/how-to/running/09-use-the-repl/#enter-a-small-session Previous: how-to/running/09-use-the-repl#open-the-project-prompt Next: how-to/running/09-use-the-repl#stop-and-leave --- <!-- ID: how-to/running/09-use-the-repl#open-the-project-prompt --> Use the REPL > Open the project prompt [guide] From a directory containing `resonon.toml`, or a directory below it, run: ```sh resonon ``` For a new piece, create the project first with `resonon new my-piece`, then `cd my-piece`. Wait for the `> ` prompt. Page: how-to/running/09-use-the-repl URL: https://resonon.org/docs/how-to/running/09-use-the-repl/#open-the-project-prompt Next: how-to/running/09-use-the-repl#enter-a-small-session --- <!-- ID: how-to/running/09-use-the-repl#stop-and-leave --> Use the REPL > Stop and leave [guide] Enter `STOP;` to stop playback. Enter `EXIT` alone on a line, or press `Ctrl+D`, to leave the REPL. Use `Ctrl+C` to discard the current input without leaving. History lasts only for this REPL session. Save code you want to keep in a `.non` file; neither history nor a saved project session is a source-code backup. [REPL](/docs/reference/running/04-repl/) lists the commands and keys. Page: how-to/running/09-use-the-repl URL: https://resonon.org/docs/how-to/running/09-use-the-repl/#stop-and-leave Previous: how-to/running/09-use-the-repl#enter-a-small-session --- <!-- ID: how-to/running/10-perform-live --> Perform Live [guide] Prepare the source and the machine before the set, then evaluate changes into the same session. Sections: - how-to/running/10-perform-live#prepare-the-set | Prepare the set - how-to/running/10-perform-live#make-a-change-while-playing | Make a change while playing - how-to/running/10-perform-live#hold-end-and-recover | Hold, end and recover Page: how-to/running/10-perform-live URL: https://resonon.org/docs/how-to/running/10-perform-live/ --- <!-- ID: how-to/running/10-perform-live#hold-end-and-recover --> Perform Live > Hold, end and recover [guide] Use `F5` to pause and resume. Use `Shift+F5` to stop and return to the start; delay and reverb tails can finish. Three stops in a row cut lingering sound while keeping the rig. If an evaluation fails, read the console, fix the statement and send the correction. Use [Debug a Session](/docs/how-to/running/08-debug-a-session/) to inspect changes already applied. `RESET;` discards the rig and variables: reserve it for rebuilding from saved source. For a timed composition, use [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/). The [transport model](/docs/explanation/running/04-transport-and-session/) explains the recovery choices. Page: how-to/running/10-perform-live URL: https://resonon.org/docs/how-to/running/10-perform-live/#hold-end-and-recover Previous: how-to/running/10-perform-live#make-a-change-while-playing --- <!-- ID: how-to/running/10-perform-live#make-a-change-while-playing --> Perform Live > Make a change while playing [guide] For example, build this drum track and start it: ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; PLAY; ``` Select only the replacement line and evaluate it with `Cmd+Enter` (`Ctrl+Enter` on Windows/Linux): ```resonon continue drums << [bd [hh sd] bd sd]; ``` Listen for the replacement on the next cycle boundary. Keep the same track name when changing its material. Leave setup and destructive commands outside the selections you use for variations. Page: how-to/running/10-perform-live URL: https://resonon.org/docs/how-to/running/10-perform-live/#make-a-change-while-playing Previous: how-to/running/10-perform-live#prepare-the-set Next: how-to/running/10-perform-live#hold-end-and-recover --- <!-- ID: how-to/running/10-perform-live#prepare-the-set --> Perform Live > Prepare the set [guide] 1. Open the project in VSCode and connect to the intended server. Check its version and project. 2. Check audio and MIDI destinations with [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/). 3. Evaluate the rig's imports, tracks, instruments and effects. Open the mixer and console. 4. Save the source and the [project session](/docs/how-to/running/12-save-and-open-a-session/). Page: how-to/running/10-perform-live URL: https://resonon.org/docs/how-to/running/10-perform-live/#prepare-the-set Next: how-to/running/10-perform-live#make-a-change-while-playing --- <!-- ID: how-to/running/11-work-with-coding-agents --> Work with Coding Agents [guide] A coding agent checks, renders and measures from the shell. A person listens at checkpoints. Sections: - how-to/running/11-work-with-coding-agents#give-the-agent-the-reference | Give the agent the reference - how-to/running/11-work-with-coding-agents#work-in-a-live-session | Work in a live session - how-to/running/11-work-with-coding-agents#connect-the-language-server | Connect the language server - how-to/running/11-work-with-coding-agents#the-loop | The loop - how-to/running/11-work-with-coding-agents#write-a-piece-the-loop-can-run | Write a piece the loop can run - how-to/running/11-work-with-coding-agents#read-the-analysis | Read the analysis - how-to/running/11-work-with-coding-agents#answer-common-questions | Answer common questions - how-to/running/11-work-with-coding-agents#listen-at-checkpoints | Listen at checkpoints - how-to/running/11-work-with-coding-agents#related | Related Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/ --- <!-- ID: how-to/running/11-work-with-coding-agents#answer-common-questions --> Work with Coding Agents > Answer common questions [guide] **Read what `send` prints.** In JSON, a `print` is an `output` object with the line in `text`, and an error is an `error` object with its text at `.error.message`: ```sh set -o pipefail # else a failed send exits with jq's 0 resonon send --code 'print(to_json(bpm()));' --message-format json | jq -c \ 'if .type == "output" then .text | fromjson elif .type == "error" then .error.message else empty end' ``` **Compare levels before and after a change.** A meter read is one instant, so reads differ with nothing changed. Render before and after; compare the stems' `integrated_lufs` and `true_peak_dbtp` in `analyze`. **See a value move over time.** `session.modulations()` lists what drives each parameter. A `scope()` probe records from when it is sent: send `scope(sweep)`, let the length play, then send `scope_snap("scope/sweep.png", length: cycles(8))` and open the PNG. **Check notes against a key.** `notes()` gives each note's `name` (`"A1"`) and MIDI `note`: ```resonon let k = Key(A1, "minor"); let outside = notes([a1 c2 e2 f#2 g2], 1).filter(fn(n) { return k.quantize(n["note"]) != n["note"]; }); print(to_json(outside.map(fn(n) { return n["name"]; }))); // ["F#2"] ``` Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#answer-common-questions Previous: how-to/running/11-work-with-coding-agents#read-the-analysis Next: how-to/running/11-work-with-coding-agents#listen-at-checkpoints --- <!-- ID: how-to/running/11-work-with-coding-agents#connect-the-language-server --> Work with Coding Agents > Connect the language server [guide] Configure your harness's language-server client to start `resonon-lsp --stdio` from the project root, for `.non` files. It speaks the Language Server Protocol over standard input and output; no harness-specific plugin or embedded agent is required. The project root selects the project's installed Resonon version. Use the diagnostics alongside `check` before sending a selection. For a non-default local server, pass `initializationOptions` with `{"server":{"host":"127.0.0.1","port":5556}}`. Clients that switch servers can send the `resonon/sessionServer` notification with `{"host":"127.0.0.1","port":5556}`. The VS Code extension sends this when its active server changes. Each server has an independent snapshot, so a second project cannot overwrite the session being checked. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#connect-the-language-server Previous: how-to/running/11-work-with-coding-agents#work-in-a-live-session Next: how-to/running/11-work-with-coding-agents#the-loop --- <!-- ID: how-to/running/11-work-with-coding-agents#give-the-agent-the-reference --> Work with Coding Agents > Give the agent the reference [guide] Read `resonon reference` before writing code for syntax and musical idioms. Then use `resonon reference search "QUERY"` to find manual sections, symbols, modules, DSP builtins, and kits. Use `--kind` to filter and `--limit` to cap results. Read a result with `resonon reference read <ID>`. Each entry gives its page ID and URL; read the page ID for an outline. Search and read use the installed version's documentation. ```sh resonon reference search "euclidean rhythm" resonon reference search Reverb --kind function --limit 3 resonon reference read AudioTrack.send ``` Search and read exit 0 on success, 1 when not found, and 2 for invalid arguments. An unknown query or ID can suggest near matches. Copy the displayed ID exactly for read. The website serves the [core](/docs/llms.txt) and the [full reference](/docs/llms-full.txt). `resonon new` and `resonon init` write `AGENTS.md` with this workflow. For Claude Code, import it from `CLAUDE.md`: ```md title="CLAUDE.md" @AGENTS.md ``` Write what is special about your piece (its key, its tempo, the sound you want) in `AGENTS.md` too. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#give-the-agent-the-reference Next: how-to/running/11-work-with-coding-agents#work-in-a-live-session --- <!-- ID: how-to/running/11-work-with-coding-agents#listen-at-checkpoints --> Work with Coding Agents > Listen at checkpoints [guide] The numbers show whether a mix is clean, not whether it is good. They cannot tell a groove that drags from one that swings, or a good sound from a bad one with the same level. Ask the agent to stop when a part is done, and listen to the render before it continues. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#listen-at-checkpoints Previous: how-to/running/11-work-with-coding-agents#answer-common-questions Next: how-to/running/11-work-with-coding-agents#related --- <!-- ID: how-to/running/11-work-with-coding-agents#read-the-analysis --> Work with Coding Agents > Read the analysis [guide] `resonon analyze` measures the folder that the render wrote, master first. Each measurement is defined in the [CLI reference](/docs/reference/setup/01-cli/#resonon-analyze). In JSON, each key has its unit in its name (`true_peak_dbtp`), and a level of no signal is `null`. A stem is the track's output; `master.wav` is the mix after the master's volume. Check these first: | Measurement | Look for | | --- | --- | | `clipped_samples` | 0 on every file | | `true_peak_dbtp` | Below 0 on every stem. On the master, about -6 to -3 while you mix; -1 or lower on a finished master | | `integrated_lufs` | Not `null`: a stem with no level plays nothing. Then compare the stems with each other | | `bands` | The energy where the part should have it: a bass in `sub` and `low`, hats in `high` | | `correlation` | Above 0 on the master. Below 0, parts cancel when they play in mono | | `dc_offset_percent` | Close to 0 | | `trailing_silence_s` | More than 0 when the piece ends with a reverb or delay, or the render cut the tail | Loudness targets for a finished master, as integrated loudness: | Destination | Integrated | True peak | | --- | --- | --- | | Spotify, YouTube | -14 LUFS | -1 dBTP | | Apple Music | -16 LUFS | -1 dBTP | | Broadcast, EBU R128 | -23 LUFS | -1 dBTP | | Broadcast, ATSC A/85 (US) | -24 LUFS | -2 dBTP | Streaming services turn a louder master down to their level, so a louder master is not louder for the listener; it only has less dynamics. Integrated loudness is measured over the whole file, so measure the whole song, not one loop. A loop that repeats has a loudness range (`loudness_range_lu`) near 0. To let the agent see a part, add `--spectrogram all`. It writes a PNG beside each WAV, with the cycles numbered along the top. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#read-the-analysis Previous: how-to/running/11-work-with-coding-agents#write-a-piece-the-loop-can-run Next: how-to/running/11-work-with-coding-agents#answer-common-questions --- <!-- ID: how-to/running/11-work-with-coding-agents#related --> Work with Coding Agents > Related [guide] - [Errors & Warnings](/docs/reference/language/10-errors-and-warnings/#checking-without-running) — what `resonon check` reports - [Render a Project](/docs/how-to/running/02-render-a-project/) — what `render()` writes, and where - [Levels & Files](/docs/reference/audio/01-levels-and-files/) — volume ranges, the pan law and what a render contains - [Command Line](/docs/reference/setup/01-cli/) — every command and its options Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#related Previous: how-to/running/11-work-with-coding-agents#listen-at-checkpoints --- <!-- ID: how-to/running/11-work-with-coding-agents#the-loop --> Work with Coding Agents > The loop [guide] | Step | Command | It tells you | | --- | --- | --- | | 1. Check | `resonon check --message-format json` | Syntax, undefined names, arity and types, without running anything | | 2. List | `print(to_json(notes(source, cycles)));` | The notes and drum hits a part plays, as text | | 3. Render | `resonon run --no-midi scripts/bounce.non` | WAV files of the stems and the mix, in the folder it names | | 4. Analyze | `resonon analyze <folder> --format json` | Levels, loudness, clipping, stereo and frequency balance | | 5. Listen | a person | Everything the numbers cannot say | `check` and `analyze` open no audio or MIDI device. `run --no-midi` disables MIDI but opens the configured audio device, as a live session does. A piece containing `PLAY` can sound alongside an already playing session; `render()` writes audio offline. See [File Runs](/docs/reference/running/03-file-runs/) for the device and transport behaviour. Each command exits with 1 when it finds an error. Repeat the loop after each change. Stop for step 5 when a part is done, before the agent builds on it. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#the-loop Previous: how-to/running/11-work-with-coding-agents#connect-the-language-server Next: how-to/running/11-work-with-coding-agents#write-a-piece-the-loop-can-run --- <!-- ID: how-to/running/11-work-with-coding-agents#work-in-a-live-session --> Work with Coding Agents > Work in a live session [guide] Start a server with `resonon server`, or use the server the editor already runs. The agent edits `.non` files, checks the selection, sends it, then reads back the session. A person listens as the music plays. ```sh # Check exactly the selection that will run, then execute it. resonon check src/main.non --lines 12-18 --message-format json resonon send src/main.non --lines 12-18 --message-format json # Code can also come from an argument, or from stdin with -. resonon check --code 'print(bpm());' resonon send --code 'print(to_json(session.tracks().map(fn(t) { return t.name(); })));' printf '%s\n' 'print(to_json(session.master.peak));' | resonon send - ``` Both commands accept a file, `--lines a-b` (inclusive, numbered from 1), `--code`, or `-` for stdin. Stdin is read only for `-`. File selections keep their original file and line numbers in errors and resolve imports relative to that file. In a live session, code without a file resolves imports from the server's working directory, both when checking and sending. Offline checks use the command's working directory. `check` opens no audio or MIDI device. A whole file or project follows the editor's mode: Live Mode while the selected server holds this project's session, File Mode otherwise. A session is the project's when its server runs in the project, or when it has run a file from the project. Start `resonon server` in the project root, as the editor does. The human output says which mode it used and, for File Mode, why. JSON includes `mode` on the final `complete` object, and `reason` when the mode is `file`. In Live Mode, a whole editor document can use its own names and names already in the session. A selection or code argument is checked as its own unit: names elsewhere in the file do not count until sent. `send` executes on the existing server, streams its output and diagnostics, and waits briefly after completion for asynchronous shader diagnostics. It exits with 0 on success, 1 on an execution error, and 2 on invalid input or a connection failure. In JSON, invalid input and a connection failure also write an `error` and then a failed `complete`. It executes the selection even when a preceding `check` reported errors, just as the editor does. A `send` that fails partway keeps the statements before the error: tracks they made and settings they changed stay in the session. Fix the failing statement and send from there; see [The Error Model](/docs/explanation/language/04-the-error-model/). The default server for `send` is `127.0.0.1:5555`. Use `--host` and `--port` when connecting elsewhere. `check` follows the local editor's selected server for the project; its `--host` and `--port` options select a different session explicitly. If that server has no session of this project, `check` does not check against anything else. It exits with 2 and says why, and in JSON it writes an `error` and then a failed `complete`. Session snapshots are local to the server's machine, so checking a remote session requires running the check there. Read state through the language, using `print(to_json(...))` with `send`. For example, `bpm()`, `beats_per_cycle()`, `is_playing()`, and `cycle()` read the transport; `session.tracks()` lists the session's tracks. Track getters read mixer settings and routing. `track.peak.get()` and `track.rms.get()` read the meter's current displayed value, and `to_json` reads meter feeds as numbers too. `scope_values()` reads the scope probes, and `scope_snap("scope.png")` draws them as the scope window would to a PNG you can open, without showing the window; `scope_show()` puts the window in front of the user. `signal.get()` reads a signal, and `parameter.get()` reads a parameter's current value, `parameter.get_norm()` reads it as a fraction of its range, and `parameter.text()` reads it as the device shows it (`"1.20 kHz"`, `"35.0 ms"`, `"Saw"`): a plugin's value in the plugin's own text. `.parameters()` lists all three for each parameter, with the range and default as text too. `parameter.set_text("800 Hz")` sets a parameter from that text, as typed into a parameter box: `"1.2k"`, `"35 ms"`, `"-6 dB"`, `"25L"`. A plugin reads the text itself. `session.modulations()` lists every parameter that a signal, an automation lane or a pattern drives: where it is, the source, the source's range, and the value and text now. `track.output()`, `track.sends()`, and `effect.inputs()` return serializable routing descriptions. Readers return data or sources. For data, `to_json` writes a track as its name, a mode such as `track.monitor()` as its name (`"auto"`), a key as its root and scale, a Note as `{name, note}`, a Scale as `{name, intervals, period}`, a Duration as `{length, unit}` (cycles/beats/seconds), devices as `{name, backend, id}` (backend dsp/CLAP/VST3), and `plugin_scan()` and `.parameters()` as their rows. `track.velocity()` returns a number or a source. Signal and Pattern sources have no JSON form: read `signal.get()` for the current value or `notes()` for the notes a pattern plays. `midi_input_events(limit, port)` returns recent MIDI input without consuming it; the history keeps at most 2000 events and `limit` bounds each result. These reads return the latest available value without waiting for a measurement window. See the [standard library reference](/docs/reference/stdlib/) for each reader's shape. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#work-in-a-live-session Previous: how-to/running/11-work-with-coding-agents#give-the-agent-the-reference Next: how-to/running/11-work-with-coding-agents#connect-the-language-server --- <!-- ID: how-to/running/11-work-with-coding-agents#write-a-piece-the-loop-can-run --> Work with Coding Agents > Write a piece the loop can run [guide] The session is the document; code and UI edit it together. `resonon save` keeps its tracks, devices, mixer and arrangement. The entry file has a lifecycle: - Open and Reset Project (`resonon open`) call `fn teardown()` if defined, reset, restore the saved session, call `fn setup()` if defined, then run the rest of the top level. - Run File Live (`resonon send` with no source) evaluates the whole entry file into the running session, without a reset and without `setup()`. - `main()` has no special meaning. Put settings that need no variable, such as `set_bpm(...)`, in `setup()`. The session owns every track: a track stays until `session.delete_track(name)` deletes it, also when no variable holds it. `resonon open` refuses when the session has changes since the last save; add `--discard-changes` to lose them. Evaluations and UI gestures share undo history; undo restores session state, not source text or variables. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). ```resonon use "std/instruments" { Sampler, Kit }; fn setup() { set_project_title("Agent Loop"); session.create_track("drums"); session.create_track("hats"); } let beat = [bd _ sd _]; let drums = session.track("drums").set_volume(-6); drums.set_instrument(Sampler(Kit("CR-78"))); drums << beat; let hats = session.track("hats").set_volume(-12); hats.set_instrument(Sampler(Kit("CR-78"))); hats << [hh*8]; ``` Put listing and rendering in a script, not in the entry file: the top level runs on each open. `resonon run scripts/bounce.non` opens the project without a window, then evaluates the script with the entry file's names in scope: ```resonon continue // List: the drum hits of one cycle print(to_json(notes(beat, 1))); // Render: each track, and the mix, for 8 cycles render(#[drums, hats, session.master], 8); ``` - **List the parts you want to check.** `notes()` takes a pattern, a timeline, a MIDI track, an array of MIDI tracks or a section. Its output is in [List the Notes a Pattern Plays](/docs/how-to/patterns/10-list-the-notes-a-pattern-plays/). For a song made of sections, list the song that `arrange()` gives. - **Render every track and `session.master`.** A stem shows which track causes a problem in the mix. - **Render enough cycles.** Include the longest section. A track that plays a pattern loops until the render stops, so its reverb or delay tail is always cut. To keep a tail, make the piece a song that ends, and render a few cycles past its end: [Render a Song](/docs/how-to/running/03-render-a-song/#keep-the-tail). - **Give the piece a title.** `set_project_title()` names the render folder. Each render writes a new folder and says where: `rendered to <folder>/`. Analyze that folder. `resonon run scripts/bounce.non --message-format json` prints the output and any error as one JSON object per line, and the folder of each render as a `rendered` object ([Machine-readable output](/docs/reference/language/10-errors-and-warnings/#machine-readable-output)). For `send`, `save`, `open`, `check` and `run`, `--message-format json` selects a message stream. After valid argument parsing, a startup refusal writes an `error` and exactly one failed `complete` with the same request ID. This includes invalid environment settings, version pins, missing project files and fatal startup failures. Launcher dispatch refusals use the same shape. Argument usage errors still go to stderr. See [Exit codes](/docs/reference/setup/01-cli/#exit-codes). `analyze --format json` writes one analysis document, without message-stream objects. The former `analyze --message-format` option is no longer accepted. Page: how-to/running/11-work-with-coding-agents URL: https://resonon.org/docs/how-to/running/11-work-with-coding-agents/#write-a-piece-the-loop-can-run Previous: how-to/running/11-work-with-coding-agents#the-loop Next: how-to/running/11-work-with-coding-agents#read-the-analysis --- <!-- ID: how-to/running/12-save-and-open-a-session --> Save and open a session [guide] Save the current tracks, mixer, arrangement and plugin state in the active project, and open them again later, as you save and open a set in a DAW. Saving evaluates no code. Opening restores the saved session, then runs the project's entry file. Sections: - how-to/running/12-save-and-open-a-session#save | Save - how-to/running/12-save-and-open-a-session#open | Open - how-to/running/12-save-and-open-a-session#keep-unsaved-changes | Keep unsaved changes - how-to/running/12-save-and-open-a-session#write-the-entry-file-for-a-saved-session | Write the entry file for a saved session - how-to/running/12-save-and-open-a-session#connection-options | Connection options Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/ --- <!-- ID: how-to/running/12-save-and-open-a-session#connection-options --> Save and open a session > Connection options [guide] Use `--host` and `--port` to select another server. `resonon save` and `resonon open` wait for the server's result. Exit status is 0 on success, 1 if the session could not be saved or opened, and 2 if the connection failed. Use `--message-format json` for machine-readable results. When a client renames a track, existing handles continue to refer to the same track. Opening the project again asks first if a track constructor in the entry file still uses an old name. Choose **Update and Open** in the window, **Save, Update Names and Reset** in VSCode, or **Update Names and Reset** in Neovim. Resonon saves the live session, updates the literal track names in the entry file, and opens the project. Cancel leaves the source and session unchanged. Comments and unrelated strings are not changed. `resonon open` refuses with `Tracks were renamed.`; update the names from an editor. Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/#connection-options Previous: how-to/running/12-save-and-open-a-session#write-the-entry-file-for-a-saved-session --- <!-- ID: how-to/running/12-save-and-open-a-session#keep-unsaved-changes --> Save and open a session > Keep unsaved changes [guide] Opening loses the changes made since the last save. When UI edits or code have changed the session since the last save, the window, VSCode and Neovim ask before they reset. `resonon open` refuses with this message: ```text The session has changes since the last save. Save them, or confirm to lose them. ``` Save the session first, or add `--discard-changes` to lose the changes: ```sh resonon open --discard-changes ``` Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/#keep-unsaved-changes Previous: how-to/running/12-save-and-open-a-session#open Next: how-to/running/12-save-and-open-a-session#write-the-entry-file-for-a-saved-session --- <!-- ID: how-to/running/12-save-and-open-a-session#open --> Save and open a session > Open [guide] In the main Resonon window, select **File > Open Project…**, or select **File > Reset Project** to open the current project again. See [Open Resonon as an app](/docs/how-to/running/16-open-resonon-as-an-app/). In VSCode, run **RESONON: Reset Project** from the Command Palette. It opens the project that the active file belongs to again, from its files. In Neovim, use `:Resonon reset`. From a terminal: ```sh resonon open resonon open path/to/project ``` Opening replaces the running session. It calls `fn teardown()` of the current session, resets the session, and restores what was saved. Tracks, routing, sends, faders, mute and solo, inputs, tempo and device chains come back. Installed plugins are loaded with their saved state. Then it runs the entry file: `fn setup()`, then the rest of the top level. The transport stays stopped. The steps are in [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). The entry file brings back the parts of a session that only code can define: - Patterns. - Custom `dsp` effects and instruments. - Sections and timelines. Code finds the opened tracks and devices by name, so a plugin that is already loaded is kept, with its state. A rebuilt `dsp` effect takes the saved parameter values before the code's own values are written. A saved `dsp` device that the entry file does not place stays in the chain as `waiting for code`. It passes audio through, or stays silent. A plugin that is not installed opens as a placeholder. It passes audio through, keeps its saved state and is reported as not installed. Saving again keeps the state, so nothing is lost when you open the project on a machine without the plugin. Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/#open Previous: how-to/running/12-save-and-open-a-session#save Next: how-to/running/12-save-and-open-a-session#keep-unsaved-changes --- <!-- ID: how-to/running/12-save-and-open-a-session#save --> Save and open a session > Save [guide] In VSCode, run **Resonon: Save Project Session** from the Command Palette. To copy external samples into the project too, run **Resonon: Collect and Save Project Session**. In the main Resonon window, press **Command-S**. When the [Editor](/docs/how-to/running/15-edit-code-in-the-window/) has the keyboard, Command-S saves the file it shows instead. From a terminal connected to the same server: ```sh resonon save resonon save --collect ``` The server saves into its active project's `session/` directory. Commit this directory with the project to keep the text document and binary plugin state together. Collect and Save copies external sample assets into `samples/` and writes project-relative references. Missing samples are reported and their references are retained. Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/#save Next: how-to/running/12-save-and-open-a-session#open --- <!-- ID: how-to/running/12-save-and-open-a-session#write-the-entry-file-for-a-saved-session --> Save and open a session > Write the entry file for a saved session [guide] A track, its mixer settings and its plugins are saved. The code that created them can run once, and then you can delete it. Put patterns at the top level, so that each open attaches them again. Put settings that need no variable in `fn setup()`. ```resonon use "std/instruments" { Sampler, Kit }; fn setup() { set_bpm(120); session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; ``` `resonon run` opens the project the same way, without a window. See [File Runs](/docs/reference/running/03-file-runs/). Page: how-to/running/12-save-and-open-a-session URL: https://resonon.org/docs/how-to/running/12-save-and-open-a-session/#write-the-entry-file-for-a-saved-session Previous: how-to/running/12-save-and-open-a-session#keep-unsaved-changes Next: how-to/running/12-save-and-open-a-session#connection-options --- <!-- ID: how-to/running/13-use-the-mixer --> Use the Mixer [guide] The Mixer is a collapsible panel below the [Arrangement](/docs/how-to/running/14-use-the-arrangement/) in the main Resonon window. The session server opens this window on its own desktop. It has one strip for each track and one for the master. The master strip stays at the right edge; the other strips scroll under it when they do not fit. It changes the same values that code changes: moving a fader and calling `set_volume()` are the same edit, and the last edit wins. Sections: - how-to/running/13-use-the-mixer#open-the-mixer | Open the Mixer - how-to/running/13-use-the-mixer#edit-project-files | Edit project files - how-to/running/13-use-the-mixer#read-a-strip | Read a strip - how-to/running/13-use-the-mixer#change-a-value | Change a value - how-to/running/13-use-the-mixer#change-a-value-with-the-keys | Change a value with the keys - how-to/running/13-use-the-mixer#add-and-delete-tracks | Add and delete tracks - how-to/running/13-use-the-mixer#set-a-track-colour | Set a track colour - how-to/running/13-use-the-mixer#add-devices-from-the-browser | Add devices from the Browser - how-to/running/13-use-the-mixer#use-the-browser-with-the-keyboard | Use the Browser with the keyboard - how-to/running/13-use-the-mixer#undo-a-change | Undo a change - how-to/running/13-use-the-mixer#read-the-meters | Read the meters - how-to/running/13-use-the-mixer#use-the-mixer-with-code | Use the Mixer with code Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/ --- <!-- ID: how-to/running/13-use-the-mixer#add-and-delete-tracks --> Use the Mixer > Add and delete tracks [guide] | Action | Result | | --- | --- | | **Command-T**, or **+** after the last strip, then **Audio Track** | Adds an audio track named `Audio 1`, `Audio 2` and so on, and selects it. | | **Command-Shift-T**, or **+**, then **MIDI Track** | Adds a MIDI track named `MIDI 1`, `MIDI 2` and so on, and selects it. | | Click a strip's name | Selects the track. The selected strip has a lighter grey background. | | Double-click a strip's name, or the track name above the Devices panel | The name becomes a field in its place, in the same font, with all of it selected. Type a new name and press Enter to rename the track, or press Escape or click elsewhere to cancel. The rename is one undo step, and the track stays selected. | | **Delete** or **Backspace**, with a track selected | Deletes the selected track and selects the next one: the one before it when it was last, the master track when no track is left. The master track cannot be deleted. | | Right-click a strip's name, **Delete Track** | Deletes that track. | The Arrangement has the same **+** under its last track, and selecting a track in one selects it in the other. A track is always selected: a project opens with the master track selected, and when code that runs again no longer makes the selected track, the next track is selected. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#add-and-delete-tracks Previous: how-to/running/13-use-the-mixer#change-a-value-with-the-keys Next: how-to/running/13-use-the-mixer#set-a-track-colour --- <!-- ID: how-to/running/13-use-the-mixer#add-devices-from-the-browser --> Use the Mixer > Add devices from the Browser [guide] The Browser lists the built-in devices and the plugins installed on this computer, as Live's browser does. It is hidden until you ask for it: press **Command-Option-B** or click the thin Browser strip right of the [Editor](/docs/how-to/running/15-edit-code-in-the-window/) to show it beside the Editor, and press the keys again or click its header to fold it back to the strip. The devices are sorted by kind, under **Instruments**, **Audio Effects** and **Other Plugins**. Each kind has one folder for each vendor: - **Resonon** is first. It holds the built-in devices. A built-in such as **Sampler** or **Reverb** loads a plugin that ships with Resonon; that plugin is not listed a second time. - The other vendors follow from A to Z. - **Unknown vendor** is last. It holds the plugins that do not name a vendor. Click a kind or a folder to open or close it. The kinds start open and the folders start closed. The session keeps the folders you open or close, with the Browser's width, when you save it. The tag at the right of each row shows the format: **CLAP**, **VST3** or **BUILT-IN**. A plugin installed as CLAP and as VST3 has two rows, one for each format. A name that is too long ends with "…"; hold the pointer over the row to see the full name, the vendor and the format. Type in the search field to filter by name, vendor or format. Every word must match. The search opens each folder that has a match. Clear the search to see the folders as you left them. Plugins that the plugin scanner could not load are listed last, under **Skipped by the scanner**, which starts closed. They cannot be added, and holding the pointer over one shows why. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#add-devices-from-the-browser Previous: how-to/running/13-use-the-mixer#set-a-track-colour Next: how-to/running/13-use-the-mixer#use-the-browser-with-the-keyboard --- <!-- ID: how-to/running/13-use-the-mixer#change-a-value --> Use the Mixer > Change a value [guide] Every fader, knob and value box works the same way: | Action | Result | | --- | --- | | Drag up or down | Changes the value. | | Shift-drag | Changes it at a tenth of the speed. | | Double-click | Resets it: 0 dB for volume, the centre for pan, −∞ for a send. | | Right-click, type, press Enter | Sets the typed value on a fader or value box. The value box becomes a field in its place. Esc or a click elsewhere cancels. Send and pan knobs have no typed value. | | Control | Range and typed values | | --- | --- | | Fader and Volume box | −∞ to +6 dB; 0 dB is at about four fifths of the fader's travel. Type `-6`, `-6 dB`, or `-inf` for silence. Right-clicking the fader types into the Volume box. | | Pan | Full left to full right. | | Send | −∞ to 0 dB. Most of the knob's travel covers −30 to −6 dB; half travel is about −16 dB. Turning up a knob at −∞ makes the send; the drag is one undo step. | | **M**, **S** | Click to turn mute or solo on or off. | Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#change-a-value Previous: how-to/running/13-use-the-mixer#read-a-strip Next: how-to/running/13-use-the-mixer#change-a-value-with-the-keys --- <!-- ID: how-to/running/13-use-the-mixer#change-a-value-with-the-keys --> Use the Mixer > Change a value with the keys [guide] A plain click on a fader, knob, value box, toggle or chooser gives it the keys. A thin light outline shows which control has them. A drag, a double-click or a right-click never takes the keys: when the [Editor](/docs/how-to/running/15-edit-code-in-the-window/) has them, the arrow keys and your typing still go to the code. | Key | Result | | --- | --- | | **Tab**, **Shift-Tab** | Gives the keys to the next or previous control. The Mixer goes from strip to strip, left to right and the master last, and from top to bottom in each strip. The track headers in the Arrangement go from track to track, and from left to right in each header. The keys stay in their area and go round from the last control to the first. | | **Up** or **Right** | Steps the value up: 0.5 dB for volume and sends, 1 for pan. One step below the lowest level gives −∞. | | **Down** or **Left** | Steps the value down. | | **Shift** with an arrow | Steps at a fine step: 0.1 dB for volume and sends. | | **Enter** | Opens the typed value on a fader or value box. Turns a toggle on or off. Opens a chooser's list; then **Down** and **Up** move in the list and **Enter** chooses. | | **Delete** or **Backspace** | Resets the value, as a double-click does. The selected track stays. | | **Escape** | Takes the keys from the control. | Space, Command-Z, Command-Shift-Z, Command-S and Command-T keep their usual action while a control has the keys. A track's devices and their parameters are in the Devices panel; see [Use the Device Panel](/docs/how-to/running/17-use-the-device-panel/). Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#change-a-value-with-the-keys Previous: how-to/running/13-use-the-mixer#change-a-value Next: how-to/running/13-use-the-mixer#add-and-delete-tracks --- <!-- ID: how-to/running/13-use-the-mixer#edit-project-files --> Use the Mixer > Edit project files [guide] The Editor occupies the left half of the main window. Press **Command-Option-E** to hide or show it. Its **Files** strip opens a resizable file explorer; **Command-Shift-E** toggles it. The explorer lists `src/`, `lib/` and `resonon.toml`. Its width and visibility are saved with the session. Click a file to open a tab. Each tab keeps its own text, undo history, selection and scroll position. A dot marks unsaved changes. With the text focused, **Command-S** saves the current file, **Command-Option-S** saves all dirty files, and **Command-W** closes the current tab. Closing a dirty tab asks whether to save, discard or cancel. Open tabs are temporary; reopening a project opens its entry file. Edits from another editor reload automatically when the local buffer is clean. If both have changed, choose **Reload** to use the disk version or **Keep mine** to retain the local text. Saving an unresolved conflict asks before overwriting. Deleted files stay open and can be saved again. Invalid UTF-8 files show a read-only preview and cannot be saved from the Editor. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#edit-project-files Previous: how-to/running/13-use-the-mixer#open-the-mixer Next: how-to/running/13-use-the-mixer#read-a-strip --- <!-- ID: how-to/running/13-use-the-mixer#open-the-mixer --> Use the Mixer > Open the Mixer [guide] - In VSCode, run **RESONON: Open Resonon Window** from the Command Palette, or open **Mixer** in the resonon **Views**. - In Neovim, run `:Resonon view`. - From code: ```resonon no-check mixer_show(); mixer_hide(); ``` From a terminal, `resonon app` starts Resonon with its own session and main window. For a server that already runs, use the editor commands above or `window_show()` in its session. Opening the main window brings it to the front. Closing it does not stop the session. Click the Mixer header or press **Command-M** to collapse or expand the panel. Drag its upper edge to resize it. Faders and meters take the height the panel has left. The sends never scroll: when the session gets more returns than the panel has room for, the panel grows until every send knob fits, and it keeps that height when returns go away. `window_show()` opens the main window, `window_hide()` closes it, `mixer_show()` expands its Mixer, and `mixer_hide()` collapses its Mixer. The Mixer needs macOS and a session server (`resonon server`, or the server VSCode starts). When you [save the session](/docs/how-to/running/12-save-and-open-a-session/) with the window open, opening the session restores its frame, screen, Mixer visibility and panel height. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#open-the-mixer Next: how-to/running/13-use-the-mixer#edit-project-files --- <!-- ID: how-to/running/13-use-the-mixer#read-a-strip --> Use the Mixer > Read a strip [guide] A track strip shows, from top to bottom: | Part | Shows | | --- | --- | | Colour | A band in the track colour. The track's header and blocks in the [Arrangement](/docs/how-to/running/14-use-the-arrangement/) have the same colour. | | Name | The track name. A name that does not fit ends in `…`: hold the pointer over it to see all of it. A muted track's name dims. | | Kind | **RETURN A**, **RETURN B** and so on, in track order, for a return track: one that another track sends or routes to. An audio track has no tag. | | **AUDIO FROM**, **AUDIO TO** | Where the track's audio comes from and where it plays to. Click a chooser to change it. A return's input is always **Tracks/Sends**. | | **SENDS** | One knob for each return, in the order of the returns, with the return's letter under it. The knobs stand in two staggered columns: **A** top left, **B** half a row lower on the right, **C** under **A**, and so on. A knob at −∞ is a return the track does not send to yet. A return strip leaves its own knob out, so the letters stay in line across the strips. While you hold the pointer over a send knob, drag it or give it the keys, the **SENDS** line shows the return's letter and the level, for example `A -1.9 dB`. From −10 dB down the level shows without its decimal. | | Pan | A knob in the middle of the strip. While you hold the pointer over it, drag it or give it the keys, the pan position shows beside it: `C`, or a percentage left (`L`) or right (`R`). | | Volume and peak | The fader value in dB, in a box that fills with the fader, and the held peak of the meter in dB. | | Fader, scale and meter | The volume, a dB scale for the meter, and the level of the track's output. The readouts, the fader and the meter share one dark well. | | **M**, **S** | Mute and solo. A lit button is on. | The master strip has **AUDIO TO**, pan, volume and peak, fader and meter. A MIDI track's strip shows **MIDI** under its name (and **MPE** when MPE is on), then **MIDI FROM**, **MIDI TO**, and three buttons for the monitor mode: **In**, **Auto** and **Off**, with the current mode lit. A MIDI track sends notes, not sound, so its well has no fader and no meter, but it has mute and solo. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#read-a-strip Previous: how-to/running/13-use-the-mixer#edit-project-files Next: how-to/running/13-use-the-mixer#change-a-value --- <!-- ID: how-to/running/13-use-the-mixer#read-the-meters --> Use the Mixer > Read the meters [guide] Each meter has a bar for the left and the right channel, from −60 dB at the bottom to +6 dB at the top. The light part of a bar is the peak level and the solid part is the RMS level. A bar is green below −12 dB, lime from −12 to −3 dB, orange from −3 to 0 dB and red above 0 dB. The white line holds the highest peak for one second, then falls. The scale beside the meter marks +6, 0, −12, −24, −36 and −48 dB. The peak box next to the volume shows that held peak in dB. The peak box turns red when the level reaches 0 dBFS, and stays red. Click it to clear it. The meters use the same ballistics as every other meter of the session. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#read-the-meters Previous: how-to/running/13-use-the-mixer#undo-a-change Next: how-to/running/13-use-the-mixer#use-the-mixer-with-code --- <!-- ID: how-to/running/13-use-the-mixer#set-a-track-colour --> Use the Mixer > Set a track colour [guide] Each track has a colour, so that you can find it in the Mixer and the Arrangement. A new track takes the next colour of the palette, also when code makes it. Right-click a strip's name and click a colour in the palette to change it. The palette has 24 colours: 12 bright hues in the top row and the same hues muted in the bottom row. The change is one undo step, and saving the session keeps it. In code, a colour is the palette index, from 0 to 23: 0 to 11 are the bright row from left to right, and 12 to 23 are the muted row. ```resonon // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); lead.set_color(17); print(lead.color()); ``` Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#set-a-track-colour Previous: how-to/running/13-use-the-mixer#add-and-delete-tracks Next: how-to/running/13-use-the-mixer#add-devices-from-the-browser --- <!-- ID: how-to/running/13-use-the-mixer#undo-a-change --> Use the Mixer > Undo a change [guide] Press **Command-Z** to undo the last change and **Command-Shift-Z** to redo it. One drag is one step, so a single undo takes the fader back to where the drag started. Arrow presses on one control are one step while less than 1 s passes between them. Adding or deleting a track, setting a track colour and adding, removing or moving a device are one step each; undoing a deletion brings the track back with its devices and their state. Undo takes back changes made in the Mixer and UI edits from other clients of the session. Code evaluations are not undo steps. Undo restores session state, including deleted tracks and devices. It does not rewind code text, variables, callbacks or the transport. `RESET`, Open and Reset Project start a new history. Correct a wrong live run in code and run it again. See [The session and your code](/docs/explanation/running/05-session-document/). Command-Z and Command-Shift-Z also undo and redo session changes while the [Editor](/docs/how-to/running/15-edit-code-in-the-window/) has the keyboard. Use **Control-Z** and **Control-Shift-Z** to undo and redo code text. Single-line fields, such as track names, dB entries and Browser search, keep Command-Z and Command-Shift-Z for their own text while focused. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#undo-a-change Previous: how-to/running/13-use-the-mixer#use-the-browser-with-the-keyboard Next: how-to/running/13-use-the-mixer#read-the-meters --- <!-- ID: how-to/running/13-use-the-mixer#use-the-browser-with-the-keyboard --> Use the Mixer > Use the Browser with the keyboard [guide] Click a row to select it. The Browser takes the arrow keys and **Return** while it has the thin grey outline and no field has the keyboard. Press **Command-F** to show the Browser, give it the keys and put the cursor in its search field. While the Editor has the keyboard, Command-F stays with the Editor. | Key | Result | | --- | --- | | **Down** / **Up** | Selects the next or the previous row. With no row selected, Down selects the first row. | | **Left** | Closes an open kind or folder. On any other row, selects the kind or folder above it. | | **Right** | Opens a closed kind or folder. On an open one, selects its first row. | | **Return** | Adds the selected item to the selected track, as a double-click does. On a kind or folder, opens or closes it. | | **Down** in the search field | Leaves the field and selects the first match. | While you search, Left and Right only move the selection; they do not open or close folders. The selected row is bright while the Browser has the keys and dim when another panel has them. When a folder closes over the selected row, or the search hides it, the kind or folder above it is selected. | Action | Result | | --- | --- | | Drag an item onto a strip | Adds it last in the track's chain. An instrument replaces the track's instrument. | | Drag an item onto the Devices panel | Adds it to the selected track: before the card under the pointer, or last anywhere else on the panel. The collapsed panel's header takes the drop too. | | Double-click an item | Adds it to the selected track, last in its chain. | To move, switch off or remove a device, use its card in the [Devices panel](/docs/how-to/running/17-use-the-device-panel/#add-move-and-remove-devices). A plugin added from the Browser opens its plugin window, as in Live. After a device is removed, **Delete** does nothing until you select a track again, so a second press cannot delete the track. While the Editor has focus, **Backspace** and **Delete** edit the code. The panel with the thin grey outline has the keys; see [give the keys back to the session](/docs/how-to/running/15-edit-code-in-the-window/#give-the-keys-back-to-the-session). The master strip takes effects only. Save the session to keep the chain. Built-in devices and installed plugins come back when you open it; custom DSP devices wait for their code. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#use-the-browser-with-the-keyboard Previous: how-to/running/13-use-the-mixer#add-devices-from-the-browser Next: how-to/running/13-use-the-mixer#undo-a-change --- <!-- ID: how-to/running/13-use-the-mixer#use-the-mixer-with-code --> Use the Mixer > Use the Mixer with code [guide] The Mixer and code edit one session. Set up two tracks and a send: ```resonon // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("verb"); } let drums = session.track("drums"); let verb = session.track("verb"); drums.set_send(verb, 0.3); ``` The Mixer shows the `drums` strip with a send to `verb`, and `verb` as a return track. Move the `drums` fader, then read the volume in code: ```resonon continue print(drums.volume()); ``` The printed value is the fader value in dB. Set the volume in code and the fader moves: ```resonon continue drums.set_volume(-12); ``` When several editors connect to one server, each one sees the changes of the others and of the Mixer. The value that was written last wins, whether code or the Mixer wrote it. Running the `set_volume()` line again sets the code's value again. See [descriptions and slots](/docs/explanation/audio/02-descriptions-and-slots/). Tracks and devices added in the Mixer are part of the session, like those code adds: code can reach them by name (`session.track("Audio 1")`), and saving the session keeps them. Each return adds a send knob to the strip of every other audio track and return; a knob turned up in the Mixer and `set_send()` in code make the same send. Page: how-to/running/13-use-the-mixer URL: https://resonon.org/docs/how-to/running/13-use-the-mixer/#use-the-mixer-with-code Previous: how-to/running/13-use-the-mixer#read-the-meters --- <!-- ID: how-to/running/14-use-the-arrangement --> Use the Arrangement and Transport [guide] The main Resonon window has the transport bar along its top and the Arrangement below it, above the [Mixer](/docs/how-to/running/13-use-the-mixer/) panel. Open the window as the Mixer page tells you: **RESONON: Open Resonon Window** in VSCode, `:Resonon view` in Neovim, or `window_show()` in code opens the running session's window. From a terminal, `resonon app` starts its own session and main window. Sections: - how-to/running/14-use-the-arrangement#use-the-transport-bar | Use the transport bar - how-to/running/14-use-the-arrangement#read-the-arrangement | Read the Arrangement - how-to/running/14-use-the-arrangement#use-the-track-headers | Use the track headers - how-to/running/14-use-the-arrangement#edit-the-song-while-it-plays | Edit the song while it plays - how-to/running/14-use-the-arrangement#move-the-playhead | Move the playhead - how-to/running/14-use-the-arrangement#keep-the-session-and-code-together | Keep the session and code together Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/ --- <!-- ID: how-to/running/14-use-the-arrangement#edit-the-song-while-it-plays --> Use the Arrangement and Transport > Edit the song while it plays [guide] Edit a lane while the song plays, for example the fill: ```resonon continue song[drums].layer("fills").at(15, 1) << [hh hh hh hh]; ``` The Arrangement shows the edit as soon as the code runs, from the moment you will hear it. A note lane changes at the next cycle boundary that the edit plays from: until the playhead reaches it, an off-white line marks that boundary, with what plays now on its left and the edit on its right. An automation lane changes at once. See [When an edit is heard](/docs/explanation/audio/04-the-arrangement-model/#when-an-edit-is-heard). Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#edit-the-song-while-it-plays Previous: how-to/running/14-use-the-arrangement#use-the-track-headers Next: how-to/running/14-use-the-arrangement#move-the-playhead --- <!-- ID: how-to/running/14-use-the-arrangement#keep-the-session-and-code-together --> Use the Arrangement and Transport > Keep the session and code together [guide] The session is the document; code and the UI edit it together. Save the project session to keep tracks, device chains, mixer settings and arrangement. Put patterns and callbacks at the top level of the entry file, so that opening the project attaches them again after it restores the saved session. Run Selection Live evaluates only the selection. Run File Live evaluates the whole entry file into the running session. Session undo covers UI gestures. Code evaluations are not undo steps: correct the source and run it again. Use text undo in the editor to change the source. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#keep-the-session-and-code-together Previous: how-to/running/14-use-the-arrangement#move-the-playhead --- <!-- ID: how-to/running/14-use-the-arrangement#move-the-playhead --> Use the Arrangement and Transport > Move the playhead [guide] Click the ruler to move the playhead there, as `SEEK` does. The click snaps to the nearest beat. Hold Option (Alt) to move the playhead to exactly where you click. While the song plays, it plays on from there; while it is stopped, the next play starts there. Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#move-the-playhead Previous: how-to/running/14-use-the-arrangement#edit-the-song-while-it-plays Next: how-to/running/14-use-the-arrangement#keep-the-session-and-code-together --- <!-- ID: how-to/running/14-use-the-arrangement#read-the-arrangement --> Use the Arrangement and Transport > Read the Arrangement [guide] Arrange a song and play it: ```resonon use "std/instruments" { Sampler, Kit }; use "std/signals" { automation }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("bass"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let bass = session.track("bass"); bass.set_instrument(Sampler(Kit("CR-78"))); let verse = section(8); verse[drums] << [bd bd sd bd]; verse[bass] << [c2 _ g1 _]; let chorus = verse.clone(); chorus[drums] << [bd sd bd sd]; let song = arrange(#[verse * 2, chorus]); song[drums].layer("fills").at(7, 1) << [hh hh hh hh]; song[drums].volume.at(8, 8) << automation().at(0, -24).at(8, 0); song.play(); ``` The Arrangement shows: | Part | Shows | | --- | --- | | Ruler | The sections, named by the variables that hold them (`verse`, `verse`, `chorus`), and the bar numbers. | | Track headers | One row for each track, in the Mixer's order, with the track colour along the left edge and the controls in [the track headers](#use-the-track-headers). | | Blocks | One block for each stretch that plays, with the notes it plays. Across, each note starts and lasts where it sounds; down, pitched notes run from high to low and each sample (`bd`, `sd`, `hh`) has a row of its own. Blocks and notes have the track colour. A block of a layer on top of `base` is paler, and a block names the layer that wins it when the lane has more than one. | | Automation rows | A thin row under the track for each automation lane of the playing song, with its values (`-24.00 → 0.00`). | | Playhead | The white line. The notes it crosses light up while they sound. | Hold the pointer over a block to see the pattern that feeds it, `+Nc` when an entry resumes in its own phase, and the layer. The blocks are what [`show(song)`](/docs/how-to/audio/17-arrange-a-song-from-sections/#check-what-it-will-play) prints: a muted layer and an entry that is fully masked have no block. The notes are those each cycle plays, so a pattern that changes from cycle to cycle shows each cycle as it is. On a track with a key (`set_key()`), degrees show at their pitch and notes at the scale tone they play; without one, each unresolved degree has a row of its own. A track that plays a pattern without a timeline, for example after `bass << [c2 g1];`, shows one block marked **↻**. When a track loops this way, all tracks share a scrolling four-cycle window: two cycles behind the playhead and two ahead. The playhead stays in the middle; time before the start is empty. Loop notes update as playback advances, including beyond the end of a timeline. A lane that plays more notes than the Arrangement draws (4096, or more than it can work out in time) dims from where its notes stop, marked **…**; the music still plays them. To change the song, change the code. Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#read-the-arrangement Previous: how-to/running/14-use-the-arrangement#use-the-transport-bar Next: how-to/running/14-use-the-arrangement#use-the-track-headers --- <!-- ID: how-to/running/14-use-the-arrangement#use-the-track-headers --> Use the Arrangement and Transport > Use the track headers [guide] Each header has the controls you use most, so you can mix without opening the Mixer. They are the Mixer's controls: a change in either shows in both, a change from code shows in both, and each change is one undo step. | Part | Shows | Action | | --- | --- | --- | | Name | The track name, dimmed while the track is muted. A return track shows its letter (**A**, **B**, as its sends are labelled) before the name. | Click the header to select the track; the Mixer selects it too. Double-click the name, type a new one and press Enter to rename the track. Esc or a click elsewhere cancels. | | **M**, **S** | Mute and solo, lit while on. A MIDI track has them too. | Click to turn mute or solo on or off. | | Volume | The volume in dB, in a box that fills with the level. | Change it as [a Mixer value](/docs/how-to/running/13-use-the-mixer/#change-a-value): drag, Shift-drag, double-click to reset to 0 dB, right-click to type. | | Pan | A knob and the pan position: `C`, `25L`, `40R`. | As the volume; double-click resets it to the centre. | | Output | Where the track plays to: **→ Master**, or the track it routes to. | — | | Meter | The level of the track's output, on the right edge. Hold the pointer over it to see the held peak. | — | | MIDI | On a MIDI track, instead of volume, pan and meter: its channel, **MPE** when it is on, and its output port. | — | | Instrument | On a tall track only: the instrument, then the lane's layers, with `(muted)` after a muted layer. | — | Right-click a header and click a colour in the palette to change the track colour, or choose **Delete Track** to delete it. The **+** under the last track adds an audio or a MIDI track. See [add and delete tracks](/docs/how-to/running/13-use-the-mixer/#add-and-delete-tracks) and [set a track colour](/docs/how-to/running/13-use-the-mixer/#set-a-track-colour). Resize tracks and headers: | Action | Result | | --- | --- | | Drag a header's bottom edge | Makes that track compact (name, **M**, **S** and meter), default, or tall (with the instrument row). | | Option-drag a header's bottom edge | Resizes every track. | | Drag the right edge of the header column | Makes the headers wider or narrower. | The track heights and the header width are part of the window layout: saving the project keeps them, and undo does not change them. Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#use-the-track-headers Previous: how-to/running/14-use-the-arrangement#read-the-arrangement Next: how-to/running/14-use-the-arrangement#edit-the-song-while-it-plays --- <!-- ID: how-to/running/14-use-the-arrangement#use-the-transport-bar --> Use the Arrangement and Transport > Use the transport bar [guide] | Control | Action | Result | | --- | --- | --- | | **▶ / Ⅱ** | Click | Plays from the playhead, as `PLAY;` does, or pauses in place, as `PAUSE;` does. Lit green while playing. | | **■** | Click | Stops and returns to the start, as `STOP;` does. | | Space | Press | Plays or resumes when stopped or paused; pauses in place when playing. Text inputs keep Space for typing. The panel with the thin grey outline has the keys. | The bar also shows: | Part | Shows | | --- | --- | | Position | Bar, beat and sixteenth, each counted from 1: `5.2.1`. One bar is one cycle. | | Cycles | The position in cycles, the number `SEEK` takes. | | Tempo | The tempo in BPM. | | Time signature | The meter, for example `4/4` or `7/8`. Beats count in its denominator. | Page: how-to/running/14-use-the-arrangement URL: https://resonon.org/docs/how-to/running/14-use-the-arrangement/#use-the-transport-bar Next: how-to/running/14-use-the-arrangement#read-the-arrangement --- <!-- ID: how-to/running/15-edit-code-in-the-window --> Edit code in the main window [guide] The Editor is the left half of the main Resonon window, from the transport bar to the bottom, left of the Browser. It shows the entry file of the open project: `src/main.non`, or the `entry` that `resonon.toml` names. Open the window as the [Mixer](/docs/how-to/running/13-use-the-mixer/) page tells you. Sections: - how-to/running/15-edit-code-in-the-window#show-the-editor | Show the Editor - how-to/running/15-edit-code-in-the-window#edit-the-file | Edit the file - how-to/running/15-edit-code-in-the-window#optional-vim-bindings | Optional Vim bindings - how-to/running/15-edit-code-in-the-window#mappings | Mappings - how-to/running/15-edit-code-in-the-window#run-code | Run code - how-to/running/15-edit-code-in-the-window#give-the-keys-back-to-the-session | Give the keys back to the session Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/ --- <!-- ID: how-to/running/15-edit-code-in-the-window#edit-the-file --> Edit code in the main window > Edit the file [guide] Click in the text to give the Editor the keyboard. A thin grey outline around the Editor shows that it has the keyboard. Most keys work as in a Mac text editor. Text undo uses Control-Z: | Keys | Result | | --- | --- | | Click, drag | Places the cursor, selects text. | | Double-click, triple-click | Selects the word, the line. | | Shift-click | Extends the selection to the click. | | Option-arrow, Command-arrow | Moves by word, to the line's start or end, to the file's start or end. Shift extends the selection. | | Command-C, Command-X, Command-V | Copies, cuts, pastes. With nothing selected, copy and cut take the whole line. | | Control-Z, Control-Shift-Z | Undoes, redoes the last change to the text. | | Command-Z, Command-Shift-Z | Undoes, redoes the last UI session change. | | Tab, Shift-Tab | Indents, outdents the selected lines. | | Command-/ | Comments or uncomments the selected lines. | | Command-S | Saves the file. | A dot after the file name shows that the file has changes that are not saved. Input methods work: the text being composed shows underlined at the cursor. Hold a letter to pick an accented one from the macOS accent menu: the accented letter replaces the one you held. When the file changes on disk and the Editor has no changes that are not saved, the Editor shows the new text. Press **Control-Space** to show completions at the cursor. The list shows one completion under the other, with the documentation of the selected one beside it. **Up** and **Down** select, and the list scrolls to keep the selection in view; **Enter** or **Tab** inserts it, and a click inserts the one clicked. **Escape** closes the list. Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#edit-the-file Previous: how-to/running/15-edit-code-in-the-window#show-the-editor Next: how-to/running/15-edit-code-in-the-window#optional-vim-bindings --- <!-- ID: how-to/running/15-edit-code-in-the-window#give-the-keys-back-to-the-session --> Edit code in the main window > Give the keys back to the session [guide] Click the Arrangement, the Mixer or the transport bar, or, with Vim bindings off, press Escape. Then **Command-S** saves the project session, and Space toggles play and pause. While the Editor has the keyboard, Command-S saves the file. Space also toggles play and pause in Vim Normal and Visual modes. In Insert mode, Space types a space. New projects start stopped; press Play in the transport to start playback. **Command-Z** and **Command-Shift-Z** undo and redo session changes with or without the Editor focused. Single-line fields, such as track names, dB entries and Browser search, keep these keys for their own text while focused. A thin grey outline shows which panel has the keys. The Editor has the outline only while it has the keyboard. Otherwise the outline is on the panel you last clicked in: the Arrangement, the Mixer, the Devices panel or the Browser. A field you type in, such as a track name or the Browser search, puts the outline on its panel. A collapsed panel has the outline on its header or strip. A click on the transport bar does not change the panel you last clicked in. If the Editor had the keyboard, the click gives the keys and the outline back to that panel. When the window opens, the Arrangement has the outline. While the Browser has the outline and no field has the keyboard, the arrow keys and Return go to the Browser; see [use the Browser with the keyboard](/docs/how-to/running/13-use-the-mixer/#use-the-browser-with-the-keyboard). Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#give-the-keys-back-to-the-session Previous: how-to/running/15-edit-code-in-the-window#run-code --- <!-- ID: how-to/running/15-edit-code-in-the-window#mappings --> Edit code in the main window > Mappings [guide] Put vimrc mapping lines in `editor_vim_maps`, under `[display]`: ```toml [display] editor_vim = true editor_vim_maps = ["inoremap fd <Esc>", "noremap H ^", "noremap L $"] ``` With these lines, `fd` typed in Insert mode returns to Normal mode, and `H` and `L` go to the first character that is not a space and to the end of the line. `noremap` maps in Normal mode, Visual mode and after an operator, so `dL` deletes to the end of the line. `nnoremap`, `xnoremap`, `onoremap` and `inoremap` map in one mode. A mapping does not remap: its keys always have their usual meaning. Keys are characters or `<Esc>`, `<CR>`, `<Tab>`, `<BS>`, `<Space>`, `<lt>` and `<Bar>`. When a key can start a mapping, the Editor waits up to one second for the next key, as Vim's `timeoutlen` does. In Insert mode, the waiting text shows at the cursor. If the next key does not continue the mapping, or no key comes in time, the waiting keys have their usual meaning. To type `fd` as text, pause after `f`. The Output strip names a line that cannot be applied. This is a scoped keymap. Search, backward find, named registers, macros, marks, block selections, window commands, and Ex commands other than `:w` are not included. Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#mappings Previous: how-to/running/15-edit-code-in-the-window#optional-vim-bindings Next: how-to/running/15-edit-code-in-the-window#run-code --- <!-- ID: how-to/running/15-edit-code-in-the-window#optional-vim-bindings --> Edit code in the main window > Optional Vim bindings [guide] Turn on **Vim Mode** on the **Editor** tab of the [Preferences window](/docs/how-to/setup/07-use-the-preferences-window/), or set `editor_vim = true` under `[display]` in `~/.resonon/preferences.toml` and run `reload_preferences()`. The open Editor changes at once. The default is off. The panel shows the mode and uses a block cursor in Normal mode and a bar in Insert mode. A file opens in Normal mode, as in Vim, where typed keys are commands: press `i` before you type text. Use `i/a/I/A`, `o/O`, Escape, `v/V`, counts, `h/j/k/l`, `w/b/e`, `0/^/$`, `gg/G`, and forward `f/t`. Operators `d/c/y` accept motions, doubled line operators, and `iw/aw`, `i(/a(`, `i"/a"` text objects. Use `x`, `p/P`, `u`, Control-R, and `.` to delete, paste, undo, redo, and repeat a change. One insert session is one undo step, including line breaks. `:w` followed by Enter saves the file. Control-Z and Control-Shift-Z also undo and redo text in every mode. Command-Z and Command-Shift-Z undo and redo session changes in every mode. Command-S and the run shortcuts still work in every mode. Visual selections use the same Run Selection Live path as mouse selections. Escape returns to Normal mode and keeps the keyboard in the Editor. When the completion list is open, Escape closes it and returns to Normal mode. Click the session to give it the keyboard. Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#optional-vim-bindings Previous: how-to/running/15-edit-code-in-the-window#edit-the-file Next: how-to/running/15-edit-code-in-the-window#mappings --- <!-- ID: how-to/running/15-edit-code-in-the-window#run-code --> Edit code in the main window > Run code [guide] With the text focused, press **Command-Enter** to Run Selection Live. With nothing selected, it runs the current line. The range flashes briefly. This evaluates in the current session, like Run Selection Live in VSCode or Neovim. Code execution is not a session undo step. Correct the source and run it again to change the result. Press **Command-Shift-Enter**, or click **Run File Live**, to save the panel's dirty files and evaluate the whole entry file into the running session. It does not reset the session or call `setup()`, and the transport and the mixer do not change. A changed pattern starts on the next cycle. A disk conflict or save error prevents the run. Session undo does not undo the run. To open the project again from its files, select **File > Reset Project**. It saves the editor files first. It asks before it loses changes made since the last save. If tracks were renamed in the session, choose **Update and Open** to update their names in code first, or **Cancel** to keep the current session. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). The **Output** strip shows printed output and execution errors, including later callback output. Click its header to collapse it, or drag its top edge to resize it. Saving the session keeps its height and whether it is shown. **Show other clients** includes subsequent output from other editors. Errors and warnings underline their source ranges; hover over an underline for the message. Click a file's diagnostic in Output to open it. Completing another run replaces that file's marks. Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#run-code Previous: how-to/running/15-edit-code-in-the-window#mappings Next: how-to/running/15-edit-code-in-the-window#give-the-keys-back-to-the-session --- <!-- ID: how-to/running/15-edit-code-in-the-window#show-the-editor --> Edit code in the main window > Show the Editor [guide] A new session shows the Editor. Press **Command-Option-E** or click the Editor header to hide it; it folds to a thin strip along the window's left edge with its name written down it. Click the strip or press the keys again to show it. Drag the Editor's right edge to resize it, from a fifth to four fifths of the window. It keeps that share of the window when you resize the window. When you [save the session](/docs/how-to/running/12-save-and-open-a-session/), opening the session restores whether the panel is shown and its share of the window. The panel shows the entry file after the session opens or runs a project, or runs code in one. Without a project it tells you to open or run one. Page: how-to/running/15-edit-code-in-the-window URL: https://resonon.org/docs/how-to/running/15-edit-code-in-the-window/#show-the-editor Next: how-to/running/15-edit-code-in-the-window#edit-the-file --- <!-- ID: how-to/running/16-open-resonon-as-an-app --> Open Resonon as an app [guide] As an app, Resonon has its own session, its own main window and an icon in the Dock. You do not need a terminal, an editor or a server that is already running. Sections: - how-to/running/16-open-resonon-as-an-app#start-the-app | Start the app - how-to/running/16-open-resonon-as-an-app#open-a-project | Open a project - how-to/running/16-open-resonon-as-an-app#start-a-new-project | Start a new project - how-to/running/16-open-resonon-as-an-app#quit | Quit Page: how-to/running/16-open-resonon-as-an-app URL: https://resonon.org/docs/how-to/running/16-open-resonon-as-an-app/ --- <!-- ID: how-to/running/16-open-resonon-as-an-app#open-a-project --> Open Resonon as an app > Open a project [guide] A saved project has a document in its folder: `<Project name>.resonon`. Finder shows it with the Resonon icon. To open the project, do one of these: - Double-click the document, or select **Open With > Resonon**. - In the app, select **File > Open Project…** and select the project folder or its document. The app opens the project as [opening a session](/docs/how-to/running/12-save-and-open-a-session/) does. It restores the saved session, then runs the entry file: `fn setup()`, then the rest of the top level. Nothing plays until you press Play or Space. A project that you did not save yet opens with an empty session, then runs its entry file. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). To open the current project again from its files, select **File > Reset Project**. If the app is open already, the project opens in the same window. When the current session has changes since it was opened or saved, or an editor file has unsaved changes, the app asks first: - **Save** saves the editor files and the session, then opens the project. If the save fails, the current session stays open. - **Discard** opens the project without saving. - **Cancel** keeps the current session. The document holds no paths, so you can move, rename or copy the project folder. Keep one `.resonon` document in each project: a project with two of them does not open, and the app tells you which documents to remove. Page: how-to/running/16-open-resonon-as-an-app URL: https://resonon.org/docs/how-to/running/16-open-resonon-as-an-app/#open-a-project Previous: how-to/running/16-open-resonon-as-an-app#start-the-app Next: how-to/running/16-open-resonon-as-an-app#start-a-new-project --- <!-- ID: how-to/running/16-open-resonon-as-an-app#quit --> Open Resonon as an app > Quit [guide] Select **Resonon > Quit Resonon** (**Command-Q**) or close the main window. The app asks the same question as before it opens a project. When the app quits, it closes plugin windows and stops its own session server. The session calls `fn teardown()` as it closes, if the entry file defines it. Page: how-to/running/16-open-resonon-as-an-app URL: https://resonon.org/docs/how-to/running/16-open-resonon-as-an-app/#quit Previous: how-to/running/16-open-resonon-as-an-app#start-a-new-project --- <!-- ID: how-to/running/16-open-resonon-as-an-app#start-a-new-project --> Open Resonon as an app > Start a new project [guide] Select **File > New Project** (**Command-N**). A new project, Untitled, opens immediately. You do not select a location for it yet. The first time you save it, with **File > Save Project** (**Command-S**) or **Save** when the app asks, the app shows the save panel. Select a location and type a name. The app moves the project there and gives it that name. The session, the undo history and the open editor files continue, and the window title shows the name. **Cancel** in the panel keeps the project Untitled. If you open another project, start a new one or quit without saving, the app deletes the Untitled project. The app asks first if the project has changes or if you saved a file in the editor. Page: how-to/running/16-open-resonon-as-an-app URL: https://resonon.org/docs/how-to/running/16-open-resonon-as-an-app/#start-a-new-project Previous: how-to/running/16-open-resonon-as-an-app#open-a-project Next: how-to/running/16-open-resonon-as-an-app#quit --- <!-- ID: how-to/running/16-open-resonon-as-an-app#start-the-app --> Open Resonon as an app > Start the app [guide] Open `Resonon.app` from Finder or the Dock. A new window opens with a new project, Untitled. Nothing from an earlier session opens, and nothing plays. Press Space to play the new project. From a terminal, `resonon app` does the same, and `resonon app <project>` opens that project instead. The app's session runs on a server of its own, on a free port of this computer only. It does not connect to, or stop, a server that `resonon server` or the editor started. Page: how-to/running/16-open-resonon-as-an-app URL: https://resonon.org/docs/how-to/running/16-open-resonon-as-an-app/#start-the-app Next: how-to/running/16-open-resonon-as-an-app#open-a-project --- <!-- ID: how-to/running/17-use-the-device-panel --> Use the Device Panel [guide] The Devices panel is a collapsible panel at the bottom of the main Resonon window. It shows the devices of the selected track, from left to right: the instrument first, then the effects in chain order. Each device is a card. Open the window as [Use the Mixer](/docs/how-to/running/13-use-the-mixer/) tells you. Sections: - how-to/running/17-use-the-device-panel#show-the-panel | Show the panel - how-to/running/17-use-the-device-panel#read-a-card | Read a card - how-to/running/17-use-the-device-panel#devices-with-their-own-panel | Devices with their own panel - how-to/running/17-use-the-device-panel#change-a-parameter | Change a parameter - how-to/running/17-use-the-device-panel#change-a-parameter-with-the-keys | Change a parameter with the keys - how-to/running/17-use-the-device-panel#parameters-a-signal-drives | Parameters a signal drives - how-to/running/17-use-the-device-panel#undo-a-change | Undo a change - how-to/running/17-use-the-device-panel#add-move-and-remove-devices | Add, move and remove devices - how-to/running/17-use-the-device-panel#read-card-changes-in-code | Read card changes in code Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/ --- <!-- ID: how-to/running/17-use-the-device-panel#add-move-and-remove-devices --> Use the Device Panel > Add, move and remove devices [guide] | Action | Result | | --- | --- | | Drag an item from the Browser onto the Devices panel | Adds it to the selected track. Over the cards, it goes before the card under the pointer, or last after the last card; on the header, the track name or the space below the cards, it goes last. While the panel is collapsed, its **Devices** header takes the drop too. An outline round the panel shows the drop, and a line between the cards shows the place. An instrument replaces the track's instrument; the master track and MIDI and return tracks take no instrument. | | Drag an effect card to the left or right | Moves the effect to the new place in the chain. The instrument stays first. | | Click a card | Selects it. The selected card has a light grey outline. | | Double-click a card | Opens the plugin window, when the device has one. | | **Delete** or **Backspace**, with a card selected | Removes the selected device. | | Right-click a card, **Remove** | Removes the device. | The Browser is in [Use the Mixer](/docs/how-to/running/13-use-the-mixer/#add-devices-from-the-browser). Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#add-move-and-remove-devices Previous: how-to/running/17-use-the-device-panel#undo-a-change Next: how-to/running/17-use-the-device-panel#read-card-changes-in-code --- <!-- ID: how-to/running/17-use-the-device-panel#change-a-parameter --> Use the Device Panel > Change a parameter [guide] The value boxes work like the [Mixer values](/docs/how-to/running/13-use-the-mixer/#change-a-value): | Action | Result | | --- | --- | | Drag up or down | Changes the value. A drag of 200 points covers the full range. | | Shift-drag | Changes it at a tenth of the speed. | | Double-click | Resets it to the parameter's default. | | Right-click, type, press Enter | Sets the typed value. Esc or a click elsewhere cancels. Text that is not a value leaves the value as it was. | | Click a chooser | Opens the list of steps. Click a step to choose it. | | Hold the pointer over a value | Shows the parameter name and the exact value. | Type a value in the unit the box shows. A bare number uses that unit: `500` in a box that shows `375 ms` sets 500 ms. A unit makes the value exact: `0.5 s`, `2.4 kHz`, `-6 dB`, `30 %`. A chooser also takes the name of a step. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#change-a-parameter Previous: how-to/running/17-use-the-device-panel#devices-with-their-own-panel Next: how-to/running/17-use-the-device-panel#change-a-parameter-with-the-keys --- <!-- ID: how-to/running/17-use-the-device-panel#change-a-parameter-with-the-keys --> Use the Device Panel > Change a parameter with the keys [guide] The keys work as on the [Mixer controls](/docs/how-to/running/13-use-the-mixer/#change-a-value-with-the-keys). A plain click on a value box, a chooser or a light gives it the keys; a drag, a double-click or a right-click never takes them from the Editor. | Key | Result | | --- | --- | | **Tab**, **Shift-Tab** | Gives the keys to the next or previous control: card after card in chain order, and in reading order in each card. The keys stay in the Devices panel and go round from the last control to the first. The **UI** and **×** buttons are not in the order. | | **Up** or **Right**, **Down** or **Left** | Steps the value up or down: 1 % of the box's travel, 0.5 dB for a level in dB, or one step for a parameter with steps. | | **Shift** with an arrow | Steps at a tenth: 0.1 % of the travel, or 0.1 dB. | | **Enter** | Opens the typed value. Switches the device on or off on a light. Opens a chooser's list; then **Down** and **Up** move in the list and **Enter** chooses. | | **Delete** or **Backspace** | Resets the parameter to its default. | | **Escape** | Takes the keys from the control. | Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#change-a-parameter-with-the-keys Previous: how-to/running/17-use-the-device-panel#change-a-parameter Next: how-to/running/17-use-the-device-panel#parameters-a-signal-drives --- <!-- ID: how-to/running/17-use-the-device-panel#devices-with-their-own-panel --> Use the Device Panel > Devices with their own panel [guide] **Reverb** and **PlateReverb** show their own panel instead of the parameter list, as a Live device does: - One knob for each parameter, with the name above it and the value below it. Reverb has Room, Damp, Width and Mix. PlateReverb has Size, Damping, Diffusion, PreDelay and Mix. - An output meter at the right edge. The clip light above it comes on when the output clips and stays on. Click the clip light to switch it off. The knobs take the same gestures and keys as the value boxes. These devices have no **UI** button: the panel is their only window. A plugin from another vendor shows the parameter list, and its **UI** button opens the plugin's own window. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#devices-with-their-own-panel Previous: how-to/running/17-use-the-device-panel#read-a-card Next: how-to/running/17-use-the-device-panel#change-a-parameter --- <!-- ID: how-to/running/17-use-the-device-panel#parameters-a-signal-drives --> Use the Device Panel > Parameters a signal drives [guide] On a device with its own panel, each knob shows the parameter's current value. When code binds a signal to a parameter, as `filter.parameter("Cutoff") << lfo` does, the knob follows the signal and is locked: - The knob dims, and its value below it follows the signal. - A drag, the arrows, **Delete**, a double-click and a typed value do nothing, and make no undo step. - The knob still takes the keys, so **Tab** goes through it. - Hold the pointer over it to see the value and *Controlled by a signal*. A display handle that sets two parameters, such as a filter curve's handle, is locked while a signal drives either of them. The other parameter stays free on its own knob. When no signal drives the parameter, the knob and the handle take edits again. A value that code sets with `set_parameter()` moves the knob when the code runs. The parameter list of a device without its own panel shows the stored value. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#parameters-a-signal-drives Previous: how-to/running/17-use-the-device-panel#change-a-parameter-with-the-keys Next: how-to/running/17-use-the-device-panel#undo-a-change --- <!-- ID: how-to/running/17-use-the-device-panel#read-a-card --> Use the Device Panel > Read a card [guide] | Part | Shows | | --- | --- | | Light | The device is on when the light is lit. Click it to switch the device on or off. The parameters of a switched-off device dim. | | Name | The device name. Hold the pointer over the card to see all of it. | | **UI** | Opens the plugin window. Only a plugin with its own window has this button. A dimmed **UI** button cannot open the window: hold the pointer over it to see why. | | **×** | Removes the device. | | Parameters | One row for each parameter, in the order the device declares them: the name at the left and the value box at the right. A head names each group of parameters. A parameter with named steps, such as a mode, shows a chooser. | A card shows about four rows. Turn the mouse wheel over the parameters to scroll the list. The wheel never changes a value. A device that is not running shows why instead of its parameters, for example `missing` for a plugin that is not installed on this computer. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#read-a-card Previous: how-to/running/17-use-the-device-panel#show-the-panel Next: how-to/running/17-use-the-device-panel#devices-with-their-own-panel --- <!-- ID: how-to/running/17-use-the-device-panel#read-card-changes-in-code --> Use the Device Panel > Read card changes in code [guide] A card and code change the same parameter. Put a delay on a track: ```resonon use "std/effects" { Delay }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("lead"); } let lead = session.track("lead"); let echo = Delay("echo", 0.25, 0.4); lead.set_effects(#[echo]); ``` Drag **Feedback** on the `echo` card, then read the value in code: ```resonon continue print(echo.parameter("Feedback").get()); print(echo.parameters()); ``` The printed value is the card's value. The value that was written last wins, whether code or the card wrote it. In the editor, a parameter that the card changed shows its current value beside the argument that set it. Running that line again sets the code's value again and removes the hint. To keep the card's value in VSCode, choose **Write UI value into code**; see [UI parameter values in code](/docs/reference/running/01-vscode-extension/#ui-parameter-values-in-code). Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#read-card-changes-in-code Previous: how-to/running/17-use-the-device-panel#add-move-and-remove-devices --- <!-- ID: how-to/running/17-use-the-device-panel#show-the-panel --> Use the Device Panel > Show the panel [guide] Press **Command-Option-D**, or click the **Devices** header, to collapse or expand the panel. Drag its upper edge to resize it. Click a track in the [Mixer](/docs/how-to/running/13-use-the-mixer/) or the [Arrangement](/docs/how-to/running/14-use-the-arrangement/) to show its devices. A project opens with the master track selected, so the panel always shows a chain. The track name shows above the cards; double-click it to rename the track. When the cards do not fit, scroll the panel to the left or right. Saving the session keeps the panel's visibility and height. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#show-the-panel Next: how-to/running/17-use-the-device-panel#read-a-card --- <!-- ID: how-to/running/17-use-the-device-panel#undo-a-change --> Use the Device Panel > Undo a change [guide] Press **Command-Z** to undo the last change and **Command-Shift-Z** to redo it. One drag is one step, so a single undo takes the parameter back to where the drag started. Arrow presses on one control are one step while less than 1 s passes between them. A double-click, a typed value and a chooser step are one step each. Switching a device on or off, and adding, moving or removing a device, are one step each. Page: how-to/running/17-use-the-device-panel URL: https://resonon.org/docs/how-to/running/17-use-the-device-panel/#undo-a-change Previous: how-to/running/17-use-the-device-panel#parameters-a-signal-drives Next: how-to/running/17-use-the-device-panel#add-move-and-remove-devices --- <!-- ID: how-to/running/18-use-the-analysis-panel --> Use the Analysis Panel [guide] The Analysis panel measures the stereo master after its devices and fader. Solo and mute therefore change what the panel measures, as they change the master output. Open the main window as [Use the Mixer](/docs/how-to/running/13-use-the-mixer/) tells you. Sections: - how-to/running/18-use-the-analysis-panel#show-the-panel | Show the panel - how-to/running/18-use-the-analysis-panel#read-loudness | Read loudness - how-to/running/18-use-the-analysis-panel#inspect-the-spectrum | Inspect the spectrum - how-to/running/18-use-the-analysis-panel#compare-stereo-channels | Compare stereo channels Page: how-to/running/18-use-the-analysis-panel URL: https://resonon.org/docs/how-to/running/18-use-the-analysis-panel/ --- <!-- ID: how-to/running/18-use-the-analysis-panel#compare-stereo-channels --> Use the Analysis Panel > Compare stereo channels [guide] Select **Stereo** for the goniometer. Mono appears vertically, left-only sound leans left, and right-only sound leans right. Opposite-polarity channels spread horizontally. Hot points stop at the outer arc so that they remain visible. The overall correlation bar and 20 frequency-band bars appear below either view. Positive values indicate similar channels; negative values indicate opposing channels. Silence in either channel gives neutral correlation. Correlation alone does not determine mono compatibility. Device changes and missing sample history restart the measurements. Allow the loudness windows to fill again. In a short panel, enlarge the window or reduce the Mixer height to show the plots. Page: how-to/running/18-use-the-analysis-panel URL: https://resonon.org/docs/how-to/running/18-use-the-analysis-panel/#compare-stereo-channels Previous: how-to/running/18-use-the-analysis-panel#inspect-the-spectrum --- <!-- ID: how-to/running/18-use-the-analysis-panel#inspect-the-spectrum --> Use the Analysis Panel > Inspect the spectrum [guide] Select **Spectrum** for the logarithmic 20 Hz–20 kHz spectrum and peak trace. The display uses the loudest FFT bin in each display interval. Wider intervals can read higher on noise; the plot is not a noise-density measurement. The slope menu defaults to **Flat**. Select **Pink Noise Slope** for a 4.5 dB/octave display tilt; this does not change the audio. Page: how-to/running/18-use-the-analysis-panel URL: https://resonon.org/docs/how-to/running/18-use-the-analysis-panel/#inspect-the-spectrum Previous: how-to/running/18-use-the-analysis-panel#read-loudness Next: how-to/running/18-use-the-analysis-panel#compare-stereo-channels --- <!-- ID: how-to/running/18-use-the-analysis-panel#read-loudness --> Use the Analysis Panel > Read loudness [guide] The number fields show momentary (**M**, 400 ms), short-term (**S**, 3 s) and integrated (**I**) loudness in LUFS. Integrated loudness uses absolute and relative gating and resets when transport starts playing. **RMS** uses a 300 ms window and the AES17 reference: a full-scale sine reads 0 dB. An em dash means silence or an incomplete measurement window. These fields do not measure true peak or loudness range. Page: how-to/running/18-use-the-analysis-panel URL: https://resonon.org/docs/how-to/running/18-use-the-analysis-panel/#read-loudness Previous: how-to/running/18-use-the-analysis-panel#show-the-panel Next: how-to/running/18-use-the-analysis-panel#inspect-the-spectrum --- <!-- ID: how-to/running/18-use-the-analysis-panel#show-the-panel --> Use the Analysis Panel > Show the panel [guide] Click the **Analysis** strip on the right of the Arrangement. Click the panel header to collapse it. Drag its left edge to set its width; double-click the edge to restore the default width. Saving the session keeps the visibility, width, selected view and spectrum slope. Analysis stops while the panel is collapsed or the main window is closed. Opening it starts fresh measurements. The floating scope window remains independent. Page: how-to/running/18-use-the-analysis-panel URL: https://resonon.org/docs/how-to/running/18-use-the-analysis-panel/#show-the-panel Next: how-to/running/18-use-the-analysis-panel#read-loudness --- <!-- ID: how-to/setup/01-build-from-source --> Build Resonon from Source [guide] If you want to make changes to the core source code of resonon or have other reasons for not using the official installers, you can build and install from source. :::caution Installation from source is generally not necessary! Changes made to the resonon source itself easily break compatibility with all existing projects. Resonon has support for custom Rust libraries, audio plugins, and many things can even be built completely within the language. If you are missing an important feature, feel free to open a request on the [GitHub repository](https://github.com/WARNS-AUDIO/RESONON), or reach out via e-mail (_contact[at]resonon.org_). We are always grateful for user feedback and ideas for improvement, but cannot guarantee any feature requests will be honored. In its current state resonon is **not open for code contributions.** ::: Sections: - how-to/setup/01-build-from-source#prerequisites | Prerequisites - how-to/setup/01-build-from-source#build-and-install | Build and install - how-to/setup/01-build-from-source#vs-code-extension | VS Code extension - how-to/setup/01-build-from-source#building-without-installing | Building without installing - how-to/setup/01-build-from-source#run-the-tests | Run the tests - how-to/setup/01-build-from-source#next-steps | Next Steps Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/ --- <!-- ID: how-to/setup/01-build-from-source#build-and-install --> Build Resonon from Source > Build and install [guide] Clone the repository and run the `install` target: ```bash git clone https://github.com/WARNS-AUDIO/RESONON.git cd RESONON make install ``` `make install` performs the full pipeline: 1. Builds the `resonon` binary (release, with built-in devices). 2. Builds the `resonon-lsp` language server and the `resonon-shim` launcher. 3. Installs them under `~/.resonon/versions/<version>+dev/` — the workspace version plus `+dev`, replacing any earlier local build. 4. Copies the bundled sample kits and the standard library alongside them. 5. Codesigns the binaries and makes this build the default, which also puts the launcher in `~/.resonon/bin/`. 6. Links `resonon` and `resonon-lsp` in `/usr/local/bin` to the launcher (this step uses `sudo`). The local build is named by the version it really is, so a project pinned to that minor runs it, and a project pinned to another installed version runs that one — the launcher chooses exactly as it does for releases. To run the local build on a project pinned elsewhere, run the binary by path (`~/.resonon/versions/<version>+dev/bin/resonon`). When it finishes, verify the install: ```bash resonon --version resonon version current ``` To add a published version beside it, use `resonon version install <version>`. Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#build-and-install Previous: how-to/setup/01-build-from-source#prerequisites Next: how-to/setup/01-build-from-source#vs-code-extension --- <!-- ID: how-to/setup/01-build-from-source#building-without-installing --> Build Resonon from Source > Building without installing [guide] If you just want to compile the binaries (for development or CI) without installing them system-wide, use `cargo` directly: ```bash cargo build --release --bin resonon cargo build --release -p resonon-lsp ``` Built-in devices are linked into the binary. No plugin staging is needed to build it. The binaries land in `target/release/`. Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#building-without-installing Previous: how-to/setup/01-build-from-source#vs-code-extension Next: how-to/setup/01-build-from-source#run-the-tests --- <!-- ID: how-to/setup/01-build-from-source#next-steps --> Build Resonon from Source > Next Steps [guide] - [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/) — make a first sound now that resonon is built. - [Command Line](/docs/reference/setup/01-cli/) — every `resonon` command and option. - [Ship a Native Extension](/docs/how-to/dsp/05-ship-a-native-extension/) — build your own native extensions. Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#next-steps Previous: how-to/setup/01-build-from-source#run-the-tests --- <!-- ID: how-to/setup/01-build-from-source#prerequisites --> Build Resonon from Source > Prerequisites [guide] - **macOS** — the build and install process is macOS-only (it codesigns the binaries and symlinks them into `/usr/local/bin`). - **Rust toolchain** — install via [rustup](https://rustup.rs). A recent stable toolchain is required. - **Node.js + npm** — only needed to build the VS Code extension. Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#prerequisites Next: how-to/setup/01-build-from-source#build-and-install --- <!-- ID: how-to/setup/01-build-from-source#run-the-tests --> Build Resonon from Source > Run the tests [guide] The full suite stages bundles for explicit bundle-contract tests. Ordinary built-in tests use the static factory: ```bash ./scripts/ci.sh test ``` Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#run-the-tests Previous: how-to/setup/01-build-from-source#building-without-installing Next: how-to/setup/01-build-from-source#next-steps --- <!-- ID: how-to/setup/01-build-from-source#vs-code-extension --> Build Resonon from Source > VS Code extension [guide] To build and install the extension from source: ```bash make install-ext ``` Page: how-to/setup/01-build-from-source URL: https://resonon.org/docs/how-to/setup/01-build-from-source/#vs-code-extension Previous: how-to/setup/01-build-from-source#build-and-install Next: how-to/setup/01-build-from-source#building-without-installing --- <!-- ID: how-to/setup/02-set-up-this-machine --> Set Up This Machine [guide] Everything about this machine — which interface, which MIDI ports, where your own kits and plugins are — lives in one file, `~/.resonon/preferences.toml`. Every key is in [Preferences](/docs/reference/setup/02-preferences/); why it is a file and not code in the piece is in [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/). Sections: - how-to/setup/02-set-up-this-machine#set-up-in-the-app | Set up in the app - how-to/setup/02-set-up-this-machine#set-up-with-the-dialog | Set up with the dialog - how-to/setup/02-set-up-this-machine#edit-the-file-by-hand | Edit the file by hand - how-to/setup/02-set-up-this-machine#add-a-kit-or-plugin-folder | Add a kit or plugin folder - how-to/setup/02-set-up-this-machine#put-a-change-in-force | Put a change in force - how-to/setup/02-set-up-this-machine#related | Related Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/ --- <!-- ID: how-to/setup/02-set-up-this-machine#add-a-kit-or-plugin-folder --> Set Up This Machine > Add a kit or plugin folder [guide] ```bash resonon config kits add "~/Music/kits" resonon config plugins add "/Volumes/Audio/Plugins" ``` `remove` takes a folder out and `list` shows the list. A path may start with `~`, but it may not be relative or name a `$VARIABLE`. The folders you add are searched in addition to the built-in ones. `resonon config paths` prints every folder resonon searches, in order. Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#add-a-kit-or-plugin-folder Previous: how-to/setup/02-set-up-this-machine#edit-the-file-by-hand Next: how-to/setup/02-set-up-this-machine#put-a-change-in-force --- <!-- ID: how-to/setup/02-set-up-this-machine#edit-the-file-by-hand --> Set Up This Machine > Edit the file by hand [guide] In VSCode, run **RESONON: Open Preferences**. It opens `~/.resonon/preferences.toml`, and creates an empty one if there is none: ```toml [audio] output = "Scarlett" sample_rate = 48000 buffer_size = 256 [[midi.outputs]] alias = "synth" port = "IAC" ``` Device and port names match exactly first, then as a substring, so `"Scarlett"` finds `"Focusrite Scarlett 2i2"`. `resonon --list-ports` prints a ready-to-paste entry for every MIDI device that is plugged in. Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#edit-the-file-by-hand Previous: how-to/setup/02-set-up-this-machine#set-up-with-the-dialog Next: how-to/setup/02-set-up-this-machine#add-a-kit-or-plugin-folder --- <!-- ID: how-to/setup/02-set-up-this-machine#put-a-change-in-force --> Set Up This Machine > Put a change in force [guide] A change in the Preferences window is in force at once. A running session does not see an edit to the file by hand, by `resonon setup` or by `resonon config` until you tell it to: ```resonon parse-only reload_preferences(); ``` It applies only what changed, and prints one line for each change. A file that does not parse changes nothing, and says why. While a take is recording, it leaves the `[audio]` section alone and says so; run it again after the take. A new process — `resonon run`, a new server — reads the file when it starts, so nothing else is needed there. Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#put-a-change-in-force Previous: how-to/setup/02-set-up-this-machine#add-a-kit-or-plugin-folder Next: how-to/setup/02-set-up-this-machine#related --- <!-- ID: how-to/setup/02-set-up-this-machine#related --> Set Up This Machine > Related [guide] - [Use the Preferences Window](/docs/how-to/setup/07-use-the-preferences-window/) — the same settings in the app - [Preferences](/docs/reference/setup/02-preferences/) — every key, type and default - [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/) — the `~/.resonon` layout and the search order - [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/) — no output, crackles, sample-rate mismatches Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#related Previous: how-to/setup/02-set-up-this-machine#put-a-change-in-force --- <!-- ID: how-to/setup/02-set-up-this-machine#set-up-in-the-app --> Set Up This Machine > Set up in the app [guide] In the app, select **Resonon > Preferences…** (Command-,). Each change in the window is in force at once. See [Use the Preferences Window](/docs/how-to/setup/07-use-the-preferences-window/). Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#set-up-in-the-app Next: how-to/setup/02-set-up-this-machine#set-up-with-the-dialog --- <!-- ID: how-to/setup/02-set-up-this-machine#set-up-with-the-dialog --> Set Up This Machine > Set up with the dialog [guide] ```bash resonon setup ``` It goes through the audio interface in and out, the sample rate and block size, the recording offset, the MIDI ports and their aliases, the kit and plugin folders, and the width `viz()` draws a cycle at. Each page offers what this machine has, and opens on what the file already says, so pressing `⏎` through a page changes nothing. The last page lists every line that would change. Confirm to write the file; press `esc` at any point to write nothing. Your comments and key order in the file are kept. `resonon setup` needs a terminal. Without one, it prints the written way to do each step. Page: how-to/setup/02-set-up-this-machine URL: https://resonon.org/docs/how-to/setup/02-set-up-this-machine/#set-up-with-the-dialog Previous: how-to/setup/02-set-up-this-machine#set-up-in-the-app Next: how-to/setup/02-set-up-this-machine#edit-the-file-by-hand --- <!-- ID: how-to/setup/03-install-a-package --> Install a Package [guide] A package is a git repository with code (`src/lib.non`), sample kits (`kits/`), or both. It installs into the project that uses it, and `resonon.toml` and `resonon.lock` record it, so the project gets the same package on every machine. Every command is in the [CLI reference](/docs/reference/setup/01-cli/#project--package-commands); every manifest key in [resonon.toml](/docs/reference/setup/04-resonon-toml/). Sections: - how-to/setup/03-install-a-package#install-a-package | Install a package - how-to/setup/03-install-a-package#pin-a-version | Pin a version - how-to/setup/03-install-a-package#install-a-cloned-projects-dependencies | Install a cloned project's dependencies - how-to/setup/03-install-a-package#update-or-remove-a-package | Update or remove a package - how-to/setup/03-install-a-package#use-a-packages-code | Use a package's code - how-to/setup/03-install-a-package#use-a-packages-kits | Use a package's kits - how-to/setup/03-install-a-package#see-what-is-installed | See what is installed - how-to/setup/03-install-a-package#related | Related Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/ --- <!-- ID: how-to/setup/03-install-a-package#install-a-cloned-projects-dependencies --> Install a Package > Install a cloned project's dependencies [guide] In a project you cloned or were sent, run it with no argument: ```bash resonon install ``` It installs every dependency in `resonon.toml` at the commit in `resonon.lock`, not at the newest one, so you get the same code as whoever committed the lock. A dependency that has moved away from the lock is put back, and the line says so: ``` Restored 'drum-kits' [kits] to /Users/you/my-song/dependencies/drum-kits, at locked commit 4f3c1a9e02b7d5c8a1f6e3b9d0c2a7e4f8b1d6c3 ``` A `version` tag in `resonon.toml` wins over the lock. If the project needs a version of resonon you do not have, `resonon install` stops before it fetches anything, and names the command that installs that version. Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#install-a-cloned-projects-dependencies Previous: how-to/setup/03-install-a-package#pin-a-version Next: how-to/setup/03-install-a-package#update-or-remove-a-package --- <!-- ID: how-to/setup/03-install-a-package#install-a-package --> Install a Package > Install a package [guide] In the project folder, name the repository with `gh:user/repo`: ```bash resonon install gh:resonon/drum-kits ``` The package is cloned into `dependencies/drum-kits`, and added to `resonon.toml` and `resonon.lock`. Resonon prints what it found in it: ``` Installed 'drum-kits' [kits] to /Users/you/my-song/dependencies/drum-kits Kits: 808 — Sampler(Kit("drum-kits/808")) vinyl — Sampler(Kit("drum-kits/vinyl")) Updated resonon.toml and resonon.lock ``` `[code]` means the package has a `src/lib.non`, `[kits]` a `kits/` folder, `[code+kits]` both. Outside a project, `resonon install` is an error: start one with `resonon new` first. Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#install-a-package Next: how-to/setup/03-install-a-package#pin-a-version --- <!-- ID: how-to/setup/03-install-a-package#pin-a-version --> Install a Package > Pin a version [guide] Add a git tag after `@`: ```bash resonon install gh:resonon/drum-kits@v1.0 ``` Or write it into `resonon.toml` and run `resonon install`: ```toml [dependencies] drum-kits = { source = "gh:resonon/drum-kits", version = "v1.0" } ``` Without a tag, the install takes the newest commit, and `resonon.lock` records which one. Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#pin-a-version Previous: how-to/setup/03-install-a-package#install-a-package Next: how-to/setup/03-install-a-package#install-a-cloned-projects-dependencies --- <!-- ID: how-to/setup/03-install-a-package#related --> Install a Package > Related [guide] - [Publish a Package](/docs/how-to/setup/04-publish-a-package/) — make your own - [Modules](/docs/reference/language/09-modules/) — how `use` finds a package - [Fix Install and Project Problems](/docs/how-to/setup/06-fix-install-and-project-problems/) — a module that is not found, a package with nothing in it Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#related Previous: how-to/setup/03-install-a-package#see-what-is-installed --- <!-- ID: how-to/setup/03-install-a-package#see-what-is-installed --> Install a Package > See what is installed [guide] ```bash resonon pkg list # every package, its type and its kits resonon pkg inspect drum-kits # its description, exports and kits ``` Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#see-what-is-installed Previous: how-to/setup/03-install-a-package#use-a-packages-kits Next: how-to/setup/03-install-a-package#related --- <!-- ID: how-to/setup/03-install-a-package#update-or-remove-a-package --> Install a Package > Update or remove a package [guide] ```bash resonon update # every dependency resonon update drum-kits # one ``` `update` fetches each dependency again, at its tag or at the newest commit, builds any native extension, and writes a new `resonon.lock`. Commit the lock: it is what makes the next `resonon install` reproducible. ```bash resonon remove drum-kits ``` `remove` takes the package out of `resonon.toml` and `resonon.lock`, and deletes its folder. Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#update-or-remove-a-package Previous: how-to/setup/03-install-a-package#install-a-cloned-projects-dependencies Next: how-to/setup/03-install-a-package#use-a-packages-code --- <!-- ID: how-to/setup/03-install-a-package#use-a-packages-code --> Install a Package > Use a package's code [guide] `use` the package by its name. It binds the name with hyphens turned into underscores: ```resonon no-check use "studio-tools"; let pattern = studio_tools.swing(42, 0.6); ``` Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#use-a-packages-code Previous: how-to/setup/03-install-a-package#update-or-remove-a-package Next: how-to/setup/03-install-a-package#use-a-packages-kits --- <!-- ID: how-to/setup/03-install-a-package#use-a-packages-kits --> Install a Package > Use a package's kits [guide] Name the kit with the package in front of it: ```resonon no-check use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("drum-kits/808"))); ``` `Kit("808")` works too. Write the package when two packages have a kit with the same name, or to show where a sound comes from. Page: how-to/setup/03-install-a-package URL: https://resonon.org/docs/how-to/setup/03-install-a-package/#use-a-packages-kits Previous: how-to/setup/03-install-a-package#use-a-packages-code Next: how-to/setup/03-install-a-package#see-what-is-installed --- <!-- ID: how-to/setup/04-publish-a-package --> Publish a Package [guide] A package is a git repository, and publishing it is pushing it to GitHub. There is no registry and no publish command: `gh:user/repo` is `https://github.com/user/repo.git`. Sections: - how-to/setup/04-publish-a-package#make-a-code-package | Make a code package - how-to/setup/04-publish-a-package#make-a-kit-package | Make a kit package - how-to/setup/04-publish-a-package#make-a-native-package | Make a native package - how-to/setup/04-publish-a-package#push-it-to-github | Push it to GitHub - how-to/setup/04-publish-a-package#tag-a-version | Tag a version - how-to/setup/04-publish-a-package#related | Related Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/ --- <!-- ID: how-to/setup/04-publish-a-package#make-a-code-package --> Publish a Package > Make a code package [guide] ```bash resonon new my-lib --lib ``` Write what you want to share into `src/lib.non`. Every top-level `fn`, `let` and `class` is exported; mark one `private` to keep it inside. `///` comments are shown by `resonon pkg inspect`, and the file's `//!` comment is the package's description: ```resonon //! my-lib — helpers for generative rhythms. private let lib_name = "my-lib"; /// Scale a value and round it to a whole number. fn scaled(value, factor) { round(value * factor) } /// Default tempo for performance templates. let default_bpm = 120; ``` Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#make-a-code-package Next: how-to/setup/04-publish-a-package#make-a-kit-package --- <!-- ID: how-to/setup/04-publish-a-package#make-a-kit-package --> Publish a Package > Make a kit package [guide] ```bash resonon new my-drums --kit ``` Put each kit in its own folder under `kits/`: ``` my-drums/ kits/ 808/ bd.wav sd.wav hh.wav ``` Files named like General MIDI drums (`bd`, `sd`, `hh`, …) get their notes without any setup. To set notes, velocity layers or root notes yourself, add a `kit.toml` and move the samples into a `samples/` folder next to it — every key is in [kit.toml](/docs/reference/setup/05-kit-toml/). A package can have code and kits: `resonon new my-pkg --lib --kit`. Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#make-a-kit-package Previous: how-to/setup/04-publish-a-package#make-a-code-package Next: how-to/setup/04-publish-a-package#make-a-native-package --- <!-- ID: how-to/setup/04-publish-a-package#make-a-native-package --> Publish a Package > Make a native package [guide] ```bash resonon new my-ext --native ``` This adds a Rust crate in `native/`. Installing the package builds it from source. For machines without a Rust toolchain, also commit a prebuilt binary for each platform you support: ```bash resonon build --dist ``` [Ship a Native Extension](/docs/how-to/dsp/05-ship-a-native-extension/) covers writing, building and publishing the extension. Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#make-a-native-package Previous: how-to/setup/04-publish-a-package#make-a-kit-package Next: how-to/setup/04-publish-a-package#push-it-to-github --- <!-- ID: how-to/setup/04-publish-a-package#push-it-to-github --> Publish a Package > Push it to GitHub [guide] ```bash cd my-lib git add . git commit -m "First version" gh repo create my-lib --public --source=. --push ``` `resonon new` already made the git repository. Anyone can now install the package: ```bash resonon install gh:yourname/my-lib ``` Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#push-it-to-github Previous: how-to/setup/04-publish-a-package#make-a-native-package Next: how-to/setup/04-publish-a-package#tag-a-version --- <!-- ID: how-to/setup/04-publish-a-package#related --> Publish a Package > Related [guide] - [Install a Package](/docs/how-to/setup/03-install-a-package/) — use one - [Share a Project](/docs/how-to/setup/05-share-a-project/) — send a piece, not a library - [Modules](/docs/reference/language/09-modules/) — `use`, exports and `private` Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#related Previous: how-to/setup/04-publish-a-package#tag-a-version --- <!-- ID: how-to/setup/04-publish-a-package#tag-a-version --> Publish a Package > Tag a version [guide] Tag a commit and push the tag: ```bash git tag v1.0 git push origin v1.0 ``` Others pin it with `resonon install gh:yourname/my-lib@v1.0`, or with `version = "v1.0"` in their `resonon.toml`. Page: how-to/setup/04-publish-a-package URL: https://resonon.org/docs/how-to/setup/04-publish-a-package/#tag-a-version Previous: how-to/setup/04-publish-a-package#push-it-to-github Next: how-to/setup/04-publish-a-package#related --- <!-- ID: how-to/setup/05-share-a-project --> Share a Project [guide] Your code travels with a project; a kit from your own library does not. These steps bring the sounds a piece uses into the project, or record the ones that must stay outside it. Why only some kits travel: [What travels with a project](/docs/explanation/setup/03-search-paths-and-portability/#what-travels-with-a-project). Sections: - how-to/setup/05-share-a-project#find-the-kits-that-will-not-travel | Find the kits that will not travel - how-to/setup/05-share-a-project#bring-a-kit-into-the-project | Bring a kit into the project - how-to/setup/05-share-a-project#list-a-kit-you-cannot-bring-in | List a kit you cannot bring in - how-to/setup/05-share-a-project#bring-in-every-listed-kit | Bring in every listed kit - how-to/setup/05-share-a-project#check-what-the-project-depends-on | Check what the project depends on - how-to/setup/05-share-a-project#drop-a-kit-you-no-longer-use | Drop a kit you no longer use - how-to/setup/05-share-a-project#check-the-project-before-you-send-it | Check the project before you send it - how-to/setup/05-share-a-project#related | Related Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/ --- <!-- ID: how-to/setup/05-share-a-project#bring-a-kit-into-the-project --> Share a Project > Bring a kit into the project [guide] ```bash resonon collect my-breaks ``` The kit is copied into `<project>/kits/`, and listed under `[local]` in `resonon.toml`. Your code does not change: the project's `kits/` is searched first, so `Kit("my-breaks")` now finds the copy. Running it again on a kit that is already in the project changes nothing. To take a fresh copy after you changed the original, delete `<project>/kits/my-breaks` and collect it again. `collect` refuses a kit from a package — `resonon install` brings that one back — and a kit whose `kit.toml` points outside its own folder. Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#bring-a-kit-into-the-project Previous: how-to/setup/05-share-a-project#find-the-kits-that-will-not-travel Next: how-to/setup/05-share-a-project#list-a-kit-you-cannot-bring-in --- <!-- ID: how-to/setup/05-share-a-project#bring-in-every-listed-kit --> Share a Project > Bring in every listed kit [guide] ```bash resonon collect ``` With no name, `collect` works through every kit under `[local]`. It copies each one it finds on this machine, names each one it cannot find, and leaves the list as it is — so a kit you delete from `kits/` later can be collected again from the same entry. Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#bring-in-every-listed-kit Previous: how-to/setup/05-share-a-project#list-a-kit-you-cannot-bring-in Next: how-to/setup/05-share-a-project#check-what-the-project-depends-on --- <!-- ID: how-to/setup/05-share-a-project#check-the-project-before-you-send-it --> Share a Project > Check the project before you send it [guide] 1. Play the piece, and note every kit resonon warns about. 2. Run `resonon collect`. 3. Run `resonon kits list`. A kit that is still `missing` is missing for the person you send it to, too. 4. Zip the project folder. You can leave out `dependencies/`: `resonon install` restores it from `resonon.toml` and `resonon.lock`. To share a kit with everyone rather than send it with one project, make it a package — see [Publish a Package](/docs/how-to/setup/04-publish-a-package/#make-a-kit-package). Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#check-the-project-before-you-send-it Previous: how-to/setup/05-share-a-project#drop-a-kit-you-no-longer-use Next: how-to/setup/05-share-a-project#related --- <!-- ID: how-to/setup/05-share-a-project#check-what-the-project-depends-on --> Share a Project > Check what the project depends on [guide] ```bash resonon kits list ``` ```text Kits this project depends on from outside it: Old-808 missing ask whoever sent you this project my-breaks in this project kits/my-breaks tape-drums on this machine /Users/you/.resonon/kits/tape-drums → resonon collect tape-drums This project's own kits, in kits/ — they travel, and need no entry: claps ``` | Standing | What to do | | --- | --- | | in this project | Nothing: it travels. | | on this machine | `resonon collect <name>` | | missing | Get it from whoever sent you the project. | | travels anyway | Nothing, but the entry is not needed: it is a package's kit or one that ships with resonon. | Open `resonon.toml` in VSCode and each `[local]` entry shows its standing at the end of the line. Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#check-what-the-project-depends-on Previous: how-to/setup/05-share-a-project#bring-in-every-listed-kit Next: how-to/setup/05-share-a-project#drop-a-kit-you-no-longer-use --- <!-- ID: how-to/setup/05-share-a-project#drop-a-kit-you-no-longer-use --> Share a Project > Drop a kit you no longer use [guide] ```bash resonon kits remove Old-808 ``` It takes the entry out of `resonon.toml` and leaves the kit's files where they are. The quick fix on the entry in VSCode does the same. Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#drop-a-kit-you-no-longer-use Previous: how-to/setup/05-share-a-project#check-what-the-project-depends-on Next: how-to/setup/05-share-a-project#check-the-project-before-you-send-it --- <!-- ID: how-to/setup/05-share-a-project#find-the-kits-that-will-not-travel --> Share a Project > Find the kits that will not travel [guide] Play the piece. The first time it loads a kit from outside the project that the project does not list, resonon warns once: ``` Warning: Kit 'my-breaks' lives outside this project: /Users/you/.resonon/kits/my-breaks It will not be there on another machine. To bring it in: resonon collect my-breaks ``` In VSCode, the kit name is marked as you type it, with the same message on hover. The quick fix on that line offers both of the next two steps: **Copy 'my-breaks' into this project** and **List 'my-breaks' under [local] in resonon.toml**. Kits in the project, kits from a package in `resonon.toml`, and the kits that ship with resonon are never marked: they travel already. A kit name your code computes — `Kit(chosen)` — cannot be marked; list it yourself, as below. Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#find-the-kits-that-will-not-travel Next: how-to/setup/05-share-a-project#bring-a-kit-into-the-project --- <!-- ID: how-to/setup/05-share-a-project#list-a-kit-you-cannot-bring-in --> Share a Project > List a kit you cannot bring in [guide] For a kit too large to send, or one you may not give away, add its name under `[local]` in `resonon.toml`: ```toml [local] kits = [ "my-breaks", "field-recordings", ] ``` The warning stops. On a machine without the kit, the piece now stops with a message that says the project needs it, and who to ask: ``` Kit 'my-breaks' is listed under [local] in resonon.toml — this project depends on it from outside itself — but it is not on this machine. If you have it elsewhere, put it in <project>/kits; if not, ask whoever sent you this project for it. `resonon kits list` shows everything this project depends on. Searched: … ``` Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#list-a-kit-you-cannot-bring-in Previous: how-to/setup/05-share-a-project#bring-a-kit-into-the-project Next: how-to/setup/05-share-a-project#bring-in-every-listed-kit --- <!-- ID: how-to/setup/05-share-a-project#related --> Share a Project > Related [guide] - [resonon.toml](/docs/reference/setup/04-resonon-toml/#local) — the `[local]` section - [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/#search-order) — where a kit name is looked up - [CLI reference](/docs/reference/setup/01-cli/#project--package-commands) — `collect` and `kits` Page: how-to/setup/05-share-a-project URL: https://resonon.org/docs/how-to/setup/05-share-a-project/#related Previous: how-to/setup/05-share-a-project#check-the-project-before-you-send-it --- <!-- ID: how-to/setup/06-fix-install-and-project-problems --> Fix Install and Project Problems [guide] Find the message or the symptom, then work through the fix. Quoted blocks are what resonon prints. Sections: - how-to/setup/06-fix-install-and-project-problems#no-project | No project - how-to/setup/06-fix-install-and-project-problems#the-project-needs-another-resonon-version | The project needs another resonon version - how-to/setup/06-fix-install-and-project-problems#a-module-is-not-found | A module is not found - how-to/setup/06-fix-install-and-project-problems#an-installed-package-has-nothing-in-it | An installed package has nothing in it - how-to/setup/06-fix-install-and-project-problems#a-new-feature-seems-missing-after-an-upgrade | A new feature seems missing after an upgrade - how-to/setup/06-fix-install-and-project-problems#resonon-is-not-found | resonon is not found - how-to/setup/06-fix-install-and-project-problems#related | Related Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/ --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#a-module-is-not-found --> Fix Install and Project Problems > A module is not found [guide] > **Module 'drum-kits' not found. Searched:** > **…** The list names every folder that was searched, and why each one was. 1. Check the package is installed: `resonon pkg list`. In a cloned project, run `resonon install`. 2. `use` the repository name, not the kit name from its `kit.toml`. 3. A hyphen cannot be part of a name, so `use "drum-kits"` binds `drum_kits`. Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#a-module-is-not-found Previous: how-to/setup/06-fix-install-and-project-problems#the-project-needs-another-resonon-version Next: how-to/setup/06-fix-install-and-project-problems#an-installed-package-has-nothing-in-it --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#a-new-feature-seems-missing-after-an-upgrade --> Fix Install and Project Problems > A new feature seems missing after an upgrade [guide] The engine runs in the server, not in the editor. Upgrading resonon does not change a server that is already running, and VSCode stays connected to it — so a feature from the new version looks like it does nothing. 1. Stop the server (**RESONON: Stop Server**) and run a line again, so that a new one starts. 2. Reload the VSCode window (**Developer: Reload Window**), so that the extension and the language server restart too. 3. Check which resonon you run: `resonon --version` and `which resonon`. Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#a-new-feature-seems-missing-after-an-upgrade Previous: how-to/setup/06-fix-install-and-project-problems#an-installed-package-has-nothing-in-it Next: how-to/setup/06-fix-install-and-project-problems#resonon-is-not-found --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#an-installed-package-has-nothing-in-it --> Fix Install and Project Problems > An installed package has nothing in it [guide] > **Installed 'my-pkg' to …/dependencies/my-pkg (warning: no lib.non or kits/ found)** The repository is not laid out as a package. Code must be at `src/lib.non`; kits must be folders under `kits/`. See [Publish a Package](/docs/how-to/setup/04-publish-a-package/). Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#an-installed-package-has-nothing-in-it Previous: how-to/setup/06-fix-install-and-project-problems#a-module-is-not-found Next: how-to/setup/06-fix-install-and-project-problems#a-new-feature-seems-missing-after-an-upgrade --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#no-project --> Fix Install and Project Problems > No project [guide] > **No resonon.toml in /Users/you/scratch or above it.** > **A piece belongs to a project — start one with `resonon new <name>`, or `resonon init` in the > folder it should live in.** Resonon finds a piece's project by walking up from the file — not from the folder you are in — to a `resonon.toml`. The editor, `resonon run` and the project commands all need one. 1. Save the file inside a project folder, or 2. make one around it: `resonon init` in the folder it should live in, or `resonon new <name>` for a new folder. Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#no-project Next: how-to/setup/06-fix-install-and-project-problems#the-project-needs-another-resonon-version --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#related --> Fix Install and Project Problems > Related [guide] - [resonon.toml](/docs/reference/setup/04-resonon-toml/) — the version pin - [CLI reference](/docs/reference/setup/01-cli/#resonon-version) — `resonon version` - [Fix Connection Problems](/docs/how-to/running/05-fix-connection-problems/) — when VSCode does not reach the server Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#related Previous: how-to/setup/06-fix-install-and-project-problems#resonon-is-not-found --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#resonon-is-not-found --> Fix Install and Project Problems > resonon is not found [guide] 1. Check the install: `resonon --version`. 2. The installer links `resonon` into `/usr/local/bin`. Check that `/usr/local/bin` is on your `PATH`. 3. For a build from source, see [Build Resonon from Source](/docs/how-to/setup/01-build-from-source/). Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#resonon-is-not-found Previous: how-to/setup/06-fix-install-and-project-problems#a-new-feature-seems-missing-after-an-upgrade Next: how-to/setup/06-fix-install-and-project-problems#related --- <!-- ID: how-to/setup/06-fix-install-and-project-problems#the-project-needs-another-resonon-version --> Fix Install and Project Problems > The project needs another resonon version [guide] > **Error: this project needs Resonon 0.12.0, but 0.11.0 is running.** The project's `resonon.toml` pins a newer minor version than the one running. The line after the error says which fix applies: 1. **`Install with: resonon version install 0.12.0`** — that version is not installed. Run the command. 2. **``Resonon 0.12.1 is installed: run the project through the `resonon` launcher, which picks it.``** — it is installed, but the binary was started directly, by its path, so the launcher did not choose it. Run `resonon`. 3. A project pinned to an *older* version runs, with a warning. In a live session the message says `this server runs …`: the server runs one version. Restart the server from that project — the editor offers it. Page: how-to/setup/06-fix-install-and-project-problems URL: https://resonon.org/docs/how-to/setup/06-fix-install-and-project-problems/#the-project-needs-another-resonon-version Previous: how-to/setup/06-fix-install-and-project-problems#no-project Next: how-to/setup/06-fix-install-and-project-problems#a-module-is-not-found --- <!-- ID: how-to/setup/07-use-the-preferences-window --> Use the Preferences Window [guide] In the app, the Preferences window edits `~/.resonon/preferences.toml`, the file that [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) describes. Each change is in force at once, as in Live: you do not run `reload_preferences()` and you do not restart. Sections: - how-to/setup/07-use-the-preferences-window#open-the-window | Open the window - how-to/setup/07-use-the-preferences-window#choose-the-audio-device | Choose the audio device - how-to/setup/07-use-the-preferences-window#add-a-kit-or-plugin-folder | Add a kit or plugin folder - how-to/setup/07-use-the-preferences-window#set-up-the-editor | Set up the editor - how-to/setup/07-use-the-preferences-window#when-the-file-does-not-parse | When the file does not parse - how-to/setup/07-use-the-preferences-window#related | Related Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/ --- <!-- ID: how-to/setup/07-use-the-preferences-window#add-a-kit-or-plugin-folder --> Use the Preferences Window > Add a kit or plugin folder [guide] On the **Folders** tab, **Kit Folders** and **Plug-In Folders** list the folders you added, as the file has them. 1. Click **Add Folder…** under a list. 2. Select the folder in the panel that opens. To take a folder out, click it in the list, then click **Remove**. A folder that is not there shows **MISSING**. Resonon searches a new kit folder at once and scans a new plugin folder at once. The system plugin folders, `CLAP_PATH` and `VST3_PATH` are always scanned. To scan all plugin folders again, for example after you install a plugin, click **Rescan Plugins**. The button is disabled until the scan is finished. Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#add-a-kit-or-plugin-folder Previous: how-to/setup/07-use-the-preferences-window#choose-the-audio-device Next: how-to/setup/07-use-the-preferences-window#set-up-the-editor --- <!-- ID: how-to/setup/07-use-the-preferences-window#choose-the-audio-device --> Use the Preferences Window > Choose the audio device [guide] On the **Audio** tab: - **Output Device** and **Input Device** list **System Default** first, then each device that is connected. **Input Device** also lists **None**: no input at all, as Live's No Device. A track that asks for an input is then silent, and Resonon tells you why. - **Sample Rate** and **Buffer Size** list the values the devices can run. - **Input Latency** and **Output Latency** show the running interface's measured delays in milliseconds. **Not available** means the engine has no measurement yet. When input is disabled, **Input Latency** and **Overall Latency** show **No input**. - **Overall Latency** shows the total recording compensation: input and output latency, plugin delay compensation and Recording Offset. It does not measure the delay you hear during playback. - **Recording Offset** moves recorded takes earlier or later, up to ±500 ms. Type a value, then press **Enter** or click outside the field. A choice reopens the interface at once. If the change cannot do all that it asks, the tab says what happened, under the controls. A device that the file names but that is not connected stays on the list, in yellow, with a warning. Nothing plays, or nothing is recorded, until you connect it. Resonon never plays on a different device instead. While a take records, the Audio tab is locked and says how many tracks record. Change the audio settings after the take. Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#choose-the-audio-device Previous: how-to/setup/07-use-the-preferences-window#open-the-window Next: how-to/setup/07-use-the-preferences-window#add-a-kit-or-plugin-folder --- <!-- ID: how-to/setup/07-use-the-preferences-window#open-the-window --> Use the Preferences Window > Open the window [guide] Select **Resonon > Preferences…**, or press **Command-,**. The window has a tab for each part of the setup in a column on the left: **Audio**, **Folders** and **Editor**. While the window is open, the main window takes no input. A click in the main window brings Preferences to the front. Audio, the transport and the code continue to run. Press **Escape** or **Command-W** to close the window. In a text field, Escape only leaves the field. The window reads the file when it opens and each time it comes to the front, so it shows an edit that you made by hand meanwhile. Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#open-the-window Next: how-to/setup/07-use-the-preferences-window#choose-the-audio-device --- <!-- ID: how-to/setup/07-use-the-preferences-window#related --> Use the Preferences Window > Related [guide] - [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/) — `resonon setup`, the file by hand and `reload_preferences()` - [Preferences](/docs/reference/setup/02-preferences/) — every key, type and default - [Fix Audio Problems](/docs/how-to/audio/21-fix-audio-problems/) — no output, crackles, sample-rate mismatches Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#related Previous: how-to/setup/07-use-the-preferences-window#when-the-file-does-not-parse --- <!-- ID: how-to/setup/07-use-the-preferences-window#set-up-the-editor --> Use the Preferences Window > Set up the editor [guide] On the **Editor** tab: - **Vim Mode** turns the Vim bindings of the code editor on and off. The open editor changes at once; its text, cursor and undo history stay. - **Vim Maps** takes one vimrc map line on each line, such as `inoremap fd <Esc>`. The maps apply when the field loses focus; Escape leaves the field and keeps the maps in force. A line that cannot be applied is marked and named under the field, and the maps in force do not change until you correct it. See [Mappings](/docs/how-to/running/15-edit-code-in-the-window/#mappings). - **Viz Resolution** is how wide `viz()` draws one cycle, in characters (8–64). Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#set-up-the-editor Previous: how-to/setup/07-use-the-preferences-window#add-a-kit-or-plugin-folder Next: how-to/setup/07-use-the-preferences-window#when-the-file-does-not-parse --- <!-- ID: how-to/setup/07-use-the-preferences-window#when-the-file-does-not-parse --> Use the Preferences Window > When the file does not parse [guide] If `preferences.toml` does not parse, the window shows the line and column of the error, and no setting can change. Click **Open preferences.toml**, correct the file and save it. The window reads it again when it comes to the front. Page: how-to/setup/07-use-the-preferences-window URL: https://resonon.org/docs/how-to/setup/07-use-the-preferences-window/#when-the-file-does-not-parse Previous: how-to/setup/07-use-the-preferences-window#set-up-the-editor Next: how-to/setup/07-use-the-preferences-window#related --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader --> Bind Audio to a Shader [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: Every audio track and the master have three live feeds you can bind to a visual with `<<`: `.rms` (the average level), `.peak`, and `.fft` (the spectrum). The feeds and their methods are in the [MeterFeed](/docs/reference/stdlib/audio/#meterfeed) and [SpectrumFeed](/docs/reference/stdlib/audio/#spectrumfeed) reference. Sections: - how-to/visuals/01-bind-audio-to-a-shader#bind-a-level | Bind a level - how-to/visuals/01-bind-audio-to-a-shader#stop-it-from-flickering | Stop it from flickering - how-to/visuals/01-bind-audio-to-a-shader#draw-the-spectrum | Draw the spectrum - how-to/visuals/01-bind-audio-to-a-shader#react-to-a-frequency-band | React to a frequency band - how-to/visuals/01-bind-audio-to-a-shader#related | Related Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/ --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader#bind-a-level --> Bind Audio to a Shader > Bind a level [guide] Declare a `float` uniform, and bind a level to it: ```resonon parse-only v.parameter("kick") << drums.rms; // one track v.parameter("level") << session.master.peak; // the whole mix ``` A level goes from `0` to `1`. `.range(lo, hi)` maps it onto what the shader expects: ```resonon parse-only v.parameter("kick") << drums.rms.range(0.2, 3.0); ``` Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/#bind-a-level Next: how-to/visuals/01-bind-audio-to-a-shader#stop-it-from-flickering --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader#draw-the-spectrum --> Bind Audio to a Shader > Draw the spectrum [guide] Bound as a whole, `.fft` arrives as a `sampler2D`: a one-row texture, lowest frequency at `x = 0`, highest at `x = 1`. Read the bin under each column: ```glsl title="shaders/analyzer.glsl" #version 300 es precision highp float; uniform sampler2D spectrum; uniform vec2 iResolution; out vec4 fragColor; void main() { vec2 uv = gl_FragCoord.xy / iResolution; float mag = texture(spectrum, vec2(uv.x, 0.5)).r; fragColor = vec4(vec3(step(uv.y, mag * 4.0)), 1.0); } ``` ```resonon use "std/instruments" { Sampler, Kit }; use "std/visuals" as gfx; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let v = gfx.load_shader("analyzer", "shaders/analyzer.glsl"); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd [hh sd hh] bd sd]; v.parameter("spectrum") << session.master.fft.smooth(120); v >> screen; PLAY; ``` `.smooth` on a spectrum glides every bin on its own, with one time or with an attack and a release (`.smooth(20, 300)`). Without it the bars flicker. Each `.fft` binding is its own texture, so different tracks can drive different samplers: ```resonon parse-only v.parameter("drumSpec") << drums.fft.smooth(80); v.parameter("bassSpec") << bass.fft.smooth(200); ``` Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/#draw-the-spectrum Previous: how-to/visuals/01-bind-audio-to-a-shader#stop-it-from-flickering Next: how-to/visuals/01-bind-audio-to-a-shader#react-to-a-frequency-band --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader#react-to-a-frequency-band --> Bind Audio to a Shader > React to a frequency band [guide] To react to "the bass" without averaging bins in GLSL, reduce a range in Hz to one `float` with `.band(lo, hi)`. The result is a level, so `.smooth` and `.range` chain on: ```glsl title="shaders/bands.glsl" #version 300 es precision highp float; uniform vec2 iResolution; uniform float bass; uniform float treble; out vec4 fragColor; void main() { vec2 uv = (gl_FragCoord.xy * 2.0 - iResolution) / min(iResolution.x, iResolution.y); float r = length(uv); float disc = smoothstep(0.6 + bass, 0.55 + bass, r); float ring = treble * smoothstep(0.02, 0.0, abs(r - 0.7)); fragColor = vec4(vec3(disc) + ring * vec3(1.0, 0.7, 0.3), 1.0); } ``` ```resonon use "std/instruments" { Sampler, Kit }; use "std/visuals" as gfx; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let v = gfx.load_shader("bands", "shaders/bands.glsl"); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd [hh sd hh] bd sd]; v.parameter("bass") << session.master.fft.band(20, 200).smooth(150).range(0, 0.4); v.parameter("treble") << session.master.fft.band(4000, 12000).smooth(80).range(0, 4); v >> screen; PLAY; ``` `.band` reads the unsmoothed spectrum, so smooth the band — `.band(…).smooth(ms)` — not the spectrum before it. Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/#react-to-a-frequency-band Previous: how-to/visuals/01-bind-audio-to-a-shader#draw-the-spectrum Next: how-to/visuals/01-bind-audio-to-a-shader#related --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader#related --> Bind Audio to a Shader > Related [guide] - [Your First Shader](/docs/tutorials/visuals/01-your-first-shader/) — a shader and its uniforms, from the start - [Shader Interface](/docs/reference/visuals/01-shader-interface/) — what each kind of value binds as - [Visuals & the Audio Engine](/docs/explanation/visuals/02-visuals-and-the-audio-engine/) — when the feeds are sampled, and what an analyzer costs Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/#related Previous: how-to/visuals/01-bind-audio-to-a-shader#react-to-a-frequency-band --- <!-- ID: how-to/visuals/01-bind-audio-to-a-shader#stop-it-from-flickering --> Bind Audio to a Shader > Stop it from flickering [guide] A raw level jumps on every transient, so a shader driven by it strobes. `.smooth(ms)` glides it; bigger is slower — about 100–200 ms feels punchy, 300–500 ms feels like a swell: ```resonon parse-only v.parameter("kick") << drums.rms.smooth(280); ``` To catch a hit at once and let it die away, give an attack and a release. `0` rises instantly: ```resonon parse-only v.parameter("kick") << drums.rms.smooth(20, 300); // up in 20 ms, down over 300 ms v.parameter("kick") << drums.rms.smooth(0, 400); // a peak follower ``` Then drive something that can move smoothly — hue, glow, a radius — rather than multiplying the whole picture's brightness by a transient. Page: how-to/visuals/01-bind-audio-to-a-shader URL: https://resonon.org/docs/how-to/visuals/01-bind-audio-to-a-shader/#stop-it-from-flickering Previous: how-to/visuals/01-bind-audio-to-a-shader#bind-a-level Next: how-to/visuals/01-bind-audio-to-a-shader#draw-the-spectrum --- <!-- ID: how-to/visuals/02-load-a-shader-from-a-file --> Load a Shader From a File [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: A shader longer than a few lines is easier to write in its own `.glsl` file, where your editor's GLSL support works on it. In VSCode, install a GLSL extension such as [Shader languages support](https://marketplace.visualstudio.com/items?itemName=slevesque.shader). Sections: - how-to/visuals/02-load-a-shader-from-a-file#load-the-file | Load the file - how-to/visuals/02-load-a-shader-from-a-file#reload-it-after-an-edit | Reload it after an edit - how-to/visuals/02-load-a-shader-from-a-file#share-glsl-between-shaders | Share GLSL between shaders - how-to/visuals/02-load-a-shader-from-a-file#related | Related Page: how-to/visuals/02-load-a-shader-from-a-file URL: https://resonon.org/docs/how-to/visuals/02-load-a-shader-from-a-file/ --- <!-- ID: how-to/visuals/02-load-a-shader-from-a-file#load-the-file --> Load a Shader From a File > Load the file [guide] ```resonon parse-only use "std/visuals" as gfx; let v = gfx.load_shader("plasma", "shaders/plasma.glsl"); v >> screen; PLAY; ``` The path is relative to the `.non` file that runs the line. The file holds the same GLSL you would put in a string: `#version 300 es`, a `precision`, and an `out vec4`. With a visuals window open, a compile error in the shader is marked in the `.glsl` file, on the line you wrote. Page: how-to/visuals/02-load-a-shader-from-a-file URL: https://resonon.org/docs/how-to/visuals/02-load-a-shader-from-a-file/#load-the-file Next: how-to/visuals/02-load-a-shader-from-a-file#reload-it-after-an-edit --- <!-- ID: how-to/visuals/02-load-a-shader-from-a-file#related --> Load a Shader From a File > Related [guide] - [load_shader](/docs/reference/stdlib/visuals/#load_shader) — the function in the reference - [Your First Shader](/docs/tutorials/visuals/01-your-first-shader/) — writing a shader, from the start Page: how-to/visuals/02-load-a-shader-from-a-file URL: https://resonon.org/docs/how-to/visuals/02-load-a-shader-from-a-file/#related Previous: how-to/visuals/02-load-a-shader-from-a-file#share-glsl-between-shaders --- <!-- ID: how-to/visuals/02-load-a-shader-from-a-file#reload-it-after-an-edit --> Load a Shader From a File > Reload it after an edit [guide] Nothing watches the file. After you save it, run the `gfx.load_shader` line again: the file is read again, and the visual named `plasma` takes the new shader, keeping its wiring and its bound uniforms. Page: how-to/visuals/02-load-a-shader-from-a-file URL: https://resonon.org/docs/how-to/visuals/02-load-a-shader-from-a-file/#reload-it-after-an-edit Previous: how-to/visuals/02-load-a-shader-from-a-file#load-the-file Next: how-to/visuals/02-load-a-shader-from-a-file#share-glsl-between-shaders --- <!-- ID: how-to/visuals/02-load-a-shader-from-a-file#share-glsl-between-shaders --> Load a Shader From a File > Share GLSL between shaders [guide] A shader's source is a string, so build it from parts. `load_file` reads a file as a string, with the same relative path: ```resonon parse-only use "std/visuals" as gfx; let lib = load_file("shaders/lib.glsl"); // #version, precision and shared functions let v = gfx.Visual("plasma", lib + load_file("shaders/plasma-main.glsl")); v >> screen; ``` A shader built with `gfx.Visual` has no file of its own, so its compile errors are marked on the `>> screen` line, and the message gives the line number within the whole string. Page: how-to/visuals/02-load-a-shader-from-a-file URL: https://resonon.org/docs/how-to/visuals/02-load-a-shader-from-a-file/#share-glsl-between-shaders Previous: how-to/visuals/02-load-a-shader-from-a-file#reload-it-after-an-edit Next: how-to/visuals/02-load-a-shader-from-a-file#related --- <!-- ID: how-to/visuals/03-build-an-operator-graph --> Build an Operator Graph [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: `std/visuals` has ready-made operators — `gfx.Noise`, `gfx.Blur`, `gfx.Displace`, `gfx.Composite` and more — that you wire into a graph instead of writing GLSL. Every operator, with its uniforms and inputs, is in the [`std/visuals` reference](/docs/reference/stdlib/visuals/). Sections: - how-to/visuals/03-build-an-operator-graph#chain-operators | Chain operators - how-to/visuals/03-build-an-operator-graph#feed-a-second-input | Feed a second input - how-to/visuals/03-build-an-operator-graph#use-one-node-in-several-places | Use one node in several places - how-to/visuals/03-build-an-operator-graph#write-a-helper-that-builds-nodes | Write a helper that builds nodes - how-to/visuals/03-build-an-operator-graph#loop-last-frame-back-in | Loop last frame back in - how-to/visuals/03-build-an-operator-graph#related | Related Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/ --- <!-- ID: how-to/visuals/03-build-an-operator-graph#chain-operators --> Build an Operator Graph > Chain operators [guide] Each constructor takes a name. Set uniforms with `<<`, and chain with `>>`, which feeds the left node into the right one's main input: ```resonon use "std/visuals" as gfx; let field = gfx.Noise("field"); field.parameter("period") << 2.0; let soft = gfx.Blur("soft"); soft.parameter("size") << 16.0; field >> soft >> screen; PLAY; ``` A uniform takes a number, a signal, a meter feed, an array of 2–4 numbers for a vector, or a table of rows, such as the keys of a ramp: ```resonon parse-only edge.parameter("strength") << Sine(8).range(0.5, 2.0); blur.parameter("size") << drums.rms.smooth(80).range(1, 40); move.parameter("scale") << #[1.5, 1.5]; ramp.parameter("keys") << #[#[0, 0.1, 0.0, 0.2, 1], #[1, 1, 1, 1, 1]]; ``` Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#chain-operators Next: how-to/visuals/03-build-an-operator-graph#feed-a-second-input --- <!-- ID: how-to/visuals/03-build-an-operator-graph#feed-a-second-input --> Build an Operator Graph > Feed a second input [guide] An operator with two inputs names its second one. Bind a node to it with `<<`: ```resonon parse-only comp.parameter("b") << other; // Composite's input B disp.parameter("by") << field; // what Displace displaces by look.parameter("table") << ramp; // Lookup's lookup table ``` Both inputs must be wired. An operator with an empty input is not drawn: putting its graph on screen is an error that names the operator and the input, and the picture on screen stays. Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#feed-a-second-input Previous: how-to/visuals/03-build-an-operator-graph#chain-operators Next: how-to/visuals/03-build-an-operator-graph#use-one-node-in-several-places --- <!-- ID: how-to/visuals/03-build-an-operator-graph#loop-last-frame-back-in --> Build an Operator Graph > Loop last frame back in [guide] To read what the graph drew in the previous frame, build it inside `gfx.feedback`. The function gets `prev`, last frame's output; wire it into an input, and return the node that is the output. The first argument is the seed: `prev` is the seed's frame until the output has drawn one of its own: ```resonon use "std/visuals" as gfx; use "std/signals" { Time }; let field = gfx.Noise("field"); field.parameter("period") << 3.0; field.parameter("tz") << Time(0.2).set_timebase(seconds(1)); let look = gfx.feedback(field, fn(prev) { let disp = gfx.Displace("trail"); disp.parameter("displace_weight_x") << 0.1; disp.parameter("displace_weight_y") << 0.1; disp.parameter("by") << prev; return field >> disp; }); look >> screen; PLAY; ``` The noise moves through its third axis, `tz`, by 0.2 each second. Each frame displaces it by the frame before, which leaves a flowing trail. The noise is also the seed, so on the first frame the noise displaces itself. The trail survives your edits. To start it again from the seed, reset the node the function returned: ```resonon continue look.reset(); ``` `examples/05_visuals/04_voronoi_feedback.non` is a whole patch built this way: a TouchDesigner feedback patch whose cells flow and warp, using fan-out and feedback together. Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#loop-last-frame-back-in Previous: how-to/visuals/03-build-an-operator-graph#write-a-helper-that-builds-nodes Next: how-to/visuals/03-build-an-operator-graph#related --- <!-- ID: how-to/visuals/03-build-an-operator-graph#related --> Build an Operator Graph > Related [guide] - [The Visual Graph](/docs/explanation/visuals/01-the-visual-graph/) — names, wiring, fan-out and feedback, and why they work this way - [Bind Audio to a Shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/) — the audio feeds you bind to uniforms Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#related Previous: how-to/visuals/03-build-an-operator-graph#loop-last-frame-back-in --- <!-- ID: how-to/visuals/03-build-an-operator-graph#use-one-node-in-several-places --> Build an Operator Graph > Use one node in several places [guide] Keep the node in a variable and wire it wherever it is needed. It is drawn once per frame, and every consumer reads that result: ```resonon use "std/visuals" as gfx; let field = gfx.Noise("field"); field.parameter("period") << 2.0; let soft = gfx.Blur("soft"); soft.parameter("size") << 12.0; let softer = gfx.Blur("softer"); softer.parameter("size") << 48.0; let comp = gfx.Composite("comp"); comp.parameter("operand") << gfx.Operand.subtract; // A - B field >> soft >> comp; // A comp.parameter("b") << (field >> softer); // B comp >> screen; PLAY; ``` Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#use-one-node-in-several-places Previous: how-to/visuals/03-build-an-operator-graph#feed-a-second-input Next: how-to/visuals/03-build-an-operator-graph#write-a-helper-that-builds-nodes --- <!-- ID: how-to/visuals/03-build-an-operator-graph#write-a-helper-that-builds-nodes --> Build an Operator Graph > Write a helper that builds nodes [guide] The name is the operator: the same name gives back the same node. A helper that builds its nodes with fixed names hands every caller the same ones, so take the name as an argument: ```resonon use "std/visuals" as gfx; fn glow(name, src) { let b = gfx.Blur(name); b.parameter("size") << 24.0; return src >> b; } glow("halo", gfx.Noise("field")) >> screen; PLAY; ``` Page: how-to/visuals/03-build-an-operator-graph URL: https://resonon.org/docs/how-to/visuals/03-build-an-operator-graph/#write-a-helper-that-builds-nodes Previous: how-to/visuals/03-build-an-operator-graph#use-one-node-in-several-places Next: how-to/visuals/03-build-an-operator-graph#loop-last-frame-back-in --- <!-- ID: how-to/visuals/04-give-each-section-its-own-visuals --> Give Each Section Its Own Visuals [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: A section has a visual lane, `section[screen]`, beside its track lanes. A section with no screen write shows black. [The Visual Graph](/docs/explanation/visuals/01-the-visual-graph/) explains what a visual is. Sections: - how-to/visuals/04-give-each-section-its-own-visuals#write-a-visual-to-each-section | Write a visual to each section - how-to/visuals/04-give-each-section-its-own-visuals#punch-a-visual-over-part-of-the-song | Punch a visual over part of the song - how-to/visuals/04-give-each-section-its-own-visuals#check-which-visual-plays-when | Check which visual plays when - how-to/visuals/04-give-each-section-its-own-visuals#related | Related Page: how-to/visuals/04-give-each-section-its-own-visuals URL: https://resonon.org/docs/how-to/visuals/04-give-each-section-its-own-visuals/ --- <!-- ID: how-to/visuals/04-give-each-section-its-own-visuals#check-which-visual-plays-when --> Give Each Section Its Own Visuals > Check which visual plays when [guide] ```resonon continue show(song); ``` ```text section — 16 cycles screen layers: base, hits 0..8 field (Noise) base 8..14 haze (Blur) base 14..16 edges (Edge) hits ``` Page: how-to/visuals/04-give-each-section-its-own-visuals URL: https://resonon.org/docs/how-to/visuals/04-give-each-section-its-own-visuals/#check-which-visual-plays-when Previous: how-to/visuals/04-give-each-section-its-own-visuals#punch-a-visual-over-part-of-the-song Next: how-to/visuals/04-give-each-section-its-own-visuals#related --- <!-- ID: how-to/visuals/04-give-each-section-its-own-visuals#punch-a-visual-over-part-of-the-song --> Give Each Section Its Own Visuals > Punch a visual over part of the song [guide] Write to a position on the song's screen lane, on a layer of its own: ```resonon continue song[screen].layer("hits").at(14, 2) << gfx.Edge("edges"); ``` Page: how-to/visuals/04-give-each-section-its-own-visuals URL: https://resonon.org/docs/how-to/visuals/04-give-each-section-its-own-visuals/#punch-a-visual-over-part-of-the-song Previous: how-to/visuals/04-give-each-section-its-own-visuals#write-a-visual-to-each-section Next: how-to/visuals/04-give-each-section-its-own-visuals#check-which-visual-plays-when --- <!-- ID: how-to/visuals/04-give-each-section-its-own-visuals#related --> Give Each Section Its Own Visuals > Related [guide] - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — sections and songs - [Add Fills to a Song](/docs/how-to/audio/18-add-fills-to-a-song/) — positions and layers - [Visuals](/docs/reference/stdlib/visuals/) — every visual operator Page: how-to/visuals/04-give-each-section-its-own-visuals URL: https://resonon.org/docs/how-to/visuals/04-give-each-section-its-own-visuals/#related Previous: how-to/visuals/04-give-each-section-its-own-visuals#check-which-visual-plays-when --- <!-- ID: how-to/visuals/04-give-each-section-its-own-visuals#write-a-visual-to-each-section --> Give Each Section Its Own Visuals > Write a visual to each section [guide] ```resonon use "std/visuals" as gfx; let verse = section(8); verse[screen] << gfx.Noise("field"); let chorus = verse.clone(); chorus[screen] << (gfx.Noise("grain") >> gfx.Blur("haze")); let song = arrange(#[verse, chorus]); ``` Open the window with `screen.show()` before `song.play()`. Playing the song builds every section's visuals up front, so a cut between sections is instant and lands on its frame. An operator with the same name in two sections is one operator: a feedback trail carries across the cut. If any section's shader fails to compile, the song's visuals don't take — the picture already on screen stays, and the error is shown. Page: how-to/visuals/04-give-each-section-its-own-visuals URL: https://resonon.org/docs/how-to/visuals/04-give-each-section-its-own-visuals/#write-a-visual-to-each-section Next: how-to/visuals/04-give-each-section-its-own-visuals#punch-a-visual-over-part-of-the-song --- <!-- ID: how-to/visuals/05-show-and-move-the-visuals-window --> Show and Move the Visuals Window [guide] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: Use a live server on macOS with a routed visual. The native window opens on the machine running the server, so use that machine's display controls. Sections: - how-to/visuals/05-show-and-move-the-visuals-window#route-a-visual-and-open-the-window | Route a visual and open the window - how-to/visuals/05-show-and-move-the-visuals-window#move-and-resize-it | Move and resize it - how-to/visuals/05-show-and-move-the-visuals-window#close-and-reopen-it | Close and reopen it Page: how-to/visuals/05-show-and-move-the-visuals-window URL: https://resonon.org/docs/how-to/visuals/05-show-and-move-the-visuals-window/ --- <!-- ID: how-to/visuals/05-show-and-move-the-visuals-window#close-and-reopen-it --> Show and Move the Visuals Window > Close and reopen it [guide] Close the window with its normal close button. To display the routed graph again, evaluate `screen.show()` or use **RESONON: Open Visuals**. For output without a live window, use [Render Visuals to Video](/docs/how-to/running/04-render-visuals-to-frames/). [Your First Shader](/docs/tutorials/visuals/01-your-first-shader/) builds a visual from source; [Screen](/docs/reference/stdlib/visuals/#screen) lists the presentation methods. Page: how-to/visuals/05-show-and-move-the-visuals-window URL: https://resonon.org/docs/how-to/visuals/05-show-and-move-the-visuals-window/#close-and-reopen-it Previous: how-to/visuals/05-show-and-move-the-visuals-window#move-and-resize-it --- <!-- ID: how-to/visuals/05-show-and-move-the-visuals-window#move-and-resize-it --> Show and Move the Visuals Window > Move and resize it [guide] Drag the window's title bar to the target display. Drag an edge or corner to resize it. Use the macOS green window button, or `Ctrl+Cmd+F`, to enter native fullscreen; use the shortcut again to leave it. There is no Resonon window-position API. Window size scales the presented picture while preserving its aspect ratio, with black bars where needed. Set the composition size independently of the window: ```resonon parse-only screen.resolution(1280, 800); ``` The default is 1920 × 1080. Width and height must be positive integers, and the dimensions multiplied by supersampling must fit the GPU's texture limit. Every operator uses this size; `screen.snap` and `render(screen)` export it too. Changing size clears feedback trails. The window draws one sample per pixel. To change supersampling quality, evaluate `screen.set_quality(2)` and check GPU load and playback; higher quality increases rendering work. Page: how-to/visuals/05-show-and-move-the-visuals-window URL: https://resonon.org/docs/how-to/visuals/05-show-and-move-the-visuals-window/#move-and-resize-it Previous: how-to/visuals/05-show-and-move-the-visuals-window#route-a-visual-and-open-the-window Next: how-to/visuals/05-show-and-move-the-visuals-window#close-and-reopen-it --- <!-- ID: how-to/visuals/05-show-and-move-the-visuals-window#route-a-visual-and-open-the-window --> Show and Move the Visuals Window > Route a visual and open the window [guide] ```resonon parse-only use "std/visuals" as gfx; let picture = gfx.Noise("background"); picture >> screen; screen.show(); PLAY; ``` Evaluate this in the live session. Alternatively, run **RESONON: Open Visuals** in VSCode after routing the visual. Calling `show()` again while the window is open does nothing. Page: how-to/visuals/05-show-and-move-the-visuals-window URL: https://resonon.org/docs/how-to/visuals/05-show-and-move-the-visuals-window/#route-a-visual-and-open-the-window Next: how-to/visuals/05-show-and-move-the-visuals-window#move-and-resize-it --- <!-- ID: hz_to_periods --> hz_to_periods [function] fn hz_to_periods(frequency: Number) -> Number Converts a frequency in Hertz to periods per cycle at the current tempo. The result is a plain number: a later tempo change does not update it. For a signal that runs in Hz at any tempo, use `.set_timebase(seconds(1))`. Parameters: frequency: Number — frequency in Hz (positive) Returns: Number — the equivalent rate in periods per cycle at the current tempo Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#hz_to_periods --- <!-- ID: index --> RESONON [reference] Resonon ships with its own audio and MIDI engine. It loads VST3 and CLAP plugins and routes and modulates anything. A project and package system shares kits, patches and whole pieces, and a native-extension interface calls into Rust when you need to go deeper. ```resonon use "std/instruments" { Sampler, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_midi_track("bass"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd _ sd [_ bd]]; let bass = session.midi_track("bass"); bass >> MidiOutput("synth"); bass << [C2 _ [E2 G2] _]; PLAY; ``` Selected in VSCode and evaluated, it plays, and you change it while it does. As a project's `src/main.non`, with `render(8);` in place of `PLAY;`, `resonon run` bounces it to a WAV file — the drums, since a MIDI track's notes go to a synth, not into the file. [Two ways to run a piece](/docs/explanation/running/01-two-ways-to-run-a-piece/) says which is for what. Sections: - index#the-manual | The manual Page: index URL: https://resonon.org/docs/ --- <!-- ID: index#the-manual --> RESONON > The manual [reference] Start with [Getting Started](/docs/tutorials/getting-started/01-installation/), then follow the [numbered learning path](/docs/tutorials/getting-started/05-arrange-a-song/#learning-path-after-getting-started). Each tutorial includes a starting-state check so an earlier exercise does not keep playing underneath it. <CardGrid> <HomeCard title="Tutorials" href="/docs/tutorials/getting-started/01-installation/" icon="graduation-cap" description="Learn by doing. Start with Getting Started: install, make a sound, build a beat, save a project and arrange a short song. Then follow the learning path through live coding, language, patterns, harmony, mixing and modulation. Choose MIDI, DSP or visuals after that." /> <HomeCard title="How-to guides" href="/docs/how-to/audio/01-play-samples/" icon="list-checks" description="Get one job done. Each guide is one task, grouped by topic: setup, running and rendering, patterns, audio, MIDI, DSP and visuals." /> <HomeCard title="Reference" href="/docs/reference/stdlib/" icon="book-open" description="Look it up: every function and method of the standard library, the language, the mini-notation, the CLI and every setting." /> <HomeCard title="Explanation" href="/docs/explanation/running/01-two-ways-to-run-a-piece/" icon="lightbulb" description="Understand why: the two ways to run a piece, how patterns and cycles work, how the audio graph is built, and why resonon behaves as it does." /> </CardGrid> Page: index URL: https://resonon.org/docs/#the-manual --- <!-- ID: interval --> interval [function] fn interval(note: Note, name: String) -> Note Returns a single Note at the given interval above the input note. Parameters: note: Note — starting note (e.g. C4, or a MIDI number such as 60) name: String — interval name: "m2", "M2", "m3", "M3", "P4", "tritone" ("TT"), "P5", "m6", "M6", "m7", "M7", "P8" ("oct") Returns: Note — the note that interval above `note` Examples: `interval(C4, "P5")` returns G4 Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#interval --- <!-- ID: is_playing --> is_playing [function] fn is_playing() -> Boolean Whether the transport is playing. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#is_playing --- <!-- ID: kit/CR-78 --> kit/CR-78 [kit] One-shot kit; samples: bd, rs, sd, cp, hh, cb, ma, cy, me, tb, gu, hb, lb, lc, cl Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: kit/TR-808 --> kit/TR-808 [kit] One-shot kit; samples: bd, rs, sd, cp, ch, oh, cy, lt, mt, ht, lc, mc, hc, cb, cl, ma Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: kit/TR-909 --> kit/TR-909 [kit] One-shot kit; samples: bd, rs, sd, cp, ch, oh, cy, lt, ht, rd, bd2, cp2, ch2, oh2 Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: kit/analysis --> kit/analysis [kit] One-shot kit; samples: impulse, silence, dc_offset Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: kit/keys --> kit/keys [kit] Melodic kit; samples: sound1 (default), sound2 Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: length --> length [function] fn length(array: Array<Any>) -> Number Returns the number of elements in an array. Parameters: array: Array — the array to measure Returns: Number — the element count Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#length-1 --- <!-- ID: load_file --> load_file [function] fn load_file(path: String) -> String Reads a text file and returns its contents as a String. The path is resolved relative to the directory of the .non file being run (falling back to the working directory). Useful for keeping GLSL shaders in external files: `gfx.Visual(load_file("shaders/plasma.glsl"))`. Parameters: path: String — file path, relative to the current .non file Returns: String — the file contents (UTF-8) Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#load_file --- <!-- ID: load_scala --> load_scala [function] fn load_scala(name: String) -> Scale Load a Scala (.scl) tuning file and return a Scale value. Searches: relative to source file, the project's scales/, ~/.resonon/scales/, bundled scales. The .scl extension is optional. Parameters: name: String — Scala file name or path (`.scl` extension optional) Returns: Scale — the scale loaded from the tuning file Examples: `load_scala("maqam/rast")`, `load_scala("my_scale.scl")` Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#load_scala --- <!-- ID: load_shader --> load_shader [function] fn load_shader(name: String, path: String) -> Visual Loads a fragment shader from an external .glsl file and compiles it. The path is resolved relative to the .non file being run, so existing shader tooling (highlighting, linting) can edit the .glsl directly. The file is read when this call runs, so re-run the line that loads it to pick up an edit: the operator hot-swaps, keeping its wiring and bindings. A compile error is reported in that .glsl, on the line you wrote it on. Parameters: name: String — the operator's name; its identity on screen path: String — shader file path, relative to the current .non file Returns: Visual — a compiled visual, bindable with `<<` and routable with `>>` Examples: `let v = load_shader("plasma", "shaders/plasma.glsl");` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#load_shader --- <!-- ID: map --> map [function] fn map(array: Array<Any>, func: Function) -> Array<Any> Transforms each element of an array using a function. Parameters: array: Array — the array to transform func: Function — takes one element, returns the transformed value Returns: Array — a new array of transformed elements Examples: `map([1, 2, 3], fn(x) { x * 2; })` returns `[2, 4, 6]` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#map-1 --- <!-- ID: markov --> markov [function] fn markov(num_states: Number, transitions: Array<Array<Number>>, initial: Number) -> Pattern Creates a Markov chain pattern with cycle-seeded transitions. Parameters: num_states: Number — number of states (positive integer) transitions: Array — transition matrix (array of rows, each summing to 1) initial: Number — initial state index (0-based) Returns: Pattern — a pattern emitting the chain's state, advanced once per cycle Module: std/generative Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/#markov --- <!-- ID: midi_clock_report --> midi_clock_report [function] fn midi_clock_report() -> NUL Print MIDI clock status: source, BPM, transport state, and PLL diagnostics. Returns: NUL — nothing; prints the status Examples: `midi_clock_report()` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_clock_report --- <!-- ID: midi_clock_send --> midi_clock_send [function] fn midi_clock_send() -> Boolean Whether outgoing MIDI clock is enabled. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_clock_send --- <!-- ID: midi_clock_source --> midi_clock_source [function] fn midi_clock_source() -> String? The followed input alias, or NUL for the internal clock. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_clock_source --- <!-- ID: midi_connected --> midi_connected [function] fn midi_connected() -> Dict<String, String> Checks the current MIDI connection status. Returns: Dict — `{alias: port_name}` for every connected output port; empty when none is connected Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_connected --- <!-- ID: midi_disconnect --> midi_disconnect [function] fn midi_disconnect(alias: String) -> NUL Disconnects a MIDI output port. Tracks routed to it keep their output, and are heard again once `reload_preferences()` reconnects it. Parameters: alias: String — output port alias, as a `[[midi.outputs]]` entry declares it Returns: NUL — nothing Examples: `midi_disconnect("synth")` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_disconnect --- <!-- ID: midi_export --> midi_export [function] fn midi_export(source: Pattern | Timeline | MidiTrack | Array<MidiTrack>, cycles: Number, path: String? = NUL) -> String Exports a pattern, timeline, MIDI track or array of MIDI tracks to a Standard MIDI File (.mid). Writes notes (pitch, velocity, channel, length), CC lanes, pitch bend and MPE setup (for `.set_tuning()` and `.set_mpe()` tracks), tempo and track names — not program changes or SysEx. A pattern or timeline is written as a single-track file (type 0); tracks as a multi-track file (type 1) with a tempo track first. The resolution is 480 ticks per quarter note. A cycle is the session's beats per cycle (`set_bpm`), so the file has the session's tempo, and its bar is one cycle: 4 beats is 4/4, 3 is 3/4, 3.5 is 7/8. A beats per cycle that no time signature can show (3.3) gets no time signature, so a DAW shows 4/4 bars, but the timing stays correct. Every note is at least one tick long. Output path: `<project>/renders/{name}_{datetime}/export.mid` (a single track is named after the track), or a custom path (relative to the project) Parameters: source: Pattern | Timeline | MidiTrack | Array — what to export; an array holds MidiTracks cycles: Number — number of cycles to export (>= 1) path: String? — output path Returns: String — the path of the written MIDI file Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#midi_export --- <!-- ID: midi_input_disconnect --> midi_input_disconnect [function] fn midi_input_disconnect(alias: String) -> NUL Disconnects a MIDI input port by alias. Parameters: alias: String — input port alias, as a `[[midi.inputs]]` entry declares it Returns: NUL — nothing Examples: `midi_input_disconnect("kb")` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_input_disconnect --- <!-- ID: midi_input_events --> midi_input_events [function] fn midi_input_events(limit: Number = 100, port: String? = NUL) -> Array<Dict<String | Number, Any>> Recent input messages, oldest first, from connected input ports. Reads do not consume messages or wait. At most 2000 messages are retained; the input service publishes within 100 ms. Each entry has port (alias), message (raw MIDI bytes), channel (1-16, or NUL for system messages), and age_ms since hardware receipt. Messages contain up to three bytes; complete SysEx payloads are not retained. Parameters: limit: Number — maximum messages, a whole number from 0 to 2000 (default 100) port: String? — exact input alias filter, or NUL for all inputs Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_input_events --- <!-- ID: midi_input_ports --> midi_input_ports [function] fn midi_input_ports() -> Array<String> Lists all available MIDI input ports. Returns: Array — the available input port names as Strings Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_input_ports --- <!-- ID: midi_latency --> midi_latency [function] fn midi_latency() -> MidiLatency The outgoing MIDI alignment mode. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_latency --- <!-- ID: midi_latency_report --> midi_latency_report [function] fn midi_latency_report() -> NUL Print the MIDI output alignment report. Shows where the automatic offset comes from — audio buffer, device latency, plugin delay compensation — and what each port ends up with after its trims. Returns: NUL — nothing; prints the report Examples: `midi_latency_report()` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_latency_report --- <!-- ID: midi_output_ports --> midi_output_ports [function] fn midi_output_ports() -> Array<String> Lists all available MIDI output ports. Returns: Array — the available output port names as Strings Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_output_ports --- <!-- ID: midi_port_clock --> midi_port_clock [function] fn midi_port_clock(alias: String) -> Boolean Returns whether a MIDI output port is opted in to receiving clock. Set by `send_clock` in the port's `[[midi.outputs]]` entry. Parameters: alias: String — port alias, from its `[[midi.outputs]]` entry Returns: Boolean — `true` if the port receives clock Examples: `midi_port_clock("cv")` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_port_clock --- <!-- ID: midi_port_clock_trim --> midi_port_clock_trim [function] fn midi_port_clock_trim(alias: String) -> Number Returns a MIDI output port's clock-only trim in milliseconds. Set by `clock_trim_ms` in the port's `[[midi.outputs]]` entry, and added to `midi_port_trim` for clock and transport messages only. Parameters: alias: String — port alias, from its `[[midi.outputs]]` entry Returns: Number — the current clock trim in milliseconds Examples: `midi_port_clock_trim("cv")` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_port_clock_trim --- <!-- ID: midi_port_trim --> midi_port_trim [function] fn midi_port_trim(alias: String) -> Number Returns a MIDI output port's timing trim in milliseconds. Set by `trim_ms` in the port's `[[midi.outputs]]` entry, and applied to notes and clock alike, on top of the automatic alignment. Parameters: alias: String — port alias, from its `[[midi.outputs]]` entry Returns: Number — the current trim in milliseconds Examples: `midi_port_trim("cv")` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_port_trim --- <!-- ID: midi_routing_report --> midi_routing_report [function] fn midi_routing_report() -> NUL Displays the current MIDI routing: connected output/input ports and active slots. Returns: NUL — nothing; prints the routing Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_routing_report --- <!-- ID: midi_trace --> midi_trace [function] fn midi_trace() -> Boolean Whether MIDI timing trace recording is enabled. Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_trace --- <!-- ID: midi_trace_report --> midi_trace_report [function] fn midi_trace_report() -> NUL Print the MIDI timing trace: clock tick spacing, note dispatch, phase errors. Prints and clears what has been captured so far; recording continues. A bench instrument, off by default: turn it on with `set_midi_trace(true)` for a measurement. Report while the transport still rolls: STOP drains the trace to stderr. Returns: NUL — nothing; prints the trace Examples: `midi_trace_report()` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#midi_trace_report --- <!-- ID: mixer_hide --> mixer_hide [function] fn mixer_hide() -> NUL Collapses the Mixer panel in the main window. The session continues to run. Returns: NUL — no value Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mixer_hide --- <!-- ID: mixer_show --> mixer_show [function] fn mixer_show() -> NUL Opens the main window with its Mixer panel expanded. Requires a running session server with the native GUI runtime. Returns: NUL — no value Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#mixer_show --- <!-- ID: ms --> ms [function] fn ms(n: Number) -> Duration A duration in milliseconds. Tempo never changes it. Parameters: n: Number — how many milliseconds (positive) Returns: Duration — `n` milliseconds Examples: `Saw(1).set_timebase(ms(250))` — one ramp every 250 ms Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#ms --- <!-- ID: noise --> noise [dsp-builtin] noise() -> Number White noise generator. Returns: random value in [-1.0, 1.0], new sample each tick Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#noise --- <!-- ID: note --> note [function] fn note(pitch: Note | Number, start: Number, length: Number, velocity: Number? = NUL, muted: Boolean = false) -> ClipNote Makes a MIDI clip note. Times round to the nearest beat-grid tick. Parameters: pitch: Note | Number — whole MIDI pitch from 0 to 127 start: Number — non-negative position in beats length: Number — positive length in beats velocity: Number? — whole velocity from 1 to 127, or NUL for the track default muted: Boolean — keep the note without playing it Returns: ClipNote — the authored note Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#note-2 --- <!-- ID: note_value --> note_value [function] fn note_value(num: Number, den: Number) -> Duration A note value: `num / den` of a whole note, which is four beats. It follows the tempo. Use `.dotted()` and `.triplet()` for dotted and triplet values. Parameters: num: Number — numerator (positive) den: Number — denominator (positive) Returns: Duration — the note value, in beats Examples: `Sine(1).set_timebase(note_value(1, 8).dotted())` — one sweep per dotted eighth Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#note_value --- <!-- ID: notes --> notes [function] fn notes(source: Pattern | Timeline | MidiTrack | Array<MidiTrack> | Section, cycles: Number, start_cycle: Number? = NUL) -> Array<Dict<String, Any>> Lists the notes a pattern, timeline, MIDI track, array of MIDI tracks or section plays, as data. Read from the same notes `midi_export` writes, so the two agree, and nothing is played or rendered to audio. Each note is a Dict: - `start`, `duration` — Number, in cycles - `start_seconds`, `duration_seconds` — Number, at the current tempo - `note`, `name` — Number and String, the pitch played (60, "C4"); an MPE track keeps a pitch between keys (60.5) - `sample` — String, a drum hit, in place of `note` and `name` ("bd") - `velocity` — Number, 1-127, with the track's default (100 unless `set_velocity` changed it) filled in - `channel` — Number, the MIDI channel 1-16; a drum hit and an audio track have none - `track` — String, the track's name, for a track or section source Notes are sorted by start, then pitch. A pattern or timeline has no track: it plays on channel 1, and its scale degrees have no key, so they are left out; use `.in_key()` first. A section lists every lane on its track, as `.play()` plays it: in the track's key, at its velocity, a drum sampler's notes as the hits of its kit. A section from `arrange` starts at cycle 0, so `start` is the position in the song. A track with a velocity signal is run over the span, from cycle 0, as `midi_export` runs it. CC and pitch bend are not listed. Print the result with `to_json()` for a tool. Parameters: source: Pattern | Timeline | MidiTrack | Array | Section — what to list; an array holds MidiTracks cycles: Number — number of cycles to list (>= 1) start_cycle: Number? — first cycle to list (optional, defaults to 0) Returns: Array — one Dict per note Examples: `print(to_json(notes([C4 E4 G4], 1)))` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#notes-1 --- <!-- ID: off_cycle --> off_cycle [function] fn off_cycle() -> NUL Clear all per-cycle callbacks registered via on_cycle(). Returns: NUL — nothing Module: std/generative (prelude) Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/#off_cycle --- <!-- ID: on_cycle --> on_cycle [function] fn on_cycle(callback: Function) -> NUL Register a per-cycle callback that runs on the interpreter thread. The callback receives the cycle number being prepared (not the current playing cycle). Multiple callbacks can be registered; they fire in registration order. Changes to the callback list (via on_cycle/off_cycle) within a callback take effect on the next cycle, not the current one. Parameters: callback: Function — takes (cycle) and is called once per cycle Returns: NUL — nothing Module: std/generative (prelude) Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/#on_cycle --- <!-- ID: onepole --> onepole [dsp-builtin] onepole(input, coeff) -> Number One-pole lowpass filter. Parameters: input — audio signal coeff — filter coefficient (0–1, higher = tracks input faster) Returns: smoothed signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#onepole --- <!-- ID: pitchbend --> pitchbend [dsp-builtin] pitchbend(channel) -> Number Read MIDI pitch bend, normalized to -1.0–1.0. Parameters: channel — MIDI channel (1–16); omit to read from any channel Returns: current pitch bend in [-1.0, 1.0] Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#pitchbend --- <!-- ID: plugin_rescan --> plugin_rescan [function] fn plugin_rescan(path: String) -> PluginList Re-opens one plugin bundle, whatever the plugin cache already says about it. `plugin_scan(force: true)` narrowed to a single bundle: the way back for a plugin skipped after a failed scan, without re-opening everything else. Errors if the bundle is missing, is not a `.clap` or `.vst3` directory, or fails to open again. Parameters: path: String — the bundle to re-open (`~` and `$VAR` are expanded) Returns: PluginList — the plugins the bundle reported (keys: name, id, vendor, format) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#plugin_rescan --- <!-- ID: plugin_scan --> plugin_scan [function] fn plugin_scan(force: Boolean = false) -> PluginList Scans CLAP and VST3 plugin directories, updates the plugin cache, and returns a PluginList with keys: name, id, vendor, format. Only bundles that changed on disk are opened, so a rescan after installing one plugin costs one bundle. Forcing re-opens everything, including bundles skipped by an earlier failure. Parameters: force: Boolean — re-open every bundle, even unchanged and previously skipped ones Returns: PluginList — the scanned plugins (keys: name, id, vendor, format) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#plugin_scan --- <!-- ID: prime_cycles --> prime_cycles [function] fn prime_cycles() -> NUL Fire cycle callbacks once, for the cycle the playhead is on, so the pattern that plays next is ready before it is needed. PLAY, RECORD and section.play() do this for you on the internal clock, as does a SEEK made while the transport is rolling. Call it by hand before external MIDI clock playback, where the incoming CLOCK_START rather than PLAY is what starts the transport. Returns: NUL — nothing Module: std/generative (prelude) Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/#prime_cycles --- <!-- ID: print --> print [function] fn print(value: Any, newline: Boolean = true) -> NUL Writes a value to the output, followed by a newline. Instances that define `__str__` are formatted through it. Parameters: value: Any — value to write newline: Boolean — append a trailing newline; pass false to suppress it Returns: NUL — nothing Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#print --- <!-- ID: project_artist --> project_artist [function] fn project_artist() -> String? The artist set for this piece, or NUL when unset. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#project_artist --- <!-- ID: project_title --> project_title [function] fn project_title() -> String? The title set for this piece, or NUL when unset. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#project_title --- <!-- ID: put --> put [function] fn put(value: Any) -> NUL Writes a value to the output with no trailing newline. Shorthand for `print(value, false)`; useful for building a line piecewise. Parameters: value: Any — value to write Returns: NUL — nothing Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#put --- <!-- ID: rand --> rand [function] fn rand(seed: Number) -> Number Deterministic random number from a seed. The same seed always returns the same value. Parameters: seed: Number — integer seed value Returns: Number — a pseudo-random value in [0.0, 1.0) Module: std/random Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/#rand --- <!-- ID: rand_true --> rand_true [function] fn rand_true() -> Number True random number, drawn from the operating system's entropy. Different each call and each run, from the first call on. Returns: Number — a random value in [0.0, 1.0) Module: std/random Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/#rand_true --- <!-- ID: range --> range [function] fn range(start_or_end: Number, end: Number? = NUL) -> Array<Number> Generates an array of sequential numbers. Parameters: start_or_end: Number — if called with one arg, this is the end (start=0); if called with two args, this is the start end: Number? — exclusive upper bound Returns: Array — sequential numbers from start to end-1 ```resonon range(3); // => #[0, 1, 2] range(2, 5); // => #[2, 3, 4] ``` Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#range --- <!-- ID: recording_offset --> recording_offset [function] fn recording_offset() -> Number Returns the recording latency residual in milliseconds. The round trip a take was recorded through is measured and corrected automatically. This is the correction on top of that measurement, for a rig whose reported latency is not quite its real one: positive says the take arrived even later and starts it further in, negative starts it later. Usually zero. A fact about the rig rather than the piece, so it is `[audio] recording_offset_ms` in `~/.resonon/preferences.toml`. Compensation moves where a take begins; it never deletes what was captured. Returns: Number — the current residual in milliseconds Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#recording_offset --- <!-- ID: reference/audio/01-levels-and-files --> Levels & Files [reference] The methods named here are in the [audio reference](/docs/reference/stdlib/audio/). Sections: - reference/audio/01-levels-and-files#volume | Volume - reference/audio/01-levels-and-files#pan | Pan - reference/audio/01-levels-and-files#audio-device | Audio device - reference/audio/01-levels-and-files#audio-files | Audio files - reference/audio/01-levels-and-files#what-a-render-contains | What a render contains - reference/audio/01-levels-and-files#preset-files | Preset files Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/ --- <!-- ID: reference/audio/01-levels-and-files#audio-device --> Levels & Files > Audio device [reference] | Fact | Value | | --- | --- | | Sample rate | The device's own, unless `sample_rate` is set in [preferences](/docs/reference/setup/02-preferences/); `48000` if the device does not say | | Buffer size | The device's own, unless `buffer_size` is set; at most 4096 frames | Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#audio-device Previous: reference/audio/01-levels-and-files#pan Next: reference/audio/01-levels-and-files#audio-files --- <!-- ID: reference/audio/01-levels-and-files#audio-files --> Levels & Files > Audio files [reference] | File | Format | | --- | --- | | A sample, a kit sound | WAV, integer or float, any bit depth, sample rate or channel count. No other format is read. | | `render` output | WAV, stereo, 48000 Hz, 24-bit integer, whatever the device's rate. Samples beyond ±1 are clipped; no dither. | | `track.save`, `clip.save` | WAV, 32-bit float, at the clip's own sample rate and channel count | A render is `cycles` cycles long, exactly: `floor(48000 / cps) × cycles` frames. It goes to a new folder. A render never writes into an earlier one's folder: one that starts in the same second as the last gets `_2` after its time, then `_3`, and so on. ```txt renders/<name>_<YYYY-MM-DD>_<HH-MM-SS>/ ├── master.wav render(n), render(session.master, n) ├── <track>.wav render(track, n), one per track rendered ├── <wav>.wav.json beside each WAV: the tempo it was bounced at ├── screen.mp4 render(screen, n) on macOS: H.264 + master AAC, 60 fps └── frames/ render(screen, n) elsewhere: frame_00000.png onwards, 60 fps ``` `<name>` is the project's `set_project_title`, else its package name, else `untitled` — lower-cased, with every character other than a letter, digit or `-` made `_`, runs of `_` made one, `_` trimmed from both ends, and cut to 50 characters. How to render is in [Render a Project](/docs/how-to/running/02-render-a-project/). Each WAV has its bounce's tempo beside it, as `master.wav.json` beside `master.wav`: `{"cps", "beats_per_cycle", "cycles"}`. A bounce plays at one tempo from start to end. `resonon analyze --spectrogram` reads it to number the cycles. Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#audio-files Previous: reference/audio/01-levels-and-files#audio-device Next: reference/audio/01-levels-and-files#what-a-render-contains --- <!-- ID: reference/audio/01-levels-and-files#pan --> Levels & Files > Pan [reference] | Fact | Value | | --- | --- | | Range | `−1` (left) to `1` (right); `0` is centre | | Law | Constant power: θ = (pan + 1)·π/4, left gain √2·cos θ, right gain √2·sin θ | | Centre | Both channels at unity, exactly | | Hard left or right | That side +3 dB, the other side silent | | A stereo track | Each channel is scaled by its gain: the pan acts as a balance | | A mono sample | Played on both channels, then panned | Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#pan Previous: reference/audio/01-levels-and-files#volume Next: reference/audio/01-levels-and-files#audio-device --- <!-- ID: reference/audio/01-levels-and-files#preset-files --> Levels & Files > Preset files [reference] `effect.save_state(path)` and `instrument.save_state(path)` write one plugin's state to a `.preset` file; `load_state(path)` reads it back. A whole session, with every plugin's state, is saved with Save Project Session instead. A `.preset` file is JSON: | Key | Value | | --- | --- | | `resonon_preset` | `1`, the format version | | `plugin_name` | The plugin's name | | `state.params` | Each parameter's value, by its path | | `state.binary_state` | The plugin's own saved state, base64, when it has one | Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#preset-files Previous: reference/audio/01-levels-and-files#what-a-render-contains --- <!-- ID: reference/audio/01-levels-and-files#volume --> Levels & Files > Volume [reference] | Fact | Value | | --- | --- | | Unit | dB. `0` is unity gain. | | Range | `−70` to `+6`. `−70` and below is silence; above `+6` is held at `+6`. | | `set_norm(0…1)` | `0` is `−70` dB, `1` is `+6` dB, linear in dB between | | A new value | Glides there over 10 ms | | From a signal | The signal's value in dB | Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#volume Next: reference/audio/01-levels-and-files#pan --- <!-- ID: reference/audio/01-levels-and-files#what-a-render-contains --> Levels & Files > What a render contains [reference] A render runs the session's audio graph offline, from cycle 0, whatever the play head is doing. It works in a [file run](/docs/reference/running/03-file-runs/) and in a live session, where live output pauses while it runs. | File | What is in it | | --- | --- | | `master.wav` | Every audio track that reaches the master: instruments, effects, faders, sends, buses, the master's effects, modulation and automation, with plugin latency compensated | | `screen.mp4` (macOS) | The routed visual at the composition size and 60 fps, with the bounced master mix as AAC audio. Both composition dimensions must be even. | | `<track>.wav` | The track's output as the mix hears it: its instrument, effects and fader, with its sidechains keyed and its latency compensated as in `master.wav`. Its buses, its sends and the master's effects are not in it. | Not in a render: | | | | --- | --- | | MIDI tracks | A WAV holds audio. [`midi_export()`](/docs/how-to/midi/08-export-midi/) writes their notes. | | A track sent to hardware outputs | Not in `master.wav`, as it is not in the master live. Its own `<track>.wav` has it. | | A track's `.set_delay()` | The round trip to outboard gear is not there to compensate, and the delay is not applied. | | Live inputs | A track's `set_input()` is silent. | | The tail | The render stops at its last cycle; a reverb or delay still sounding is cut. To keep it, render more cycles: a song plays nothing past its end, so they hold only the tail. | Each `<track>.wav` is a pass of the whole session: every other track and bus keeps playing, so a sidechain key — a track, a bus, a return, or a key that is ducked itself — reaches the track's effects as in the mix. A key is read after its track's fader, before mute and solo, so a muted track still keys. Only the track itself reaches the file. A render of `n` tracks and `session.master` takes about `n + 1` times as long as `session.master` alone. Effects are not cleared first: in a live session, a delay or reverb still sounding carries it into the render's first cycle. `rand_true()` and `choose_true()` give a new value every call, in a render too, so a render that uses them differs every time; seeded `rand()` and `choose()` do not. Page: reference/audio/01-levels-and-files URL: https://resonon.org/docs/reference/audio/01-levels-and-files/#what-a-render-contains Previous: reference/audio/01-levels-and-files#audio-files Next: reference/audio/01-levels-and-files#preset-files --- <!-- ID: reference/dsp/01-dsp-blocks --> DSP Blocks [reference] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: A `dsp` block is compiled into the audio graph and runs once per sample. The code its functions may contain is in [DSP Code](/docs/reference/dsp/03-dsp-code/); the functions and constants it can call are in the [DSP builtins reference](/docs/reference/stdlib/dsp-builtins/). | Declaration | Makes | Entry point | Instantiated with | | :-- | :-- | :-- | :-- | | `dsp effect Name { … }` | an effect | `fn process(…) -> …` | `Name("slot")`, placed with `track.set_effects(#[…])` | | `dsp instrument Name { … }` | an instrument | `fn render(note, velocity, gate) -> (l, r)` | `Name()`, placed with `track.set_instrument(…)` | | `dsp signal Name { … }` | a signal | `fn process(…) -> out` | `Name(…)`, bound with `<<` | | `dsp fn name(…) -> out { … }` | a pure function | — | called from `dsp` code | | `dsp object Name { … }` | a stateful component | — | `let x = Name();` inside `dsp` code | Sections: - reference/dsp/01-dsp-blocks#members | Members - reference/dsp/01-dsp-blocks#transport-and-midi | Transport and MIDI - reference/dsp/01-dsp-blocks#dsp-effect | dsp effect - reference/dsp/01-dsp-blocks#dsp-instrument | dsp instrument - reference/dsp/01-dsp-blocks#dsp-signal | dsp signal - reference/dsp/01-dsp-blocks#dsp-fn | dsp fn - reference/dsp/01-dsp-blocks#dsp-object | dsp object - reference/dsp/01-dsp-blocks#helper-functions | Helper functions - reference/dsp/01-dsp-blocks#imports | Imports - reference/dsp/01-dsp-blocks#doc-comments | Doc comments - reference/dsp/01-dsp-blocks#related | Related Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/ --- <!-- ID: reference/dsp/01-dsp-blocks#doc-comments --> DSP Blocks > Doc comments [reference] `///` above a `dsp` declaration, a `param` or a helper documents it for the editor: hovering an effect lists its documented params, and hovering a param or helper shows its own comment. A signal's params are its constructor's arguments, and are listed as such. ```resonon /// A gain stage with a soft ceiling. dsp effect SoftGain { /// Linear gain before the ceiling. param level: 1.0 range(0, 4); /// Bends `x` smoothly towards ±1. fn soften(x) -> y { return __native("tanh", x); } fn process(left, right) -> (out_l, out_r) { return (soften(left * level), soften(right * level)); } } ``` Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#doc-comments Previous: reference/dsp/01-dsp-blocks#imports Next: reference/dsp/01-dsp-blocks#related --- <!-- ID: reference/dsp/01-dsp-blocks#dsp-effect --> DSP Blocks > dsp effect [reference] Without `input` and `output` declarations, an effect is stereo in, stereo out: ```resonon no-check fn process(left, right) -> (out_l, out_r) ``` With declarations, `process` takes one argument per input channel, in declaration order — two for a `stereo` input, one for a `mono` one — and returns one value per output channel: | Declarations | Signature | | :-- | :-- | | `input main: stereo; input sidechain: mono; output: stereo;` | `fn process(main_l, main_r, sc) -> (out_l, out_r)` | | `input main: mono; output: mono;` | `fn process(input) -> output` | Every input after the first is fed with `effect.connect_input(name, track)`. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#dsp-effect Previous: reference/dsp/01-dsp-blocks#transport-and-midi Next: reference/dsp/01-dsp-blocks#dsp-instrument --- <!-- ID: reference/dsp/01-dsp-blocks#dsp-fn --> DSP Blocks > dsp fn [reference] ```resonon no-check dsp fn name(a, b) -> out { … } ``` A pure function: no `param`, `state` or `buffer`, and one return value. Every `dsp` block of the file can call it, wherever the `dsp fn` is written. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#dsp-fn Previous: reference/dsp/01-dsp-blocks#dsp-signal Next: reference/dsp/01-dsp-blocks#dsp-object --- <!-- ID: reference/dsp/01-dsp-blocks#dsp-instrument --> DSP Blocks > dsp instrument [reference] ```resonon no-check fn render(note, velocity, gate) -> (out_l, out_r) ``` | Argument | Value | | :-- | :-- | | `note` | MIDI note number; fractional for pitches between semitones | | `velocity` | `0.0`–`1.0` | | `gate` | `1.0` while the note is held, `0.0` after its note-off | `render` runs once per sample for every sounding voice; the voices are summed. An instrument has 16 voices. A note takes the first free voice; when none is free, the quietest voice is taken. After note-off a voice keeps running until its output stays below −120 dBFS (`1e-6`) for 64 samples, then it is free. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#dsp-instrument Previous: reference/dsp/01-dsp-blocks#dsp-effect Next: reference/dsp/01-dsp-blocks#dsp-signal --- <!-- ID: reference/dsp/01-dsp-blocks#dsp-object --> DSP Blocks > dsp object [reference] ```resonon no-check dsp object Name { state …; buffer …; fn method(…) -> out { … } } ``` Methods may have any name; there is no entry point and no `param`. Each `let x = Name();` inside a block is a separate instance with its own state. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#dsp-object Previous: reference/dsp/01-dsp-blocks#dsp-fn Next: reference/dsp/01-dsp-blocks#helper-functions --- <!-- ID: reference/dsp/01-dsp-blocks#dsp-signal --> DSP Blocks > dsp signal [reference] ```resonon no-check fn process(input_1, input_2, …) -> out ``` `process` returns one value per sample. Its arguments, if any, are inputs fed by other signals. The constructor takes the inputs first, then the params in declaration order. Any argument can be given by name instead. A number where a signal is expected is a constant signal; a signal given for a param modulates it per sample. ```resonon no-check Remap(Wobble()) // input `source` = Wobble() Remap(source: Wobble(), lo: 0.2) // by name Wobble(8.0) // no inputs: first param, speed = 8 ``` Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#dsp-signal Previous: reference/dsp/01-dsp-blocks#dsp-instrument Next: reference/dsp/01-dsp-blocks#dsp-fn --- <!-- ID: reference/dsp/01-dsp-blocks#helper-functions --> DSP Blocks > Helper functions [reference] Any `fn` in a block other than its entry point is a helper: - It is visible only in its block, and shadows a `dsp fn` of the same name. - It can read and write the block's `param`, `state`, `voice state` and `buffer` names, but sees only its own arguments — not the entry point's arguments or locals. - A block declares each helper once, and has one entry point; a second `fn process` or `fn render` is an error. Every helper, `dsp fn` and `dsp object` method is checked when it is compiled, called or not. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#helper-functions Previous: reference/dsp/01-dsp-blocks#dsp-object Next: reference/dsp/01-dsp-blocks#imports --- <!-- ID: reference/dsp/01-dsp-blocks#imports --> DSP Blocks > Imports [reference] `dsp fn` and `dsp object` are exported from a module like any other definition, unless marked `private`, and imported with a selective `use`. Only a module's `dsp` blocks can call imported DSP code; the blocks of the file being run, or of an executed selection, can call only what that file defines itself. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#imports Previous: reference/dsp/01-dsp-blocks#helper-functions Next: reference/dsp/01-dsp-blocks#doc-comments --- <!-- ID: reference/dsp/01-dsp-blocks#members --> DSP Blocks > Members [reference] | Member | effect | instrument | signal | object | | :-- | :-: | :-: | :-: | :-: | | `param name: default range(min, max) unit u smooth ms;` | ✓ | ✓ | ✓ | — | | `state name: initial;` | ✓ | ✓ | ✓ | ✓ | | `voice state name: initial;` | — | ✓ | — | — | | `buffer name(size);` | ✓ | ✓ | ✓ | ✓ | | `input name: stereo;` / `input name: mono;` | ✓ | — | — | — | | `output: stereo;` / `output: mono;` | ✓ | — | — | — | | `latency: samples;` | ✓ | ✓ | — | — | | `range: min..max` | — | — | ✓ | — | | `fn name(…) -> out { … }` | ✓ | ✓ | ✓ | ✓ | - **`param`** — a control, read by name inside the block and set from outside with `.parameter(name)`, `.set_parameter` and `<<`. `range(min, max)` is optional; it scales normalized values and bounds modulation. `unit u` is optional: the unit the value is in, which sets how `.text()`, `.parameters()` and the editor show it. `u` is one of `Hz` (`440 Hz`, `1.20 kHz`), `ms` (`35.0 ms`, `1.20 s`), `s` (`250 ms`, `1.50 s`), `dB` (`-6.0 dB`) or `%`, for a value from 0 to 1 (`0.5` shows as `50 %`). Without `unit`, the value shows as the number. `smooth ms` is optional: a value that is set glides to its new value over `ms` milliseconds instead of stepping. A bound signal is never smoothed. Without `smooth`, a set value applies at once. In an instrument, one value is shared by all voices. - **`state`** — a variable that keeps its value from one sample to the next. - **`voice state`** — a `state` of which every voice has its own copy, set back to its initial value on each note-on. In an instrument, a plain `state` currently behaves the same way. - **`buffer name(size)`** — `size` numbers, all `0` at the start. An index is truncated to a whole number and wraps modulo `size`, so `buf[size]` is `buf[0]`; a negative index reads and writes `buf[0]`. In an instrument, every voice has its own buffers, cleared on each note-on. - **`latency: samples`** — the delay the block adds, in samples, on top of what the engine computes for its graph. Default `0`. See [Declare Latency](/docs/how-to/dsp/02-declare-latency/). - **`range: min..max`** — the span of a signal's output. Default `-1..1`. It takes no `;`. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#members Next: reference/dsp/01-dsp-blocks#transport-and-midi --- <!-- ID: reference/dsp/01-dsp-blocks#related --> DSP Blocks > Related [reference] - [DSP Builtins](/docs/reference/stdlib/dsp-builtins/) — every `__native` function and constant - [Effect](/docs/reference/stdlib/audio/#effect) — the methods of a placed effect - [The Audio-Thread Contract](/docs/explanation/dsp/02-the-audio-thread-contract/) — why a block is shaped like this Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#related Previous: reference/dsp/01-dsp-blocks#doc-comments --- <!-- ID: reference/dsp/01-dsp-blocks#transport-and-midi --> DSP Blocks > Transport and MIDI [reference] The clock constants `CPS`, `BPC`, `CYCLE`, `TIME`, `CYCLES`, `POSITION`, `CYCLE_PHASE`, `BEAT_PHASE`, `CYCLE_EDGE` and `BEAT_EDGE`, and the MIDI functions `cc`, `pitchbend` and `aftertouch`, follow the session only in a `dsp signal` — and in the `dsp fn`s and object methods it calls. In an effect or an instrument, `TIME`, `CYCLES`, `POSITION` and the MIDI functions are unknown names, `CPS`, `BPC` and `CYCLE` are the fixed values `1`, `4` and `0`, and the phase and edge constants are `0`. `SR`, `INV_SR`, `PI` and `TWOPI` work everywhere. `TIME` and `CYCLES` are how far the signal has run since it started, in seconds and in cycles. A tempo change bends `CYCLES` and never jumps it, and the phase and edge constants are built on it (`CYCLE_PHASE` is `fract(CYCLES)`). Use `CYCLES` for anything that should stay on the beat, and `TIME` for anything that should keep its speed whatever the tempo. `POSITION` is the same distance counted in the signal's timebase: cycles unless `.set_timebase()` sets another unit. Use it for any length a user should be able to give in their own unit — the stdlib `Ramp` measures its `duration` with it, so `signal_ramp(0, 1, 4).set_timebase(seconds(1))` is a four-second ramp. Page: reference/dsp/01-dsp-blocks URL: https://resonon.org/docs/reference/dsp/01-dsp-blocks/#transport-and-midi Previous: reference/dsp/01-dsp-blocks#members Next: reference/dsp/01-dsp-blocks#dsp-effect --- <!-- ID: reference/dsp/02-native-extensions --> Native Extensions [reference] A native extension is a Rust library built against the `resonon-ext` crate. Writing and shipping one is covered in [Ship a Native Extension](/docs/how-to/dsp/05-ship-a-native-extension/). Sections: - reference/dsp/02-native-extensions#attribute-macros | Attribute macros - reference/dsp/02-native-extensions#resonon_extension | resonon_extension! - reference/dsp/02-native-extensions#types | Types - reference/dsp/02-native-extensions#calls-from-resonon | Calls from resonon - reference/dsp/02-native-extensions#boundary-rules | Boundary rules - reference/dsp/02-native-extensions#library-files | Library files - reference/dsp/02-native-extensions#related | Related Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/ --- <!-- ID: reference/dsp/02-native-extensions#attribute-macros --> Native Extensions > Attribute macros [reference] All come from `use resonon_ext::prelude::*;`. | Macro | On | Makes | | :-- | :-- | :-- | | `#[ext_fn]` | a function | a function resonon can call | | `#[ext_class]` | a struct | a class whose instances resonon holds as opaque handles | | `#[ext_new]` | a function returning the class | the class's constructor | | `#[ext_method(Class)]` | a function whose first parameter is `&Class` or `&mut Class` | a method; `&Class` reads, `&mut Class` writes | `ext_fn`, `ext_new` and `ext_method` take an optional `doc = "…"`, which `resonon pkg inspect` prints. Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#attribute-macros Next: reference/dsp/02-native-extensions#resonon_extension --- <!-- ID: reference/dsp/02-native-extensions#boundary-rules --> Native Extensions > Boundary rules [reference] | | Rule | | :-- | :-- | | Thread | Every call runs on the interpreter thread, never on the audio thread. The library is loaded on its first call. | | Panics | Functions generated by `ext_fn`, `ext_new` and `ext_method` catch a panic and return it as a resonon error carrying the panic message. An exported function written by hand, or in another language, must catch its own panics and return a non-zero code with an `ExtValue::Error`; a panic that unwinds across the boundary aborts the process. | | Handles | A handle is valid only in the extension that made it. Passing it to another extension is an error. | | Object types | An object is typed by the `native class` named after its `#[ext_class]` struct, declared where `__ext` was called: its methods and read-only field bodies dispatch through that class, and `type()` names it. A field body uses an ordinary `#[ext_method]` export through `__ext`, and runs on every read. An object with no such class is dropped and refused. See [Ship a native extension](/docs/how-to/dsp/05-ship-a-native-extension/#wrap-them-in-libnon). | | Locking | Each class has one lock, covering all its instances. A call into a class waits for any other call into it to finish. | | Returned values | Strings and arrays are copied across the boundary. Do not return a pointer to memory the extension keeps using. | | Allocator | The default Rust allocator. A custom `#[global_allocator]` is not supported. | | Trust | An extension is not sandboxed: it runs with the process's rights. `resonon pkg inspect` loads it. | Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#boundary-rules Previous: reference/dsp/02-native-extensions#calls-from-resonon Next: reference/dsp/02-native-extensions#library-files --- <!-- ID: reference/dsp/02-native-extensions#calls-from-resonon --> Native Extensions > Calls from resonon [reference] | Call | Does | | :-- | :-- | | `__ext(extension, function, ...args)` | calls `function` of the extension named `extension`, loading it on first use | | `reload_ext(extension)` | unloads the extension and loads its library again; fails while an object from it is alive | Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#calls-from-resonon Previous: reference/dsp/02-native-extensions#types Next: reference/dsp/02-native-extensions#boundary-rules --- <!-- ID: reference/dsp/02-native-extensions#library-files --> Native Extensions > Library files [reference] The extension named `my_ext` is looked for in the `bin/` directory of the package `my-ext` or `my_ext`: the current project if it is that package, then the packages under `./lib`, then those under `./dependencies`. In each, the platform build wins over the generic one: 1. `bin/<name>-<os>-<arch>.<ext>`, e.g. `my_ext-macos-aarch64.dylib`, written by `resonon build --dist` 2. `bin/<name>.<ext>`, e.g. `my_ext.dylib`, written by `resonon build` `<ext>` is `dylib`, `so` or `dll`. `-` in a name is read as `_`. A package's module is bound under its directory name with `-` changed to `_`: `use "my-ext";` binds `my_ext`. That name and the `name` in `resonon_extension!` are separate; the scaffold keeps them the same. Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#library-files Previous: reference/dsp/02-native-extensions#boundary-rules Next: reference/dsp/02-native-extensions#related --- <!-- ID: reference/dsp/02-native-extensions#related --> Native Extensions > Related [reference] - [resonon.toml](/docs/reference/setup/04-resonon-toml/) — the `[native]` section - [Native Extensions: Safety & Threading](/docs/explanation/dsp/04-native-extension-safety-and-threading/) — what an extension may and may not do Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#related Previous: reference/dsp/02-native-extensions#library-files --- <!-- ID: reference/dsp/02-native-extensions#resonon_extension --> Native Extensions > resonon_extension! [reference] ```rust resonon_extension! { name: "my_ext", functions: [double, stepper_new, stepper_next], classes: [Stepper] } ``` | Field | Value | | :-- | :-- | | `name` | the extension name that `__ext` dispatches on | | `functions` | every `ext_fn`, `ext_new` and `ext_method` | | `classes` | every `ext_class`; may be left out when there are none | A class missing from `classes` has no type: the handle cleanup and the class lookup the runtime calls are generated only for the classes listed there. An object of such a class is refused. Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#resonon_extension Previous: reference/dsp/02-native-extensions#attribute-macros Next: reference/dsp/02-native-extensions#types --- <!-- ID: reference/dsp/02-native-extensions#types --> Native Extensions > Types [reference] The Rust types a function or method can take and return, and the resonon value each one carries across the boundary: | Resonon value | `ExtValue` variant | Rust parameter | Rust return | | :------------ | :----------------- | :------------- | :---------- | | `42`, `3.14` | `Number(f64)` | `f64` | `f64` | | A note, `C4` | `Note(f64)` | `f64`, the fractional MIDI pitch | — (an `f64` returns a Number) | | `true`, `false` | `Boolean(bool)` | `bool` | `bool` | | `"hello"` | `String` | `&str` (borrowed, read-only) or `String` (owned) | `String` | | `#[1, 2, 3]` | `Array` | `Vec<f64>`, an array of numbers | `Vec<f64>` | | `NUL` | `Nul` | — | `()`, no return value | | `_` (rest) | `Rest` | — | — | | An `#[ext_class]` instance | `Handle(u64)` | — | — | Any other Rust type is a compile error that names the supported ones. `&str` cannot be returned: return `String` instead. Page: reference/dsp/02-native-extensions URL: https://resonon.org/docs/reference/dsp/02-native-extensions/#types Previous: reference/dsp/02-native-extensions#resonon_extension Next: reference/dsp/02-native-extensions#calls-from-resonon --- <!-- ID: reference/dsp/03-dsp-code --> DSP Code [reference] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: The code inside a `dsp` block's functions is compiled for the audio thread. It uses the language's syntax, but only the part of it listed here. What a block may declare around its functions is in [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/). A construct outside this part is a `dsp` error when the block is defined, wherever it is — in the entry point, a helper, a `dsp fn` or an object method, called or not: ```txt DSP error at /home/me/song/src/main.non:5:10: 'string' is not supported in DSP blocks ``` Sections: - reference/dsp/03-dsp-code#values | Values - reference/dsp/03-dsp-code#names | Names - reference/dsp/03-dsp-code#if--else | if / else - reference/dsp/03-dsp-code#for | for - reference/dsp/03-dsp-code#return | return - reference/dsp/03-dsp-code#operators | Operators - reference/dsp/03-dsp-code#calls | Calls - reference/dsp/03-dsp-code#not-supported | Not supported - reference/dsp/03-dsp-code#example | Example Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/ --- <!-- ID: reference/dsp/03-dsp-code#calls --> DSP Code > Calls [reference] | Call | Rule | | --- | --- | | `__native("name", …)` | A [DSP builtin](/docs/reference/stdlib/dsp-builtins/). The name is a string literal; the argument count must match. | | `helper(…)` | A `fn` of the same block. | | `name(…)` | A `dsp fn` of the file, or one imported with `use`. | | `x.method(…)` | A method of a `dsp object` instance. | Helpers, `dsp fn`s and methods are inlined where they are called, up to 16 calls deep; a function that calls itself is an error: `inlining recursion limit exceeded for helper 'f'`. Parameters are plain names, with no default values, rest parameters or types. `let x = Name();` makes an instance of a `dsp object`, with no arguments. It is written in the entry point's body, outside any `if` or `for`. `__native("cc", n, ch)`, `__native("pitchbend", ch)` and `__native("aftertouch", ch)` take whole number literals: a controller `0`–`127`, a channel `1`–`16`. The channel is optional; without it they read any channel. | Error | Cause | | --- | --- | | `bare builtin call 'sin' — use __native("sin", ...) instead` | A builtin called by its name. | | `__native first argument must be a string literal` | `__native(name, …)` with a variable name. | | `'tanh' expects 1 argument(s), got 2` | The wrong number of arguments for a builtin. | | `helper 'f' expects 2 arguments but got 1` | The wrong number of arguments for a helper. | | `'unknown function 'print'' is not supported in DSP blocks` | Any other function. | Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#calls Previous: reference/dsp/03-dsp-code#operators Next: reference/dsp/03-dsp-code#not-supported --- <!-- ID: reference/dsp/03-dsp-code#example --> DSP Code > Example [reference] ```resonon dsp fn soft(x) -> y { return __native("tanh", x); } dsp effect Crush { param steps: 16 range(2, 64); state held: 0; state count: 0; fn process(left, right) -> (out_l, out_r) { let mono = (left + right) * 0.5; let step = if steps > 1.0 { 1.0 / steps } else { 1.0 }; count = (count + 1.0) % 4.0; held = if count == 0.0 { __native("floor", mono / step) * step } else { held }; for i in range(2) { held = held * 0.999; } return (soft(held), soft(held)); } } let crush = Crush("crush"); ``` Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#example Previous: reference/dsp/03-dsp-code#not-supported --- <!-- ID: reference/dsp/03-dsp-code#for --> DSP Code > for [reference] `for i in range(N) { … }` with `N` a number literal. The loop is unrolled when the block is compiled: `N` copies of the body, `i` being `0` to `N - 1`. A non-whole `N` is truncated. Any other `for` is an error: `for loops in DSP blocks must use range(N) with a constant`. `range(n)` with a variable, `range(start, end)` and iterating anything but `range` all fail. Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#for Previous: reference/dsp/03-dsp-code#if--else Next: reference/dsp/03-dsp-code#return --- <!-- ID: reference/dsp/03-dsp-code#if--else --> DSP Code > if / else [reference] | Rule | Error when broken | | --- | --- | | Every `if` has an `else`. | `if/else in DSP blocks must have an else branch` | | Both branches give one value, or both give two. | `if/else branches must both be mono or both be stereo` | Each sample, only the branch the condition picks runs. The other branch's assignments and buffer writes do not happen, and its builtins with memory — a filter, a delay, a sample-and-hold — do not advance: they hold where they were until a sample takes their branch again. `if` is also an expression: `let g = if x > 0.0 { 1.0 } else { 0.0 };`. Its value is the last statement of the branch that ran. A branch that ends with a `let` or a `for` gives no value, and using that `if` as a value is an error. Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#if--else Previous: reference/dsp/03-dsp-code#names Next: reference/dsp/03-dsp-code#for --- <!-- ID: reference/dsp/03-dsp-code#names --> DSP Code > Names [reference] | Form | Rule | | --- | --- | | `let x = value;` | A local. It cannot be assigned again. | | `name = value;` | Only for a `state` or `voice state` name. | | `name += value;` | `+=`, `-=`, `*=`, `/=` and `%=`, for the same names. | | `buf[i]`, `buf[i] = value;`, `buf[i] += value;` | Only for a `buffer` name. | Assigning a local, a `param` or an argument is an error: `cannot assign to 'x' (only state variables can be assigned)`. Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#names Previous: reference/dsp/03-dsp-code#values Next: reference/dsp/03-dsp-code#if--else --- <!-- ID: reference/dsp/03-dsp-code#not-supported --> DSP Code > Not supported [reference] Each of these is an error, `'<construct>' is not supported in DSP blocks`: | Construct | Name in the error | | --- | --- | | `"text"`, `f"…"` | `string`, `format string` | | `NUL`, `let x;` | `nul` | | `C4`, `[C4 E4]`, `<…>`, `{…}` | `note`, `pattern`, `alternating`, `polymetric` | | `C4:maj` in a pattern | `chord` | | `#[…]`, `#{…}` | `array literal`, `dict literal` | | `match` | `match` | | `loop`, `do N`, `break`, `continue` | `loop`, `do`, `break`, `continue` | | `fn(x) { … }` | `anonymous function` | | `assert` | `assert` | | `use` | `use` | | `a.b`, `a.b = c`, a method of anything but an object instance | `property access`, `property assignment`, `method call` | | `<<`, `>>` | `output`, `route` | | `...xs`, `f(name: value)` | `spread`, `named argument` | | `PLAY`, `PAUSE`, `STOP`, `RESET`, `RECORD`, `SEEK` | `play`, `pause`, `stop`, `reset`, `record`, `seek` | Also rejected, with their own message: | Construct | Error | | --- | --- | | `let (a, b) = …;` | `tuple destructuring (let (a, b) = ...) is not supported in DSP blocks; bind elements individually (e.g. let a = t[0];)` | | `f(a)(b)` | `chained call application (f(a)(b)) is not supported in DSP blocks; bind the intermediate result to a variable first` | | `fn` or `class` inside a function | a parse error: a definition is written at the top level | Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#not-supported Previous: reference/dsp/03-dsp-code#calls Next: reference/dsp/03-dsp-code#example --- <!-- ID: reference/dsp/03-dsp-code#operators --> DSP Code > Operators [reference] | Operators | Result | | --- | --- | | `+ - * /` | Arithmetic. `/` by `0` is `0`. | | `%` | Remainder, with the sign of the left side. `%` by `0` is `0`. | | `== != < > <= >=` | `1` or `0` | | `&&`, `\|\|`, `!` | `1` or `0`, testing each side against `0`. Both sides are always evaluated. | | unary `-`, `+` | Negation, identity | Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#operators Previous: reference/dsp/03-dsp-code#return Next: reference/dsp/03-dsp-code#calls --- <!-- ID: reference/dsp/03-dsp-code#return --> DSP Code > return [reference] | Rule | Error when broken | | --- | --- | | A `return` has a value. | `return in DSP blocks must have a value` | | A `return` is the last statement of its function, or the last of an `if`/`else` branch that is. | `return must be the last statement of the function` | | Every path through the entry point ends with a `return`. | `every path through the function must end with a return` | | The entry point returns one value per output channel: `return (l, r);` for stereo, `return out;` for mono. | `process function returns 1 value(s) but 2 output(s) declared` | | A pair `(a, b)` appears only in a `return` of the entry point. A helper, `dsp fn` or method returns one value. | `tuples are only allowed in return statements` | A helper, `dsp fn` or method without a `return` gives the value of its last statement. Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#return Previous: reference/dsp/03-dsp-code#for Next: reference/dsp/03-dsp-code#operators --- <!-- ID: reference/dsp/03-dsp-code#values --> DSP Code > Values [reference] Every value is a number (a 64-bit float). `true` is `1` and `false` is `0`. A condition is true when it is not `0`. Page: reference/dsp/03-dsp-code URL: https://resonon.org/docs/reference/dsp/03-dsp-code/#values Next: reference/dsp/03-dsp-code#names --- <!-- ID: reference/language/01-values-and-types --> Values & Types [reference] Resonon is gradually typed: you never have to write a type, and an annotation you do write is a runtime contract. An untyped variable can hold any value; a typed variable checks every write. Operators on values are in [Operators](/docs/reference/language/03-operators/); collections are in [Collections & Iterators](/docs/reference/language/05-collections-and-iterators/). Why containers share and primitives copy is in [Values & Sharing](/docs/explanation/language/01-values-and-sharing/). Sections: - reference/language/01-values-and-types#comments | Comments - reference/language/01-values-and-types#docstring-template | Docstring template - reference/language/01-values-and-types#literals | Literals - reference/language/01-values-and-types#numbers | Numbers - reference/language/01-values-and-types#strings | Strings - reference/language/01-values-and-types#booleans-and-truthiness | Booleans and truthiness - reference/language/01-values-and-types#nul | NUL - reference/language/01-values-and-types#notes | Notes - reference/language/01-values-and-types#type-annotations | Type annotations - reference/language/01-values-and-types#where-a-value-is-checked | Where a value is checked - reference/language/01-values-and-types#conversions | Conversions - reference/language/01-values-and-types#collection-types | Collection types - reference/language/01-values-and-types#optional-types | Optional types - reference/language/01-values-and-types#interfaces-and-enums | Interfaces and enums - reference/language/01-values-and-types#type | type() Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/ --- <!-- ID: reference/language/01-values-and-types#booleans-and-truthiness --> Values & Types > Booleans and truthiness [reference] `if` conditions, match guards, `assert`, `&&`, `||` and `!` require an actual Boolean; any other value is a type error. Where a callback's result is tested — `.filter()`, `.find()`, `.any()`, `.all()` — only `false` and `NUL` are falsy, and everything else, including `0`, `""` and `#[]`, is truthy. ```resonon print(#[0, "", false, NUL, #[]].filter(fn(x) { return x; })); // [0, "", []] ``` Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#booleans-and-truthiness Previous: reference/language/01-values-and-types#strings Next: reference/language/01-values-and-types#nul --- <!-- ID: reference/language/01-values-and-types#collection-types --> Values & Types > Collection types [reference] `Array<T>` checks every element against `T`. `Dict<K, V>` checks every key against `K` and every value against `V`; its key type is `String`, `Number`, or `String | Number`. Collections and tuples nest: `Array<(Note, Number)>` and `Dict<String, Array<Number>>` are valid types. Bare `Array`, `Dict`, and `Iterator` mean `Array<Any>`, `Dict<String | Number, Any>`, and `Iterator<Any>`. Only these three builtin types take type arguments. `Array<Note | Number>` accepts both note literals and MIDI numbers; collection checks preserve the original elements. ```resonon let velocities: Array<Number> = #[80, 100]; let notes: Array<Note | Number> = #[C4, 64, G4]; let controls: Dict<String, Number> = #{"cutoff": 1200, "resonance": 0.3}; let steps: Iterator<Number> = velocities.iter(); assert steps.next() == 80; ``` Checks happen at annotated boundaries. An array, dict, or tuple is checked through its nested contents; an empty collection fits any element type. Shared collections can still change after a check, and crossing another annotated boundary checks their contents again. An `Iterator<T>` is checked by kind without pulling values from it; its lazy values are checked by their own annotations when they run. Parentheses group types: `((Number) -> Number)?` is an optional function, and `(Number) -> (Number | String)` is a function returning either type. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#collection-types Previous: reference/language/01-values-and-types#conversions Next: reference/language/01-values-and-types#optional-types --- <!-- ID: reference/language/01-values-and-types#comments --> Values & Types > Comments [reference] | Syntax | Kind | | ------ | ---- | | `// …` | Line comment | | `/* … */` | Block comment | | `/// …` | Doc comment for the definition below it | | `//! …` | Doc comment for the file; only at the top of the file | | `//// …` | Line comment (four or more slashes) | ```resonon //! File documentation — what this file is. // Line comment /* Block comment */ /// Doubles a number. fn double(x) { return x * 2; } print(double(4)); ``` Doc comments are shown by `show()`, editor hover, and `resonon pkg inspect`. - `///` documents the next `fn`, `let`, `class`, class method, native class field, `interface`, interface method, `enum`, enum variant or `dsp` definition. Blank lines and ordinary comments in between change nothing; consecutive `///` blocks join into one. - A `///` with nothing below it to document — above a `use`, an expression, a stored class field, inside a block, or at the end of the file — is an error. - A `//!` anywhere but the top of the file is an error. - A doc comment with an `Experimental:` line marks what it documents as experimental, with the text after it saying what may change: `show()`, editor hover and completion say so. In a file's `//!`, it marks everything the file defines. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#comments Next: reference/language/01-values-and-types#docstring-template --- <!-- ID: reference/language/01-values-and-types#conversions --> Values & Types > Conversions [reference] A class can declare how a value of another type becomes one of its values, with [`fn from`](/docs/reference/language/07-classes/#conversions). Where an annotation asks for the class and a value does not fit it, the class's `from` converts the value once, at that place. A MIDI number converts to a `Note`: 60 is C4, and a fraction is microtonal. ```resonon let n: Note = 60.5; // a quarter-tone above C4 fn up(x: Note) -> Note { return x + 12; } assert up(60) == C5; print(chord(60, "maj")); ``` - A value that fits as it is is not converted. `x: Note | Number` given `60` keeps the Number. - Nothing inside a collection converts. An `Array<Note>` given `#[60]` is a type error. `Array<Note | Number>` takes MIDI numbers as they are. - Operators do not convert, and a conversion never leads to another one. - When the `from`s of two members of a union both take a value, it is a type error that names both. - When `from` refuses a value, the error is at the place that asked for the conversion: `up: x expects a Note; the Number inf does not convert to a Note: a MIDI note number is finite`. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#conversions Previous: reference/language/01-values-and-types#where-a-value-is-checked Next: reference/language/01-values-and-types#collection-types --- <!-- ID: reference/language/01-values-and-types#docstring-template --> Values & Types > Docstring template [reference] Use a short summary, describe the arguments and result, and include a working example. Put the types in the declaration; a type written only in a comment does not guard a value. This template uses the same section headers as the standard library: ```resonon /// Transposes a note by a number of semitones, or keeps an absent note absent. /// /// Parameters: /// root: Note? — the note, or NUL for no note /// steps: Number — semitones to transpose; defaults to one octave /// Returns: /// Note? — the transposed note, or NUL when root is absent /// Examples: /// transpose_note(C4, 7) /// transpose_note(NUL) fn transpose_note(root: Note?, steps: Number = 12) -> Note? { if root == NUL { return NUL; } return root + steps; } assert transpose_note(C4, 7) == G4; assert transpose_note(NUL) == NUL; ``` Keep comment types identical to the declaration, including `?`, unions and collection element types. Use `Parameters:` for arguments, `Returns:` for the result and `Example:` or `Examples:` for examples. Visual operators also use `Uniforms:` and `Inputs:` for controls and texture inputs; these are separate from their constructor arguments. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#docstring-template Previous: reference/language/01-values-and-types#comments Next: reference/language/01-values-and-types#literals --- <!-- ID: reference/language/01-values-and-types#interfaces-and-enums --> Values & Types > Interfaces and enums [reference] An interface annotation accepts values of classes that explicitly declare `implements` for that interface. Merely defining matching methods does not implement it. For example, a script pattern says `class Arp implements Pattern`. See [Interfaces](/docs/reference/language/07-classes/#interfaces) and [Script Patterns](/docs/reference/patterns/02-script-patterns/). An enum annotation accepts only that enum's variants, rather than a String with the same spelling: ```resonon enum Articulation { short, long } fn gate(style: Articulation) -> Number { return if style == Articulation.short { 0.25 } else { 0.9 }; } assert gate(Articulation.short) == 0.25; ``` `Variant` accepts a variant of any enum. Every enum implements it without saying so, and a class cannot. A `Variant` does not fit an annotation of one enum: the editor flags a `Variant` passed where an `Articulation` is asked for, and running checks the variant itself. See [Enums](/docs/reference/language/08-enums/) for matching and live editing. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#interfaces-and-enums Previous: reference/language/01-values-and-types#optional-types Next: reference/language/01-values-and-types#type --- <!-- ID: reference/language/01-values-and-types#literals --> Values & Types > Literals [reference] | Type | Literals | | ---- | -------- | | Number | `42`, `3.14`, `.5`, `5.`, `1e-3`, `2.5e2`, `0xFF`, `0b1010`, `0xFF_FF`, `0b1010_0011` | | String | `"text"`, `f"text {expr}"` | | Boolean | `true`, `false` | | NUL | `NUL` | | Note | `C4`, `F#3`, `Bb2`, `C-1` … `G9` | | Rest | `_` | | Pattern | `[C4 E4 G4]`, `<C4 E4>`, `{C4 D4 E4}` — see [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/) | | Array | `#[1, 2, 3]` | | Dict | `#{"key": 1, 36: "kick"}` | | Tuple | `(1, "a")` | | Function | `fn(x) { return x * 2; }` | Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#literals Previous: reference/language/01-values-and-types#docstring-template Next: reference/language/01-values-and-types#numbers --- <!-- ID: reference/language/01-values-and-types#notes --> Values & Types > Notes [reference] A note literal is a letter, an optional accidental (`#` or `b`), and an octave from `-1` to `9`. Notes map to MIDI 0–127 (`C-1` to `G9`, `C4` = 60); a note outside that range is a parse error. Notes compare with Numbers by MIDI value. A name like `Cs2` is not a note; it parses as an identifier. ```resonon assert C4 == 60; assert A4 >= 69; assert Bb3 == A#3; print(C-1); // the lowest MIDI note print(G9); // the highest ``` Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#notes Previous: reference/language/01-values-and-types#nul Next: reference/language/01-values-and-types#type-annotations --- <!-- ID: reference/language/01-values-and-types#nul --> Values & Types > NUL [reference] `NUL` is the absence of a value. - `NUL == NUL` is `true`; `NUL` equals nothing else (not `0`, not `false`). - `NUL` cannot be ordered (`NUL < 1`) or used in arithmetic, except that `"text" + NUL` gives `"textNUL"`. - A function without a `return` returns `NUL`. Iterators return `NUL` once exhausted, and `dict.get(key)` returns `NUL` for a missing key. - Reading a variable that was never defined is an error, not `NUL`. - `NUL` can be stored in arrays, dicts and tuples. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#nul Previous: reference/language/01-values-and-types#booleans-and-truthiness Next: reference/language/01-values-and-types#notes --- <!-- ID: reference/language/01-values-and-types#numbers --> Values & Types > Numbers [reference] There is one `Number` type: `5` and `5.0` are the same value. Hex and binary literals accept `_` separators. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#numbers Previous: reference/language/01-values-and-types#literals Next: reference/language/01-values-and-types#strings --- <!-- ID: reference/language/01-values-and-types#optional-types --> Values & Types > Optional types [reference] `T?` is a value of type `T`, or NUL. The `?` applies to the whole type it ends: `Note | Number?` is a Note, a Number or NUL. `(Number) -> Number?` is a function that returns an optional Number. - NUL in a type is written with `?`. `Number | NUL` is an error that names the fix, `Number?`. - `Any` already includes NUL, so `Any?` is an error. `NUL?` is an error too. `-> NUL` alone stays legal. - A parameter that defaults to NUL takes NUL, so its type says so: `x: Number? = NUL`. A parameter written `x: Number = NUL` is an error. `x: Any = NUL` and `x = NUL` stay legal. ```resonon fn transpose(root: Note | Number? = NUL, steps: Number = 12) -> Note | Number? { if root == NUL { return NUL; } return root + steps; } print(transpose(C4)); // C5 print(transpose()); // NUL ``` A name in an annotation is a type where the annotation is written: - `Number`, `Boolean`, `NUL`, `Rest`, `Function` and `Any`, everywhere. - `Self`, only as the whole return type of a method: `fn clone() -> Self`. It is the type of the value the method is called on, so `#[1, 2].clone()` is an `Array<Number>` and a class's `clone()` is that class. `Self?`, `Array<Self>` and `Self` in any other annotation are errors. - The classes, interfaces and enums of the file, and the ones it imports. - The types of the prelude, such as `String`, `Note`, `Pattern`, `AudioTrack` and `Signal`. A type of a module, such as `Sampler`, needs a `use` of its module. The editor marks a name that is not a type as `unknown type`. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#optional-types Previous: reference/language/01-values-and-types#collection-types Next: reference/language/01-values-and-types#interfaces-and-enums --- <!-- ID: reference/language/01-values-and-types#strings --> Values & Types > Strings [reference] Strings are double-quoted and immutable; every string method returns a new string. The methods are in the [`String` reference](/docs/reference/stdlib/core/#string). | Escape | Character | |--------|-----------| | `\"` | Double quote | | `\\` | Backslash | | `\n` | Newline | | `\r` | Carriage return | | `\t` | Tab | An `f` prefix makes a format string: any expression inside `{…}` is evaluated and formatted as `print()` would show it. `{{` and `}}` are literal braces. String literals may appear inside the braces. ```resonon let vel = 100; let notes = #["C4", "E4", "G4"]; print(f"Dynamics: {if vel > 80 { "loud" } else { "soft" }}"); print(f"Root: {notes[0]}, count: {notes.length()}"); print(f"Literal braces: {{like this}}"); assert "Tempo: " + 120 == "Tempo: 120"; // + also concatenates ``` A string is not directly iterable: `for ch in "abc"` is an error; iterate `"abc".iter()`, which yields one-character strings. Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#strings Previous: reference/language/01-values-and-types#numbers Next: reference/language/01-values-and-types#booleans-and-truthiness --- <!-- ID: reference/language/01-values-and-types#type --> Values & Types > type() [reference] `type(value)` returns the type's name as a String; for a class instance, the class name; for an [enum](/docs/reference/language/08-enums/) variant, the enum name. ```resonon assert type(42) == "Number"; assert type("hi") == "String"; assert type(true) == "Boolean"; assert type([C4 D4]) == "Pattern"; assert type((1, 2)) == "Tuple"; print(type(#[1])); ``` Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#type Previous: reference/language/01-values-and-types#interfaces-and-enums --- <!-- ID: reference/language/01-values-and-types#type-annotations --> Values & Types > Type annotations [reference] An annotation is a contract. A value is checked against it where the value crosses it, and a value that does not fit is a type error at that place. The language server uses annotations for signatures, hover, completion and diagnostics too. The spelling rules for NUL below are checked when the code is read. | Where | Syntax | | ----- | ------ | | Parameter | `fn f(x: Number)` | | Return | `fn f() -> Number` | | Method returning its receiver's type | `fn clone() -> Self` | | Union | `Number \| String` | | Optional | `Number?` — a Number or NUL | | Function type | `(Number) -> Number` | | Collection | `Array<Note>`, `Dict<String, Number>`, `Iterator<Event>` | | Grouped type | `((Number) -> Number)?` | | Class field | `let speed: Number;` | | Tuple destructuring | `let (f, l): (Number, String) = (440, "A4");` | | Variable | `let x: Number = 1;` | ```resonon fn apply(f: (Number) -> Number, x: Number | String) -> Number { return f(x); } print(apply(fn(n) { return n * 2; }, 5)); // 10 ``` Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#type-annotations Previous: reference/language/01-values-and-types#notes Next: reference/language/01-values-and-types#where-a-value-is-checked --- <!-- ID: reference/language/01-values-and-types#where-a-value-is-checked --> Values & Types > Where a value is checked [reference] - **Arguments.** Each argument, and each default a call leaves to a parameter. A rest parameter's type is the type of each value it collects: `...notes: Note`. - **Returns.** The value a `return` gives, and NUL when the body runs to its end. - **Variables.** `let x: T` makes a typed variable: its value and every later write fit `T`, a compound write (`x += 1`) and a closure's write included. A typed parameter is a typed variable too. `let (a, b): (A, B)` types each name. A later `let x = …` without a type makes `x` untyped again. - **Fields.** Every write to a typed field. When an instance is made, each typed field that cannot be NUL must be set, by `new`. An unannotated binding adds no type contract; operations still follow their own type rules. A pattern callback checks the same annotations, on the thread that plays it. ```resonon let tempo: Number = 120; fn faster() { tempo += 5; } faster(); assert tempo == 125; let sound = C4; // no contract: the next value may have another type sound = "kick"; assert sound == "kick"; let tempo = "fast"; // a fresh unannotated let removes the previous contract assert tempo == "fast"; ``` ```resonon no-check let tempo: Number = 120; tempo = "fast"; // Type error: tempo is a Number; got the String "fast" ``` Page: reference/language/01-values-and-types URL: https://resonon.org/docs/reference/language/01-values-and-types/#where-a-value-is-checked Previous: reference/language/01-values-and-types#type-annotations Next: reference/language/01-values-and-types#conversions --- <!-- ID: reference/language/02-variables-and-scope --> Variables & Scope [reference] Why names resolve the way they do, and what that means while music is playing, is in [Names & Live Editing](/docs/explanation/language/02-names-and-live-editing/). Sections: - reference/language/02-variables-and-scope#declaring-and-assigning | Declaring and assigning - reference/language/02-variables-and-scope#destructuring | Destructuring - reference/language/02-variables-and-scope#block-scope | Block scope - reference/language/02-variables-and-scope#one-definition-per-name | One definition per name - reference/language/02-variables-and-scope#definitions-live-at-the-top-level | Definitions live at the top level - reference/language/02-variables-and-scope#name-resolution | Name resolution - reference/language/02-variables-and-scope#shadowing-the-standard-library | Shadowing the standard library Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/ --- <!-- ID: reference/language/02-variables-and-scope#block-scope --> Variables & Scope > Block scope [reference] A `let` inside `{ … }` — a block, a loop body, a function body, a match arm — is local to it and may shadow an outer name: ```resonon let x = "outer"; { let x = "inner"; assert x == "inner"; } assert x == "outer"; print(x); ``` Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#block-scope Previous: reference/language/02-variables-and-scope#destructuring Next: reference/language/02-variables-and-scope#one-definition-per-name --- <!-- ID: reference/language/02-variables-and-scope#declaring-and-assigning --> Variables & Scope > Declaring and assigning [reference] | Form | Meaning | | ---- | ------- | | `let x = value;` | Declare `x` in the current scope (or redefine it) | | `let x;` | Declare `x` with the value `NUL` | | `x = value;` | Assign to an existing `x`; any type | | `x += value;` | Compound assignment — see [Operators](/docs/reference/language/03-operators/#assignment) | | `let (a, b) = tuple;` | Destructure a tuple | | `private let x = value;` | A module-level binding not exported — see [Modules](/docs/reference/language/09-modules/#visibility) | A name can't be a keyword: `let if = 1;` is a parse error. See [Keywords](/docs/reference/language/11-keywords/). ```resonon let x = 10; x = "now a string"; // a variable takes any type let count = 1; count += 1; assert count == 2; let later; assert later == NUL; ``` Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#declaring-and-assigning Next: reference/language/02-variables-and-scope#destructuring --- <!-- ID: reference/language/02-variables-and-scope#definitions-live-at-the-top-level --> Variables & Scope > Definitions live at the top level [reference] `fn`, `class`, `enum` and `dsp` definitions are written at the top level of a file. Inside a block or a function they are an error; bind a closure with `let` instead. A definition exists from the line that defines it: a call written above its `fn` fails as undefined unless an earlier run defined it. Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#definitions-live-at-the-top-level Previous: reference/language/02-variables-and-scope#one-definition-per-name Next: reference/language/02-variables-and-scope#name-resolution --- <!-- ID: reference/language/02-variables-and-scope#destructuring --> Variables & Scope > Destructuring [reference] A destructuring `let` unpacks a tuple into names. `_` discards an element, and patterns nest. The shape must match: a non-tuple, or a tuple of another length, is a runtime error. ```resonon let (x, y) = (3, 4); let (first, _) = (10, 20); let (a, (b, c)) = (1, (2, 3)); assert x + y + first + b == 19; ``` Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#destructuring Previous: reference/language/02-variables-and-scope#declaring-and-assigning Next: reference/language/02-variables-and-scope#block-scope --- <!-- ID: reference/language/02-variables-and-scope#name-resolution --> Variables & Scope > Name resolution [reference] The session has one namespace: every top-level `let`, `fn`, `class`, `enum` and `dsp` definition, and every name a `use` binds, executed last wins. Below it is the standard library. | Where a name is used | Resolves against | | -------------------- | ---------------- | | At the top level | The session, then the standard library | | Inside a `fn` body or a class method, a name that is not a parameter or local | The session, at call time, then the standard library — never the caller's locals | | Inside a closure (`fn(…) { … }` value), a name it reads | The value, captured when the closure is created | | Inside a closure, a name it calls | The session, when the closure runs, as in a `fn` body | | Inside a pattern callback (`map`, `map_with_timing`, a class's `query`) | As in a closure: a name it reads is captured when the pattern is made, a name it calls is looked up each time the pattern computes a cycle | | Inside a module | The module's own names, then the standard library — see [Modules](/docs/reference/language/09-modules/#what-a-module-sees) | ```resonon let tempo = 120; fn beat_ms() { return 60000 / tempo; // the session's tempo, looked up at each call } fn play(tempo) { // a parameter, local to play return beat_ms(); // still reads the session's tempo } assert play(999) == 500; tempo = 150; assert beat_ms() == 400; // session lookups are live let base = 100; let get_base = fn() { return base; }; base = 999; assert get_base() == 100; // the closure captured 100 let twice = fn(x) { return double(x); }; fn double(x) { return x * 2; } assert twice(4) == 8; // a called name is looked up when the closure runs print("resolved"); ``` A closure captures only the variables it reads. A `fn` may refer to a name defined later in the file, as long as that name exists when the function is called. Assignment changes the binding a name has, whichever kind it is: after `fn f() {}`, `f = 5;` makes `f` the number 5. A name only the standard library defines can't be assigned; bind your own with `let` or `fn`. Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#name-resolution Previous: reference/language/02-variables-and-scope#definitions-live-at-the-top-level Next: reference/language/02-variables-and-scope#shadowing-the-standard-library --- <!-- ID: reference/language/02-variables-and-scope#one-definition-per-name --> Variables & Scope > One definition per name [reference] Within one piece of source — one file, or one selection you execute — a name has one definition. - A `fn`, `class`, `enum` or `dsp` definition may not repeat a name. Arity does not distinguish functions; use [default values](/docs/reference/language/06-functions/#default-values) for optional parameters. - The same holds inside a definition: one definition per method or field name in a class, per variant in an enum, and per helper `fn` in a `dsp` block. A field and a method may share a name. - A top-level `let` claims its name too: `let tempo = 120;` beside `fn tempo()` is an error in either order. - A name a `use` binds is claimed the same way, by a second `use` too: `use "std/effects" { Delay };` beside `dsp effect Delay` is an error. Rename the import with `as`. - A `let` may repeat a `let`. A `let` inside a function or block is its own. A repeated definition is reported where it is written, and nothing in that source runs: ```resonon no-check fn greet() { print("hi"); } fn greet(name) { print(f"hi {name}"); } // error: fn 'greet' repeats the fn at 1:1 ``` A *later* run may bind the name again, with any kind of binding: a `fn` replaces a `let` or an import, a `use` replaces a `fn`. The binding executed last wins, from the next line or call on. Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#one-definition-per-name Previous: reference/language/02-variables-and-scope#block-scope Next: reference/language/02-variables-and-scope#definitions-live-at-the-top-level --- <!-- ID: reference/language/02-variables-and-scope#shadowing-the-standard-library --> Variables & Scope > Shadowing the standard library [reference] Any standard-library name can be bound in the session, and from then on your code gets yours. The standard library's own functions keep resolving within the standard library, so your binding cannot break them: ```resonon fn clamp(x, lo, hi) { return x; } // your clamp, for your code assert clamp(5, 0, 1) == 5; let print = "not a function"; put("put still prints\n"); // put calls the standard library's print ``` Page: reference/language/02-variables-and-scope URL: https://resonon.org/docs/reference/language/02-variables-and-scope/#shadowing-the-standard-library Previous: reference/language/02-variables-and-scope#name-resolution --- <!-- ID: reference/language/03-operators --> Operators [reference] Resonon is strict: outside the cross-type rules in [Type compatibility](#type-compatibility), mixing types is a type error rather than a silent coercion. Sections: - reference/language/03-operators#arithmetic | Arithmetic - reference/language/03-operators#comparison | Comparison - reference/language/03-operators#logical | Logical - reference/language/03-operators#assignment | Assignment - reference/language/03-operators#output- | Output << - reference/language/03-operators#routing- | Routing >> - reference/language/03-operators#precedence | Precedence - reference/language/03-operators#type-compatibility | Type compatibility Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/ --- <!-- ID: reference/language/03-operators#arithmetic --> Operators > Arithmetic [reference] | Operator | Meaning | Example | | ----------- | ---------------------------------------------------- | ------------------- | | `+` | Add; concatenate strings; transpose a Note or Event up | `10 + 3` → `13` | | `-` | Subtract; transpose down; interval between two pitches | `10 - 3` → `7` | | `*` | Multiply; scale a pitch's frequency | `10 * 3` → `30` | | `/` | Divide; scale a pitch's frequency; ratio of two pitches | `10 / 4` → `2.5` | | `%` | Remainder | `10 % 3` → `1` | | `-` (unary) | Negate | `-10` | | `+` (unary) | Identity | `+10` | On a Note or an Event, `+` and `-` move by semitones and `*` and `/` scale the frequency (a Note is stored as MIDI, the log of frequency, so a frequency ratio is the harmonic-series operation). An Event keeps its velocity and timing. Results are unclamped until output, where they are pinned to MIDI 0–127. ```resonon assert C4 + 2 == D4; // up 2 semitones assert C4 - 12 == C3; // down an octave assert C5 - C4 == 12; // semitone interval, a Number assert C4 * 2 == C5; // double the frequency: an octave up assert C4 / 2 == C3; // half the frequency: an octave down assert C5 / C4 == 2; // frequency ratio, a Number assert "value: " + 42 == "value: 42"; print(C4 * 3 / 2); // a just perfect fifth above C4 ``` Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#arithmetic Next: reference/language/03-operators#comparison --- <!-- ID: reference/language/03-operators#assignment --> Operators > Assignment [reference] | Operator | Equivalent | | -------- | --------------- | | `=` | Assign | | `+=` | `x = x + value` | | `-=` | `x = x - value` | | `*=` | `x = x * value` | | `/=` | `x = x / value` | | `%=` | `x = x % value` | The target is a variable, a field (`p.x += 1`) or an index (`d["k"] += 1`). Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#assignment Previous: reference/language/03-operators#logical Next: reference/language/03-operators#output- --- <!-- ID: reference/language/03-operators#comparison --> Operators > Comparison [reference] `==` equal, `!=` not equal, `<` less, `>` greater, `<=` less or equal, `>=` greater or equal. Every comparison returns a Boolean. Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#comparison Previous: reference/language/03-operators#arithmetic Next: reference/language/03-operators#logical --- <!-- ID: reference/language/03-operators#logical --> Operators > Logical [reference] | Operator | Meaning | | -------- | ----------------------------- | | `&&` | AND; stops at the first `false` | | `\|\|` | OR; stops at the first `true` | | `!` | NOT | Operands must be Booleans. There is no truthy coercion (`true && 0` is a type error). Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#logical Previous: reference/language/03-operators#comparison Next: reference/language/03-operators#assignment --- <!-- ID: reference/language/03-operators#output- --> Operators > Output << [reference] `target << value;` sends a value to a target: a pattern or script pattern to a track, or a value or [signal](/docs/explanation/audio/03-signals-and-time/) to a parameter. It is a statement, written once per statement, and each side is a whole expression. ```resonon parse-only lead << [C4 E4 G4].fast(2); // play a pattern on a track echo.parameter("Feedback") << 0.6; // set a parameter filter.parameter("Cutoff") << Sine(2).range_exp(400, 4000); // modulate a parameter ``` Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#output- Previous: reference/language/03-operators#assignment Next: reference/language/03-operators#routing- --- <!-- ID: reference/language/03-operators#precedence --> Operators > Precedence [reference] From tightest to loosest. Operators on one row bind equally and associate left to right. | Binds | Operators | Kind | | ----- | --------- | ---- | | 1 (tightest) | `f(x)`, `a[i]`, `a.b` | Postfix: call, index, member access | | 2 | `-`, `+`, `!` | Prefix: negation, identity, logical NOT | | 3 | `*`, `/`, `%` | Multiplicative | | 4 | `+`, `-` | Additive | | 5 | `<`, `>`, `<=`, `>=` | Comparison | | 6 | `==`, `!=` | Equality | | 7 | `&&` | Logical AND | | 8 | `\|\|` | Logical OR | | 9 (loosest) | `>>` | Routing | ```resonon let xs = #[1, 2, 3]; assert 2 + 3 * 4 == 14; // * before + assert (2 + 3) * 4 == 20; // parentheses first assert -xs[2] == -3; // index before negation assert !false && false == false; // == before && assert true || false && false; // && before || print("precedence holds"); ``` `>>` binds loosest, so each side is a whole expression and `a >> b >> c` chains left to right: `gfx.Noise("field") >> gfx.Blur("soft") >> screen`. `<<` is not an expression operator. It is written once per statement, `target << value`, and each side is a whole expression: `lead << [C4 E4 G4].fast(2);`. Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#precedence Previous: reference/language/03-operators#routing- Next: reference/language/03-operators#type-compatibility --- <!-- ID: reference/language/03-operators#routing- --> Operators > Routing >> [reference] `a >> b` sets the **single audio output** of track `a` to `b` — another track, `session.master`, hardware channels (`Output(2, 3)`), or `session.nowhere` (Live's Sends Only: only the track's sends are heard) — and evaluates to `b`, so routes chain: `drums >> bus >> session.master`. Every track has exactly one output, `session.master` by default; `>>` is the only way to set it. Sends are a separate mechanism, `track.set_send()`; see [Share an Effect with a Send](/docs/how-to/audio/05-share-an-effect-with-a-send/). On a MIDI track, `a >> b` sets its output to a port and channel, `MidiOutput("synth", 2)`, or to `session.nowhere` (Live's No Output, where a new MIDI track starts): `bass >> MidiOutput("synth", 2)`. A MIDI track is no one's destination, so its chain is one hop. Between visual operators, `>>` fills the primary input. An audio routing chain is applied as one change. Every source and destination is checked first; if any link is invalid, none of the chain's outputs change. Operand expressions still evaluate in order before routing is checked. Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#routing- Previous: reference/language/03-operators#output- Next: reference/language/03-operators#precedence --- <!-- ID: reference/language/03-operators#type-compatibility --> Operators > Type compatibility [reference] The result of each operator for each pair of operand types. | Operator | Number↔Number | String↔String | Note↔Number | Note↔Note | Event↔Number | NUL as operand | | -------------- | :-----------: | :-----------: | :---------: | :------------: | :----------: | :------------: | | `+` | Number | String | Note | error | Event | error | | `-` | Number | error | Note | Number (interval) | Event | error | | `*` | Number | error | Note | error | error | error | | `/` | Number | error | Note | Number (ratio) | error | error | | `%` | Number | error | error | error | error | error | | `==` `!=` | Boolean | Boolean | Boolean | Boolean | error | Boolean | | `<` `>` `<=` `>=` | Boolean | error | Boolean | Boolean | Boolean | error | | `&&` `\|\|` `!` | error | error | error | error | error | error | - `+` with a String on either side coerces the other side to a String, `NUL` included (`"got: " + NUL` is `"got: NUL"`). - For `-` and `/` the Note must be on the left (`C4 - 2`, `C4 / 2`); `2 - C4` and `2 / C4` are errors. `+` and `*` are commutative. - The frequency ratio in `*` and `/` must be positive. - Logical operators accept Boolean ↔ Boolean only. - `<<` takes a Track or Parameter on the left and a Pattern, Signal or value on the right. - `>>` routes an AudioTrack to an AudioTrack, `session.master`, `Output(…)` or `session.nowhere` (Sends Only), `session.master` to `Output(…)`, and a MidiTrack to `MidiOutput(…)` or `session.nowhere` (No Output). `Output(…)`, `MidiOutput(…)` and `session.nowhere` only end a chain. It is the one way to set an output. Between visual operators it fills the primary input; see [The Visual Graph](/docs/explanation/visuals/01-the-visual-graph/#two-wiring-rules). Page: reference/language/03-operators URL: https://resonon.org/docs/reference/language/03-operators/#type-compatibility Previous: reference/language/03-operators#precedence --- <!-- ID: reference/language/04-control-flow --> Control Flow [reference] Every condition — in `if`, a match guard, or `assert` — must be a Boolean. A non-Boolean is a type error; there is no truthy coercion. Sections: - reference/language/04-control-flow#if--else | if / else - reference/language/04-control-flow#loops | Loops - reference/language/04-control-flow#what-for-iterates | What for iterates - reference/language/04-control-flow#match | match - reference/language/04-control-flow#assert | assert - reference/language/04-control-flow#transport-statements | Transport statements Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/ --- <!-- ID: reference/language/04-control-flow#assert --> Control Flow > assert [reference] `assert condition;` or `assert condition, message;` stops the script with an assertion error when `condition` is `false`. The message may be any value; it is formatted as `print()` would show it. ```resonon let gain = 0.8; assert gain >= 0.0 && gain <= 1.0, "gain must be in [0, 1]"; ``` ```resonon no-check assert 2 > 3, "two is not greater than three"; // → Assertion failed: two is not greater than three ``` Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#assert Previous: reference/language/04-control-flow#match Next: reference/language/04-control-flow#transport-statements --- <!-- ID: reference/language/04-control-flow#if--else --> Control Flow > if / else [reference] ```resonon let x = 5; if x > 10 { print("big"); } else if x > 0 { print("positive"); } else { print("other"); } ``` | Form | Meaning | | ---- | ------- | | `if c { … }` | Runs the block when `c` is `true` | | `if c { … } else { … }` | Runs one of the two blocks | | `if c { … } else if d { … }` | Chains another condition | | `if c { … } else statement` | The `else` branch may be any one statement | | `if c statement` | Short form: one statement, no `else` | ```resonon let level = 3; let peaks = 0; if level > 2 peaks += 1; if level > 5 { print("clip"); } else print("ok"); assert peaks == 1; ``` With an `else` and blocks on both branches, `if` is an expression: its value is the last expression of the branch taken. There is no conditional operator (`c ? a : b`); use this form. ```resonon let mood = "happy"; let tempo = if mood == "happy" { 140 } else { 80 }; assert tempo == 140; ``` Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#if--else Next: reference/language/04-control-flow#loops --- <!-- ID: reference/language/04-control-flow#loops --> Control Flow > Loops [reference] | Form | Runs | | ---- | ---- | | `loop { … }` | Until `break` | | `do N { … }` | `N` times; `N` is evaluated once and truncated to an integer, and must be a Number | | `do N statement` | `N` times, one statement | | `for x in source { … }` | Once per element of `source` | | `loop:label { … }` | A labeled loop, for `break:label` and `continue:label` | `break` leaves the innermost loop and `continue` starts its next iteration. With a label, they act on the loop with that label. Only `loop` takes a label. ```resonon let r = 0; loop:rows { r += 1; let c = 0; loop:cols { c += 1; if c >= 2 { continue:rows; } // next row if r >= 3 { break:rows; } // leave the outer loop } } assert r == 3; let n = 0; do 2.9 { n += 1; } assert n == 2; do 3 n += 1; assert n == 5; ``` Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#loops Previous: reference/language/04-control-flow#if--else Next: reference/language/04-control-flow#what-for-iterates --- <!-- ID: reference/language/04-control-flow#match --> Control Flow > match [reference] `match subject { pattern => value … }` tests the arms top to bottom and evaluates the first that matches. It is an expression, and also a statement. Arms are separated by newlines or commas; an arm body is an expression or a `{ … }` block whose last expression is its value. | Pattern | Matches | | ------- | ------- | | `42`, `"text"`, `true` | An equal Number, String or Boolean | | `C4` | A Note, or a Number with that MIDI value (and a Note pattern matches a Number subject) | | `NUL` | Only `NUL` | | `_` | Anything | | `Style.legato` | An equal value read through dots, such as an [enum](/docs/reference/language/08-enums/#in-match) variant; it never binds | | `name` | Anything, and binds it to `name` in the guard and body | | `(p1, p2, …)` | A tuple of that length whose elements match | | `pattern if condition` | The pattern, when the guard is `true` | ```resonon fn drum_name(n) { match n { C2 => "kick" D2 => "snare" F#2 => "closed hat" x if x > 100 => "high" _ => "other" } } assert drum_name(36) == "kick"; assert drum_name(120) == "high"; let where = match (0, 5) { (0, 0) => "origin", (0, y) => "on the y-axis", _ => "elsewhere", }; assert where == "on the y-axis"; print(drum_name(38)); ``` - Only Numbers, Strings, Booleans, Notes, enum variants, `NUL` and tuples of those are matched by literal patterns. An Array, Dict, Pattern, function or iterator subject reaches only `_` or a binding. - There is no exhaustiveness check. If no arm matches at run time, it is an error. - A guard that is not a Boolean is a runtime type error. Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#match Previous: reference/language/04-control-flow#what-for-iterates Next: reference/language/04-control-flow#assert --- <!-- ID: reference/language/04-control-flow#transport-statements --> Control Flow > Transport statements [reference] `PLAY`, `PAUSE`, `STOP`, `RESET` and `SEEK` are statements that drive the transport. See [Transport](/docs/reference/running/02-transport/). Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#transport-statements Previous: reference/language/04-control-flow#assert --- <!-- ID: reference/language/04-control-flow#what-for-iterates --> Control Flow > What for iterates [reference] | Source | Yields | | ------ | ------ | | `range(n)`, `range(start, end)` | Numbers `0 … n-1`, `start … end-1` | | Array, Tuple | Each element | | Dict | Each **key**, in unspecified order; `dict.entries()` gives `[key, value]` pairs | | Iterator | Each value it yields | | Pattern | Each [event](/docs/reference/stdlib/audio/#events), forever — limit it with `.iter().take(n)` | A String is not iterable; iterate `string.iter()`. ```resonon for i in range(2, 5) { print(i); } // 2, 3, 4 for k in #{"cutoff": 74} { print(k); } // cutoff for pair in #["a", "b"].iter().enumerate() { print(pair[0]); } for event in [C4 D4].iter().take(4) { print(event.note()); } ``` Page: reference/language/04-control-flow URL: https://resonon.org/docs/reference/language/04-control-flow/#what-for-iterates Previous: reference/language/04-control-flow#loops Next: reference/language/04-control-flow#match --- <!-- ID: reference/language/05-collections-and-iterators --> Collections & Iterators [reference] The methods of each type are in the generated reference: [Array](/docs/reference/stdlib/core/#array), [Dict](/docs/reference/stdlib/core/#dict), [Tuple](/docs/reference/stdlib/core/#tuple) and [Iterator](/docs/reference/stdlib/core/#iterator). Arrays, dicts and class instances are shared on assignment; see [Values & Sharing](/docs/explanation/language/01-values-and-sharing/). | Type | Literal | Size | Mutable | Elements | | ---- | ------- | ---- | ------- | -------- | | Array | `#[a, b, c]` | Grows and shrinks | Yes | Any, mixed | | Dict | `#{key: value, …}` | Grows and shrinks | Yes | String or Number keys, any values | | Tuple | `(a, b, …)` | Fixed, at least 2 | No | Any, mixed | Trailing commas are allowed in all three literals, and all three nest. Sections: - reference/language/05-collections-and-iterators#arrays | Arrays - reference/language/05-collections-and-iterators#dicts | Dicts - reference/language/05-collections-and-iterators#tuples | Tuples - reference/language/05-collections-and-iterators#iterators | Iterators Page: reference/language/05-collections-and-iterators URL: https://resonon.org/docs/reference/language/05-collections-and-iterators/ --- <!-- ID: reference/language/05-collections-and-iterators#arrays --> Collections & Iterators > Arrays [reference] ```resonon let nums = #[1, 2, 3, 4, 5]; assert nums[0] == 1; // zero-based assert nums.get(4) == 5; // same as indexing nums[0] = 10; // index assignment nums.push(6); // push and pop mutate in place assert nums.pop() == 6; let matrix = #[#[1, 2], #[3, 4]]; assert matrix[1][0] == 3; print(nums); ``` `.push()` and `.pop()` change the array; every other method returns a new value. An array is played as a pattern with `Sequence(array)`. Page: reference/language/05-collections-and-iterators URL: https://resonon.org/docs/reference/language/05-collections-and-iterators/#arrays Next: reference/language/05-collections-and-iterators#dicts --- <!-- ID: reference/language/05-collections-and-iterators#dicts --> Collections & Iterators > Dicts [reference] Keys are Strings or Numbers, and the two are distinct: `200` and `"200"` are different keys. A dict has no order — `.keys()`, `.values()` and `.entries()` return entries in any order. ```resonon let cc = #{"cutoff": 74, "reso": 71, 7: "volume"}; assert cc["cutoff"] == 74; // a missing key is an error assert cc.get("drive") == NUL; // .get returns NUL instead cc["cutoff"] = 20; // index assignment adds or replaces cc["cutoff"] += 1; cc.set("drive", 0.3); assert cc.remove("reso") == 71; // .remove returns the removed value assert cc.contains_key(7); print(cc); ``` `.merge(other)` returns a new dict in which `other`'s keys win. The dict callbacks of `.map()`, `.filter()` and `.reduce()` receive the key and the value: `fn(k, v)`, `fn(acc, k, v)`. Page: reference/language/05-collections-and-iterators URL: https://resonon.org/docs/reference/language/05-collections-and-iterators/#dicts Previous: reference/language/05-collections-and-iterators#arrays Next: reference/language/05-collections-and-iterators#tuples --- <!-- ID: reference/language/05-collections-and-iterators#iterators --> Collections & Iterators > Iterators [reference] An iterator is a lazy, single-use sequence. Get one with `.iter()`: | Source | Yields | Ends | | ------ | ------ | ---- | | Array, Tuple | Each element | After the last | | String | Each character, as a one-character String | After the last | | Dict | Each key, in unspecified order | After the last | | Pattern | Each [event](/docs/reference/stdlib/audio/#events), one per step | **Never** | The [Iterator reference](/docs/reference/stdlib/core/#iterator) groups its methods: - **Advancing and transforming** methods (`take`, `skip`, `step_by`, `enumerate`, `map`, `filter`, `zip`, `chain`) return a new iterator and do no work yet. `enumerate` and `zip` yield `[a, b]` arrays; `zip` stops when either side ends. - **Consuming** methods (`next`, `collect`, `count`, `first`, `last`, `find`, `any`, `all`, `fold`, `flatten`) pull values through and return a result. `next()` returns `NUL` once the iterator is exhausted. ```resonon let it = #[10, 20].iter(); assert it.next() == 10; assert it.next() == 20; assert it.next() == NUL; // exhausted, and stays exhausted let evens = #[1, 2, 3, 4, 5, 6].iter() .filter(fn(x) { return x % 2 == 0; }) // lazy .map(fn(x) { return x * 10; }) // lazy .collect(); // runs the pipeline print(evens); // [20, 40, 60] let notes = [C4 E4 G4].iter().take(3).map(fn(e) { return e.note(); }).collect(); print(notes); // [60, 64, 67] ``` A pattern iterator never ends, so a consuming method on it without `.take(n)` first never returns: ```resonon no-check [C4 D4 E4].iter().collect(); // runs forever ``` Array `.map()` and `.filter()` return arrays; the same methods on an iterator return iterators. `for … in` accepts an iterator directly. Page: reference/language/05-collections-and-iterators URL: https://resonon.org/docs/reference/language/05-collections-and-iterators/#iterators Previous: reference/language/05-collections-and-iterators#tuples --- <!-- ID: reference/language/05-collections-and-iterators#tuples --> Collections & Iterators > Tuples [reference] A tuple is a fixed group of two or more values; `(1)` is a parenthesised expression, not a tuple. It cannot be changed. Index it with `t[i]`; compare it with `==` and `!=`, element by element (tuples of different lengths are never equal). Unpack it with a [destructuring `let`](/docs/reference/language/02-variables-and-scope/#destructuring) or a [`match` tuple pattern](/docs/reference/language/04-control-flow/#match). ```resonon let point = (3, 4); let mixed = (1, "hello", C4); assert mixed[2] == C4; assert mixed.length() == 3; assert (1, 2) == (1, 2); assert (1, 2) != (1, 2, 3); let box = ((0, 0), (640, 480)); assert box[1][0] == 640; print(point); ``` A DSP block's stereo return `(out_l, out_r)` is a tuple. Page: reference/language/05-collections-and-iterators URL: https://resonon.org/docs/reference/language/05-collections-and-iterators/#tuples Previous: reference/language/05-collections-and-iterators#dicts Next: reference/language/05-collections-and-iterators#iterators --- <!-- ID: reference/language/06-functions --> Functions [reference] Where a function looks up the names it uses is in [Variables & Scope](/docs/reference/language/02-variables-and-scope/#name-resolution). Sections: - reference/language/06-functions#defining-a-function | Defining a function - reference/language/06-functions#parameters | Parameters - reference/language/06-functions#default-values | Default values - reference/language/06-functions#rest-parameters-and-spread | Rest parameters and spread - reference/language/06-functions#calling | Calling - reference/language/06-functions#closures | Closures - reference/language/06-functions#documenting-a-function | Documenting a function Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/ --- <!-- ID: reference/language/06-functions#calling --> Functions > Calling [reference] | Call | Rule | | ---- | ---- | | `f(a, b)` | Positional arguments, in order | | `f(a, name: value)` | Named arguments, in any order, after all positional ones. The separator is `:`; `f(name = value)` is a parse error | | Too few arguments | Error, unless the missing parameters have defaults | | Too many arguments | Error, unless there is a rest parameter | Named arguments are not supported for built-in functions. ```resonon fn point(x = 0, y = 0, z = 0) { return f"({x}, {y}, {z})"; } assert point(z: 5) == "(0, 0, 5)"; assert point(1, z: 3) == "(1, 0, 3)"; print(point(y: 2, x: 1)); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#calling Previous: reference/language/06-functions#rest-parameters-and-spread Next: reference/language/06-functions#closures --- <!-- ID: reference/language/06-functions#closures --> Functions > Closures [reference] A function value captures the variables it references, by value, when it is created. Changing the outer variable afterwards does not change the closure. A closure may be returned, which makes factories: ```resonon fn make_adder(n) { return fn(x) { return x + n; }; } let add5 = make_adder(5); assert add5(3) == 8; let base = 100; let get_base = fn() { return base; }; base = 999; assert get_base() == 100; print("captured"); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#closures Previous: reference/language/06-functions#calling Next: reference/language/06-functions#documenting-a-function --- <!-- ID: reference/language/06-functions#default-values --> Functions > Default values [reference] A default is evaluated at call time, in the function's scope, so it may use earlier parameters — and, in a method, `this`. `= NUL` makes a parameter optional with no value. An annotated parameter that defaults to NUL has an optional type, `x: Number? = NUL` (see [Optional types](/docs/reference/language/01-values-and-types/#optional-types)). ```resonon fn range_step(start, end, step = 1) { let out = #[]; let i = start; loop { if i >= end { break; } out.push(i); i += step; } return out; } assert range_step(0, 5).length() == 5; assert range_step(0, 10, 2).length() == 5; fn greet(name = NUL) { if name != NUL { print("Hello, " + name); } } greet(); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#default-values Previous: reference/language/06-functions#parameters Next: reference/language/06-functions#rest-parameters-and-spread --- <!-- ID: reference/language/06-functions#defining-a-function --> Functions > Defining a function [reference] | Form | Meaning | | ---- | ------- | | `fn name(params) { … }` | A named function, at the top level of a file | | `fn name(params) -> Type { … }` | With an [annotated](/docs/reference/language/01-values-and-types/#type-annotations) return type | | `private fn name(params) { … }` | Not exported from a module | | `fn(params) { … }` | A function value (closure), anywhere an expression fits | `return value;` leaves the function. Without a `return`, the value of the last expression in the body is returned, or `NUL` if there is none. Functions are values: pass them, return them, store them. A function may call itself. ```resonon fn square(x) { x * x // implicit return } fn grade(score) { if score >= 90 { return "A"; } return "B"; } let double = fn(x) { return x * 2; }; fn apply_twice(f, x) { return f(f(x)); } fn factorial(n) { if n <= 1 { return 1; } return n * factorial(n - 1); } assert square(5) == 25; assert apply_twice(double, 3) == 12; assert factorial(5) == 120; print(grade(95)); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#defining-a-function Next: reference/language/06-functions#parameters --- <!-- ID: reference/language/06-functions#documenting-a-function --> Functions > Documenting a function [reference] A `///` comment above a `fn` is its documentation; `show(fn_name)` prints the signature, with any annotations, and the documentation. The rules are in [Comments](/docs/reference/language/01-values-and-types/#comments). ```resonon /// Clamp a value to the given range. /// Parameters: /// value — the value to clamp /// lo — lower bound /// hi — upper bound /// Returns: the clamped value fn clamp_to(value: Number, lo: Number, hi: Number) -> Number { if value < lo { return lo; } if value > hi { return hi; } return value; } show(clamp_to); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#documenting-a-function Previous: reference/language/06-functions#closures --- <!-- ID: reference/language/06-functions#parameters --> Functions > Parameters [reference] | Parameter | Syntax | Rule | | --------- | ------ | ---- | | Required | `x` | Must be passed | | Default value | `x = expr` | Optional; after the required parameters | | Rest | `...xs` | Last; collects the remaining arguments into an Array (empty if none); no default | Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#parameters Previous: reference/language/06-functions#defining-a-function Next: reference/language/06-functions#default-values --- <!-- ID: reference/language/06-functions#rest-parameters-and-spread --> Functions > Rest parameters and spread [reference] `...xs` in a parameter list collects arguments into an array. `...value` in a call spreads an array or a tuple into arguments; it can be mixed with ordinary arguments, and spreading anything else is a type error. Spread is only for call arguments: `#[...xs, 4]` is a parse error. ```resonon fn sum(...nums) { return nums.reduce(fn(acc, x) { return acc + x; }, 0); } fn add3(a, b, c) { return a + b + c; } let values = #[1, 2, 3]; assert sum(...values) == 6; assert sum() == 0; assert add3(10, ...#[20, 30]) == 60; assert add3(...(1, 2, 3)) == 6; print(sum(1, 2, 3, 4)); ``` Page: reference/language/06-functions URL: https://resonon.org/docs/reference/language/06-functions/#rest-parameters-and-spread Previous: reference/language/06-functions#default-values Next: reference/language/06-functions#calling --- <!-- ID: reference/language/07-classes --> Classes [reference] A class instance is shared on assignment and can be changed through any name that refers to it; see [Values & Sharing](/docs/explanation/language/01-values-and-sharing/). A class that implements `Pattern` is a [script pattern](/docs/reference/patterns/02-script-patterns/). Sections: - reference/language/07-classes#defining-a-class | Defining a class - reference/language/07-classes#fields | Fields - reference/language/07-classes#display | Display - reference/language/07-classes#conversions | Conversions - reference/language/07-classes#in-modules | In modules - reference/language/07-classes#interfaces | Interfaces - reference/language/07-classes#native-classes | Native classes - reference/language/07-classes#not-supported | Not supported Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/ --- <!-- ID: reference/language/07-classes#conversions --> Classes > Conversions [reference] `fn from` declares how a value of another type becomes a value of the class. Where an annotation asks for the class and a value does not fit it, `from` converts the value once, at that place: an argument, a return, a typed variable or a typed field. ```resonon class Hz { let value: Number; fn new(value) { this.value = value; } fn from(n: Number) -> Hz { return Hz(n); } } fn period_ms(f: Hz) -> Number { return 1000 / f.value; } assert period_ms(500) == 2; // 500 converts to Hz(500) let a: Hz = 440; assert a.value == 440; ``` - A class has one `from`. It takes one annotated parameter, has no default or rest parameter, returns the class itself, and does not use `this`. A union parameter (`x: Number | String`) takes several types. - `from` is not a method: `a.from(1)` is an error. Write `let a: Hz = 1;` instead. - What `from` returns must be the class as it is. A conversion never leads to another one. - An interface cannot declare `from`. - A pattern callback converts too, with the same `from`. How conversions apply at a boundary is in [Values & Types](/docs/reference/language/01-values-and-types/#conversions). The prelude's `Note` converts a MIDI number: `chord(60, "maj")`. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#conversions Previous: reference/language/07-classes#display Next: reference/language/07-classes#in-modules --- <!-- ID: reference/language/07-classes#defining-a-class --> Classes > Defining a class [reference] ```resonon class Point { let x; // field let y: Number; // typed field: every write is checked fn new(x, y = 0) { // constructor this.x = x; this.y = y; } fn add(other) -> Point { // method return Point(this.x + other.x, this.y + other.y); } fn __str__() { // how print() and f-strings show it return f"({this.x}, {this.y})"; } } let p = Point(3, 4); // call the class to construct let q = p.add(Point(y: 2, x: 1)); // named arguments work assert q.x == 4; print(q); // (4, 6) ``` | Member | Syntax | Notes | | ------ | ------ | ----- | | Field | `let name;` or `let name: Type;` | Declared once; takes no `///` documentation | | Constructor | `fn new(params) { … }` | Called by `ClassName(args)`; sets fields through `this` | | Method | `fn name(params) { … }` | Called as `instance.name(args)`; `///` documents it | | Display | `fn __str__() { … }` | Used by `print()` and format strings | | Conversion | `fn from(x: Source) -> ClassName { … }` | Applied where the class is asked for; never called | Parameters of `new` and methods follow the [function rules](/docs/reference/language/06-functions/#parameters): defaults, named arguments, rest parameters, and argument-count errors. A method's default may use `this`. A field and a method may share a name: `p.x` reads the field and `p.x()` calls the method. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#defining-a-class Next: reference/language/07-classes#fields --- <!-- ID: reference/language/07-classes#display --> Classes > Display [reference] With `__str__`, `print()` and `f"{…}"` show what it returns. Without it, or when it returns a non-String, an instance shows as its class name and its fields in alphabetical order: ```resonon class Pair { let b; let a; fn new(a, b) { this.a = a; this.b = b; } } print(Pair(1, 2)); // Pair { a: 1, b: 2 } assert type(Pair(1, 2)) == "Pair"; ``` Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#display Previous: reference/language/07-classes#fields Next: reference/language/07-classes#conversions --- <!-- ID: reference/language/07-classes#fields --> Classes > Fields [reference] Fields are read and assigned from anywhere, including through nested instances, and take compound assignment: ```resonon class Inner { let value; fn new(v) { this.value = v; } } class Outer { let inner; fn new(i) { this.inner = i; } } let o = Outer(Inner(1)); o.inner.value = 5; o.inner.value += 1; assert o.inner.value == 6; print(o.inner.value); ``` A method that assigns to `this` changes the instance in place, and every name sharing the instance sees the change. A class that implements [`Clone`](#interfaces) has `.clone()`, which makes an independent copy. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#fields Previous: reference/language/07-classes#defining-a-class Next: reference/language/07-classes#display --- <!-- ID: reference/language/07-classes#in-modules --> Classes > In modules [reference] A class in a module is exported like a `fn` and constructed as `module.ClassName(args)`. `private class` keeps it inside the module. See [Modules](/docs/reference/language/09-modules/#visibility). Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#in-modules Previous: reference/language/07-classes#conversions Next: reference/language/07-classes#interfaces --- <!-- ID: reference/language/07-classes#interfaces --> Classes > Interfaces [reference] An `interface` names the methods that several classes have in common. A class that names it after `implements` defines those methods, and its values fit the interface wherever an annotation names it: ```resonon interface Shape { fn area() -> Number; // required: each class defines it fn twice() -> Number { // default: a class may leave it out return 2 * this.area(); } } class Square implements Shape { let side: Number; fn new(side) { this.side = side; } fn area() -> Number { return this.side * this.side; } } fn total(a: Shape, b: Shape) -> Number { return a.area() + b.area(); } assert total(Square(2), Square(3)) == 13; assert Square(2).twice() == 8; // the default, with this as the square ``` - An interface holds methods only: no fields, no `new` and no `from`. An interface does not implement another interface. - A method written with `;` is required. A method with a body is a default. - A class implements several interfaces with a list: `class Clip implements Shape, Named`. - A class's own method is used before a default. When two of its interfaces have a method of the same name, the class must define that method itself. - In a default, `this` is the instance. The editor completes `this.` with the interface's methods. - An interface is a type and makes no values: a function can have the same name. - `type(x)` names the class of the value, not the interface. A builtin value that implements an interface natively is named by the interface: `type([C4 E4])` is `"Pattern"`. - The stdlib's `Pattern` is an interface: a class that implements it is a pattern, and has every combinator. See [Script Patterns](/docs/reference/patterns/02-script-patterns/). A method of an interface may return `Self`: the type of the value it is called on. A class implementing it returns its own class, written by name or as `Self`. The prelude's `Clone` is such an interface. A class that implements it defines what its copy is: ```resonon class Point implements Clone { let x; let y; fn new(x, y) { this.x = x; this.y = y; } fn clone() -> Self { return Point(this.x, this.y); } } let a = Point(1, 2); let b = a.clone(); b.x = 10; assert a.x == 1; ``` Arrays, dicts, tuples, sections and timelines are `Clone` natively. A copy clones each value inside it that is `Clone`, through that value's own `clone()`, and shares every other value. The class is checked when its definition runs, and the editor shows the same errors. The class must define each required method itself. Each method must have the interface's parameter names, in the same order, with a default and a rest parameter where the interface has one. Each parameter must take the values that the interface's parameter takes. When the interface declares a return type, the class must declare a return type that fits it: ```resonon no-check class Blob implements Shape { } // → Type error at 1:23: Blob implements Shape but has no area() ``` A class keeps the interfaces as they were when its definition ran. If you execute an interface again with changes, the classes defined before keep the old methods. The next class definition is checked against the new interface. In a module, an interface is exported as a class is, and `private interface` keeps it in the module. Import it by name: `use "./shapes" { Shape };`. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#interfaces Previous: reference/language/07-classes#in-modules Next: reference/language/07-classes#native-classes --- <!-- ID: reference/language/07-classes#native-classes --> Classes > Native classes [reference] A `native class` is the type of values the engine or a [native extension](/docs/how-to/dsp/05-ship-a-native-extension/) makes: `AudioTrack`, `Pattern`, `Sampler`. It declares the methods and read-only fields of those values: - It has no `new`. Its fields are read-only; assigning one is an error. - Its name is a type, not a constructor. A function such as `Sampler(path)`, or a method such as `session.create_track(name)`, makes the values. A native field declares its type and a body: ```resonon parse-only native class Counter { /// The current counter value. let count: Number { return __ext("my_ext", "counter_count", this); } } ``` The body runs on every read of `counter.count`, with `this` bound to the receiver. It resolves names in the defining module, like a native method, and checks the result against its declared type. There is no cache. A field body must be a cheap read; use a method for work that changes state or takes time. A native field without a body is an error. The standard library declares its builtin types this way. Write one only for the values a native extension returns. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#native-classes Previous: reference/language/07-classes#interfaces Next: reference/language/07-classes#not-supported --- <!-- ID: reference/language/07-classes#not-supported --> Classes > Not supported [reference] - Inheritance — no `extends` or `super`. Classes share methods through an [interface](#interfaces). - Static methods or fields — every member belongs to an instance. - Private members — every field and method is public. For encapsulation, use module-level `private`. - Getters and setters for user classes — their fields are stored and assigned directly. Native read-only fields are the exception described above. Page: reference/language/07-classes URL: https://resonon.org/docs/reference/language/07-classes/#not-supported Previous: reference/language/07-classes#native-classes --- <!-- ID: reference/language/08-enums --> Enums [reference] An enum is a closed set of named choices. Use one where a value is one of a fixed list, such as a blend mode or a playing style, instead of a String the code must spell correctly. Sections: - reference/language/08-enums#declaring-an-enum | Declaring an enum - reference/language/08-enums#reading-a-variant | Reading a variant - reference/language/08-enums#comparing | Comparing - reference/language/08-enums#in-match | In match - reference/language/08-enums#annotations | Annotations - reference/language/08-enums#running-a-declaration-again | Running a declaration again - reference/language/08-enums#in-modules | In modules - reference/language/08-enums#not-supported | Not supported Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/ --- <!-- ID: reference/language/08-enums#annotations --> Enums > Annotations [reference] An enum name is a type in an [annotation](/docs/reference/language/01-values-and-types/#type-annotations). Only a variant of that enum fits it: the editor flags a String or a variant of another enum, and running refuses one. A String that spells a variant gets the variant to write in the error, `(write Style.legato)`. ```resonon enum Style { staccato, legato } fn play_as(style: Style) -> Number { return match style { Style.staccato => 0.25, _ => 1.0 }; } print(play_as(Style.staccato)); // 0.25 ``` `Variant` accepts a variant of any enum, for a parameter that takes a choice from more than one enum. A device parameter's `set()` is one: each choice parameter says which enum it takes. A Number or a String is no `Variant`, and a `Variant` does not fit an annotation of one enum. ```resonon enum Style { staccato, legato } fn enum_of(choice: Variant) -> String { return type(choice); } assert enum_of(Style.legato) == "Style"; assert enum_of(Monitor.auto) == "Monitor"; ``` Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#annotations Previous: reference/language/08-enums#in-match Next: reference/language/08-enums#running-a-declaration-again --- <!-- ID: reference/language/08-enums#comparing --> Enums > Comparing [reference] `==` and `!=` compare two variants of one enum by name. A variant compared with a variant of another enum, or with a String or Number, is a type error. A variant compared with `NUL` is not equal to it. ```resonon enum Style { staccato, legato } assert Style.legato == Style.legato; assert Style.legato != Style.staccato; assert Style.legato != NUL; print(Style.legato == Style.staccato); // false ``` ```resonon no-check enum Mode { legato } Style.legato == Mode.legato; // error: expected matching types Style.legato == "legato"; // error: expected matching types ``` Variants have no order: `<`, `>`, `<=` and `>=` are type errors. Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#comparing Previous: reference/language/08-enums#reading-a-variant Next: reference/language/08-enums#in-match --- <!-- ID: reference/language/08-enums#declaring-an-enum --> Enums > Declaring an enum [reference] ```resonon /// How a part is played. enum Style { /// Short and detached. staccato, /// Connected. legato, accent, // a trailing comma is allowed } print(Style.legato); // Style.legato ``` - An enum is written at the top level of a file, like a `class`. - Its name starts with an upper-case letter, as a type name does. - A variant is lower snake_case: `ease_in`, not `EaseIn`. The error names the snake_case spelling. - An enum has at least one variant, and names each variant once. - `///` documents the enum and each variant. The editor shows the docs on hover and in completion, and `show(Style)` prints them with the variants. An enum name is claimed like every other definition: see [One definition per name](/docs/reference/language/02-variables-and-scope/#one-definition-per-name). Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#declaring-an-enum Next: reference/language/08-enums#reading-a-variant --- <!-- ID: reference/language/08-enums#in-match --> Enums > In match [reference] A dotted name in a `match` arm compares the subject with the variant. It never binds a name. See [match](/docs/reference/language/04-control-flow/#match). ```resonon enum Style { staccato, legato, accent } fn velocity(style) { match style { Style.staccato => 70, Style.accent => 120, _ => 90, } } assert velocity(Style.accent) == 120; print(velocity(Style.legato)); // 90 ``` There is no exhaustiveness check: add `_` for the variants no arm names. Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#in-match Previous: reference/language/08-enums#comparing Next: reference/language/08-enums#annotations --- <!-- ID: reference/language/08-enums#in-modules --> Enums > In modules [reference] A module exports an enum like a `class`. Read its variants through the module, or import the enum by name. `private enum` keeps it inside the module. See [Modules](/docs/reference/language/09-modules/#visibility). ```resonon parse-only // lib/styles.non enum Style { staccato, legato } private enum Internal { a, b } ``` ```resonon parse-only use "styles"; use "styles" { Style }; let a = styles.Style.legato; assert a == Style.legato; ``` An enum declared in the session and an enum of the same name declared in a module are two enums: their variants do not compare. Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#in-modules Previous: reference/language/08-enums#running-a-declaration-again Next: reference/language/08-enums#not-supported --- <!-- ID: reference/language/08-enums#not-supported --> Enums > Not supported [reference] - Values on a variant — a variant is a name only. It carries no number and no data. - Methods — an enum has only its variants. - Calling an enum — `Style()` is a type error. - Iterating an enum — `for s in Style` is a type error. - A variant as a Dict key — Dict keys are Strings and Numbers. Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#not-supported Previous: reference/language/08-enums#in-modules --- <!-- ID: reference/language/08-enums#reading-a-variant --> Enums > Reading a variant [reference] `Enum.variant` reads a variant. A variant prints as it is written, and `type()` returns its enum's name. The enum itself prints as `<enum Style>`, and `type()` returns `enum Style`. ```resonon enum Style { staccato, legato } let s = Style.staccato; assert type(s) == "Style"; assert type(Style) == "enum Style"; print(s); // Style.staccato print(Style); // <enum Style> ``` A variant the enum does not declare is an error. It lists the variants and suggests the closest: ```resonon no-check let s = Style.legatto; // enum Style has no variant 'legatto'. Did you mean 'legato'? Variants: staccato, legato ``` The editor reports the misspelt variant before the code runs. Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#reading-a-variant Previous: reference/language/08-enums#declaring-an-enum Next: reference/language/08-enums#comparing --- <!-- ID: reference/language/08-enums#running-a-declaration-again --> Enums > Running a declaration again [reference] Running an `enum` declaration again declares the same enum again. Variants read before the run stay equal to the variants read after it, even when the new declaration changes the variant order. An enum is told apart by its name and by where it is declared: the session, or a module file. Run this first: ```resonon enum Style { staccato, legato } let before = Style.legato; print(before); ``` Then run this, with the variants in a new order: ```resonon parse-only enum Style { legato, staccato } assert before == Style.legato; // still equal ``` Page: reference/language/08-enums URL: https://resonon.org/docs/reference/language/08-enums/#running-a-declaration-again Previous: reference/language/08-enums#annotations Next: reference/language/08-enums#in-modules --- <!-- ID: reference/language/09-modules --> Modules [reference] Any `.non` file loaded with `use` is a module. Installing packages is in [Install a Package](/docs/how-to/setup/03-install-a-package/); the standard library's modules and what each exports are in the [Standard Library reference](/docs/reference/stdlib/). Sections: - reference/language/09-modules#use | use - reference/language/09-modules#what-a-module-sees | What a module sees - reference/language/09-modules#exports | Exports - reference/language/09-modules#visibility | Visibility - reference/language/09-modules#resolving-a-use-path | Resolving a use path - reference/language/09-modules#packages | Packages - reference/language/09-modules#standard-library-submodules | Standard library submodules - reference/language/09-modules#when-a-module-is-evaluated | When a module is evaluated - reference/language/09-modules#circular-imports | Circular imports - reference/language/09-modules#inspecting-a-module | Inspecting a module - reference/language/09-modules#conventions | Conventions Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/ --- <!-- ID: reference/language/09-modules#circular-imports --> Modules > Circular imports [reference] Modules must form a directed acyclic graph. A cycle is an error that lists the chain: ``` Runtime error at 3:1: Circular import: /music/lib/a.non → /music/lib/b.non → /music/lib/a.non Modules must form a directed acyclic graph. ``` Move the definitions both sides need into a third module. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#circular-imports Previous: reference/language/09-modules#when-a-module-is-evaluated Next: reference/language/09-modules#inspecting-a-module --- <!-- ID: reference/language/09-modules#conventions --> Modules > Conventions [reference] - Module files: `snake_case.non`. - Library entry points: `src/lib.non`. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#conventions Previous: reference/language/09-modules#inspecting-a-module --- <!-- ID: reference/language/09-modules#exports --> Modules > Exports [reference] A module exports its top-level: - `let` bindings, evaluated when the module is loaded; - `fn`, `class`, `enum` and `dsp` definitions; - `use` imports, as named fields (`use "./scales";` in `theory` makes `theory.scales`). Exports are read with dot access: `lib.default_bpm`, `lib.patterns.kick()`, `shapes.Circle(5)`. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#exports Previous: reference/language/09-modules#what-a-module-sees Next: reference/language/09-modules#visibility --- <!-- ID: reference/language/09-modules#inspecting-a-module --> Modules > Inspecting a module [reference] `show(module)` prints the module's path, the first line of its `//!` documentation, its exports (functions with signatures and doc summaries, variables with types, nested modules) and its private items. `show(module.function)` prints one function. ``` ┌────────────────────────────────────────┐ Module: lib (from /path/to/lib_example/src/lib.non) Library entry point Exports: patterns: Module default_bpm: Number fn rest(beats) - Generate rests for a number of beats Private: INTERNAL_VEL: Number └────────────────────────────────────────┘ ``` Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#inspecting-a-module Previous: reference/language/09-modules#circular-imports Next: reference/language/09-modules#conventions --- <!-- ID: reference/language/09-modules#packages --> Modules > Packages [reference] A package is a directory with a `src/lib.non` entry point, as `resonon new <name> --lib` creates. A bare `lib.non` at the top of a directory is not an entry point. ``` drums/ resonon.toml src/ lib.non ← entry point patterns.non ← imported by lib.non, exported as drums.patterns fills.non ``` Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#packages Previous: reference/language/09-modules#resolving-a-use-path Next: reference/language/09-modules#standard-library-submodules --- <!-- ID: reference/language/09-modules#resolving-a-use-path --> Modules > Resolving a use path [reference] | Order | Path | Resolves to | | ----- | ---- | ----------- | | 1 | `std/…` | The standard library shipped with this resonon version | | 2 | `./…`, `../…` | Relative to the importing file | | 3 | `/…` | The absolute path | | 4 | A bare name equal to `[package].name` in `resonon.toml` | The project's own `src/lib.non` | | 5 | Any other bare name | `./lib`, then `./dependencies`, in the project | - The project is the nearest directory above the **importing file** with a `resonon.toml`. A file with none above it is refused before anything runs. - For relative and absolute paths, a package's `src/lib.non` is tried first, then the file. In the project directories, the file is tried first, then the package. - There is no machine-wide module path and no setting that adds one. A module outside the project is reached by naming its path in the `use`: `use "../shared-lib/src/lib" { groove };`. - `RESONON_STDLIB_PATH` replaces the standard library with another copy. It takes the absolute path of an existing directory; any other value is ignored with a warning at startup. - The editor resolves `use` the same way. - `resonon config paths` prints the resolved directories. The full search order, with kits, is in [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/#search-order). A module that is not found is reported with every directory searched: ``` Module 'my_library' not found. Searched: /music/proj/lib (project) /music/proj/dependencies (project) ``` A package installed on this machine but not declared by the project gets its own message, naming the `resonon install` that declares it. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#resolving-a-use-path Previous: reference/language/09-modules#visibility Next: reference/language/09-modules#packages --- <!-- ID: reference/language/09-modules#standard-library-submodules --> Modules > Standard library submodules [reference] A standard-library module can be imported whole or by submodule; the two mix freely. | Module | Submodules | |:-------|:-----------| | `std/effects` | `std/effects/filters`, `std/effects/delay`, `std/effects/reverb`, `std/effects/distortion` | | `std/instruments` | `std/instruments/sample`, `std/instruments/sampler`, `std/instruments/melodic` | ```resonon use "std/effects" { Reverb }; use "std/effects/filters" { Filter, FilterType }; ``` Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#standard-library-submodules Previous: reference/language/09-modules#packages Next: reference/language/09-modules#when-a-module-is-evaluated --- <!-- ID: reference/language/09-modules#use --> Modules > use [reference] | Form | Binds | | ---- | ----- | | `use "path";` | The module, under an alias derived from the path | | `use "path" as name;` | The module, under `name` | | `use "path" { a, b };` | `a` and `b` directly, with no module prefix | | `use "path" { a as x, b };` | `a` under the name `x` (`a` itself is not bound), and `b` | | `private use "path";` | The module, usable in this file but not re-exported | The `.non` extension is added when missing. The derived alias is: - for a file, its stem: `use "./patterns"` binds `patterns`; - for a package's `src/lib.non`, the package directory: `use "./drums"` and `use "./drums/src/lib"` both bind `drums`; - with hyphens replaced by underscores: `use "drum-kits"` binds `drum_kits`. ```resonon use "std/effects" { Delay as D, Reverb }; let echo = D("echo", 0.25, 0.4); // `Delay` itself is not in scope ``` A name a `use` binds has one definition in its file or selection: a second `use`, a `fn`, `class`, `enum` or `dsp` definition, or a top-level `let` binding it too is a [repeated definition](/docs/reference/language/02-variables-and-scope/#one-definition-per-name), and nothing in that source runs. Rename one side with `as` to keep both. Across executions, the binding executed last wins: a `use` run after `fn Delay` replaces it, and running the `fn` again brings it back. The module is asked for the *exported* name, so `use "./drums" { kik as k }` reports that `drums` has no export `kik`. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#use Next: reference/language/09-modules#what-a-module-sees --- <!-- ID: reference/language/09-modules#visibility --> Modules > Visibility [reference] `private` before a `let`, `fn`, `class`, `enum`, `dsp` definition or `use` keeps it out of the exports. Reading it from outside is an error: ``` Cannot access private 'BASE_VEL' in module 'drums' ``` `private` only has an effect in a file loaded with `use`; at the top level of a script it is accepted and does nothing. `show(module)` lists private items in a separate section. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#visibility Previous: reference/language/09-modules#exports Next: reference/language/09-modules#resolving-a-use-path --- <!-- ID: reference/language/09-modules#what-a-module-sees --> Modules > What a module sees [reference] A module's code — its top level, its functions and its class methods — sees the module's own top-level names and the standard library. It never sees the names of the file that imports it, so a module reads the same wherever it is used; pass what it needs as arguments. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#what-a-module-sees Previous: reference/language/09-modules#use Next: reference/language/09-modules#exports --- <!-- ID: reference/language/09-modules#when-a-module-is-evaluated --> Modules > When a module is evaluated [reference] - A module is evaluated when its source, or the source of anything it imports, differs from what the session last evaluated. Otherwise the session's copy is reused, so a module that creates a track at its top level creates it once. - Within one execution, a module has one version, however often it is imported. - `RESET;` clears the session, so every module is evaluated again. Page: reference/language/09-modules URL: https://resonon.org/docs/reference/language/09-modules/#when-a-module-is-evaluated Previous: reference/language/09-modules#standard-library-submodules Next: reference/language/09-modules#circular-imports --- <!-- ID: reference/language/10-errors-and-warnings --> Errors & Warnings [reference] What to do about the common ones is in [Fix Language Errors](/docs/how-to/language/01-fix-language-errors/). Sections: - reference/language/10-errors-and-warnings#where-an-error-is-shown | Where an error is shown - reference/language/10-errors-and-warnings#when-code-stops | When code stops - reference/language/10-errors-and-warnings#kinds | Kinds - reference/language/10-errors-and-warnings#warnings | Warnings - reference/language/10-errors-and-warnings#screen-errors | Screen errors - reference/language/10-errors-and-warnings#severity-in-the-editor | Severity in the editor - reference/language/10-errors-and-warnings#checking-without-running | Checking without running - reference/language/10-errors-and-warnings#editor-only-diagnostics | Editor-only diagnostics - reference/language/10-errors-and-warnings#machine-readable-output | Machine-readable output Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/ --- <!-- ID: reference/language/10-errors-and-warnings#checking-without-running --> Errors & Warnings > Checking without running [reference] `resonon check` reports what the editor shows in File Mode, from the same analysis. It runs no code and opens no audio or MIDI device. With no file, it checks the project's `src/main.non` and `src/lib.non`, and the modules that they import. `resonon check path.non` checks one file. Each error has the severity that the editor gives it. An error found as you type is an `error` line. A warning found as you type is a `warning` line, and its text starts with `Warning:`. A `Kit("…")` found outside the project is a `warning` line with the code `kit_outside_project` and the severity `information`. See the shared [exit-code contract](/docs/reference/setup/01-cli/#exit-codes). Warnings do not change the exit status. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#checking-without-running Previous: reference/language/10-errors-and-warnings#severity-in-the-editor Next: reference/language/10-errors-and-warnings#editor-only-diagnostics --- <!-- ID: reference/language/10-errors-and-warnings#editor-only-diagnostics --> Errors & Warnings > Editor-only diagnostics [reference] These come from the language server, not from running code: | Code | Severity | Where | Meaning | | --- | --- | --- | --- | | `kit-unportable` | Information | `.non` | A `Kit("…")` whose kit is outside the project and not listed under `[local]`. | | `kit-missing` | Warning | `resonon.toml` | A `[local] kits` entry found nowhere. | | `kit-outside-project` | Information | `resonon.toml` | A `[local] kits` entry found only outside the project. | | `kit-travels-anyway` | Hint | `resonon.toml` | A `[local] kits` entry for a kit that travels anyway — in the project, a dependency, or the kits resonon ships — so the entry does nothing. | | `manifest-unknown-key` | Warning | `resonon.toml` | A key resonon does not read. | | `manifest-syntax` | Error | `resonon.toml` | TOML that does not parse. | Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#editor-only-diagnostics Previous: reference/language/10-errors-and-warnings#checking-without-running Next: reference/language/10-errors-and-warnings#machine-readable-output --- <!-- ID: reference/language/10-errors-and-warnings#kinds --> Errors & Warnings > Kinds [reference] The code is what VSCode shows beside the message. | Code | Text | Raised by | | --- | --- | --- | | `parse` | `Parse error at L: …` | Code that does not fit the grammar, a note literal above MIDI 127 (`B9`: `Invalid note 'B9'`), or a definition written inside a function or block. | | `runtime` | `Runtime error at L: …` | A failure with no kind of its own: a bad argument value, a failed operation. | | `type` | `Type error at L: expected X, got Y`, or the annotation's own sentence: `Type error at L: f: x expects a Number, got the String "a"` | A value of the wrong type for an operator or a condition, or one that does not fit an annotation it crosses. | | `type` | `Warning: Type warning at L: expected a Timeline; a Timeline \| Section may be a Section` | Found only by the editor and `resonon check`: a value that is one of several types, where only some of them fit. Running fails if the value is one of the others. | | `conformance` | `Type error at L: Blob implements Shape but has no area()` | A class that names an interface after `implements` but does not define what it asks, or defines it differently. The class is not defined. See [Interfaces](/docs/reference/language/07-classes/#interfaces). | | `signature_drift` | `Internal error: the standard library's signature and the native N disagree: …` | A standard-library function and the native behind it disagree on an argument's type. Never your code: report it. | | `undefined_variable` | `Undefined variable 'x' at L` | A name that is not defined. | | `undefined_function` | `Undefined function 'f' at L` | A call of a name that is not defined. | | `undefined_type` | `unknown type T at L` | A name in an annotation that is not a type there. The editor and `resonon check` report it, and running reports it when a value meets the annotation. | | `undefined_method` | `Undefined method 'm' for type T at L` | A method the value's type does not have. | | `undefined_property` | `Undefined property 'p' for type T at L` | A field a class instance does not have. | | `arity_mismatch` | `Arity mismatch at L: 'f' expects N arguments, got M` | Too few or too many arguments. `N` is a number, a range `min-max`, or `variadic`. | | `division_by_zero` | `Division by zero at L` | `/` or `%` by `0`. | | `index_out_of_bounds` | `Index out of bounds at L: index I is out of range for length N` | An array, tuple or string index past its end. | | `assertion_failed` | `Assertion failed at L: message` | An `assert` whose condition is `false`. Without a message: `Assertion failed at L`. | | `borrow_error` | `Borrow error at L: …` | A class instance changed while resonon itself still holds it. It should not happen; report it. | | `private_access` | `Cannot access private 'x' in module 'm' at L` | A `private` definition used from outside its module. | | `read_only_field` | `Cannot assign 'f' of type T: it is read-only at L` | An assignment to a field of a built-in type, such as `session.master = x`. Resonon sets these fields; code only reads them. | | `module_not_found` | `Runtime error at L: Module 'p' not found. Searched:` and each folder searched | A `use` path found in no search path. | | `duplicate_definition` | `Duplicate definition at L: fn 'f' repeats the fn at L2.` and a line saying what to do | A name bound twice in one file or selection — by two definitions, a `let` and a definition, or a `use` and anything else. | | `dsp` | `DSP error at L: …` | A `dsp` block that does not compile. See [DSP Code](/docs/reference/dsp/03-dsp-code/). | | `plugin_skipped` | `Runtime error at L: …` | A plugin that the plugin scan skipped after it crashed. The editor offers to retry it. | | `version_mismatch` | `Runtime error at L: …` | Code from a project that needs a newer resonon than the server runs. The editor offers to restart the server. | `L` is the location. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#kinds Previous: reference/language/10-errors-and-warnings#when-code-stops Next: reference/language/10-errors-and-warnings#warnings --- <!-- ID: reference/language/10-errors-and-warnings#machine-readable-output --> Errors & Warnings > Machine-readable output [reference] For `send`, `save`, `open`, `check` and `run`, `--message-format json` prints one JSON object per line on stdout. Each object has the form the server sends to the editor. Its `type` tells what it is: | `type` | What it is | | --- | --- | | `output` | Text from `print()`, in `text`. | | `warning` | A warning, in `warning`. | | `error` | An error, in `error`. | | `notice` | A remark about the machine or the preferences, in `text`. | | `rendered` | A `render()` or `render_master()` that wrote its files: the absolute path of its folder, in `path`. | | `visual_diagnostic` | A [screen error](#screen-errors), in `error`. `kind` is `graph` or `shader`. `ok` is `true` when a shader that the visuals window compiles has no error. | | `complete` | The last line. `success` is `false` after an error. | A `warning` and an `error` have the same fields: | Field | What it is | | --- | --- | | `message` | The full text, as `resonon run` prints it. | | `error_type` | The code. | | `marks` | Where the editor marks it. Each mark has a `location` (`file`, `line`, `column` and `end`), a `severity`, the code in `error_type`, and the text without the location in `message`. | ```json {"type":"error","id":"…","error":{"message":"Division by zero at /home/me/song/src/main.non:2:13","error_type":"division_by_zero","marks":[{"location":{"line":2,"column":13,"file":"/home/me/song/src/main.non","end":{"line":2,"column":14}},"severity":"error","error_type":"division_by_zero","message":"Division by zero"}]},"timestamp":"12:00:00"} {"type":"complete","id":"…","success":false,"timestamp":"12:00:00"} ``` After valid argument parsing, stdout contains only these JSON objects. A refusal before execution writes an `error` followed by exactly one `complete` with `success: false`. Both objects have the same request ID. This includes invalid environment settings, a refused version pin, missing project or entry files, and fatal engine, interpreter or GUI startup failures. Launcher dispatch failures, such as a missing default version or runtime, use the same shape. Argument usage errors, such as unknown flags or missing option values, retain normal stderr output. They do not produce a message stream. The [exit-code contract](/docs/reference/setup/01-cli/#exit-codes) is the same as without the option. Startup refusals exit with `2` because execution could not be attempted. `resonon analyze <folder> --format json` writes one analysis document, without message-stream objects or a final `complete`. It does not accept `--message-format`. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#machine-readable-output Previous: reference/language/10-errors-and-warnings#editor-only-diagnostics --- <!-- ID: reference/language/10-errors-and-warnings#screen-errors --> Errors & Warnings > Screen errors [reference] A screen graph that does not build, and a shader that does not compile, are screen errors. They do not stop the code, and `resonon run` exits as it would without them. `resonon run` prints each one as `Screen error at L: …`. The editor shows it at the line, with the code `graph` or `shader`. Only the visuals window (`screen.show()`) reports a shader that does not compile as a screen error. `resonon run` waits for the window to compile before it says how the run went. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#screen-errors Previous: reference/language/10-errors-and-warnings#warnings Next: reference/language/10-errors-and-warnings#severity-in-the-editor --- <!-- ID: reference/language/10-errors-and-warnings#severity-in-the-editor --> Errors & Warnings > Severity in the editor [reference] The editor checks code as you type, without running it, and runs no code to confirm what it finds. | Found | Severity | | --- | --- | | After you evaluate: any error | Error | | As you type: `parse`, `duplicate_definition`, `dsp`, `module_not_found`, `undefined_*`, `arity_mismatch`, `private_access`, `read_only_field` | Error | | As you type: `type`, `runtime`, `division_by_zero`, `index_out_of_bounds`, `assertion_failed`, `borrow_error` | Warning | Errors found as you type stay until the code changes; errors from an evaluation clear at your next evaluation. In [Live Mode](/docs/reference/running/01-vscode-extension/#live-mode-and-file-mode) (online), a `duplicate_definition` between two top-level bindings in the file is not shown: each selection is evaluated on its own. [File Mode](/docs/reference/running/01-vscode-extension/#live-mode-and-file-mode) (offline) shows them. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#severity-in-the-editor Previous: reference/language/10-errors-and-warnings#screen-errors Next: reference/language/10-errors-and-warnings#checking-without-running --- <!-- ID: reference/language/10-errors-and-warnings#warnings --> Errors & Warnings > Warnings [reference] A warning does not stop the code. `resonon run` prints it as `Warning: …`. Each warning has a code: | Code | Raised by | | --- | --- | | `audio_device` | An audio device that did not open, went away, or cannot do what was asked. | | `preferences` | A preference that is not applied, found when the session starts or by `reload_preferences()`. | | `track_deleted` | A deleted track that other tracks output to, send to or sidechain from. | | `dsp_not_rebuilt` | A `dsp effect` or `instrument` changed so that the instances that run it cannot take the new version. | | `screen_graph` | A screen graph that does not build, when no editor shows it. | | `section_lane_skipped` | A section lane that plays nothing, because its track is deleted or its target is not found. | | `unsupported_on_device` | `show_gui()` or `hide_gui()` on a built-in DSP effect, or `programs()` or `set_program()` on an effect or instrument that is not VST3. | | `external_clock_unprimed` | `set_midi_clock_source()` while `on_cycle` callbacks are set. Call `prime_cycles()` before playback. | | `midi_port_not_connected` | A MIDI track routed to a port that the preferences declare, but whose device is not connected. | | `render_leaves_out` | A render that leaves out of `master.wav` a track routed to hardware outputs. | | `midi_export_skips_track` | A `midi_export()` that leaves out of the file a track with no pattern. | | `main_not_called` | An entry file that defines `fn main()` and does not call it. Nothing calls `main()` on its own; `fn setup()` runs when the project opens. | | `kit_outside_project` | A `Kit("…")` found outside the project. It does not travel with the project. | | `version_mismatch` | A project that targets an older resonon than the one that runs it. The code plays. | A warning is located at the place in your code that ran when it was raised: the call that warned, or the statement. A warning raised between two evaluations, for example by an `on_cycle` callback, has no location, because the code may have changed since it ran. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#warnings Previous: reference/language/10-errors-and-warnings#kinds Next: reference/language/10-errors-and-warnings#screen-errors --- <!-- ID: reference/language/10-errors-and-warnings#when-code-stops --> Errors & Warnings > When code stops [reference] | Error | What runs | | --- | --- | | A parse error | Nothing of the file or selection. Every parse error in it is reported, up to 100. | | A definition repeated in one file or selection | Nothing of it. Every repeat is reported. | | Any other error | Everything before the statement that raised it. Its changes stay in the session; nothing is rolled back. See [The Error Model](/docs/explanation/language/04-the-error-model/). | | A warning | Everything; the warning is printed as `Warning: …`. | Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#when-code-stops Previous: reference/language/10-errors-and-warnings#where-an-error-is-shown Next: reference/language/10-errors-and-warnings#kinds --- <!-- ID: reference/language/10-errors-and-warnings#where-an-error-is-shown --> Errors & Warnings > Where an error is shown [reference] | Where | What it shows | | --- | --- | | `resonon run`, `resonon view console`, the REPL | The full text, with the location. A parse error adds the source line and a caret. | | VSCode Problems panel and underlines | The text without the location, underlined where it happened, with the kind's code beside it. | | `resonon check` | What the editor shows, as text, without running the code. See [Checking without running](#checking-without-running). | | `resonon run --message-format json`, `resonon check --message-format json` | One JSON object per line. See [Machine-readable output](#machine-readable-output). | A location is `path:line:column`, or `line:column` for code that has no file. Some errors have no location, and print their text alone. ```txt Parse error at /home/me/song/src/main.non:1:12: expected neg, pos, not, or primary | 1 | let x = 1 +; | ^ ``` `resonon run` exits with status `1` after an error. Page: reference/language/10-errors-and-warnings URL: https://resonon.org/docs/reference/language/10-errors-and-warnings/#where-an-error-is-shown Next: reference/language/10-errors-and-warnings#when-code-stops --- <!-- ID: reference/language/11-keywords --> Keywords [reference] Sections: - reference/language/11-keywords#reserved | Reserved - reference/language/11-keywords#dsp-words | DSP words Page: reference/language/11-keywords URL: https://resonon.org/docs/reference/language/11-keywords/ --- <!-- ID: reference/language/11-keywords#dsp-words --> Keywords > DSP words [reference] The words a [`dsp` definition](/docs/reference/dsp/01-dsp-blocks/) is made of, such as `effect`, `param`, `state`, `input`, `output`, `range` and `process`, are only keywords where that definition expects them. Everywhere else they are ordinary names. That includes the code inside a `dsp` definition, and functions such as `track.set_input(...)` and `range(...)`. ```resonon let state = 1; let input = range(0, 3); assert state == 1; ``` Page: reference/language/11-keywords URL: https://resonon.org/docs/reference/language/11-keywords/#dsp-words Previous: reference/language/11-keywords#reserved --- <!-- ID: reference/language/11-keywords#reserved --> Keywords > Reserved [reference] These words can never be a name. They can't be used for a variable, a function, a parameter, a class, a field, a method, an import alias, a loop label or a sample in a pattern. | Keyword | What it is | | ------- | ---------- | | `let` | Declares a variable. See [Variables & Scope](/docs/reference/language/02-variables-and-scope/) | | `fn` | Defines a function. See [Functions](/docs/reference/language/06-functions/) | | `return` | Leaves a function with a value. See [Functions](/docs/reference/language/06-functions/) | | `class` | Defines a class. See [Classes](/docs/reference/language/07-classes/) | | `native` | Marks a class whose values the engine makes. See [Classes](/docs/reference/language/07-classes/#native-classes) | | `interface` | Defines an interface. See [Classes](/docs/reference/language/07-classes/#interfaces) | | `implements` | Names the interfaces a class implements. See [Classes](/docs/reference/language/07-classes/#interfaces) | | `enum` | Defines an enum. See [Enums](/docs/reference/language/08-enums/) | | `use` | Imports a module. See [Modules](/docs/reference/language/09-modules/#use) | | `as` | Renames an import. See [Modules](/docs/reference/language/09-modules/#use) | | `private` | Keeps a definition out of a module's exports. See [Modules](/docs/reference/language/09-modules/#visibility) | | `dsp` | Starts a `dsp` definition. See [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) | | `if` | Runs code when a condition holds. See [Control Flow](/docs/reference/language/04-control-flow/#if--else) | | `else` | The other branch of an `if`. See [Control Flow](/docs/reference/language/04-control-flow/#if--else) | | `match` | Picks a branch by value. See [Control Flow](/docs/reference/language/04-control-flow/#match) | | `loop` | Repeats until `break`. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `do` | Repeats a set number of times. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `for` | Iterates. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `in` | Names what `for` iterates. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `break` | Leaves a loop. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `continue` | Starts a loop's next iteration. See [Control Flow](/docs/reference/language/04-control-flow/#loops) | | `assert` | Stops with an error when a condition fails. See [Control Flow](/docs/reference/language/04-control-flow/#assert) | | `true` | The Boolean true. See [Values & Types](/docs/reference/language/01-values-and-types/#booleans-and-truthiness) | | `false` | The Boolean false. See [Values & Types](/docs/reference/language/01-values-and-types/#booleans-and-truthiness) | | `NUL` | The absence of a value. See [Values & Types](/docs/reference/language/01-values-and-types/#nul) | | `PLAY` | Starts the play head. See [Transport](/docs/reference/running/02-transport/) | | `PAUSE` | Holds the play head where it is. See [Transport](/docs/reference/running/02-transport/) | | `STOP` | Returns the play head to the start. See [Transport](/docs/reference/running/02-transport/) | | `RESET` | Discards the whole session. See [Transport](/docs/reference/running/02-transport/) | | `RECORD` | Plays, and records the armed tracks. See [Transport](/docs/reference/running/02-transport/) | | `SEEK` | Moves the play head to a cycle. See [Transport](/docs/reference/running/02-transport/) | Using a keyword as a name is a parse error, reported at the word: ```resonon no-check let if = 7; // → Parse error at 1:5: `if` is a keyword and cannot be used as a name ``` A keyword only counts when it stands as a whole word, so `letter`, `iffy` and `PLAYING` are all ordinary names. Page: reference/language/11-keywords URL: https://resonon.org/docs/reference/language/11-keywords/#reserved Next: reference/language/11-keywords#dsp-words --- <!-- ID: reference/midi/01-midi-messages --> MIDI Messages [reference] Byte values are hexadecimal. Channels are numbered 1–16 in code and 0–15 in the status byte. Every message carries its own status byte; resonon never sends running status. The functions named here are in the [MIDI reference](/docs/reference/stdlib/midi/). Sections: - reference/midi/01-midi-messages#notes | Notes - reference/midi/01-midi-messages#control-change | Control change - reference/midi/01-midi-messages#pitch-bend | Pitch bend - reference/midi/01-midi-messages#mpe | MPE - reference/midi/01-midi-messages#clock | Clock - reference/midi/01-midi-messages#pause-stop-and-panic | Pause, stop and panic - reference/midi/01-midi-messages#timing | Timing - reference/midi/01-midi-messages#midi-export | MIDI export Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/ --- <!-- ID: reference/midi/01-midi-messages#clock --> MIDI Messages > Clock [reference] Sent when `set_midi_clock_send(true)` is on and the port's entry has `send_clock`. | Message | Byte | Sent | | --- | --- | --- | | Timing clock | `F8` | 24 per quarter note, from the audio thread | | Start | `FA` | Playback starts from the very top: `PLAY` or `RECORD` from stopped, a `SEEK` to `0` while playing | | Continue | `FB` | Playback starts anywhere else: `PLAY` or `RECORD` from paused, a `SEEK` while playing, a port that starts receiving clock while playing | | Stop | `FC` | `PAUSE`, `STOP`; a `SEEK` while playing, before the new position | | Song position | `F2 lsb msb` | Before every Continue: the first sixteenth at or after the play head. In sixteenths; it wraps at 16384 | In each audio buffer, transport messages go first, then clock ticks, then notes. Transport messages go out at the top of the buffer the play head starts, stops or lands in. Each tick is sent on the sample the play head reaches it, the rule notes follow, so a tick on a beat lands with that beat's notes. A tempo change bends the ticks with the music, with no burst and no gap. The first tick after Continue is the sixteenth its song position names. `set_midi_clock_source("alias")` follows the clock of an input port: | Message received | What resonon does | | --- | --- | | Start | Moves to the start, and plays from the next clock tick | | Stop | Pauses | | Song position | Keeps it for the next Continue | | Continue | Moves to the kept position exactly, if there is one, and plays from the next clock tick | | Clock tick | Tempo; and the play head's phase, which is steered onto the source by up to ±0.5 % in speed, never by a jump | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#clock Previous: reference/midi/01-midi-messages#mpe Next: reference/midi/01-midi-messages#pause-stop-and-panic --- <!-- ID: reference/midi/01-midi-messages#control-change --> MIDI Messages > Control change [reference] | Fact | Value | | --- | --- | | Message | `Bn controller value` | | Controller | `0`–`127` | | Value | `0`–`127`, rounded and clamped, from a number, pattern or signal | | From a signal | Sent only when the value changes, at most 30 times a second, or the rate set with `.set_send_rate()` | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#control-change Previous: reference/midi/01-midi-messages#notes Next: reference/midi/01-midi-messages#pitch-bend --- <!-- ID: reference/midi/01-midi-messages#midi-export --> MIDI Messages > MIDI export [reference] | Fact | Value | | --- | --- | | Resolution | 480 ticks per quarter note; a cycle is 4 quarter notes | | `midi_export(pattern, …)` | A type 0 file | | `midi_export(track, …)`, `midi_export(#[tracks], …)` | A type 1 file; the tempo is in the first track | | Default path | `renders/<name>_<date>_<time>/export.mid`, or `<track>.mid` for one track | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#midi-export Previous: reference/midi/01-midi-messages#timing --- <!-- ID: reference/midi/01-midi-messages#mpe --> MIDI Messages > MPE [reference] `.set_mpe(range, lo, hi)`: a lower zone with member channels `lo`–`hi`, default `2`–`16`. | Fact | Value | | --- | --- | | Zone message | On the first MPE note of a port: RPN 6 on channel 1, `B0 65 00`, `B0 64 06`, `B0 06 members`, `B0 26 00`, `B0 65 7F`, `B0 64 7F`, where `members` is the number of member channels | | Bend range | RPN 0 with the range on every member channel, sent with the zone message | | Channel for a note | The next member channel in turn; when all are busy, the one whose note ends soonest | | Per-note expression sent | Pitch bend only: no channel pressure, no CC 74 | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#mpe Previous: reference/midi/01-midi-messages#pitch-bend Next: reference/midi/01-midi-messages#clock --- <!-- ID: reference/midi/01-midi-messages#notes --> MIDI Messages > Notes [reference] | Fact | Value | | --- | --- | | Note-on | `9n note velocity` | | Note-off | `8n note 00`. A note-on with velocity `0` is never sent. | | Note number | Rounded, and clamped to `0`–`127` | | Velocity | `1`–`127`; a `0` from a pattern or `^0` plays at `1`. Default `100`. A `^v` in a pattern wins over the track's `.set_velocity()`. | | Velocity from a signal | Read when the note starts; rounded, and clamped to `1`–`127` | | Incoming note-on with velocity `0` | Read as a note-off | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#notes Next: reference/midi/01-midi-messages#control-change --- <!-- ID: reference/midi/01-midi-messages#pause-stop-and-panic --> MIDI Messages > Pause, stop and panic [reference] | Event | Sent | | --- | --- | | `PAUSE`, `STOP`, the start of playback | A note-off for every note resonon started that is still sounding, and pitch bend back to centre on every channel it bent | | `SEEK`, playing or paused; `section.play()`; `PLAY` after the audio device has been away | The same | | The third `STOP` in a row, and every `STOP` after it | The note-offs, then on all 16 channels of every open port CC 64 `0` (sustain off) and CC 123 (all notes off), then pitch bend centre | | An output port closed or unplugged | The note-offs, then on all 16 channels CC 64 `0` (sustain off) and CC 123 (all notes off), then pitch bend centre | | An input port disconnected | CC 123 on the output channel of every track playing it through | CC 120 (all sound off) is never sent. Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#pause-stop-and-panic Previous: reference/midi/01-midi-messages#clock Next: reference/midi/01-midi-messages#timing --- <!-- ID: reference/midi/01-midi-messages#pitch-bend --> MIDI Messages > Pitch bend [reference] | Fact | Value | | --- | --- | | Message | `En lsb msb`, 14 bits; centre `8192` (`00 40`) | | Range | `.set_tuning()` ±2 semitones; `.set_mpe()` ±48; either takes `0` < range ≤ `96` | | Range message | RPN 0: `Bn 65 00`, `Bn 64 00`, `Bn 06 semitones`, `Bn 26 00`, closed with RPN null `Bn 65 7F`, `Bn 64 7F` — before the first note on a channel when the range is not 2, and again whenever it changes | | Beyond the range | Clamped | | Order | Bend before the note-on; back to centre right after the note-off, on the same sample | Two microtonal notes that overlap on one channel, outside MPE, share one bend: resonon prints a warning. Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#pitch-bend Previous: reference/midi/01-midi-messages#control-change Next: reference/midi/01-midi-messages#mpe --- <!-- ID: reference/midi/01-midi-messages#timing --> MIDI Messages > Timing [reference] | Fact | Value | | --- | --- | | Timestamps | Every message is scheduled for when the audio it belongs with reaches the converter (`set_midi_latency(MidiLatency.auto)`, the default), plus the port's `trim_ms` — and for clock, `clock_trim_ms` | | Trims | `−500` to `500` ms; a value outside is ignored | | Linux | Ports are JACK MIDI ports. Each message is written in the JACK cycle, and at the frame, that its timestamp falls on | | Ports | At most 32 per session | | Thru | More than 2000 messages in 100 ms stops thru on that input for 1 second | | System exclusive | Not read or forwarded | Page: reference/midi/01-midi-messages URL: https://resonon.org/docs/reference/midi/01-midi-messages/#timing Previous: reference/midi/01-midi-messages#pause-stop-and-panic Next: reference/midi/01-midi-messages#midi-export --- <!-- ID: reference/patterns/01-mini-notation-grammar --> Mini-Notation Grammar [reference] Every token that can go inside pattern brackets. The examples below are fragments; a pattern goes to a track like this: ```resonon use "std/instruments" { Sampler, Kit }; // Create the track once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("TR-808"))); drums << [bd <sd [sd sd]>, ch*8, <_ oh>]; PLAY; ``` Sections: - reference/patterns/01-mini-notation-grammar#structure | Structure - reference/patterns/01-mini-notation-grammar#modifiers | Modifiers - reference/patterns/01-mini-notation-grammar#decorations | Decorations - reference/patterns/01-mini-notation-grammar#combining-order | Combining Order - reference/patterns/01-mini-notation-grammar#element-types | Element Types - reference/patterns/01-mini-notation-grammar#polymetric-groups | Polymetric Groups - reference/patterns/01-mini-notation-grammar#euclidean-rhythms | Euclidean Rhythms - reference/patterns/01-mini-notation-grammar#see-also | See Also Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/ --- <!-- ID: reference/patterns/01-mini-notation-grammar#combining-order --> Mini-Notation Grammar > Combining Order [reference] When several postfixes attach to one element they appear in a fixed order: ```txt element velocity euclid modifier C4 ^80 (3,8) *2 ``` So `C4^80(3,8)*2` is valid; reordering the postfixes is not. Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#combining-order Previous: reference/patterns/01-mini-notation-grammar#decorations Next: reference/patterns/01-mini-notation-grammar#element-types --- <!-- ID: reference/patterns/01-mini-notation-grammar#decorations --> Mini-Notation Grammar > Decorations [reference] Postfixes that shape *what* an element plays. These combine with each other and with a modifier. | Token | Name | Meaning | | ------------- | -------------- | ------------------------------------------------------------------- | | `^v` | Velocity | Strike velocity `1`–`127`, e.g. `C4^120`; `^0` plays at `1`. | | `(k,n)` | Euclidean | `k` pulses spread over `n` steps. | | `(k,n,r)` | Euclidean + rot| As above, rotated left by `r` steps, modulo `n`. | | `Root:Quality`| Chord | A chord, e.g. `C4:maj7`; add `~i` for inversion `i` (`C4:maj7~1`), `~-i` to invert downwards (`C4:maj~-1`). | | `^N` | Scale degree | Degree `N` of the current scale/key (see [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/)). | | `^N:Quality` | Degree chord | A chord built on scale degree `N`, with an optional `~i`. | | `^N:` | Diatonic chord | The key's own triad on degree `N`; `^N:~i` inverts it. | | `^bN`, `^#N` | Altered degree | Degree `N` a semitone lower or higher, e.g. `^b3`, `^#4`, `^b-2`. As a chord root it names its quality: `^b6:maj`. | | `.method(…)` | Sample method | Shape one sample hit; chains, e.g. `bd.vel(0.8).pan(0.5)`. | ```resonon parse-only let accented = [C4^120 C4^60 C4^60 C4^60]; // accent on beat 1 let euclid = [bd(3,8) sd(5,8,2)]; // euclidean kick + rotated snare let chords = [D4:min7 G4:7 C4:maj7~1]; // ii–V–I, last chord inverted let degrees = [^1 ^3 ^5 ^3]; // arpeggio over the current scale let diatonic = [^1: ^4: ^5:~1]; // the key's triads, the last inverted let borrowed = [^1: ^b6:maj ^b7:maj ^1:]; // bVI and bVII, borrowed from the parallel minor let lower = [c4 e4:min~-1]; // lower case; E minor inverted downwards let shaped = [bd.gain(1.2) sd.pitch(-5).pan(0.5)]; ``` Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#decorations Previous: reference/patterns/01-mini-notation-grammar#modifiers Next: reference/patterns/01-mini-notation-grammar#combining-order --- <!-- ID: reference/patterns/01-mini-notation-grammar#element-types --> Mini-Notation Grammar > Element Types [reference] What can sit in a slot: | Kind | Examples | Notes | | ----------- | --------------------------------- | -------------------------------------------------- | | Note | `C4`, `F#3`, `Bb-1`, `g9` | Scientific pitch; octaves `-1`–`9` (C4 = MIDI 60). Upper or lower case inside a pattern; upper case only outside one. | | Number | `60`, `-5`, `0.5` | Raw values for numeric patterns and automation. | | Sample | `bd`, `sd`, `hh` | Kit sample names; accept `.method(…)` postfixes. | | Chord | `C4:maj`, `a3:min7` | See the [chord qualities](/docs/reference/patterns/03-scales-chords-intervals/#chord-qualities). Only inside a pattern; outside one, use `chord()`. | | Scale degree| `^1`, `^-3`, `^b3`, `^5:min`, `^2:`| Resolved against the active scale/key. | | Rest | `_` | Silence for one slot. | Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#element-types Previous: reference/patterns/01-mini-notation-grammar#combining-order Next: reference/patterns/01-mini-notation-grammar#polymetric-groups --- <!-- ID: reference/patterns/01-mini-notation-grammar#euclidean-rhythms --> Mini-Notation Grammar > Euclidean Rhythms [reference] `(k,n)` spreads `k` hits over `n` steps as evenly as possible, inside the element's slot; the element sounds on the hits and rests on the other steps. `(k,n,r)` rotates the result left by `r` steps, modulo `n`. Like every modifier and decoration, `(k,n)` belongs to an element inside brackets: write `[<C4 E4>(5,16)]`, not `<C4 E4>(5,16)`. Outside brackets the same rhythm is the method `<C4 E4>.euclid(5,16)`. | Rotation | `(3,8,r)` | Hit steps | | -------- | ----------------- | --------- | | 0 | `x . . x . . x .` | 0, 3, 6 | | 2 | `. x . . x . x .` | 1, 4, 6 | | 3 | `x . . x . x . .` | 0, 3, 5 | Traditional cells written this way: | Pattern | Hits | Name | | -------- | --------------------------------- | ---------- | | `(3,4)` | `x x x .` | Cumbia | | `(3,8)` | `x . . x . . x .` | Tresillo | | `(5,8)` | `x . x x . x x .` | Cinquillo | | `(5,16)` | `x . . x . . x . . x . . x . . .` | Bossa nova | | `(7,16)` | `x . . x . x . x . . x . x . x .` | Samba | Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#euclidean-rhythms Previous: reference/patterns/01-mini-notation-grammar#polymetric-groups Next: reference/patterns/01-mini-notation-grammar#see-also --- <!-- ID: reference/patterns/01-mini-notation-grammar#modifiers --> Mini-Notation Grammar > Modifiers [reference] Postfix timing shorthand on a single element. **At most one per element.** | Token | Name | Effect | Example | Equivalent | | ----- | --------- | --------------------------------------------------- | ----------- | -------------- | | `*n` | Fast | Play `n` times **within** the slot (speeds up) | `bd*2` | `[bd bd]` | | `/n` | Slow | Stretch the element over `n` cycles in the slot | `[C4 D4]/2` | spans 2 cycles | | `@n` | Weight | Take an `n×` share of the cycle (plays once, longer)| `bd@2 sd` | bd 2/3, sd 1/3 | | `!n` | Replicate | Expand into `n` separate slots at normal speed | `bd!3` | `bd bd bd` | ```resonon parse-only let fast = [bd sd*2]; // sd plays twice inside its half let slow = [<C4 D4>/2 E4]; // the alternation advances every 2 cycles let weighted = [C4@3 D4]; // long C4, quick D4 let replicate = [bd!4]; // same as [bd bd bd bd] ``` `*n`, `/n`, and `@n` accept decimals (`*1.5`, `@2.5`). `*n` and `/n` take 0.0001 to 10000, the range of `.fast()` and `.slow()`; `@n` must be greater than 0 (`_` is a rest); `!n` takes integers only. Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#modifiers Previous: reference/patterns/01-mini-notation-grammar#structure Next: reference/patterns/01-mini-notation-grammar#decorations --- <!-- ID: reference/patterns/01-mini-notation-grammar#polymetric-groups --> Mini-Notation Grammar > Polymetric Groups [reference] `{ … }` gives every element one step. `%n` sets the steps per cycle; without it, a group has as many steps per cycle as its first voice has elements, or `1` for a group with one voice. A voice of `L` elements over `N` steps runs at `N / L` passes per cycle, and wraps when the two don't divide. | Pattern | Steps/cycle | Voice lengths | Passes/cycle | | ------------------- | ----------- | ------------- | ---------------- | | `{C4 D4 E4}` | 1 | 3 | 1/3 | | `{C4 D4 E4}%3` | 3 | 3 | 1 — as `[C4 D4 E4]` | | `{C4 D4 E4}%6` | 6 | 3 | 2 | | `{C4 E4 G4, F4 A4}` | 3 | 3, 2 | 1, 3/2 | Voices in `{ … }` share one grid of steps; voices in `[ … , … ]` each divide the cycle by their own length. Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#polymetric-groups Previous: reference/patterns/01-mini-notation-grammar#element-types Next: reference/patterns/01-mini-notation-grammar#euclidean-rhythms --- <!-- ID: reference/patterns/01-mini-notation-grammar#see-also --> Mini-Notation Grammar > See Also [reference] - [Your First Groove](/docs/tutorials/patterns/02-your-first-groove/) — the same syntax, step by step - [Polymeter & Euclidean Rhythm](/docs/explanation/patterns/04-polymeter-and-euclidean-rhythm/) — phasing meters and euclidean rhythms - [Pattern methods](/docs/reference/stdlib/patterns/) — `.fast()`, `.slow()`, `.reverse()` and the rest of the method API - [Scales, Chords & Intervals](/docs/reference/patterns/03-scales-chords-intervals/) — chord qualities and scale names Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#see-also Previous: reference/patterns/01-mini-notation-grammar#euclidean-rhythms --- <!-- ID: reference/patterns/01-mini-notation-grammar#structure --> Mini-Notation Grammar > Structure [reference] How elements are grouped and how time is divided. | Token | Name | Meaning | | ------------ | ----------------- | ----------------------------------------------------------------------- | | `[ … ]` | Sequence | Elements share the slot, each gets `slot / count`. Nest to subdivide. | | `,` | Parallel groups | Split a bracket into simultaneous voices, each on its own time grid. | | `< … >` | Alternation | One element per cycle, chosen by `cycle % count`; fills the whole slot. | | `{ … }` | Polymetric | Steps per cycle = length of the first group (or `1` for a single group).| | `{ … }%n` | Polymetric ÷ n | Force `n` steps per cycle regardless of group length. | | `_` | Rest | A silent slot. | ```resonon parse-only let sequence = [C4 D4 E4]; // three slots, 1/3 cycle each let nested = [[C4 D4] E4]; // C4,D4 in the first half; E4 in the second let parallel = [C4 D4, E4 F4 G4]; // two voices, 2-against-3 let alt = <C4 D4 E4>; // C4, then D4, then E4 — one per cycle let poly = {C4 D4 C4 E4}%3; // three steps per cycle, phasing over four let with_rest = [C4 _ E4 _]; // notes on slots 1 and 3 ``` A pattern nested in a slot plays exactly what it plays on its own, fitted into the slot. A pattern inside `< … >` advances one cycle each time its turn comes round, so every element of an inner alternation gets played: ```resonon parse-only let turns = <<C4 D4> E4>; // C4 E4 D4 E4, then repeats ``` Page: reference/patterns/01-mini-notation-grammar URL: https://resonon.org/docs/reference/patterns/01-mini-notation-grammar/#structure Next: reference/patterns/01-mini-notation-grammar#modifiers --- <!-- ID: reference/patterns/02-script-patterns --> Script Patterns [reference] A class that implements the `Pattern` interface is a pattern. Send an instance to a track with `<<` and resonon calls `query()` once per cycle. For worked examples, see [Write a Pattern as a Class](/docs/how-to/patterns/07-write-a-pattern-as-a-class/). Sections: - reference/patterns/02-script-patterns#the-interface | The interface - reference/patterns/02-script-patterns#where-the-instance-is-captured | Where the instance is captured - reference/patterns/02-script-patterns#the-call | The call - reference/patterns/02-script-patterns#return-values | Return values - reference/patterns/02-script-patterns#what-query-may-do | What query() may do Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/ --- <!-- ID: reference/patterns/02-script-patterns#return-values --> Script Patterns > Return values [reference] | Return value | Result | |:-------------|:-------| | Number (`60`) | A MIDI note filling the cycle | | Note (`C4`) | A note filling the cycle | | Array (`#[C4, E4, G4]`) | A chord — all notes sound together for the cycle | | Pattern (`[C4 E4 G4]`, or an instance of a class implementing `Pattern`) | A sub-pattern, laid out across the cycle | | `[_]` | A rest — silence for the cycle | Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/#return-values Previous: reference/patterns/02-script-patterns#the-call Next: reference/patterns/02-script-patterns#what-query-may-do --- <!-- ID: reference/patterns/02-script-patterns#the-call --> Script Patterns > The call [reference] For each cycle, the track: 1. Rebuilds the instance's fields by replaying `query()` for every earlier cycle, starting from the field values the instance had when it was sent to the track. 2. Calls `query(cycle)` with the cycle number (0, 1, 2, …). 3. Converts the return value into the events of that cycle. | Rule | Consequence | |:-----|:------------| | Fields assigned in `query()` carry to the next cycle. | `this.idx = this.idx + 1;` advances once per cycle. | | State is replayed from cycle 0. | The same cycle always returns the same result, in any order and after any seek. | | Fields are captured when the instance is sent to a track, or passed to a combinator. | Changing the original instance afterwards does not change the playing pattern. | | `cps` is in scope inside `query()`. | The current tempo, in cycles per second. | Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/#the-call Previous: reference/patterns/02-script-patterns#where-the-instance-is-captured Next: reference/patterns/02-script-patterns#return-values --- <!-- ID: reference/patterns/02-script-patterns#the-interface --> Script Patterns > The interface [reference] ```resonon no-check class Arp implements Pattern { fn query(cycle) -> Note | Number | Rest | Array | Pattern? { … } } ``` - The class defines `query` with one parameter named `cycle`, and declares its return type as the interface does. A class that does not conform is refused where it is defined. - A class with a `query` method that does not say `implements Pattern` is not a pattern: `<<` refuses it and names the fix. - The class has every combinator of `Pattern` (`.fast()`, `.transpose()`, `.stack()`, …), and every parameter typed `Pattern` takes its instances. Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/#the-interface Next: reference/patterns/02-script-patterns#where-the-instance-is-captured --- <!-- ID: reference/patterns/02-script-patterns#what-query-may-do --> Script Patterns > What query() may do [reference] `query()` runs in a restricted evaluator, so that it is deterministic and safe to run away from the main thread. | Supported | Not supported | |:----------|:--------------| | `let`, `if`/`else`, `match`, `return`, `for`, `loop` | `print()`, `put()` | | Arithmetic, field and array access | Audio and MIDI operations | | Calls to your own functions, methods and classes | Native functions | | Seeded `rand()` and `choose()` from `std/random` | | Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/#what-query-may-do Previous: reference/patterns/02-script-patterns#return-values --- <!-- ID: reference/patterns/02-script-patterns#where-the-instance-is-captured --> Script Patterns > Where the instance is captured [reference] A combinator, `<<` and a stdlib parameter typed `Pattern` each capture the instance as it is at that moment, fields and methods. A later write to the instance changes nothing already captured: ```resonon no-check let walk = Arp(#[C4, E4]); let fast = walk.fast(2); // captures walk now walk.notes = #[D4]; // fast still plays C4 and E4 ``` A function of your own that takes `p: Pattern` gets the instance itself, not a capture. Page: reference/patterns/02-script-patterns URL: https://resonon.org/docs/reference/patterns/02-script-patterns/#where-the-instance-is-captured Previous: reference/patterns/02-script-patterns#the-interface Next: reference/patterns/02-script-patterns#the-call --- <!-- ID: reference/patterns/03-scales-chords-intervals --> Scales, Chords & Intervals [reference] The names `Scale()`, `Key()`, `chord()`, `interval()` and chord literals accept. The functions and the `Scale` and `Key` types are in the [`std/theory` reference](/docs/reference/stdlib/theory/). Sections: - reference/patterns/03-scales-chords-intervals#scales | Scales - reference/patterns/03-scales-chords-intervals#chord-qualities | Chord qualities - reference/patterns/03-scales-chords-intervals#intervals | Intervals Page: reference/patterns/03-scales-chords-intervals URL: https://resonon.org/docs/reference/patterns/03-scales-chords-intervals/ --- <!-- ID: reference/patterns/03-scales-chords-intervals#chord-qualities --> Scales, Chords & Intervals > Chord qualities [reference] Accepted by `chord(root, quality)`, `key.chord(degree, quality)`, and chord literals (`C4:min7`, `^2:min7`). `chord_names()` returns the names. A chord literal writes each quality by its short name (`maj`, `min`, `5` for `major`, `minor`, `power`). Literals also accept five shorthands that `chord()` and `key.chord()` do not: `m` (`min`), `m7` (`min7`), `m9` (`min9`), `m6` (`min6`) and `dom` (`dom7`). | Quality | Aliases | Notes | Intervals (semitones) | Character | |:--------|:--------|:------|:----------------------|:----------| | `"major"` | `"maj"` | 3 | 0 4 7 | Bright, stable | | `"minor"` | `"min"` | 3 | 0 3 7 | Dark, melancholic | | `"dim"` | — | 3 | 0 3 6 | Tense, unstable | | `"aug"` | — | 3 | 0 4 8 | Bright, unsettled | | `"7"` | `"dom7"` | 4 | 0 4 7 10 | Bluesy, wants to resolve | | `"maj7"` | — | 4 | 0 4 7 11 | Lush, jazzy | | `"min7"` | — | 4 | 0 3 7 10 | Smooth, mellow | | `"dim7"` | — | 4 | 0 3 6 9 | Dramatic, symmetrical | | `"aug7"` | — | 4 | 0 4 8 10 | Altered dominant | | `"sus2"` | — | 3 | 0 2 7 | Open, ambiguous | | `"sus4"` | — | 3 | 0 5 7 | Suspended, tense | | `"6"` | `"maj6"` | 4 | 0 4 7 9 | Warm, vintage | | `"min6"` | — | 4 | 0 3 7 9 | Bittersweet | | `"9"` | — | 5 | 0 4 7 10 14 | Rich dominant | | `"maj9"` | — | 5 | 0 4 7 11 14 | Lush, expansive | | `"min9"` | — | 5 | 0 3 7 10 14 | Smooth, complex | | `"add9"` | — | 4 | 0 4 7 14 | Bright, open | | `"power"` | `"5"` | 2 | 0 7 | Neutral, heavy | ```resonon assert chord_names().length() == 18; print(chord(C4, "min7")); // [C4, Eb4, G4, Bb4] print(chord(C4, "power")); // [C4, G4] ``` An inversion (`chord(root, quality, n)`, or `~n` in a literal) moves the lowest `n` notes up an octave; a negative `n` moves the highest notes down. Page: reference/patterns/03-scales-chords-intervals URL: https://resonon.org/docs/reference/patterns/03-scales-chords-intervals/#chord-qualities Previous: reference/patterns/03-scales-chords-intervals#scales Next: reference/patterns/03-scales-chords-intervals#intervals --- <!-- ID: reference/patterns/03-scales-chords-intervals#intervals --> Scales, Chords & Intervals > Intervals [reference] Accepted by `interval(note, name)`. Case matters: `"M3"` is a major third, `"m3"` a minor third. | Name | Aliases | Interval | Semitones | |:-----|:--------|:---------|:----------| | `"m2"` | — | Minor 2nd | 1 | | `"M2"` | — | Major 2nd | 2 | | `"m3"` | — | Minor 3rd | 3 | | `"M3"` | — | Major 3rd | 4 | | `"P4"` | — | Perfect 4th | 5 | | `"tritone"` | `"TT"` | Tritone | 6 | | `"P5"` | — | Perfect 5th | 7 | | `"m6"` | — | Minor 6th | 8 | | `"M6"` | — | Major 6th | 9 | | `"m7"` | — | Minor 7th | 10 | | `"M7"` | — | Major 7th | 11 | | `"P8"` | `"oct"` | Octave | 12 | ```resonon assert interval(C4, "P5") == G4; assert interval(C4, "TT") == interval(C4, "tritone"); print(interval(C4, "m3")); // Eb4 ``` Page: reference/patterns/03-scales-chords-intervals URL: https://resonon.org/docs/reference/patterns/03-scales-chords-intervals/#intervals Previous: reference/patterns/03-scales-chords-intervals#chord-qualities --- <!-- ID: reference/patterns/03-scales-chords-intervals#scales --> Scales, Chords & Intervals > Scales [reference] Accepted by `Scale(name)`, `Key(root, name)` and `track.set_key(name, root)`. `scale_names()` returns the names, without the aliases. | Scale | Aliases | Notes | Intervals (semitones) | Character | |:------|:--------|:------|:----------------------|:----------| | `"major"` | `"ionian"` | 7 | 0 2 4 5 7 9 11 | Bright, happy, resolved | | `"minor"` | `"aeolian"` | 7 | 0 2 3 5 7 8 10 | Dark, melancholic | | `"dorian"` | — | 7 | 0 2 3 5 7 9 10 | Minor with a bright 6th | | `"phrygian"` | — | 7 | 0 1 3 5 7 8 10 | Spanish, exotic | | `"lydian"` | — | 7 | 0 2 4 6 7 9 11 | Dreamy, floating | | `"mixolydian"` | — | 7 | 0 2 4 5 7 9 10 | Bluesy major, rock | | `"locrian"` | — | 7 | 0 1 3 5 6 8 10 | Unstable, diminished | | `"harmonic_minor"` | — | 7 | 0 2 3 5 7 8 11 | Classical tension | | `"melodic_minor"` | — | 7 | 0 2 3 5 7 9 11 | Jazz minor | | `"pentatonic_major"` | — | 5 | 0 2 4 7 9 | Open, folk | | `"pentatonic_minor"` | — | 5 | 0 3 5 7 10 | Blues, rock riffs | | `"blues"` | — | 6 | 0 3 5 6 7 10 | Gritty, soulful | | `"whole_tone"` | — | 6 | 0 2 4 6 8 10 | Dreamlike, ambiguous | | `"chromatic"` | — | 12 | 0 1 2 3 4 5 6 7 8 9 10 11 | All semitones | ```resonon assert scale_names().length() == 14; assert Scale("pentatonic_minor").length() == 5; print(Scale("ionian").intervals()); // [0, 2, 4, 5, 7, 9, 11] — the major scale ``` A custom scale is an interval array starting at `0` and strictly ascending; fractional values are microtonal. `Scale(intervals, period)` sets a repeat period other than 12 semitones. `load_scala(name)` reads a Scala `.scl` file. Page: reference/patterns/03-scales-chords-intervals URL: https://resonon.org/docs/reference/patterns/03-scales-chords-intervals/#scales Next: reference/patterns/03-scales-chords-intervals#chord-qualities --- <!-- ID: reference/running/01-vscode-extension --> VSCode Extension [reference] The extension evaluates code on a resonon server and bundles the language server. A walk-through is [Live Coding Workflow](/docs/tutorials/running/01-live-coding-workflow/). Sections: - reference/running/01-vscode-extension#key-bindings | Key bindings - reference/running/01-vscode-extension#commands | Commands - reference/running/01-vscode-extension#evaluation-and-transport | Evaluation and transport - reference/running/01-vscode-extension#project | Project - reference/running/01-vscode-extension#servers | Servers - reference/running/01-vscode-extension#views-plugins-and-preferences | Views, plugins and preferences - reference/running/01-vscode-extension#sidebar | Sidebar - reference/running/01-vscode-extension#settings | Settings - reference/running/01-vscode-extension#status-bar | Status bar - reference/running/01-vscode-extension#language-features | Language features - reference/running/01-vscode-extension#live-mode-and-file-mode | Live Mode and File Mode - reference/running/01-vscode-extension#diagnostics | Diagnostics - reference/running/01-vscode-extension#formatting | Formatting - reference/running/01-vscode-extension#quick-fixes | Quick fixes - reference/running/01-vscode-extension#ui-parameter-values-in-code | UI parameter values in code - reference/running/01-vscode-extension#versions | Versions Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/ --- <!-- ID: reference/running/01-vscode-extension#commands --> VSCode Extension > Commands [reference] Every command is in the command palette, prefixed `RESONON:`. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#commands Previous: reference/running/01-vscode-extension#key-bindings Next: reference/running/01-vscode-extension#evaluation-and-transport --- <!-- ID: reference/running/01-vscode-extension#diagnostics --> VSCode Extension > Diagnostics [reference] Parse errors, undefined names and wrong argument counts are underlined as you type; runtime errors are underlined after you evaluate, and clear at your next evaluation. Both are in the Problems panel. A name defined twice at the top level of a file, or defined and also imported with `use`, is marked only in [File Mode](#live-mode-and-file-mode). In Live Mode, evaluating a new definition further down is how you change one. A name repeated inside one definition, such as two methods `m` in a class, or inside a module the file imports, is marked in both modes: either is always evaluated whole. Every kind and its severity: [Errors & Warnings](/docs/reference/language/10-errors-and-warnings/). In `resonon.toml`, each `[local] kits` entry is followed by a note: `in this project`, `on this machine`, `travels anyway` or `missing`. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#diagnostics Previous: reference/running/01-vscode-extension#live-mode-and-file-mode Next: reference/running/01-vscode-extension#formatting --- <!-- ID: reference/running/01-vscode-extension#evaluation-and-transport --> VSCode Extension > Evaluation and transport [reference] | Command | What it does | | --- | --- | | Run Selection Live | Runs the selection, or the line the cursor is on. Connects first if needed. | | Run File Live | Saves edited files, then evaluates the whole entry file of the project into the running session. It does not reset the session or call `setup()`. Not a session undo step. | | Play / Pause | `PLAY` when stopped or paused, `PAUSE` when playing. | | Stop | `STOP`. | | Reset | `RESET`: discards the session. | Both evaluate commands are also in the editor's title bar. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#evaluation-and-transport Previous: reference/running/01-vscode-extension#commands Next: reference/running/01-vscode-extension#project --- <!-- ID: reference/running/01-vscode-extension#formatting --> VSCode Extension > Formatting [reference] | Rule | | | --- | --- | | Indentation | One level per open bracket, in the editor's tab size, with spaces or a tab as the editor is set | | Continuation | A line starting with `.` is indented one more level | | Blank lines | At most 2 in a row; none at the end | | Trailing whitespace | Removed | | End of file | Exactly one newline | | Line endings | CRLF kept if most lines use it | | Unchanged | Line breaks, spacing inside a line, comments, and lines that start inside a string or `/* */` comment | A file that does not parse is left unchanged. `resonon.toml` is not formatted. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#formatting Previous: reference/running/01-vscode-extension#diagnostics Next: reference/running/01-vscode-extension#quick-fixes --- <!-- ID: reference/running/01-vscode-extension#key-bindings --> VSCode Extension > Key bindings [reference] | Key | Command | Active when | | --- | --- | --- | | `Cmd+Enter` (`Ctrl+Enter` on Windows and Linux) | Run Selection Live | A resonon editor has focus | | `Cmd+Shift+Enter` (`Ctrl+Shift+Enter` on Windows and Linux) | Run File Live | A resonon editor has focus | | `F5` | Play / Pause | A resonon file is open | | `Shift+F5` | Stop. Three in a row cut everything still sounding | A resonon file is open | | `Ctrl+Shift+F5` | Reset | A resonon file is open | What each transport command does: [Transport](/docs/reference/running/02-transport/). Reset Project has no key binding. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#key-bindings Next: reference/running/01-vscode-extension#commands --- <!-- ID: reference/running/01-vscode-extension#language-features --> VSCode Extension > Language features [reference] The language server works on `.non` files and on `resonon.toml`. | Feature | How | What it does | | --- | --- | --- | | Hover | Point at a name | The type, signature and documentation of a variable, function, class, method or module member. | | Completion | Type, or `Ctrl+Space` | Keywords and names; methods after a `.`; parameter names in `.parameter("…")` and `.set_parameter("…")`; effect slot names in `.effect("…")`; module paths in `use "…"` and names in its `{ … }`. | | Signature help | Type `(` or `,` | The parameters of the function being called, including module functions (`gfx.Visual(`) and DSP builtins inside a `dsp` block. | | Go to Definition | `Cmd+Click` or `F12` | Jumps to where a name is defined, in the file, a module or the standard library. On the path string of `gfx.load_shader(...)` or `load_file(...)` it opens that file. | | Find All References | `Shift+F12` | Every use of the name in the current file. | | Rename Symbol | `F2` | Renames the name in the current file. Refused on a keyword, and for a new name that is not an identifier or is a keyword. | | Format Document | `Shift+Alt+F` | Re-indents the whole file; see below. | | Inlay hints | — | `name:` before each positional argument of a call to your own function, class or method. | | Outline | Outline view, breadcrumbs | Functions, classes and their methods, `dsp` declarations, `let` bindings and `use`s. | | Diagnostics | — | Underlines errors; see below. | | Quick fixes | `Cmd+.` (`Ctrl+.`) | See below. | Completion of values, effect slots and parameters reads the state of the session after your last evaluation; in File Mode, it offers only names in the file. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#language-features Previous: reference/running/01-vscode-extension#status-bar Next: reference/running/01-vscode-extension#live-mode-and-file-mode --- <!-- ID: reference/running/01-vscode-extension#live-mode-and-file-mode --> VSCode Extension > Live Mode and File Mode [reference] The editor reads code in one of two modes, and switches between them on its own. The [status bar](#status-bar) shows which. | Mode | When | What the editor reads | | --- | --- | --- | | **File Mode** (offline) | Nothing has been evaluated yet, and again after `RESET`, or when the server stops or crashes | The file, as one program run top to bottom | | **Live Mode** (online) | From the first evaluation, in any file | The session: the file is a scratchpad of selections, each evaluated on its own | Each evaluation of any file switches every open file to Live Mode, because definitions belong to the whole session. A server that crashed is noticed at your next edit. Rename and Find All References work on the current file, match methods by name only, and skip strings and comments. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#live-mode-and-file-mode Previous: reference/running/01-vscode-extension#language-features Next: reference/running/01-vscode-extension#diagnostics --- <!-- ID: reference/running/01-vscode-extension#project --> VSCode Extension > Project [reference] | Command | What it does | | --- | --- | | Reset Project | Saves edited files, then opens the project of the active file again from its files: `teardown()`, `RESET`, the saved session, then the entry file with `setup()`. Asks first when the session has changes since the last save, and when tracks were renamed since the code named them. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). | | Save Project Session | Saves the session into the project's `session/` folder. | | Collect and Save Project Session | Copies external samples into the project, then saves the session. | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#project Previous: reference/running/01-vscode-extension#evaluation-and-transport Next: reference/running/01-vscode-extension#servers --- <!-- ID: reference/running/01-vscode-extension#quick-fixes --> VSCode Extension > Quick fixes [reference] | Where | Fix | | --- | --- | | An undefined name | **Did you mean `X`?** — the closest defined name, including DSP builtins inside a `dsp` block | | A `Kit("…")` whose kit is outside the project | **Copy 'k' into this project**; **List 'k' under [local] in resonon.toml** | | A `[local] kits` entry | **Copy 'k' into this project** (for a kit on this machine, outside the project); **Remove 'k' from resonon.toml** | | A misspelled key in `resonon.toml` | **Rename to `key`** | | A plugin that was skipped after a crash | **Retry** *plugin* — opens the plugin again | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#quick-fixes Previous: reference/running/01-vscode-extension#formatting Next: reference/running/01-vscode-extension#ui-parameter-values-in-code --- <!-- ID: reference/running/01-vscode-extension#servers --> VSCode Extension > Servers [reference] | Command | What it does | | --- | --- | | Connect to Server | Connects to the active server; with several known, offers a list; with none known, starts a local one. | | Disconnect from Server | Disconnects from the active server. | | Start Server | Starts a local server and connects to it. | | Stop Server | Stops the active server. | | Add Server... | Adds a server by host and port. | | Refresh Servers | Refreshes the **Servers** view. | | Connect to Server... | Connects to the server clicked in the **Servers** view. | | Disconnect | Disconnects from the server clicked in the **Servers** view. | | Set as Active Server | Makes a connected server the one evaluations go to. | | Stop Server Process | Stops a server this window started. | | Remove Server | Removes a server added by hand. | | Set Display Name | Sets the name other clients see for you. | | Toggle Output Filter (Own / All) | Shows only your own output, or every client's. | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#servers Previous: reference/running/01-vscode-extension#project Next: reference/running/01-vscode-extension#views-plugins-and-preferences --- <!-- ID: reference/running/01-vscode-extension#settings --> VSCode Extension > Settings [reference] | Setting | Default | What it is | | --- | --- | --- | | `resonon.server.path` | `""` | The `resonon` binary. Empty searches `PATH`. A path into one version (`~/.resonon/versions/<v>/bin/resonon`) bypasses the launcher, so projects' pinned versions no longer apply. | | `resonon.server.port` | `5555` | Port of a server the extension starts. | | `resonon.client.name` | `""` | Your display name. Empty uses your system user name. | | `resonon.lsp.enabled` | `true` | The [language features](#language-features). | | `resonon.lsp.path` | `""` | The `resonon-lsp` binary. Empty searches `PATH`. A path into one version gives every project that version. | | `resonon.audio.multicore` | `false` | Render audio on several CPU cores, in a server the extension starts. | | `resonon.plugins.autoScan` | `true` | Keep the plugin database up to date automatically. | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#settings Previous: reference/running/01-vscode-extension#sidebar Next: reference/running/01-vscode-extension#status-bar --- <!-- ID: reference/running/01-vscode-extension#sidebar --> VSCode Extension > Sidebar [reference] The resonon icon in the activity bar opens four views: | View | Contents | | --- | --- | | Servers | Every server found on the network, started from this window, or added by hand. Click to connect. | | Server Controls | Start and stop the server, reset, preferences, plugin rescan, add a server, connect, disconnect, display name. | | Transport | Play / pause, stop, Run Selection Live, Run File Live, Reset Project. | | Views | Console, mixer, routing, MIDI monitor, scope, visuals. | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#sidebar Previous: reference/running/01-vscode-extension#views-plugins-and-preferences Next: reference/running/01-vscode-extension#settings --- <!-- ID: reference/running/01-vscode-extension#status-bar --> VSCode Extension > Status bar [reference] The **RESONON** item shows the connection: | Text | State | Click | | --- | --- | --- | | `$(circle-slash) RESONON` | Disconnected | Connect | | `$(sync~spin) RESONON` | Connecting or reconnecting | — | | `$(circle-filled) RESONON: studio (as Alice) $(pulse) 12%` | Connected, with the server's name, your display name and the audio CPU load | Server menu | The **LSP** item shows the language server of the current file, its version and, while it runs, the [mode](#live-mode-and-file-mode), for example `$(check) LSP 0.14.0 · Live`: | Text | State | | --- | --- | | `$(sync~spin) LSP 0.14.0` | Starting | | `$(check) LSP 0.14.0 · File` | Running, in File Mode | | `$(check) LSP 0.14.0 · Live` | Running, in Live Mode | | `$(circle-slash) LSP 0.14.0` | Stopped | | `$(error) LSP 0.14.0` | Failed. Click to retry | Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#status-bar Previous: reference/running/01-vscode-extension#settings Next: reference/running/01-vscode-extension#language-features --- <!-- ID: reference/running/01-vscode-extension#ui-parameter-values-in-code --> VSCode Extension > UI parameter values in code [reference] In Live Mode, a parameter changed in the Mixer or the Devices panel shows its current value beside the last executed argument that set it. **Write UI value into code** replaces that numeric literal when you choose the action. It does not evaluate the code. Running the original line again restores the coded value and clears the hint. Variables and expressions still show the value, but the action explains that only numeric literals can be rewritten. Hints are hidden if the executed source lines have changed, or if the editor is in File Mode. The UI never edits source by itself. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#ui-parameter-values-in-code Previous: reference/running/01-vscode-extension#quick-fixes Next: reference/running/01-vscode-extension#versions --- <!-- ID: reference/running/01-vscode-extension#versions --> VSCode Extension > Versions [reference] Each project gets its own language server, running the version its `resonon.toml` pins. Files outside a project share one running your default version. If a project pins a version you don't have, a notification offers to install it. The server you evaluate on runs one version: that of the project it was started from. Code from a project that needs a newer version is refused, with an offer to restart the server for that project when that version is installed. Code from a project that targets an older version runs, with a warning the first time in a session. Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#versions Previous: reference/running/01-vscode-extension#ui-parameter-values-in-code --- <!-- ID: reference/running/01-vscode-extension#views-plugins-and-preferences --> VSCode Extension > Views, plugins and preferences [reference] | Command | What it does | | --- | --- | | Open Console | Server output, in a terminal. | | Open Resonon Window | Opens the main window on the server. | | Open Routing | Audio and MIDI routing, in a terminal. | | Open Scope | An oscilloscope on the output, in a terminal. | | Open MIDI Monitor | All MIDI on this machine, in a terminal. Needs no server. | | Open Visuals | The native visuals window of the active server. | | Rescan Plugins | Scans the plugin folders for new and changed plugins. | | Rescan Plugins (Full) | Opens every plugin again, including those skipped after a crash. | | Retry Skipped Plugins... | Opens chosen skipped plugins again. | | Open Preferences | Opens `~/.resonon/preferences.toml`. | | Restart Language Server | Restarts the language server of the current file. | The terminal views are the ones `resonon view` opens; see the [CLI reference](/docs/reference/setup/01-cli/#resonon-view-name). Page: reference/running/01-vscode-extension URL: https://resonon.org/docs/reference/running/01-vscode-extension/#views-plugins-and-preferences Previous: reference/running/01-vscode-extension#servers Next: reference/running/01-vscode-extension#sidebar --- <!-- ID: reference/running/02-transport --> Transport [reference] The transport statements drive the session's play head. They are statements, not function calls, and end with `;`. In VSCode, `F5`, `Shift+F5` and `Ctrl+Shift+F5` send them ([key bindings](/docs/reference/running/01-vscode-extension/#key-bindings)). | Statement | Play head | Sound | Session | | --- | --- | --- | --- | | `PLAY;` | Runs on from where it is | Plays | Kept | | `PAUSE;` | Stays where it is | Notes are released; tails ring out | Kept | | `STOP;` | Returns to the start | Notes are released; tails ring out | Kept | | `STOP;` three times | At the start | Cut: see below | Kept | | `RECORD;` | Runs on from where it is | Plays, and records armed tracks | Kept | | `SEEK n;` | Moves to cycle `n` | Unchanged | Kept | | `RESET;` | — | Everything stops | Discarded | In a [file run](/docs/reference/running/03-file-runs/) the statements do the same, and the run ends after the file's last statement, with playback. ```resonon PLAY; PAUSE; PLAY; SEEK 16; STOP; ``` Sections: - reference/running/02-transport#play | PLAY - reference/running/02-transport#pause | PAUSE - reference/running/02-transport#stop | STOP - reference/running/02-transport#record | RECORD - reference/running/02-transport#seek | SEEK - reference/running/02-transport#reset | RESET Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/ --- <!-- ID: reference/running/02-transport#pause --> Transport > PAUSE [reference] Stops playback and keeps the play head where it is. Every sounding note gets a note-off. The next `PLAY` runs on from the same place. Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#pause Previous: reference/running/02-transport#play Next: reference/running/02-transport#stop --- <!-- ID: reference/running/02-transport#play --> Transport > PLAY [reference] Starts playback from the play head. Cycle callbacks are run for the current cycle first, so the first cycle is not empty. Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#play Next: reference/running/02-transport#pause --- <!-- ID: reference/running/02-transport#record --> Transport > RECORD [reference] Starts playback like `PLAY`, and records every armed track. With nothing armed it only plays. `STOP` ends the take; `PAUSE` does not. See [Record a Take](/docs/how-to/audio/12-record-a-take/). Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#record Previous: reference/running/02-transport#stop Next: reference/running/02-transport#seek --- <!-- ID: reference/running/02-transport#reset --> Transport > RESET [reference] Discards the whole session — every variable, track, instrument and effect — and starts a new, empty one. It is not a way to silence the music; three `STOP`s are. Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#reset Previous: reference/running/02-transport#seek --- <!-- ID: reference/running/02-transport#seek --> Transport > SEEK [reference] `SEEK n;` moves the play head to cycle `n`; `n` is any number expression, and below `0` means `0`. While playing, playback jumps there, and cycle callbacks run for that cycle first. Notes still sounding are released, as on `PAUSE`; reverb and delay tails ring on. While paused or stopped, the next `PLAY` starts from there. See [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/). Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#seek Previous: reference/running/02-transport#record Next: reference/running/02-transport#reset --- <!-- ID: reference/running/02-transport#stop --> Transport > STOP [reference] Stops playback and returns the play head to the start. It stops the transport, not the sound: reverb and delay tails ring out, and faders stay where they are. `STOP` while already stopped escalates. The third one in a row is a panic: every output fades to silence over a few milliseconds, every instrument and effect is flushed — reverb, delay lines, sounding voices — and every MIDI note resonon started that is still sounding gets its note-off. Then every open MIDI port gets sustain off and all notes off on all 16 channels, which also stops notes played through thru, and pitch bend goes back to centre. Tracks, instruments and patterns are kept. The messages sent are in [MIDI Messages](/docs/reference/midi/01-midi-messages/#pause-stop-and-panic). Page: reference/running/02-transport URL: https://resonon.org/docs/reference/running/02-transport/#stop Previous: reference/running/02-transport#pause Next: reference/running/02-transport#record --- <!-- ID: reference/running/03-file-runs --> File Runs [reference] `resonon run` opens the project without a window, evaluates an optional script in it, and exits. It runs from any directory inside the project. It opens the project as Open does in the editor: 1. It restores the saved session, if the project has one. 2. It binds the function definitions and `use` imports of the entry file. 3. It calls `fn setup()`, if the entry file defines it. 4. It runs the rest of the top level of the entry file. Then it evaluates the script, if you name one. The script path is relative to the working directory. The names that the top level of the entry file defines are in scope in the script. The entry file is `src/main.non`, or the file `entry` names under `[package]` in [`resonon.toml`](/docs/reference/setup/04-resonon-toml/#package). The options are in [Command Line](/docs/reference/setup/01-cli/#running-code). When each part of the entry file runs is in [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). ```bash resonon run resonon run scripts/bounce.non resonon run --no-midi scripts/bounce.non ``` `resonon run` does not connect to a live server. To evaluate the entry file in a live session, use Run File Live. `resonon send` with no source sends it for the project in the working directory. Run Selection Live from a shell with the same `send` command: ```bash resonon send resonon send --code 'print(7);' printf 'print(7);' | resonon send - resonon send src/main.non --lines 4-8 ``` These commands edit the running session incrementally. Use `resonon save` to save it. Sections: - reference/running/03-file-runs#what-it-opens | What it opens - reference/running/03-file-runs#start-and-end | Start and end - reference/running/03-file-runs#what-it-writes | What it writes - reference/running/03-file-runs#exit-status | Exit status - reference/running/03-file-runs#related | Related Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/ --- <!-- ID: reference/running/03-file-runs#exit-status --> File Runs > Exit status [reference] See the shared [exit-code contract](/docs/reference/setup/01-cli/#exit-codes). A project-open, parse, or runtime error fails the run. A missing project or entry file, a refused version pin, or an unreadable explicitly named script prevents the requested run. Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/#exit-status Previous: reference/running/03-file-runs#what-it-writes Next: reference/running/03-file-runs#related --- <!-- ID: reference/running/03-file-runs#related --> File Runs > Related [reference] - [Two Ways to Run a Piece](/docs/explanation/running/01-two-ways-to-run-a-piece/) — live and file runs - [Render a Project](/docs/how-to/running/02-render-a-project/) — writing WAV files - [Errors & Warnings](/docs/reference/language/10-errors-and-warnings/) — what an error prints Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/#related Previous: reference/running/03-file-runs#exit-status --- <!-- ID: reference/running/03-file-runs#start-and-end --> File Runs > Start and end [reference] | | | | --- | --- | | Start | The saved session, if the project has one (as `resonon open`), otherwise an empty one; transport stopped | | `fn setup()` | Called after the definitions and imports of the entry file, before the rest of its top level, if the file defines it | | Script | Evaluated after the top level of the entry file, if you name one | | Transport | `PLAY`, `STOP` and the other [transport statements](/docs/reference/running/02-transport/) run as they do live | | `sleep(s)` | The piece plays for `s` seconds before the next statement. `on_cycle` callbacks fire and `print()` output appears while it does, as in a live session. | | End | After the last statement of the script, or of the entry file when there is no script. Playback, recording and MIDI clock stop with it. The session closes and calls `fn teardown()`, if the entry file defines it. | | `RESET` | Ends the run there. What follows it does not run. | Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/#start-and-end Previous: reference/running/03-file-runs#what-it-opens Next: reference/running/03-file-runs#what-it-writes --- <!-- ID: reference/running/03-file-runs#what-it-opens --> File Runs > What it opens [reference] | | In a file run | | --- | --- | | Preferences | `~/.resonon/preferences.toml`, read once, when the run starts | | Audio device | The one `[audio]` names, as live. With no device, a line says so and the run goes on; `render()` needs none. | | MIDI ports | The declared `[[midi.outputs]]` and `[[midi.inputs]]`. None with `--no-midi`. | | Plugin sweep | In the background, unless auto-scan is off | | Server | None | | Visuals window | None, unless the piece calls `screen.show()` | | Scope window | None, unless the piece calls `scope_show()` | Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/#what-it-opens Next: reference/running/03-file-runs#start-and-end --- <!-- ID: reference/running/03-file-runs#what-it-writes --> File Runs > What it writes [reference] Nothing but what the piece asks for: audio where it calls `render()`, into the project's `renders/` ([Audio Files](/docs/reference/audio/01-levels-and-files/#audio-files)), and MIDI where it calls `midi_export()`. `print()` goes to standard output, errors to standard error. Page: reference/running/03-file-runs URL: https://resonon.org/docs/reference/running/03-file-runs/#what-it-writes Previous: reference/running/03-file-runs#start-and-end Next: reference/running/03-file-runs#exit-status --- <!-- ID: reference/running/04-repl --> REPL [reference] `resonon` with no file opens the REPL, in the project of the working directory. Its flags are in the [CLI reference](/docs/reference/setup/01-cli/). Sections: - reference/running/04-repl#input | Input - reference/running/04-repl#commands | Commands - reference/running/04-repl#keys | Keys Page: reference/running/04-repl URL: https://resonon.org/docs/reference/running/04-repl/ --- <!-- ID: reference/running/04-repl#commands --> REPL > Commands [reference] These words are read by the REPL itself, alone on a line, in capitals: | Command | What it does | | --- | --- | | `EXIT` | Leaves the REPL. | | `RESET` | Discards the session and prints `Session reset.` — as the [`RESET;` statement](/docs/reference/running/02-transport/#reset). | | `RELOAD name` | Loads the native extension `name` again — as `reload_ext("name")`. Without a name: `Usage: RELOAD <extension_name>`. | The [transport statements](/docs/reference/running/02-transport/) work as they do in a file run and from VSCode. Page: reference/running/04-repl URL: https://resonon.org/docs/reference/running/04-repl/#commands Previous: reference/running/04-repl#input Next: reference/running/04-repl#keys --- <!-- ID: reference/running/04-repl#input --> REPL > Input [reference] The prompt is `> `. Each line is evaluated when you press `Enter`, on its own: a statement cannot continue on the next line. A line that does not end in `;` or `}` gets a `;` added, so `PLAY` runs `PLAY;`. Only the text before the first `//` is looked at for this. Output of `print()` from a cycle callback, and errors raised there, are printed between prompts. Page: reference/running/04-repl URL: https://resonon.org/docs/reference/running/04-repl/#input Next: reference/running/04-repl#commands --- <!-- ID: reference/running/04-repl#keys --> REPL > Keys [reference] | Key | What it does | | --- | --- | | `Enter` | Evaluates the line | | `Ctrl+C` | Discards the line and shows a new prompt | | `Ctrl+D` | Leaves the REPL | | `↑` / `↓` | The previous and next lines of this session | | `Ctrl+R` | Searches the lines of this session | | `←` / `→`, `Ctrl+A` / `Ctrl+E` | Moves in the line, to its start or end | The history is kept only while the REPL runs; nothing is written to disk. Page: reference/running/04-repl URL: https://resonon.org/docs/reference/running/04-repl/#keys Previous: reference/running/04-repl#commands --- <!-- ID: reference/running/05-terminal-views --> Terminal Views [reference] `resonon view <name>` opens a view in the terminal; VSCode's **Open …** commands open the same views. The names and flags are in the [CLI reference](/docs/reference/setup/01-cli/#resonon-view-name). | View | Shows | Needs a server | | --- | --- | --- | | `console` | The server's output | Yes | | `routing` | Audio and MIDI routing, per track | Yes | | `scope` | Each signal passed to [`scope()`](/docs/reference/stdlib/audio/#scope), one lane each | Yes | | `midi_monitor` | All MIDI on this machine | No | In every view, `q` or `Ctrl+C` quits. When the connection drops, the view returns to the connect screen and shows why. Sections: - reference/running/05-terminal-views#connect-screen | Connect screen - reference/running/05-terminal-views#console | console - reference/running/05-terminal-views#mixer | Mixer - reference/running/05-terminal-views#routing | routing - reference/running/05-terminal-views#scope | scope - reference/running/05-terminal-views#midi_monitor | midi_monitor Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/ --- <!-- ID: reference/running/05-terminal-views#connect-screen --> Terminal Views > Connect screen [reference] A view that needs a server opens on a list of the servers found on the network, unless it was given `--host` or `--port`. Either flag connects directly; a missing host is `127.0.0.1` and a missing port is `5555`. Loopback-only servers do not advertise; use the Manual field or connect directly. A server leaves the list 6 seconds after it was last heard. | Focus | Key | What it does | | --- | --- | --- | | Server list | `↑` / `↓` | Selects a server | | | `Enter` | Connects to the selected server | | | `Tab` | Moves to the address field | | | `q` | Quits | | Address field (`host:port`) | Typing, `Backspace` | Edits the address | | | `Enter` | Connects to the address | | | `Tab` | Returns to the server list | | | `Esc` | Leaves the field | | Anywhere | `Ctrl+C` | Quits | Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#connect-screen Next: reference/running/05-terminal-views#console --- <!-- ID: reference/running/05-terminal-views#console --> Terminal Views > console [reference] | Key | What it does | | --- | --- | | `↑` / `↓` | Scrolls one line | | `PgUp` / `PgDn` | Scrolls 20 lines | | `Home` | Goes to the top | | `End` | Goes to the bottom, and follows new output again | | `f` | Shows only your own output, or every client's | | `c` | Clears | Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#console Previous: reference/running/05-terminal-views#connect-screen Next: reference/running/05-terminal-views#mixer --- <!-- ID: reference/running/05-terminal-views#midi_monitor --> Terminal Views > midi_monitor [reference] | Key | What it does | | --- | --- | | `↑` / `↓`, `PgUp` / `PgDn`, `Home` / `End` | Scrolls, as in `console` | | `a` | Turns following new messages on or off | | `c` | Clears | | `Tab` | Opens the port list | | `f` | Opens the filter menu | In the port list: | Key | What it does | | --- | --- | | `↑` / `↓` | Selects a port | | `Space`, `Enter` | Starts or stops listening to the port | | `r` | Looks for ports again | | `Tab`, `Esc` | Closes the list | In the filter menu, `↑` / `↓` select, `Space` or `Enter` turns a filter on or off, and `f` or `Esc` closes it. The filters are Notes, CC, Program Change, Pitch Bend, Aftertouch, and System (clock, start, stop). Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#midi_monitor Previous: reference/running/05-terminal-views#scope --- <!-- ID: reference/running/05-terminal-views#mixer --> Terminal Views > Mixer [reference] The Mixer is a collapsible panel in the main window, below the transport bar and the Arrangement. `resonon app` opens the application. In Neovim, `:Resonon view` opens the main window on the configured server's desktop. It connects first if needed, but does not start a server. Its controls are in [Use the Mixer](/docs/how-to/running/13-use-the-mixer/) and [Use the Arrangement and Transport](/docs/how-to/running/14-use-the-arrangement/). Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#mixer Previous: reference/running/05-terminal-views#console Next: reference/running/05-terminal-views#routing --- <!-- ID: reference/running/05-terminal-views#routing --> Terminal Views > routing [reference] | Key | What it does | | --- | --- | | `↑` / `↓` | Selects a track | | `←` / `→` | Scrolls | | `Enter` | Opens the selected track | | `Tab` | Switches between the global view and the track | | `Esc` | Goes back to the global view | Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#routing Previous: reference/running/05-terminal-views#mixer Next: reference/running/05-terminal-views#scope --- <!-- ID: reference/running/05-terminal-views#scope --> Terminal Views > scope [reference] Keys act on the selected lane. | Key | What it does | | --- | --- | | `↑` / `↓` | Selects a lane | | `j` / `k` | Doubles or halves the vertical range, from 0.125× to 64× the signal's range | | `l` / `h` | Doubles or halves the time shown, from 1× to 128× | | `b` | Shows the lane from `0` or from `−max` to `max` | Page: reference/running/05-terminal-views URL: https://resonon.org/docs/reference/running/05-terminal-views/#scope Previous: reference/running/05-terminal-views#routing Next: reference/running/05-terminal-views#midi_monitor --- <!-- ID: reference/running/06-network --> Network [reference] The flags and environment variables that set these are in the [CLI reference](/docs/reference/setup/01-cli/). A server shared with other people is set up in [Run a Shared Server](/docs/how-to/running/01-run-a-shared-server/). Sections: - reference/running/06-network#ports | Ports - reference/running/06-network#discovery | Discovery - reference/running/06-network#trust-and-access | Trust and access - reference/running/06-network#connection | Connection Page: reference/running/06-network URL: https://resonon.org/docs/reference/running/06-network/ --- <!-- ID: reference/running/06-network#connection --> Network > Connection [reference] The server pings every client every 30 seconds. VSCode tries to reconnect 3 times after the connection drops; a terminal view returns to its connect screen. Page: reference/running/06-network URL: https://resonon.org/docs/reference/running/06-network/#connection Previous: reference/running/06-network#trust-and-access --- <!-- ID: reference/running/06-network#discovery --> Network > Discovery [reference] Loopback-only binds send no beacon. Network-bound servers send the following beacon: | Fact | Value | | --- | --- | | Sent | Once a second, on the loopback interface: only views and editors on the same machine receive it | | Content | JSON: `service` (`"resonon"`), `ws_port`, `name` | | `name` | `--name`, or the machine's host name | | Listeners | The terminal views' connect screen and VSCode's **Servers** view, on loopback and the default interface | | Removed from the list | 6 s after the last beacon in a terminal view; 4 s in VSCode, for a server not connected | A server that discovery does not reach is added by address: **Add Server...** in VSCode, the address field of the connect screen, or `--host` and `--port`. Page: reference/running/06-network URL: https://resonon.org/docs/reference/running/06-network/#discovery Previous: reference/running/06-network#ports Next: reference/running/06-network#trust-and-access --- <!-- ID: reference/running/06-network#ports --> Network > Ports [reference] | Port | Protocol | Use | Set with | | --- | --- | --- | --- | | `5555` | TCP, WebSocket (`ws://`, no TLS) | Clients: VSCode, terminal views | `--port`; VSCode: `resonon.server.port` | | `5556` | UDP multicast, group `239.255.82.78` | Discovery beacon | Fixed | The server binds `127.0.0.1` for this machine only by default. Use `--host` to bind another address, such as `0.0.0.0` for every interface. When it is ready it prints: ```txt [server] Listening on 127.0.0.1:5555 ``` The language server opens no port; it talks to VSCode over stdio. Page: reference/running/06-network URL: https://resonon.org/docs/reference/running/06-network/#ports Next: reference/running/06-network#discovery --- <!-- ID: reference/running/06-network#trust-and-access --> Network > Trust and access [reference] The loopback default limits direct network exposure; local programs remain trusted. Any program that can connect can control the session. Explicit network binding provides no authentication or encryption (`ws://`, not TLS). Loopback binding does not provide browser-origin protection. Page: reference/running/06-network URL: https://resonon.org/docs/reference/running/06-network/#trust-and-access Previous: reference/running/06-network#discovery Next: reference/running/06-network#connection --- <!-- ID: reference/running/07-neovim --> Neovim [reference] :::caution[Experimental] The Neovim integration is experimental. Its keys and settings may change. ::: The plugin plays a `.non` file on a resonon server, as the [VSCode extension](/docs/reference/running/01-vscode-extension/) does, and starts the language server for it. It needs Neovim 0.12 or later, with `resonon` and `resonon-lsp` on your `PATH`. Sections: - reference/running/07-neovim#install | Install - reference/running/07-neovim#keys | Keys - reference/running/07-neovim#commands | Commands - reference/running/07-neovim#while-you-type | While you type - reference/running/07-neovim#statusline | Statusline - reference/running/07-neovim#settings | Settings - reference/running/07-neovim#test-the-window-command | Test the window command Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/ --- <!-- ID: reference/running/07-neovim#commands --> Neovim > Commands [reference] | Command | What it does | | --- | --- | | `:Resonon eval` | Evaluates the line the cursor is on, or a range: `:'<,'>Resonon eval`. | | `:Resonon run` | Run File Live: writes changed buffers, then evaluates the whole entry file into the running session, without `RESET` or `setup()`. | | `:Resonon reset` | Reset Project: writes changed buffers, then opens the project again from its files: `teardown()`, `RESET`, the saved session, then the entry file with `setup()`. Asks first when the session has changes since the last save, and when tracks were renamed since the code named them. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). | | `:Resonon play`, `stop` | Transport. `play` pauses when playing. | | `:Resonon output` | Shows or hides the output buffer. | | `:Resonon view {name}` | Opens `console`, `routing`, `scope` or `midi_monitor` in a terminal split; omit the name to open the main window. See [Terminal Views](/docs/reference/running/05-terminal-views/) and [Use the Mixer](/docs/how-to/running/13-use-the-mixer/). | | `:Resonon connect`, `disconnect` | Connects to the configured server, or drops the connection. | | `:Resonon server start`, `stop` | Starts or stops a server in the current project. A server the plugin started stops when Neovim exits. | Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#commands Previous: reference/running/07-neovim#keys Next: reference/running/07-neovim#while-you-type --- <!-- ID: reference/running/07-neovim#install --> Neovim > Install [reference] The plugin is `editors/nvim` in a checkout of the [resonon repository](https://github.com/WARNS-AUDIO/RESONON/). With [lazy.nvim](https://github.com/folke/lazy.nvim): ```lua { dir = "/path/to/resonon/editors/nvim", ft = "resonon", opts = {}, } ``` With any other plugin manager, add `editors/nvim` to the runtime path. `require("resonon").setup()` is needed only to change a default. Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#install Next: reference/running/07-neovim#keys --- <!-- ID: reference/running/07-neovim#keys --> Neovim > Keys [reference] | Key | Action | Modes | | --- | --- | --- | | `Ctrl+E` | Evaluate the selection, or the line the cursor is on | Normal, visual, select, insert | | `Ctrl+Enter`, `Cmd+Enter` | The same, where the terminal tells them apart from `Enter` | Normal, visual, select, insert | | `<LocalLeader>e` | The same | Normal, visual | | `Ctrl+Shift+Enter`, `Cmd+Shift+Enter` | Run File Live, where the terminal tells them apart from `Enter`: write changed buffers, then evaluate the whole entry file into the running session, without `RESET` or `setup()` | Normal, select, insert | | `<LocalLeader>f` | The same | Normal | | `F5`, `<LocalLeader>p` | Play / Pause | Normal (`F5` also select and insert) | | `Shift+F5`, `<LocalLeader>s` | Stop | Normal (`Shift+F5` also select and insert) | | `Ctrl+Shift+F5` | Reset the server (`RESET`) | Normal, select, insert | Reset Project has no default key; use `:Resonon reset`, or give `reset_project` a key in [`keymaps`](#settings). `Ctrl+E` reaches Neovim in every terminal. `Ctrl+Enter` and `Cmd+Enter`, the VSCode keys, and their `Shift` forms reach it in kitty, WezTerm, Ghostty and Neovide; in other terminals they are a plain `Enter`. The selection stays after it is evaluated, so the same code can be evaluated again. The evaluated lines flash. The first evaluation connects to the server, and starts one in the project when none is listening. What the code prints goes to the output buffer, and an error is shown on the line where it happened. What each transport action does: [Transport](/docs/reference/running/02-transport/). Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#keys Previous: reference/running/07-neovim#install Next: reference/running/07-neovim#commands --- <!-- ID: reference/running/07-neovim#settings --> Neovim > Settings [reference] The defaults: ```lua require("resonon").setup({ cmd = "resonon", lsp = { enabled = true, cmd = "resonon-lsp", autocomplete = true, signature_help = true, inlay_hints = true, }, server = { host = "127.0.0.1", port = 5555, autostart = true, -- start a server in the project when none is listening }, client_name = nil, -- the name other clients see; defaults to your login name audio = { multicore = false }, plugins = { auto_scan = true }, show_all_output = false, -- also show what other clients print flash_ms = 150, -- 0 turns the flash off keymaps = { run_selection_live = { "<C-e>", "<C-CR>", "<D-CR>", "<LocalLeader>e" }, run_file_live = { "<C-S-CR>", "<D-S-CR>", "<LocalLeader>f" }, play_pause = { "<F5>", "<LocalLeader>p" }, stop = { "<S-F5>", "<LocalLeader>s" }, reset = "<C-S-F5>", }, }) ``` `keymaps = false` sets no keys, and an action set to `false` gets none. `reset_project` has no default key; set it in `keymaps` to give Reset Project one. A key with `Ctrl` or `Cmd`, or a function key, is also set in select and insert mode. The flash uses the `ResononFlash` highlight group. Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#settings Previous: reference/running/07-neovim#statusline Next: reference/running/07-neovim#test-the-window-command --- <!-- ID: reference/running/07-neovim#statusline --> Neovim > Statusline [reference] `require("resonon").statusline()` gives the connection, the CPU load and the session mode (Live or File): ```lua vim.o.statusline = "%f %m%=%{%v:lua.require'resonon'.statusline()%} " ``` Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#statusline Previous: reference/running/07-neovim#while-you-type Next: reference/running/07-neovim#settings --- <!-- ID: reference/running/07-neovim#test-the-window-command --> Neovim > Test the window command [reference] From the repository root, run the headless regression tests: ```sh nvim --headless -u NONE -l editors/nvim/tests/view.lua ``` The tests control the connection and process boundaries. They require no server, project, audio device or desktop. Unnamed `:Resonon view` connects to the configured server before requesting its main window. It does not start a server, even when `server.autostart` is enabled. Named terminal views keep their existing commands. Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#test-the-window-command Previous: reference/running/07-neovim#settings --- <!-- ID: reference/running/07-neovim#while-you-type --> Neovim > While you type [reference] The language server starts for each project, from the project's folder. Some of what it offers shows without being asked for, as in VSCode: | Feature | When it shows | | --- | --- | | Completion | On a name, and after `.`, `(`, `,`, `"` and `{`; not in a comment. `Ctrl+N` and `Ctrl+P` move through it, and `Ctrl+Y` takes an item. | | Signature help | Above the cursor while it is inside a call, with the current argument highlighted. | | Inlay hints | Always. | With blink.cmp or nvim-cmp installed, completion is left to that plugin; signature help is left to blink.cmp when its signature is enabled. Hover, go to definition, references, rename, formatting and code actions are on Neovim's own keys: `K`, `Ctrl+]`, `grr`, `grn`, `gq` and `gra`. Page: reference/running/07-neovim URL: https://resonon.org/docs/reference/running/07-neovim/#while-you-type Previous: reference/running/07-neovim#commands Next: reference/running/07-neovim#statusline --- <!-- ID: reference/setup/01-cli --> Command Line [reference] The `resonon` binary runs a project, drops into a REPL, or manages the runtime around it (server, views, versions, plugins). This page covers the runtime CLI. The project and package commands (`init`, `new`, `install`, …) are under [Project & Package Commands](#project--package-commands). Sections: - reference/setup/01-cli#exit-codes | Exit codes - reference/setup/01-cli#running-code | Running Code - reference/setup/01-cli#options | Options - reference/setup/01-cli#resonon-server | resonon server - reference/setup/01-cli#resonon-view-name | resonon view NAME - reference/setup/01-cli#resonon-version | resonon version - reference/setup/01-cli#resonon-version-list | resonon version list - reference/setup/01-cli#resonon-version-install | resonon version install - reference/setup/01-cli#resonon-version-switch | resonon version switch - reference/setup/01-cli#resonon-version-current | resonon version current - reference/setup/01-cli#resonon-plugin | resonon plugin - reference/setup/01-cli#resonon-plugin-scan | resonon plugin scan - reference/setup/01-cli#resonon-plugin-rescan | resonon plugin rescan - reference/setup/01-cli#resonon-plugin-list | resonon plugin list - reference/setup/01-cli#resonon-setup | resonon setup - reference/setup/01-cli#resonon-config | resonon config - reference/setup/01-cli#resonon-config-paths | resonon config paths - reference/setup/01-cli#resonon-config-kits | resonon config kits - reference/setup/01-cli#resonon-config-kits-add | resonon config kits add - reference/setup/01-cli#resonon-config-kits-remove | resonon config kits remove - reference/setup/01-cli#resonon-config-kits-list | resonon config kits list - reference/setup/01-cli#resonon-config-plugins | resonon config plugins - reference/setup/01-cli#resonon-config-plugins-add | resonon config plugins add - reference/setup/01-cli#resonon-config-plugins-remove | resonon config plugins remove - reference/setup/01-cli#resonon-config-plugins-list | resonon config plugins list - reference/setup/01-cli#project--package-commands | Project & Package Commands - reference/setup/01-cli#resonon-init | resonon init - reference/setup/01-cli#resonon-new | resonon new - reference/setup/01-cli#resonon-build | resonon build - reference/setup/01-cli#resonon-install | resonon install - reference/setup/01-cli#resonon-update | resonon update - reference/setup/01-cli#resonon-remove | resonon remove - reference/setup/01-cli#resonon-collect | resonon collect - reference/setup/01-cli#resonon-kits | resonon kits - reference/setup/01-cli#resonon-kits-list | resonon kits list - reference/setup/01-cli#resonon-kits-remove | resonon kits remove - reference/setup/01-cli#resonon-run | resonon run - reference/setup/01-cli#resonon-check | resonon check - reference/setup/01-cli#resonon-send | resonon send - reference/setup/01-cli#resonon-save | resonon save - reference/setup/01-cli#resonon-open | resonon open - reference/setup/01-cli#resonon-analyze | resonon analyze - reference/setup/01-cli#resonon-reference | resonon reference - reference/setup/01-cli#resonon-reference-search | resonon reference search - reference/setup/01-cli#resonon-reference-read | resonon reference read - reference/setup/01-cli#resonon-app | resonon app - reference/setup/01-cli#resonon-client | resonon client - reference/setup/01-cli#resonon-pkg | resonon pkg - reference/setup/01-cli#resonon-pkg-install | resonon pkg install - reference/setup/01-cli#resonon-pkg-list | resonon pkg list - reference/setup/01-cli#resonon-pkg-inspect | resonon pkg inspect - reference/setup/01-cli#resonon-pkg-update | resonon pkg update - reference/setup/01-cli#environment-variables | Environment Variables - reference/setup/01-cli#startup-sequence | Startup Sequence - reference/setup/01-cli#see-also | See Also Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/ --- <!-- ID: reference/setup/01-cli#environment-variables --> Command Line > Environment Variables [reference] Each is read once at startup. Where a flag or VSCode setting does the same, it is listed beside it. | Variable | Accepts | Description | | --- | --- | --- | | `RESONON_HEADLESS` | 1, true, yes, on / 0, false, no, off (case-insensitive) | Run without opening audio hardware. The graph remains available for offline rendering; transport has no audio callback. Default: off. | | `RESONON_PARALLEL` | 1, true, yes, on / 0, false, no, off (case-insensitive) | Multicore audio rendering. Default: off. Flag: `--multicore[=<BOOL>]`. VSCode: `resonon.audio.multicore`. | | `RESONON_PLUGIN_AUTO_SCAN` | 1, true, yes, on / 0, false, no, off (case-insensitive) | The plugin sweep at startup. Off makes scanning strictly manual. Default: on. Flag: `--plugin-auto-scan=<BOOL>`. VSCode: `resonon.plugins.autoScan`. | | `RESONON_SUBPROCESS_SCAN` | 1, true, yes, on / 0, false, no, off (case-insensitive) | Plugin scanning in an isolated child process. Off opens bundles in resonon's own process: a debugging aid that gives up crash isolation, so a plugin that dies on load takes the session with it. Default: on. | | `RESONON_WORKERS` | a whole number, 1 or more | Audio worker threads. | | `RESONON_SPIN_BUDGET` | a whole number, 0 or more | How long an idle audio worker spins before it parks. | | `RESONON_LOG` | a level for resonon (warn, info, debug, trace), and/or target=level for another crate, comma-separated, e.g. debug,naga=info | The log filter. Falls back to `RUST_LOG`, then `info`. Warnings from resonon and errors from any crate are always shown. | | `RESONON_RELEASE_BASE_URL` | anything | Release download base URL. Defaults to the published release service; used by the launcher when installing a version. | | `RESONON_HOME` | an absolute path to a directory, or to nothing yet | The resonon home, `~/.resonon` by default. See [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/). | | `RESONON_STDLIB_PATH` | an absolute path to a directory that is there | A standard library of your own, in place of the one that ships with this build. | Every variable follows the same rules: - **The environment variable wins, then the flag, then the default.** - On/off is `1`, `true`, `yes` or `on` against `0`, `false`, `no` or `off`, in any case. - **Unset and empty mean the same thing:** not given. `RESONON_WORKERS=` falls through to the default. - **A value resonon cannot read stops it starting**, naming the variable and what it takes: ``` Error: RESONON_PARALLEL=ture is not a boolean. Accepted: 1, true, yes, on / 0, false, no, off (case-insensitive). ``` - **Except a location.** An unusable `RESONON_HOME` or `RESONON_STDLIB_PATH` is ignored, the default stands, and the startup says so: | | Nothing there yet | Something else there, or a relative path | | --- | --- | --- | | `RESONON_HOME` | Applied: resonon makes it. | Ignored; `~/.resonon` stands. | | `RESONON_STDLIB_PATH` | Ignored; the shipped standard library stands. | Ignored; the shipped standard library stands. | Both are settled once, when the process starts. `resonon config paths` prints the directory that was actually taken. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#environment-variables Previous: reference/setup/01-cli#resonon-pkg-update Next: reference/setup/01-cli#startup-sequence --- <!-- ID: reference/setup/01-cli#exit-codes --> Command Line > Exit codes [reference] Every `resonon` command uses the same exit-code contract: | Code | Meaning | | --- | --- | | `0` | Done: the requested work completed successfully. | | `1` | Ran and failed: code or a check found errors, a project failed to open, or a file the command discovered could not be read or drawn. Operational failures, such as compilation, downloads, writes, or a stopped or unsaved plugin sweep, also use this code. | | `2` | Could not be attempted: invalid usage or an unreadable environment knob; a refused version pin; a missing project, entry file, or build prerequisite; an explicitly named input that cannot be read; a connection failure; or a named server without this project's session. | Warnings and notes alone do not fail a check. A skipped, blocklisted plugin bundle alone does not fail a discovery sweep. For a rescan of several named paths, invalid input takes precedence over a failed scan, and every path is attempted. The launcher uses the same contract. A failure before the selected binary starts exits 2; once the binary runs, the launcher preserves its exit status. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#exit-codes Next: reference/setup/01-cli#running-code --- <!-- ID: reference/setup/01-cli#options --> Command Line > Options [reference] ```text resonon [OPTIONS] [COMMAND] ``` | Argument | Default | Description | | --- | --- | --- | | `--list-ports` | false | List available MIDI ports (with paste-ready declarations) and exit | | `--no-midi` | false | Disable MIDI entirely. Port declarations still succeed and still get a stable alias, so a piece evaluates identically with and without hardware — nothing is opened and nothing is sent. For CI and headless rendering | | `--multicore[=<MULTICORE>]` | — | Enable multicore audio rendering. `--multicore` or `--multicore=true` turns it on; `--multicore=false` off; omit for the default (off). `RESONON_PARALLEL` overrides this flag. An explicit value requires `=` | | `--plugin-auto-scan[=<PLUGIN_AUTO_SCAN>]` | — | Sweep the plugin folders in the background at startup. Default: on. `--plugin-auto-scan=false` disables the sweep; a bare flag enables it. `RESONON_PLUGIN_AUTO_SCAN` overrides this flag. An explicit value requires `=` | | `-h, --help` | — | Print help | | `-V, --version` | — | Print version | ```bash resonon run # run the project's src/main.non resonon --list-ports # see attached MIDI devices resonon run --no-midi # run with MIDI disabled (CI, headless) resonon # start the REPL ``` :::note `--multicore` and `--plugin-auto-scan` take their value with `=` only. A space-separated value is read as a command: `resonon --plugin-auto-scan false` is refused, because `false` is not one. The `RESONON_PARALLEL` and `RESONON_PLUGIN_AUTO_SCAN` environment variables override these flags when set. ::: Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#options Previous: reference/setup/01-cli#running-code Next: reference/setup/01-cli#resonon-server --- <!-- ID: reference/setup/01-cli#project--package-commands --> Command Line > Project & Package Commands [reference] These scaffold projects and manage dependencies. The tasks are in [Install a Package](/docs/how-to/setup/03-install-a-package/), [Publish a Package](/docs/how-to/setup/04-publish-a-package/) and [Share a Project](/docs/how-to/setup/05-share-a-project/). Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#project--package-commands Previous: reference/setup/01-cli#resonon-config-plugins-list Next: reference/setup/01-cli#resonon-init --- <!-- ID: reference/setup/01-cli#resonon-analyze --> Command Line > resonon analyze [reference] ```text resonon analyze [OPTIONS] <PATH> ``` Measure rendered audio: levels, loudness, clipping, stereo and bands The mixer's meters, run over a WAV file, or over every WAV in a folder such as `renders/<name>_<datetime>/` (master first, then the stems). Nothing is played; no device is opened. Sample peak and RMS are the mixer meter's own: the largest |x|, and the root of the mean square with the whole file as the window. A full-scale sine reads 0 dBFS peak and -3.01 dBFS RMS. Crest factor is peak minus RMS. The file's RMS is the mean power of its channels. True peak (dBTP): ITU-R BS.1770-4 Annex 2, oversampled 4x below 96 kHz, 2x below 192 kHz. The file is taken as silence before and after, so a file that starts or stops abruptly can read above its sample peak at the edge, as a DAC would play it. Loudness (LUFS): BS.1770-4 K-weighting and gating. Integrated loudness is gated at -70 LUFS and -10 LU; momentary (400 ms) and short-term (3 s) maxima are taken at a 100 ms step; loudness range (LU) is EBU Tech 3342. DC offset is the channel mean, in percent of full scale; the furthest from zero is shown. Clipped samples are at or beyond full scale. Leading and trailing silence is the time before the first and after the last sample above -60 dBFS. Stereo files: correlation is +1 for mono, 0 for unrelated channels and -1 for opposite polarity. S/M is the side energy against the mid energy in dB: -inf for mono content, 0 for equal energy. Bands: sub below 60 Hz, low 60-250 Hz, low mid 250 Hz-2 kHz, high mid 2-6 kHz, high above 6 kHz. Measured on a Welch spectrum (Hann window, 50% overlap, about 6 Hz resolution). Each band has its level, in dBFS RMS, and its share of the file's energy. The shares add up to 100%. Spectrograms (--spectrogram VIEW, repeatable): one PNG per view, `<name>.<view>.png` beside each WAV. Time left to right over the whole file; frequency bottom to top, log scale, 20 Hz to 20 kHz; level as colour, fixed from -120 to 0 dBFS, so pictures compare across files and runs. A full-scale sine reads 0 dBFS. The spectrum is a Hann window of about 85 ms. Each column keeps the loudest moment in it, so short transients show in long files. A WAV that `render` bounced has its tempo beside it in `<name>.wav.json`, and its cycles are numbered along the top. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `<PATH>` | — | A WAV file, or a folder of them | | `--spectrogram <VIEW>` | — | Draw a spectrogram of this view of each file: `all` (the mean energy of every channel), `left`, `right`, `mid` ((L+R)/2) or `side` ((L-R)/2). A mono file plays on both sides: its `side` is silent. Repeat for more views | | `--format <FORMAT>` | human | How the measurements are printed. `human`: a table of levels and a table of bands, one row per file. `json`: one object on one line, `{"silence_threshold_dbfs", "files": [...]}`, with each key's unit in its name (`true_peak_dbtp`) and per-channel values in `per_channel`. A level of no signal (-inf dB) and a value that cannot be measured are `null`. A file that cannot be read is `{"path", "error"}`. Each file lists its pictures in `spectrograms`: `{"view", "path"}`, or `{"view", "error"}` | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-analyze Previous: reference/setup/01-cli#resonon-open Next: reference/setup/01-cli#resonon-reference --- <!-- ID: reference/setup/01-cli#resonon-app --> Command Line > resonon app [reference] ```text resonon app [OPTIONS] [PROJECT] ``` Open Resonon as an app: its own session and main window, in the Dock The session runs on a server of its own, on a free loopback port; no other server is joined or stopped. Closing the window or quitting asks to save first. A project folder or its `.resonon` document opens the project: its saved session, then its entry file. `Resonon.app` starts this way when opened from Finder or the Dock. | Argument | Default | Description | | --- | --- | --- | | `[PROJECT]` | — | Project folder or `.resonon` document to open | | `--no-midi` | false | Disable MIDI entirely. Port declarations still succeed and still get a stable alias, so a piece evaluates identically with and without hardware — nothing is opened and nothing is sent. For CI and headless rendering | | `--multicore[=<MULTICORE>]` | — | Enable multicore audio rendering. `--multicore` or `--multicore=true` turns it on; `--multicore=false` off; omit for the default (off). `RESONON_PARALLEL` overrides this flag. An explicit value requires `=` | | `--plugin-auto-scan[=<PLUGIN_AUTO_SCAN>]` | — | Sweep the plugin folders in the background at startup. Default: on. `--plugin-auto-scan=false` disables the sweep; a bare flag enables it. `RESONON_PLUGIN_AUTO_SCAN` overrides this flag. An explicit value requires `=` | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-app Previous: reference/setup/01-cli#resonon-reference-read Next: reference/setup/01-cli#resonon-client --- <!-- ID: reference/setup/01-cli#resonon-build --> Command Line > resonon build [reference] ```text resonon build [OPTIONS] ``` Build native extension | Argument | Default | Description | | --- | --- | --- | | `--dist` | false | Output with platform-specific name for binary distribution | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-build Previous: reference/setup/01-cli#resonon-new Next: reference/setup/01-cli#resonon-install --- <!-- ID: reference/setup/01-cli#resonon-check --> Command Line > resonon check [reference] ```text resonon check [OPTIONS] [FILE] ``` Check the project, or one file, without running it What the editor shows, from the same analysis: syntax, undefined names and methods, arity, types, and the modules each file imports. Nothing runs, and no audio or MIDI device is opened. With no source, checks the project's src/main.non and src/lib.non; `-` checks code read from stdin. `--lines` checks just that selection, with the session's names. Whole files follow the editor's Live/File mode: Live while the server holds this project's session, one that runs in the project or has run a file from it. Reports the mode used (the final JSON `complete` has a `mode` field, `live` or `file`, and in File Mode a `reason`). Warnings and notes do not fail the check. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `[FILE]` | — | Source file, or `-` to read code from stdin | | `--code <CODE>` | — | Code to execute or check instead of a file | | `--lines <LINES>` | — | Inclusive 1-based file lines, for example `4-12` | | `--host <HOST>` | — | Check against this server's session instead of the editor's selected one | | `--port <PORT>` | — | Check against this server's session instead of the editor's selected one | | `--message-format <MESSAGE_FORMAT>` | human | How errors, warnings and output are printed. `json`: one JSON object per line on stdout, in the form the server sends its clients — `output`, `warning`, `error`, `notice`, `rendered`, `visual_diagnostic`, and a final `complete` with the outcome. After valid argument parsing, startup and launcher refusals write an `error` and exactly one failed `complete` with the same request ID. Argument usage errors retain stderr output. The exit code does not change | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-check Previous: reference/setup/01-cli#resonon-run Next: reference/setup/01-cli#resonon-send --- <!-- ID: reference/setup/01-cli#resonon-client --> Command Line > resonon client [reference] ```text resonon client [OPTIONS] ``` Bridge a running server to stdin/stdout, for editor integrations Each line read from stdin is one JSON message sent to the server; each message the server sends is written to stdout as one line of JSON. The messages are the server's own protocol, unchanged. Ends when stdin closes or the server closes the connection. | Argument | Default | Description | | --- | --- | --- | | `--port <PORT>` | 5555 | Server port | | `--host <HOST>` | 127.0.0.1 | Server host | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-client Previous: reference/setup/01-cli#resonon-app Next: reference/setup/01-cli#resonon-pkg --- <!-- ID: reference/setup/01-cli#resonon-collect --> Command Line > resonon collect [reference] ```text resonon collect [KIT] ``` Copy a kit into the project so it travels with it A kit resolved out of your own library plays here and is missing on the machine you send this project to. This brings it in — the name in your code does not change, because `<project>/kits` is searched first. With no argument, collects every kit `resonon.toml` declares. | Argument | Default | Description | | --- | --- | --- | | `[KIT]` | — | Kit to collect (omit to collect everything declared in resonon.toml) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-collect Previous: reference/setup/01-cli#resonon-remove Next: reference/setup/01-cli#resonon-kits --- <!-- ID: reference/setup/01-cli#resonon-config --> Command Line > resonon config [reference] ```text resonon config <COMMAND> ``` Inspect the active configuration Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config Previous: reference/setup/01-cli#resonon-setup Next: reference/setup/01-cli#resonon-config-paths --- <!-- ID: reference/setup/01-cli#resonon-config-kits --> Command Line > resonon config kits [reference] ```text resonon config kits <COMMAND> ``` The folders this machine keeps sampler kits in. `[folders] kits` in `~/.resonon/preferences.toml`, which you may also edit by hand. Distinct from `resonon kits`, whose subject is what one project declares: this is the machine, that is the piece. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-kits Previous: reference/setup/01-cli#resonon-config-paths Next: reference/setup/01-cli#resonon-config-kits-add --- <!-- ID: reference/setup/01-cli#resonon-config-kits-add --> Command Line > resonon config kits add [reference] ```text resonon config kits add <DIR> ``` Add a folder to the list. A leading `~` is kept as written and expanded per machine. Relative paths are stored absolute. A quoted path naming `$VAR` is refused; an unquoted variable is expanded by the shell before Resonon sees it. A folder that is not there right now is still added and reported as absent — an unmounted drive is not a mistake. | Argument | Default | Description | | --- | --- | --- | | `<DIR>` | — | Folder to search | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-kits-add Previous: reference/setup/01-cli#resonon-config-kits Next: reference/setup/01-cli#resonon-config-kits-remove --- <!-- ID: reference/setup/01-cli#resonon-config-kits-list --> Command Line > resonon config kits list [reference] ```text resonon config kits list ``` Print the list, as written and as it resolves Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-kits-list Previous: reference/setup/01-cli#resonon-config-kits-remove Next: reference/setup/01-cli#resonon-config-plugins --- <!-- ID: reference/setup/01-cli#resonon-config-kits-remove --> Command Line > resonon config kits remove [reference] ```text resonon config kits remove <DIR> ``` Take a folder off the list. Either as it is written in the file or as it resolves on this machine. | Argument | Default | Description | | --- | --- | --- | | `<DIR>` | — | Folder to stop searching | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-kits-remove Previous: reference/setup/01-cli#resonon-config-kits-add Next: reference/setup/01-cli#resonon-config-kits-list --- <!-- ID: reference/setup/01-cli#resonon-config-paths --> Command Line > resonon config paths [reference] ```text resonon config paths ``` Print every directory resonon searches, in order, and why. "Where is it looking?" should not require reading the source. Each entry says where it came from — the project, this machine's preferences, or the install — and whether it exists on disk. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-paths Previous: reference/setup/01-cli#resonon-config Next: reference/setup/01-cli#resonon-config-kits --- <!-- ID: reference/setup/01-cli#resonon-config-plugins --> Command Line > resonon config plugins [reference] ```text resonon config plugins <COMMAND> ``` The folders this machine keeps CLAP and VST3 plugins in. `[folders] plugins` in `~/.resonon/preferences.toml`. Added to the standard folders for this OS and to `CLAP_PATH` / `VST3_PATH`, never instead of them. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-plugins Previous: reference/setup/01-cli#resonon-config-kits-list Next: reference/setup/01-cli#resonon-config-plugins-add --- <!-- ID: reference/setup/01-cli#resonon-config-plugins-add --> Command Line > resonon config plugins add [reference] ```text resonon config plugins add <DIR> ``` Add a folder to the list. A leading `~` is kept as written and expanded per machine. Relative paths are stored absolute. A quoted path naming `$VAR` is refused; an unquoted variable is expanded by the shell before Resonon sees it. A folder that is not there right now is still added and reported as absent — an unmounted drive is not a mistake. | Argument | Default | Description | | --- | --- | --- | | `<DIR>` | — | Folder to search | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-plugins-add Previous: reference/setup/01-cli#resonon-config-plugins Next: reference/setup/01-cli#resonon-config-plugins-remove --- <!-- ID: reference/setup/01-cli#resonon-config-plugins-list --> Command Line > resonon config plugins list [reference] ```text resonon config plugins list ``` Print the list, as written and as it resolves Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-plugins-list Previous: reference/setup/01-cli#resonon-config-plugins-remove Next: reference/setup/01-cli#project--package-commands --- <!-- ID: reference/setup/01-cli#resonon-config-plugins-remove --> Command Line > resonon config plugins remove [reference] ```text resonon config plugins remove <DIR> ``` Take a folder off the list. Either as it is written in the file or as it resolves on this machine. | Argument | Default | Description | | --- | --- | --- | | `<DIR>` | — | Folder to stop searching | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-config-plugins-remove Previous: reference/setup/01-cli#resonon-config-plugins-add Next: reference/setup/01-cli#resonon-config-plugins-list --- <!-- ID: reference/setup/01-cli#resonon-init --> Command Line > resonon init [reference] ```text resonon init [OPTIONS] <NAME> ``` Initialize a new project in the current directory | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Project name | | `--lib` | false | Create a library project (src/lib.non instead of src/main.non) | | `--kit` | false | Create a sample kit project (kits/ directory) | | `--native` | false | Create a native Rust extension project (implies --lib) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-init Previous: reference/setup/01-cli#project--package-commands Next: reference/setup/01-cli#resonon-new --- <!-- ID: reference/setup/01-cli#resonon-install --> Command Line > resonon install [reference] ```text resonon install [SOURCE] ``` Install a package or all dependencies from resonon.toml | Argument | Default | Description | | --- | --- | --- | | `[SOURCE]` | — | Package source (e.g. gh:user/repo or gh:user/repo@v1.0). Omit to install from resonon.toml | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-install Previous: reference/setup/01-cli#resonon-build Next: reference/setup/01-cli#resonon-update --- <!-- ID: reference/setup/01-cli#resonon-kits --> Command Line > resonon kits [reference] ```text resonon kits <COMMAND> ``` The kits this project depends on from outside it A project's own kits, in `<project>/kits`, need no declaration — they travel because they are already there. This list is the other ones: kits drawn from your library or from elsewhere on this machine, recorded so the project says where its sounds came from. `resonon collect` adds to it and satisfies it; nothing removes from it but you. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-kits Previous: reference/setup/01-cli#resonon-collect Next: reference/setup/01-cli#resonon-kits-list --- <!-- ID: reference/setup/01-cli#resonon-kits-list --> Command Line > resonon kits list [reference] ```text resonon kits list ``` List what this project declares, and where each kit is right now. Three answers, because the way out of each is different: a kit in the project travels already, a kit on this machine is one `resonon collect` away, and a kit that is nowhere has to come from whoever sent you the project. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-kits-list Previous: reference/setup/01-cli#resonon-kits Next: reference/setup/01-cli#resonon-kits-remove --- <!-- ID: reference/setup/01-cli#resonon-kits-remove --> Command Line > resonon kits remove [reference] ```text resonon kits remove <NAME> ``` Forget a declaration — the project no longer draws on that kit Only ever a decision, never a deduction: `Kit(…)` names can be computed, so nothing can work out on your behalf that a kit has stopped being used. The kit's own files are left where they are. | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Kit name, as it appears in resonon.toml | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-kits-remove Previous: reference/setup/01-cli#resonon-kits-list Next: reference/setup/01-cli#resonon-run --- <!-- ID: reference/setup/01-cli#resonon-new --> Command Line > resonon new [reference] ```text resonon new [OPTIONS] <NAME> ``` Create a new project in a new directory | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Project name (used as directory name) | | `--lib` | false | Create a library project (src/lib.non instead of src/main.non) | | `--kit` | false | Create a sample kit project (kits/ directory) | | `--native` | false | Create a native Rust extension project (implies --lib) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-new Previous: reference/setup/01-cli#resonon-init Next: reference/setup/01-cli#resonon-build --- <!-- ID: reference/setup/01-cli#resonon-open --> Command Line > resonon open [reference] ```text resonon open [OPTIONS] [PROJECT] ``` Open a project in the running server, or reset the open one to its files Reset Project: calls the session's teardown(), resets, restores the saved session, defines the entry file's functions, calls its setup() and runs the rest of its top level. The transport stays stopped and the undo history starts again. Reports plugins that are not installed. Refuses when the session has changes since the last save, unless `--discard-changes` is given. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `[PROJECT]` | . | The project folder, or any path inside it | | `--discard-changes` | false | Lose the session changes made since the last save | | `--host <HOST>` | 127.0.0.1 | Server host | | `--port <PORT>` | 5555 | Server port | | `--message-format <MESSAGE_FORMAT>` | human | How errors, warnings and output are printed. `json`: one JSON object per line on stdout, in the form the server sends its clients — `output`, `warning`, `error`, `notice`, `rendered`, `visual_diagnostic`, and a final `complete` with the outcome. After valid argument parsing, startup and launcher refusals write an `error` and exactly one failed `complete` with the same request ID. Argument usage errors retain stderr output. The exit code does not change | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-open Previous: reference/setup/01-cli#resonon-save Next: reference/setup/01-cli#resonon-analyze --- <!-- ID: reference/setup/01-cli#resonon-pkg --> Command Line > resonon pkg [reference] ```text resonon pkg <COMMAND> ``` Manage RESONON packages Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-pkg Previous: reference/setup/01-cli#resonon-client Next: reference/setup/01-cli#resonon-pkg-install --- <!-- ID: reference/setup/01-cli#resonon-pkg-inspect --> Command Line > resonon pkg inspect [reference] ```text resonon pkg inspect <NAME> ``` Inspect a package's exports | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Package name (directory name in lib path) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-pkg-inspect Previous: reference/setup/01-cli#resonon-pkg-list Next: reference/setup/01-cli#resonon-pkg-update --- <!-- ID: reference/setup/01-cli#resonon-pkg-install --> Command Line > resonon pkg install [reference] ```text resonon pkg install [SOURCE] ``` Install a package (from source or all from resonon.toml) | Argument | Default | Description | | --- | --- | --- | | `[SOURCE]` | — | Package source (e.g. gh:user/repo or gh:user/repo@v1.0). Omit to install from resonon.toml | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-pkg-install Previous: reference/setup/01-cli#resonon-pkg Next: reference/setup/01-cli#resonon-pkg-list --- <!-- ID: reference/setup/01-cli#resonon-pkg-list --> Command Line > resonon pkg list [reference] ```text resonon pkg list ``` List installed packages Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-pkg-list Previous: reference/setup/01-cli#resonon-pkg-install Next: reference/setup/01-cli#resonon-pkg-inspect --- <!-- ID: reference/setup/01-cli#resonon-pkg-update --> Command Line > resonon pkg update [reference] ```text resonon pkg update [NAME] ``` Update installed packages to latest matching versions | Argument | Default | Description | | --- | --- | --- | | `[NAME]` | — | Package name to update (omit to update all) | `init` and `new` take flags that choose the project type; they combine. A native extension implies a library. Every scaffold writes `resonon.toml`, `README.md`, an MIT `LICENSE`, an `AGENTS.md` for coding agents and a `.gitignore` that excludes `dependencies/` and `renders/`, and initializes a git repository unless it is already inside one. On a machine with no preferences file, and only in a terminal, it then offers to run `resonon setup`. `resonon pkg list` shows a package's type as `[code]` (it has `src/lib.non`), `[kits]` (it has `kits/`) or `[code+kits]`. `collect` and `kits` are the tools for a project that depends on your own kit library — see [Share a Project](/docs/how-to/setup/05-share-a-project/). Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-pkg-update Previous: reference/setup/01-cli#resonon-pkg-inspect Next: reference/setup/01-cli#environment-variables --- <!-- ID: reference/setup/01-cli#resonon-plugin --> Command Line > resonon plugin [reference] ```text resonon plugin <COMMAND> ``` Manage audio plugins (CLAP + VST3) Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-plugin Previous: reference/setup/01-cli#resonon-version-current Next: reference/setup/01-cli#resonon-plugin-scan --- <!-- ID: reference/setup/01-cli#resonon-plugin-list --> Command Line > resonon plugin list [reference] ```text resonon plugin list ``` List discovered plugins from caches (CLAP + VST3) ```bash resonon plugin scan resonon plugin scan --force resonon plugin rescan ~/Library/Audio/Plug-Ins/VST3/Whatever.vst3 resonon plugin list ``` `rescan` re-opens only the bundles it names, skipped ones included. It exits non-zero if a named bundle still will not load. In the editor the same retry is `plugin_rescan(path)`, usually reached as the plugin-named **Retry …** quick fix on the error itself. Any run that starts the audio engine — `resonon run`, the REPL, a server — also sweeps in the background, unless auto-scan is off. See [Find What Is Installed](/docs/how-to/audio/03-use-a-plugin/#find-what-is-installed). Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-plugin-list Previous: reference/setup/01-cli#resonon-plugin-rescan Next: reference/setup/01-cli#resonon-setup --- <!-- ID: reference/setup/01-cli#resonon-plugin-rescan --> Command Line > resonon plugin rescan [reference] ```text resonon plugin rescan <PATHS>... ``` Re-open specific plugin bundles, whatever the database already says. `--force` scoped to one bundle: the way back for a plugin that was skipped, without paying for a full rescan of everything else. | Argument | Default | Description | | --- | --- | --- | | `<PATHS>...` | — | Bundles to re-open (`.clap` or `.vst3`) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-plugin-rescan Previous: reference/setup/01-cli#resonon-plugin-scan Next: reference/setup/01-cli#resonon-plugin-list --- <!-- ID: reference/setup/01-cli#resonon-plugin-scan --> Command Line > resonon plugin scan [reference] ```text resonon plugin scan [OPTIONS] ``` Scan plugin directories and update the plugin database (CLAP + VST3). Only bundles that are new or have changed since the last scan are opened. | Argument | Default | Description | | --- | --- | --- | | `--force` | false | Re-open every bundle, including ones blocklisted after crashing or hanging a previous scan | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-plugin-scan Previous: reference/setup/01-cli#resonon-plugin Next: reference/setup/01-cli#resonon-plugin-rescan --- <!-- ID: reference/setup/01-cli#resonon-reference --> Command Line > resonon reference [reference] ```text resonon reference [COMMAND] ``` Print the core reference, search the manual, or read one entry Without a command, print the core reference of this version. Web: https://resonon.org/docs/llms.txt Full reference: https://resonon.org/docs/llms-full.txt Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-reference Previous: reference/setup/01-cli#resonon-analyze Next: reference/setup/01-cli#resonon-reference-search --- <!-- ID: reference/setup/01-cli#resonon-reference-read --> Command Line > resonon reference read [reference] ```text resonon reference read <ID> ``` Read an entry by ID, or list a page's sections | Argument | Default | Description | | --- | --- | --- | | `<ID>` | — | Entry ID from search, or a page ID from read | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-reference-read Previous: reference/setup/01-cli#resonon-reference-search Next: reference/setup/01-cli#resonon-app --- <!-- ID: reference/setup/01-cli#resonon-reference-search --> Command Line > resonon reference search [reference] ```text resonon reference search [OPTIONS] <QUERY> ``` Search manual sections, symbols, modules, DSP builtins, and kits | Argument | Default | Description | | --- | --- | --- | | `<QUERY>` | — | Words to find; quote a query that contains spaces | | `--kind <K>` | — | Filter by kind | | `--limit <N>` | 10 | Maximum number of results | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-reference-search Previous: reference/setup/01-cli#resonon-reference Next: reference/setup/01-cli#resonon-reference-read --- <!-- ID: reference/setup/01-cli#resonon-remove --> Command Line > resonon remove [reference] ```text resonon remove <NAME> ``` Remove a dependency from the project | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Package name to remove | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-remove Previous: reference/setup/01-cli#resonon-update Next: reference/setup/01-cli#resonon-collect --- <!-- ID: reference/setup/01-cli#resonon-run --> Command Line > resonon run [reference] ```text resonon run [OPTIONS] [SCRIPT] ``` Open the project headless, then evaluate a script in it Opens the project as the editor does: restores its saved session, defines the entry file's functions, calls its setup() and runs the rest of its top level. Then evaluates the script, if one is given, in the opened project, and exits. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `[SCRIPT]` | — | A script to evaluate after the project opens, such as scripts/bounce.non | | `--message-format <MESSAGE_FORMAT>` | human | How errors, warnings and output are printed. `json`: one JSON object per line on stdout, in the form the server sends its clients — `output`, `warning`, `error`, `notice`, `rendered`, `visual_diagnostic`, and a final `complete` with the outcome. After valid argument parsing, startup and launcher refusals write an `error` and exactly one failed `complete` with the same request ID. Argument usage errors retain stderr output. The exit code does not change | | `--no-midi` | false | Disable MIDI entirely. Port declarations still succeed and still get a stable alias, so a piece evaluates identically with and without hardware — nothing is opened and nothing is sent. For CI and headless rendering | | `--multicore[=<MULTICORE>]` | — | Enable multicore audio rendering. `--multicore` or `--multicore=true` turns it on; `--multicore=false` off; omit for the default (off). `RESONON_PARALLEL` overrides this flag. An explicit value requires `=` | | `--plugin-auto-scan[=<PLUGIN_AUTO_SCAN>]` | — | Sweep the plugin folders in the background at startup. Default: on. `--plugin-auto-scan=false` disables the sweep; a bare flag enables it. `RESONON_PLUGIN_AUTO_SCAN` overrides this flag. An explicit value requires `=` | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-run Previous: reference/setup/01-cli#resonon-kits-remove Next: reference/setup/01-cli#resonon-check --- <!-- ID: reference/setup/01-cli#resonon-save --> Command Line > resonon save [reference] ```text resonon save [OPTIONS] ``` Save the running session in its project without evaluating code Connects to a live server and waits for the save result. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `--collect` | false | Copy external samples into the project before saving | | `--host <HOST>` | 127.0.0.1 | Server host | | `--port <PORT>` | 5555 | Server port | | `--message-format <MESSAGE_FORMAT>` | human | How errors, warnings and output are printed. `json`: one JSON object per line on stdout, in the form the server sends its clients — `output`, `warning`, `error`, `notice`, `rendered`, `visual_diagnostic`, and a final `complete` with the outcome. After valid argument parsing, startup and launcher refusals write an `error` and exactly one failed `complete` with the same request ID. Argument usage errors retain stderr output. The exit code does not change | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-save Previous: reference/setup/01-cli#resonon-send Next: reference/setup/01-cli#resonon-open --- <!-- ID: reference/setup/01-cli#resonon-send --> Command Line > resonon send [reference] ```text resonon send [OPTIONS] [FILE] ``` Execute a file or code in a running live session The source is a file, `--code`, or `-` to read stdin. With no source, Run File Live: the session evaluates the entry file of the project in the working directory, without RESET and without calling setup(). Waits for execution and a short settling period for asynchronous diagnostics. See exit codes in the CLI reference: https://resonon.org/docs/reference/setup/01-cli/#exit-codes | Argument | Default | Description | | --- | --- | --- | | `[FILE]` | — | Source file, or `-` to read code from stdin | | `--code <CODE>` | — | Code to execute or check instead of a file | | `--lines <LINES>` | — | Inclusive 1-based file lines, for example `4-12` | | `--host <HOST>` | 127.0.0.1 | Server host | | `--port <PORT>` | 5555 | Server port | | `--message-format <MESSAGE_FORMAT>` | human | How errors, warnings and output are printed. `json`: one JSON object per line on stdout, in the form the server sends its clients — `output`, `warning`, `error`, `notice`, `rendered`, `visual_diagnostic`, and a final `complete` with the outcome. After valid argument parsing, startup and launcher refusals write an `error` and exactly one failed `complete` with the same request ID. Argument usage errors retain stderr output. The exit code does not change | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-send Previous: reference/setup/01-cli#resonon-check Next: reference/setup/01-cli#resonon-save --- <!-- ID: reference/setup/01-cli#resonon-server --> Command Line > resonon server [reference] ```text resonon server [OPTIONS] ``` Start the WebSocket server for remote code execution | Argument | Default | Description | | --- | --- | --- | | `--port <PORT>` | 5555 | WebSocket server port | | `--host <HOST>` | 127.0.0.1 | WebSocket server host address | | `--name <NAME>` | — | Custom server name for discovery (defaults to hostname) | | `--no-midi` | false | Disable MIDI entirely. Port declarations still succeed and still get a stable alias, so a piece evaluates identically with and without hardware — nothing is opened and nothing is sent. For CI and headless rendering | | `--multicore[=<MULTICORE>]` | — | Enable multicore audio rendering. `--multicore` or `--multicore=true` turns it on; `--multicore=false` off; omit for the default (off). `RESONON_PARALLEL` overrides this flag. An explicit value requires `=` | | `--plugin-auto-scan[=<PLUGIN_AUTO_SCAN>]` | — | Sweep the plugin folders in the background at startup. Default: on. `--plugin-auto-scan=false` disables the sweep; a bare flag enables it. `RESONON_PLUGIN_AUTO_SCAN` overrides this flag. An explicit value requires `=` | ```bash resonon server --port 6000 --name "studio" ``` Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-server Previous: reference/setup/01-cli#options Next: reference/setup/01-cli#resonon-view-name --- <!-- ID: reference/setup/01-cli#resonon-setup --> Command Line > resonon setup [reference] ```text resonon setup ``` Set up this machine: audio, MIDI, folders — one question at a time The Preferences dialog, in the terminal. Every setting `~/.resonon/preferences.toml` holds, offered against the devices and ports this rig actually has, so an interface is chosen from a list rather than typed from memory. Nothing is written until the last page, which names every line that would change, and a file you have commented keeps its comments. Needs a terminal. Without one it says what to run instead. ```bash resonon setup ``` Edits `~/.resonon/preferences.toml` one page at a time: audio input and output, sample rate, block size, recording offset, MIDI ports and their aliases, kit and plugin folders, and the `viz()` width. | Behaviour | | | --- | --- | | Choices | Devices and ports this machine has, offered as a list. | | Starting values | What the file already says; `⏎` keeps them. | | Writing | Only on the last page, which lists every changed line. `esc` writes nothing. | | Formatting | Comments, spacing and key order are kept. | | Without a terminal | Prints the written way to make each setting, and exits. | See [Set Up This Machine](/docs/how-to/setup/02-set-up-this-machine/). Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-setup Previous: reference/setup/01-cli#resonon-plugin-list Next: reference/setup/01-cli#resonon-config --- <!-- ID: reference/setup/01-cli#resonon-update --> Command Line > resonon update [reference] ```text resonon update [NAME] ``` Update installed packages to latest matching versions | Argument | Default | Description | | --- | --- | --- | | `[NAME]` | — | Package name to update (omit to update all) | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-update Previous: reference/setup/01-cli#resonon-install Next: reference/setup/01-cli#resonon-remove --- <!-- ID: reference/setup/01-cli#resonon-version --> Command Line > resonon version [reference] `resonon` is a launcher. Run inside a project, it runs the Resonon version that project's `resonon.toml` pins (`package.resonon`); outside a project, it runs the **default**. Versions live under `~/.resonon/versions/`. `resonon version` is the launcher's own command, and answers the same whatever the project pins. With no subcommand, it lists installed versions. ```text resonon version [COMMAND] ``` Manage installed versions of Resonon Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-version Previous: reference/setup/01-cli#resonon-view-name Next: reference/setup/01-cli#resonon-version-list --- <!-- ID: reference/setup/01-cli#resonon-version-current --> Command Line > resonon version current [reference] ```text resonon version current ``` Print the version that runs in this directory, and why `<VERSION>` is spelled as `resonon version list` prints it — bare, with no `v` prefix (`0.11.0`, not `v0.11.0`), though a `v` is accepted and ignored. Installing a version is enough for the projects that pin it: from then on they run it. `switch` only changes the default. A running live server keeps the version it started with until it is restarted. ```bash resonon version list resonon version current # e.g. "0.12.1 (pinned by /songs/techno/resonon.toml)" resonon version install 0.12.0 # projects pinning 0.12 now run it resonon version switch 0.12.0 # make it the default outside projects ``` `current` always prints the version first, then why it runs here: `(default)`, `(pinned by …/resonon.toml)`, or `(default; …/resonon.toml pins 0.13.0, not installed)`. Run it without `sudo`: with `sudo`, it works on root's `~/.resonon`, not yours. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-version-current Previous: reference/setup/01-cli#resonon-version-switch Next: reference/setup/01-cli#resonon-plugin --- <!-- ID: reference/setup/01-cli#resonon-version-install --> Command Line > resonon version install [reference] ```text resonon version install [OPTIONS] <VERSION> ``` Download and install a published version | Argument | Default | Description | | --- | --- | --- | | `<VERSION>` | — | Version to install (e.g. 0.11.0), as it appears on the release page | | `--switch` | false | Also make it the default, the version used where no project pins one | | `--force` | false | Re-download over an existing install | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-version-install Previous: reference/setup/01-cli#resonon-version-list Next: reference/setup/01-cli#resonon-version-switch --- <!-- ID: reference/setup/01-cli#resonon-version-list --> Command Line > resonon version list [reference] ```text resonon version list ``` List installed versions, marking the default Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-version-list Previous: reference/setup/01-cli#resonon-version Next: reference/setup/01-cli#resonon-version-install --- <!-- ID: reference/setup/01-cli#resonon-version-switch --> Command Line > resonon version switch [reference] ```text resonon version switch <VERSION> ``` Make an installed version the default, used where no project pins one | Argument | Default | Description | | --- | --- | --- | | `<VERSION>` | — | Version to make the default, named as `resonon version list` shows it | Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-version-switch Previous: reference/setup/01-cli#resonon-version-install Next: reference/setup/01-cli#resonon-version-current --- <!-- ID: reference/setup/01-cli#resonon-view-name --> Command Line > resonon view NAME [reference] ```text resonon view [OPTIONS] <NAME> ``` Open a terminal view | Argument | Default | Description | | --- | --- | --- | | `<NAME>` | — | Terminal view name | | `--port <PORT>` | — | Server port, default 5555 (terminal views show auto-discovery when both host and port are omitted) | | `--host <HOST>` | — | Server host, default 127.0.0.1 | | `--midi-port <MIDI_PORT>` | — | MIDI input port filter for the midi_monitor view (partial match) | NAME is required: `console`, `routing`, `scope` or `midi_monitor`. Use `resonon app` to open the main window. ```bash resonon view routing --host 10.0.0.5 --port 5555 ``` Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#resonon-view-name Previous: reference/setup/01-cli#resonon-server Next: reference/setup/01-cli#resonon-version --- <!-- ID: reference/setup/01-cli#running-code --> Command Line > Running Code [reference] ``` resonon run [OPTIONS] resonon [OPTIONS] ``` With no command, start the interactive REPL. `run` evaluates the project's entry point. A piece is run by `resonon run`, in its project. A file named on the command line is not a way to run one: `resonon song.non` is a usage error. The project is the nearest directory at or above the working directory that holds a `resonon.toml` — the same one the `resonon` launcher read to choose the version that runs. `resonon run` opens the project as the editor does: it restores the project's saved session, if there is one, opens the entry file (`src/main.non`, or `entry` in `resonon.toml`), calls its `fn setup()` if it defines one and runs the rest of its top level. Then it evaluates the script named after `run`, if there is one, and exits. It writes files only where the code asks it to: audio where it calls `render()`, MIDI where it calls `midi_export()`. What it opens, and its exit status, are in [File Runs](/docs/reference/running/03-file-runs/). The options go before or after `run`: `resonon run --no-midi` and `resonon --no-midi run` are the same. With no `resonon.toml` at or above the working directory, `resonon run` and the REPL are refused before anything is opened: ``` No resonon.toml in /Users/you/scratch or above it. A piece belongs to a project — start one with `resonon new <name>`, or `resonon init` in the folder it should live in. ``` `resonon new` and `resonon init` are under [Project & Package Commands](#project--package-commands). Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#running-code Previous: reference/setup/01-cli#exit-codes Next: reference/setup/01-cli#options --- <!-- ID: reference/setup/01-cli#see-also --> Command Line > See Also [reference] - [Preferences](/docs/reference/setup/02-preferences/) — every key in `~/.resonon/preferences.toml` - [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/) — the `~/.resonon` layout and where resonon looks - [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/) — where each kind of setting lives, and why - [Startup & the Environment](/docs/explanation/setup/04-startup-and-the-environment/) — why the knobs are flags and variables, and the order of startup - [Run a Shared Server](/docs/how-to/running/01-run-a-shared-server/) — running and connecting to the server - [Fix Install and Project Problems](/docs/how-to/setup/06-fix-install-and-project-problems/) — no project, the wrong version, a module not found Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#see-also Previous: reference/setup/01-cli#startup-sequence --- <!-- ID: reference/setup/01-cli#startup-sequence --> Command Line > Startup Sequence [reference] When you run `resonon run` or the REPL, it: 1. Validates environment variables and initializes logging. 2. Reads `~/.resonon/preferences.toml` and installs folder, display and MIDI declarations. 3. Parses CLI arguments and checks the project's version pin. Management commands handle their work and exit early. 4. Installs bundled kits when needed and removes retired built-in plugin bundles; handles `--list-ports` and checks that a project is present. 5. Resolves operational flags and `[audio]` against this machine's hardware. 6. Starts the plugin sweep in the background, unless auto-scan is off. 7. Opens audio and the declared MIDI ports before evaluating the first line of user code. 8. Runs `src/main.non` or starts the REPL. Page: reference/setup/01-cli URL: https://resonon.org/docs/reference/setup/01-cli/#startup-sequence Previous: reference/setup/01-cli#environment-variables Next: reference/setup/01-cli#see-also --- <!-- ID: reference/setup/02-preferences --> Preferences [reference] This machine's preferences live in one file, read before any code runs: ``` ~/.resonon/preferences.toml ``` Every key is optional. With no file, resonon uses the system default devices at their own sample rate and block size. `resonon setup` writes the file interactively, and `reload_preferences()` puts a change in force in a running session. Why these settings are data about the machine rather than calls in a piece: [The Machine and the Piece](/docs/explanation/setup/01-machine-and-piece/). ```toml [audio] output = "Focusrite Scarlett 2i2" input = "Focusrite Scarlett 2i2" sample_rate = 48000 buffer_size = 256 recording_offset_ms = 2.5 [[midi.outputs]] alias = "daw" port = "IAC Driver Resonon" [[midi.outputs]] alias = "synth" port = "Moog Sub 37" optional = true trim_ms = -2.5 send_clock = true [[midi.inputs]] alias = "kb" port = "Arturia KeyStep" [folders] kits = ["~/Music/kits", "/Volumes/Audio/Samples/kits"] plugins = ["/Volumes/Audio/Plugins"] [display] viz_resolution = 48 ``` A key nothing reads, or a value this machine cannot honour, is named at startup and dropped, and the rest of the file is applied. A file that does not parse applies nothing, and says so. Sections: - reference/setup/02-preferences#audio | audio] - reference/setup/02-preferences#midioutputs-and-midiinputs | midi.outputs]] and midi.inputs]] - reference/setup/02-preferences#outputs | Outputs - reference/setup/02-preferences#inputs | Inputs - reference/setup/02-preferences#folders | folders] - reference/setup/02-preferences#display | display] Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/ --- <!-- ID: reference/setup/02-preferences#audio --> Preferences > audio] [reference] | Key | Type | Default | What it is | | --- | --- | --- | --- | | `output` | String | The system default | Output device, by name. Exact match first, then substring: `"Scarlett"` finds `"Focusrite Scarlett 2i2"`. Not connected means nothing plays until it is, never a substitute device. | | `input` | String or false | The system default, opened when a track first needs an input | Input device, matched the same way, or `false` for no input device: nothing is captured and a track's input stays silent. A named device opens at startup; not connected means capture stays closed and playback is unaffected. | | `sample_rate` | Whole number | A rate `input` and `output` can both run | The whole session's sample rate in Hz. A rate the device cannot run is named and dropped. Set, it stands: an input that cannot join it is refused. | | `buffer_size` | Whole number | The device's | Buffer size in frames per block. resonon reports the size the device actually settled on, and says so if it differs. | | `recording_offset_ms` | Number | `0` | Signed correction in milliseconds on top of the round trip a recorded take is already compensated by. ±500 ms at most. | While a take is recording, `reload_preferences()` leaves the whole `[audio]` section alone and says so. Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#audio Next: reference/setup/02-preferences#midioutputs-and-midiinputs --- <!-- ID: reference/setup/02-preferences#display --> Preferences > display] [reference] | Key | Type | Default | What it is | | --- | --- | --- | --- | | `editor_vim` | Boolean | `false` | Enable Vim bindings in the native code editor. | | `editor_vim_maps` | Array of strings | `[]` | Vim mappings, one vimrc line each, such as `"inoremap fd <Esc>"` or `"noremap H ^"`. `noremap`, `nnoremap`, `xnoremap`, `onoremap` and `inoremap` are accepted; mapped keys never remap. A line that cannot be applied is named, and the maps in force stay until it is fixed. | | `viz_resolution` | Whole number | `24` | How wide `viz()` draws one cycle, in characters (8–64). Pick a multiple of the subdivision you are looking at: 24 shows sixteenths in 4/4, 30 shows triplets. | Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#display Previous: reference/setup/02-preferences#folders --- <!-- ID: reference/setup/02-preferences#folders --> Preferences > folders] [reference] | Key | Type | Default | What it is | | --- | --- | --- | --- | | `kits` | Array of strings | `[]` | Kit folders, searched after the project's own. See [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/#search-order). | | `plugins` | Array of strings | `[]` | CLAP and VST3 plugin folders, searched as well as the standard ones. | Entries must be absolute. Only a leading `~` or `~/` is expanded, to your home directory (`~user` is not). An entry naming an environment variable, or a relative one, is reported and left out of the search. A folder that is not there, such as an unmounted drive, is kept. `resonon config kits add` / `remove` / `list` and `resonon config plugins …` edit these lists without opening the file. Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#folders Previous: reference/setup/02-preferences#inputs Next: reference/setup/02-preferences#display --- <!-- ID: reference/setup/02-preferences#inputs --> Preferences > Inputs [reference] | Key | Type | Default | What it is | | --- | --- | --- | --- | | `alias` | String | Required | The name pieces use for the port. | | `port` | String | Required | The name the system gives the port. | | `optional` | Boolean | `false` | The device is not always plugged in: its absence is expected rather than reported as a problem. | | `clock_trim_ms` | Number | `0` | While resonon follows this port's clock, moves what resonon plays by this many milliseconds against it, on top of the automatic alignment. Positive is later. | - A trim is kept to the microsecond and must be within ±500 ms. One further out is named, left at zero, and the port still opens. On an input, `trim_ms` and `send_clock` are named as keys nothing reads: an input's only trim is `clock_trim_ms`, for the clock resonon follows from it. - A port whose device is absent keeps its alias. A track pointed at it stays valid, and its events are counted and reported against it by name. `reload_preferences()` tries an absent device again. - Moving an alias to another port and reloading closes the old device first, even when the new one is not plugged in. - Under `resonon --no-midi` every entry is a reservation: nothing is opened and nothing is sent. `resonon --list-ports` prints a paste-ready entry per attached device. Per-port trims in use: [Align Hardware with the Mix](/docs/how-to/midi/06-align-hardware-with-the-mix/). Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#inputs Previous: reference/setup/02-preferences#outputs Next: reference/setup/02-preferences#folders --- <!-- ID: reference/setup/02-preferences#midioutputs-and-midiinputs --> Preferences > midi.outputs]] and midi.inputs]] [reference] One entry per port, opened in file order before the first bar of every session. Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#midioutputs-and-midiinputs Previous: reference/setup/02-preferences#audio Next: reference/setup/02-preferences#outputs --- <!-- ID: reference/setup/02-preferences#outputs --> Preferences > Outputs [reference] | Key | Type | Default | What it is | | --- | --- | --- | --- | | `alias` | String | Required | The name pieces use for the port. | | `port` | String | Required | The name the system gives the port. | | `optional` | Boolean | `false` | The device is not always plugged in: its absence is expected rather than reported as a problem. | | `trim_ms` | Number | `0` | Moves the port's notes *and* clock by this many milliseconds, on top of the automatic alignment. Positive is later. | | `clock_trim_ms` | Number | `0` | Milliseconds added to clock and transport messages only. | | `send_clock` | Boolean | `false` | The port receives MIDI clock while `set_midi_clock_send(true)` is on. | Page: reference/setup/02-preferences URL: https://resonon.org/docs/reference/setup/02-preferences/#outputs Previous: reference/setup/02-preferences#midioutputs-and-midiinputs Next: reference/setup/02-preferences#inputs --- <!-- ID: reference/setup/03-home-and-search-paths --> Home & Search Paths [reference] `resonon config paths` prints every directory below as this machine resolves it, in order, with where each came from and whether it exists. The editor resolves through the same list. Sections: - reference/setup/03-home-and-search-paths#the-resonon-home | The resonon home - reference/setup/03-home-and-search-paths#search-order | Search order - reference/setup/03-home-and-search-paths#plugin-folders | Plugin folders Page: reference/setup/03-home-and-search-paths URL: https://resonon.org/docs/reference/setup/03-home-and-search-paths/ --- <!-- ID: reference/setup/03-home-and-search-paths#plugin-folders --> Home & Search Paths > Plugin folders [reference] CLAP and VST3 plugins are looked for in all of these, both formats in each: - the standard plugin folders for your OS; - `CLAP_PATH` and `VST3_PATH`, the variables the CLAP and VST3 specifications define; - every `[folders] plugins` entry in [preferences](/docs/reference/setup/02-preferences/#folders). Page: reference/setup/03-home-and-search-paths URL: https://resonon.org/docs/reference/setup/03-home-and-search-paths/#plugin-folders Previous: reference/setup/03-home-and-search-paths#search-order --- <!-- ID: reference/setup/03-home-and-search-paths#search-order --> Home & Search Paths > Search order [reference] Searched in this order; the first match wins. A folder you name is searched in addition to the built-in ones, never instead of them. | Order | Where | Modules | Kits | | ----- | ----- | ------- | ---- | | 1 | The project | `./lib`, `./dependencies` | `./kits`, then `./lib/*/kits` and `./dependencies/*/kits` | | 2 | This machine | — | every `[folders] kits` entry, in file order | | 3 | The resonon home | — | the kits shipped with this version, then `~/.resonon/kits` | - Project directories are relative to the project root, the nearest directory above the importing file with a `resonon.toml`. - There is no machine-wide module path. A module is reachable through this project's `dependencies/` or `lib/`, or by a relative or absolute path in the `use`. See [Modules](/docs/reference/language/09-modules/#resolving-a-use-path). - A package's kits are searched wherever the package is: `Kit("808")` finds a declared package's kit as `Kit("drum-kits/808")` does. Qualify the name when two packages ship a kit of the same name. - A Scala file named without a path (`"werckmeister"`, `.scl` added when missing) is looked for next to the `.non` file that names it, then in the project's `scales/`, `~/.resonon/scales/`, and the scales shipped with this version. - **Sample files are not searched for.** `Sample("kick.wav")` is a path, relative to the `.non` file that names it, or absolute. - The standard library ships with each version and is found automatically. `RESONON_STDLIB_PATH` replaces it. Page: reference/setup/03-home-and-search-paths URL: https://resonon.org/docs/reference/setup/03-home-and-search-paths/#search-order Previous: reference/setup/03-home-and-search-paths#the-resonon-home Next: reference/setup/03-home-and-search-paths#plugin-folders --- <!-- ID: reference/setup/03-home-and-search-paths#the-resonon-home --> Home & Search Paths > The resonon home [reference] Everything resonon stores per user lives under `~/.resonon`. `RESONON_HOME` relocates the whole directory; see [Environment Variables](/docs/reference/setup/01-cli/#environment-variables) for what it accepts. | Path | What it holds | | ----------------------------------- | ------------------------------------ | | `~/.resonon/preferences.toml` | This machine's [preferences](/docs/reference/setup/02-preferences/). | | `~/.resonon/bin/` | The launcher `resonon` and `resonon-lsp` lead to. | | `~/.resonon/versions/` | Installed resonon versions. | | `~/.resonon/versions/default` | The version that runs where no project pins one. | | `~/.resonon/versions/<v>/kits/` | The kits that ship with a version. | | `~/.resonon/versions/<v>/scales/` | The Scala tunings that ship with a version. | | `~/.resonon/kits/` | Your own sampler kit library. | | `~/.resonon/scales/` | Your own Scala (`.scl`) tunings. | | `~/.resonon/cache/clap-cache.json` | CLAP plugin database. | | `~/.resonon/cache/vst3-cache.json` | VST3 plugin database. | Built-in reverbs and samplers load from the application without a plugin folder or scan. On the first startup that needs audio, Resonon removes retired built-in bundles from `~/.resonon/plugins/` and records completion in `~/.resonon/.factory-bundles-retired`. Installer lock files remain in place. Later startups leave bundles reinstalled by an older version alone. The plugin database carries a format version. One written by a different resonon version is discarded and rebuilt, so the first sweep after upgrading opens every bundle again. Page: reference/setup/03-home-and-search-paths URL: https://resonon.org/docs/reference/setup/03-home-and-search-paths/#the-resonon-home Next: reference/setup/03-home-and-search-paths#search-order --- <!-- ID: reference/setup/04-resonon-toml --> resonon.toml [reference] The project manifest, at the project root. `resonon init` / `resonon new` create it: ```toml [package] name = "my-project" version = "0.1.0" authors = ["Your Name <email>"] resonon = "0.10.0" [dependencies] drums = { source = "gh:resonon/drum-kits", version = "v1.0" } synths = { source = "gh:user/synths" } ``` Sections: - reference/setup/04-resonon-toml#package | package] - reference/setup/04-resonon-toml#dependencies | dependencies] - reference/setup/04-resonon-toml#local | local] - reference/setup/04-resonon-toml#native | native] - reference/setup/04-resonon-toml#keys-that-arent-manifest-keys | Keys that aren't manifest keys Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/ --- <!-- ID: reference/setup/04-resonon-toml#dependencies --> resonon.toml > dependencies] [reference] Each entry maps a package name to its source. The key is the local package name (the directory it installs into). | Field | Required | Description | | --------- | -------- | -------------------------------------- | | `source` | Yes | Package source (`gh:user/repo`). | | `version` | No | Git tag to pin to (e.g. `"v1.0"`). | Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/#dependencies Previous: reference/setup/04-resonon-toml#package Next: reference/setup/04-resonon-toml#local --- <!-- ID: reference/setup/04-resonon-toml#keys-that-arent-manifest-keys --> resonon.toml > Keys that aren't manifest keys [reference] A key resonon doesn't read is **named, not obeyed and not fatal**: ```text warning: /my-project/resonon.toml has a key that is not a manifest key: `[package] versoin` — nothing reads this key. Did you mean `version`? ``` It is reported once; everything else in the file still applies, and the piece still plays. In VSCode the key is underlined where it is written, with a **Rename to `version`** quick fix. A file that cannot be parsed stops every command that reads it, naming the line. `resonon install` checks this before it fetches anything, and leaves nothing on disk when it fails. Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/#keys-that-arent-manifest-keys Previous: reference/setup/04-resonon-toml#native --- <!-- ID: reference/setup/04-resonon-toml#local --> resonon.toml > local] [reference] What the project draws on that has **no** upstream to fetch it from. An entry has no `source`. | Field | Required | Description | | ------ | -------- | --------------------------------------------------------------- | | `kits` | No | Kits that came from outside the project and cannot be fetched. | `resonon collect` writes these entries for you. See [Share a Project](/docs/how-to/setup/05-share-a-project/#list-a-kit-you-cannot-bring-in). Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/#local Previous: reference/setup/04-resonon-toml#dependencies Next: reference/setup/04-resonon-toml#native --- <!-- ID: reference/setup/04-resonon-toml#native --> resonon.toml > native] [reference] Present only for packages with a native Rust extension. See [Ship a Native Extension](/docs/how-to/dsp/05-ship-a-native-extension/). | Field | Required | Description | | ------- | -------- | --------------------------------------------------- | | `crate` | Yes | Path to the native Rust crate (relative to the project root). | Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/#native Previous: reference/setup/04-resonon-toml#local Next: reference/setup/04-resonon-toml#keys-that-arent-manifest-keys --- <!-- ID: reference/setup/04-resonon-toml#package --> resonon.toml > package] [reference] | Field | Required | Description | | --------- | -------- | ------------------------------------ | | `name` | Yes | Package name. | | `version` | No | Package version. Informational. | | `authors` | No | List of authors. Informational. | | `resonon` | No | resonon version the project is pinned to. | | `entry` | No | The entry file: it runs when the project opens, on Reset Project and on Run File Live. Relative to the project root. Default `src/main.non`. | `resonon` pins the project to a version, at major.minor precision; patch releases are interchangeable. **The default version runs unless the project needs a different minor; then the newest installed patch of that minor runs.** A pinned version that is not installed is not downloaded. Every command that works on a project checks the pin first — running a piece, the REPL, `build`, `install`, `update`, `remove`, `collect`, `kits`, `pkg`, and each evaluation in a live server: | The pin, against the running version | Result | | --- | --- | | The same minor | Runs. | | A newer minor | Refused. | | An older minor | Runs, with a warning. | The message says what to do: install the pinned version, or, if it is installed, run from inside the project so the launcher picks it. To upgrade a project, change `resonon` to the new version. Page: reference/setup/04-resonon-toml URL: https://resonon.org/docs/reference/setup/04-resonon-toml/#package Next: reference/setup/04-resonon-toml#dependencies --- <!-- ID: reference/setup/05-kit-toml --> kit.toml [reference] A `kit.toml` controls how a kit's samples are mapped and played. Every section is optional — with no `kit.toml`, resonon auto-detects WAV files in the directory. Every path a `kit.toml` names must be relative, must live under `samples/`, and must not climb out of the kit with `..`. Loading a kit that breaks this is an error that names every offending path. Sections: - reference/setup/05-kit-toml#kit--metadata | kit] — metadata - reference/setup/05-kit-toml#defaults--bulk-note-mappings | defaults] — bulk note mappings - reference/setup/05-kit-toml#samples--per-sample-settings | samples] — per-sample settings - reference/setup/05-kit-toml#note-resolution | Note Resolution Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/ --- <!-- ID: reference/setup/05-kit-toml#defaults--bulk-note-mappings --> kit.toml > defaults] — bulk note mappings [reference] Map sample names to notes in one place instead of repeating `note` in every entry. Values are note names (`"C2"`, `"F#3"`) or MIDI numbers (`36`, `42`): ```toml [defaults] bd = "C2" sd = "D2" hh = "F#2" ``` Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/#defaults--bulk-note-mappings Previous: reference/setup/05-kit-toml#kit--metadata Next: reference/setup/05-kit-toml#samples--per-sample-settings --- <!-- ID: reference/setup/05-kit-toml#kit--metadata --> kit.toml > kit] — metadata [reference] | Field | Type | Default | Description | | ---------------- | ------ | -------------- | ------------------------------------------------------------- | | `name` | String | Directory name | Display name for the kit. | | `author` | String | — | Kit author. | | `mode` | String | `"oneshot"` | Playback mode: `"oneshot"` or `"melodic"`. | | `default_sample` | String | Sole sample | Initial sample for `SamplerMelodic`; required when ambiguous. | **Oneshot** plays each sample at a fixed pitch — standard for drums. **Melodic** repitches samples relative to each sample's `root` note — use it for tonal instruments. Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/#kit--metadata Next: reference/setup/05-kit-toml#defaults--bulk-note-mappings --- <!-- ID: reference/setup/05-kit-toml#note-resolution --> kit.toml > Note Resolution [reference] When a sample has no explicit `note`, resonon resolves it in order: 1. Explicit `note` in the `[samples]` entry. 2. A `[defaults]` mapping. 3. The GM drum mapping below (by sample name). 4. Sequential assignment from C2 (MIDI 36). | Name | Aliases | Note | | --------- | --------------------- | -------- | | `bd` | `kick`, `bass` | C2 (36) | | `sd` | `snare` | D2 (38) | | `rs` | `rim`, `rimshot` | C#2 (37) | | `hh` | `hihat`, `hat`, `ch` | F#2 (42) | | `hh_open` | `hihat_open`, `oh` | A#2 (46) | | `cp` | `clap` | D#2 (39) | | `lt` | `tom`, `tom_low` | A2 (45) | | `mt` | `tom_mid` | B2 (47) | | `ht` | `tom_high`, `tom_hi` | D3 (50) | | `crash` | `cy` | C#3 (49) | | `ride` | — | D#3 (51) | | `cb` | `cowbell` | G#3 (56) | | `ma` | `maracas` | A#4 (70) | | `cl` | `clave` | D#5 (75) | | `lc` | `conga_low` | E4 (64) | | `mc` | `conga_mid` | D#4 (63) | | `hc` | `conga_high` | D4 (62) | With no `kit.toml`, each `.wav` becomes a sample named after its filename, notes come from the table above (or sequentially from C2), and the mode defaults to oneshot — so a minimal kit is just a folder of WAV files. Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/#note-resolution Previous: reference/setup/05-kit-toml#samples--per-sample-settings --- <!-- ID: reference/setup/05-kit-toml#samples--per-sample-settings --> kit.toml > samples] — per-sample settings [reference] Each key defines a sample: | Field | Type | Default | Description | | ------------- | ---------------- | ------------- | ------------------------------------------------------------ | | `files` | Array of strings | — | WAV paths under `samples/` in the kit directory. Multiple files enable round-robin. | | `note` | String or number | Auto-assigned | MIDI note that triggers this sample (`"C2"` or `36`). | | `root` | String or number | — | Root pitch for melodic mode (`"C4"` or `60`). | | `choke_group` | Number | — | Samples sharing a group cut each other off. | | `velocity` | Number | `1.0` | Default velocity (`0.0`–`1.0`). | | `loop_start` | Number | — | Loop start, normalized (`0.0`–`1.0`). | | `loop_end` | Number | — | Loop end, normalized (`0.0`–`1.0`). | A drum kit with a choke group (the open and closed hats cut each other): ```toml [kit] name = "Lo-Fi Drums" [samples] bd = { files = ["samples/kick.wav"] } sd = { files = ["samples/snare.wav"], note = "D2" } hh = { files = ["samples/hihat_closed.wav"], note = "F#2", choke_group = 1 } hh_open = { files = ["samples/hihat_open.wav"], note = "A#2", choke_group = 1 } ``` Multiple files per sample give automatic round-robin variation: ```toml [samples] sd = { files = ["samples/snare_1.wav", "samples/snare_2.wav", "samples/snare_3.wav"], note = "D2" } ``` A melodic kit repitches relative to each `root`; use loop points for sustaining sounds: ```toml [kit] name = "Tape Piano" mode = "melodic" default_sample = "piano" [samples] piano = { files = ["samples/piano_c4.wav"], root = "C4" } pad = { files = ["samples/pad_c3.wav"], root = "C3", loop_start = 0.1, loop_end = 0.95 } ``` `SamplerMelodic(Kit("Tape Piano"))` loads `piano` immediately. A melodic kit with exactly one sample may omit `default_sample`; a kit with several samples must declare it. Each selectable melodic sample names exactly one file—multiple files are round-robin material for the drum sampler. The selected file and its root must be valid when the device is constructed, so broken presets fail with an error instead of producing a silent instrument. Page: reference/setup/05-kit-toml URL: https://resonon.org/docs/reference/setup/05-kit-toml/#samples--per-sample-settings Previous: reference/setup/05-kit-toml#defaults--bulk-note-mappings Next: reference/setup/05-kit-toml#note-resolution --- <!-- ID: reference/setup/06-project-layout --> Project Layout [reference] A project is the folder holding `resonon.toml`, and everything below it. `resonon new` and `resonon init` create one; their flags are in the [CLI reference](/docs/reference/setup/01-cli/#project--package-commands). Sections: - reference/setup/06-project-layout#files-and-folders | Files and folders - reference/setup/06-project-layout#file-types | File types Page: reference/setup/06-project-layout URL: https://resonon.org/docs/reference/setup/06-project-layout/ --- <!-- ID: reference/setup/06-project-layout#file-types --> Project Layout > File types [reference] | Extension | What it is | Read | Written | | --- | --- | --- | --- | | `.non` | resonon source | Run, `use` | — | | `.toml` | `resonon.toml`, `kit.toml`, `preferences.toml` | At start and on `use` | `resonon.toml` by the package commands | | `.lock` | `resonon.lock` | `install` | The package commands | | `.wav` | Audio | Samples, kits | `render`, `track.save`, `clip.save` | | `.scl` | Scala tuning | `load_scala` | — | | `.glsl` | GLSL fragment shader | `gfx.load_shader` | — | | `.mid` | Standard MIDI File | — | `midi_export` | | `.png` | Image | — | `screen >> "file.png"`, `render(screen, n)` outside macOS | | `.mp4` | Video with master audio | — | `render(screen, n)` on macOS | | `.preset` | A plugin's state, JSON | `load_state` | `save_state` | A kit folder without a `kit.toml` has its `.wav` files found by name ([kit.toml](/docs/reference/setup/05-kit-toml/)). Page: reference/setup/06-project-layout URL: https://resonon.org/docs/reference/setup/06-project-layout/#file-types Previous: reference/setup/06-project-layout#files-and-folders --- <!-- ID: reference/setup/06-project-layout#files-and-folders --> Project Layout > Files and folders [reference] ```txt my-song/ ├── resonon.toml the manifest ├── resonon.lock exact dependency commits ├── src/ │ ├── main.non a piece's entry point │ └── lib.non a library's entry point ├── scripts/ scripts for resonon run, such as a bounce ├── lib/ your own modules ├── kits/ sampler kits that travel with the project ├── scales/ Scala tunings ├── dependencies/ installed packages ├── native/ a native extension's Rust crate ├── bin/ a native extension's built libraries ├── renders/ renders and MIDI exports ├── session/ the saved project session ├── samples/ samples copied by Collect and Save ├── README.md ├── LICENSE ├── AGENTS.md └── .gitignore ``` | Path | Holds | Created by | Written by | | --- | --- | --- | --- | | `resonon.toml` | The [manifest](/docs/reference/setup/04-resonon-toml/) | `new`, `init` | `install`, `update`, `remove`, `collect`, `kits remove`, you | | `resonon.lock` | The [lock file](/docs/reference/setup/07-resonon-lock/) | `install` | `install`, `update`, `remove` | | `src/main.non` | The [entry file](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle): Open, Reset Project, Run File Live and `resonon run` evaluate it; `entry` in the manifest names another | `new`, `init` | you | | `src/lib.non` | The module a package's users import | `new --lib`, `--native` | you | | `scripts/` | Scripts for `resonon run <script>`, such as a bounce | you | you | | `lib/` | Modules found by `use` | you | you | | `kits/` | Kits found by `Kit("…")` | `new --kit` (with `.gitkeep`), `collect` | `collect`, you | | `scales/` | `.scl` files found by `load_scala` | you | you | | `dependencies/<name>/` | One installed package each | `install` | `install`, `update`, `remove` | | `native/` | `Cargo.toml` and `src/lib.rs` of the extension | `new --native` | you | | `bin/` | The extension's library, built by `resonon build` | `new --native` (with `.gitkeep`) | `build` | | `renders/<name>_<date>_<time>/` | One `render` or `midi_export` call | `render`, `midi_export` | the same | | `session/` | The saved [session document](/docs/explanation/running/05-session-document/) and plugin state | Save Project Session, `resonon save` | the same | | `samples/collected-*/` | Samples and kits copied into the project | Collect and Save Project Session, `resonon save --collect` | the same | | `README.md`, `LICENSE` | A readme; the MIT licence with the current year | `new`, `init` | you | | `AGENTS.md` | Where a coding agent starts: `resonon reference`, which includes [the agent guide](/docs/how-to/running/11-work-with-coding-agents/) | `new`, `init` | you | | `.gitignore` | `dependencies/` and `renders/`; with `--native` also `native/target/` and the built libraries in `bin/` | `new`, `init` | you | `new` and `init` also run `git init`, unless the folder is already inside a git repository. `resonon.lock` is not ignored: commit it. The layout of a render and of a preset file is in [Levels & Files](/docs/reference/audio/01-levels-and-files/). Where modules, kits and scales are searched for is in [Home & Search Paths](/docs/reference/setup/03-home-and-search-paths/). Page: reference/setup/06-project-layout URL: https://resonon.org/docs/reference/setup/06-project-layout/#files-and-folders Next: reference/setup/06-project-layout#file-types --- <!-- ID: reference/setup/07-resonon-lock --> resonon.lock [reference] `resonon.lock` sits next to `resonon.toml` and records the exact commit of every dependency. resonon writes it; it is not edited by hand. Commit it with the project. Installing with it is in [Install a Package](/docs/how-to/setup/03-install-a-package/). ```toml # Auto-generated by Resonon. Do not edit. [[package]] name = "drum-kits" source = "gh:resonon/drum-kits" version = "v1.0" commit = "4f3c1a9e02b7d5c8a1f6e3b9d0c2a7e4f8b1d6c3" [[package]] name = "synths" source = "gh:user/synths" commit = "9b2d7e41c0a3f58e6d1b4c7a2e9f0d3b8c5a1e67" platform = "macos-aarch64" ``` Sections: - reference/setup/07-resonon-lock#package | package]] - reference/setup/07-resonon-lock#written-by | Written by - reference/setup/07-resonon-lock#read-by | Read by Page: reference/setup/07-resonon-lock URL: https://resonon.org/docs/reference/setup/07-resonon-lock/ --- <!-- ID: reference/setup/07-resonon-lock#package --> resonon.lock > package]] [reference] One table per dependency, sorted by `name`. | Field | Type | Present | Value | | --- | --- | --- | --- | | `name` | string | Always | The dependency's key in `resonon.toml`, and its folder under `dependencies/` | | `source` | string | Always | Where it is fetched from, without an `@tag` | | `version` | string | With a tag | The tag it is pinned to | | `commit` | string | Always | The full git commit hash installed | | `platform` | string | With a native extension | The `os-arch` it was built on, e.g. `macos-aarch64` or `linux-x86_64` | The file records no resonon version: the version a project needs is `resonon` in [`resonon.toml`](/docs/reference/setup/04-resonon-toml/). Page: reference/setup/07-resonon-lock URL: https://resonon.org/docs/reference/setup/07-resonon-lock/#package Next: reference/setup/07-resonon-lock#written-by --- <!-- ID: reference/setup/07-resonon-lock#read-by --> resonon.lock > Read by [reference] | When | What happens | | --- | --- | | `resonon install` | Each dependency is checked out at its `commit` | | `resonon install`, a native extension | Rebuilt when `platform` is another platform and no library for this one is in the package | | A `use` of an installed dependency | When the installed commit differs from the lock, once per package per session: `warning: installed 'name' (commit …) does not match resonon.lock (commit …)` | Page: reference/setup/07-resonon-lock URL: https://resonon.org/docs/reference/setup/07-resonon-lock/#read-by Previous: reference/setup/07-resonon-lock#written-by --- <!-- ID: reference/setup/07-resonon-lock#written-by --> resonon.lock > Written by [reference] Every write replaces the whole file. | Command | Lock | | --- | --- | | `resonon install <source>` | Adds or replaces that dependency's entry | | `resonon install` | Installs every dependency at its locked commit — or at its tag, when `resonon.toml` pins one — and writes the result | | `resonon update` | Fetches every dependency again, at its tag or newest commit, and writes the result | | `resonon update <name>` | The same, for one dependency | | `resonon remove <name>` | Removes that dependency's entry | In a project with no dependencies, `resonon install` and `resonon update` write no lock. Page: reference/setup/07-resonon-lock URL: https://resonon.org/docs/reference/setup/07-resonon-lock/#written-by Previous: reference/setup/07-resonon-lock#package Next: reference/setup/07-resonon-lock#read-by --- <!-- ID: reference/stdlib/audio --> std/audio [reference] Track routing, instrument and effect hosting, parameter access, recording, events, and the audio-engine functions. Sections: - Session | class Session - Session.master | master: Master - Session.nowhere | nowhere: Nowhere - Session.create_track | fn create_track(name: String) -> AudioTrack - Session.create_midi_track | fn create_midi_track(name: String) -> MidiTrack - Session.track | fn track(name: String) -> AudioTrack - Session.midi_track | fn midi_track(name: String) -> MidiTrack - Session.delete_track | fn delete_track(name: String) -> NUL - Session.tracks | fn tracks() -> Array<AudioTrack | MidiTrack> - Session.modulations | fn modulations() -> Array<Dict<String, Any>> - AudioTrack | class AudioTrack - AudioTrack.set_name | fn set_name(name: String) -> AudioTrack - AudioTrack.set_color | fn set_color(index: Number) -> AudioTrack - AudioTrack.color | fn color() -> Number - AudioTrack.name | fn name() -> String - AudioTrack.volume | fn volume() -> Number - AudioTrack.pan | fn pan() -> Number - AudioTrack.output | fn output() -> Dict<String, Any>? - AudioTrack.sends | fn sends() -> Array<Dict<String, Any>> - AudioTrack.input | fn input() -> Array<Number>? - AudioTrack.monitor | fn monitor() -> Monitor - AudioTrack.velocity | fn velocity() -> Number | Signal | Pattern - AudioTrack.tuning | fn tuning() -> Number? - AudioTrack.mpe | fn mpe() -> Array<Number>? - AudioTrack.key | fn key() -> Key? - AudioTrack.punch_points | fn punch_points() -> Array<Number?> - AudioTrack.set_instrument | fn set_instrument(instrument: Instrument) -> AudioTrack - AudioTrack.instrument | fn instrument() -> Instrument? - AudioTrack.remove_instrument | fn remove_instrument() -> AudioTrack - AudioTrack.set_effects | fn set_effects(effects: Array<Effect>) -> AudioTrack - AudioTrack.effects | fn effects() -> Array<Effect> - AudioTrack.effect | fn effect(name: String) -> Effect - AudioTrack.remove_send | fn remove_send(destination: AudioTrack | Master) -> AudioTrack - AudioTrack.set_send | fn set_send(destination: AudioTrack | Master, amount: Number | Signal | Pattern) -> AudioTrack - AudioTrack.send | fn send(destination: AudioTrack | Master) -> SendParam - AudioTrack.delete | fn delete() -> NUL - AudioTrack.routing_report | fn routing_report() -> NUL - AudioTrack.set_volume | fn set_volume(value: Number) -> AudioTrack - AudioTrack.set_pan | fn set_pan(value: Number) -> AudioTrack - AudioTrack.mute | fn mute() -> AudioTrack - AudioTrack.unmute | fn unmute() -> AudioTrack - AudioTrack.is_muted | fn is_muted() -> Boolean - AudioTrack.solo | fn solo() -> AudioTrack - AudioTrack.add_solo | fn add_solo() -> AudioTrack - AudioTrack.unsolo | fn unsolo() -> AudioTrack - AudioTrack.is_soloed | fn is_soloed() -> Boolean - AudioTrack.set_input | fn set_input(channel: Number, right: Number? = NUL) -> AudioTrack - AudioTrack.set_delay | fn set_delay(ms: Number) -> AudioTrack - AudioTrack.delay | fn delay() -> Number - AudioTrack.arm | fn arm() -> AudioTrack - AudioTrack.disarm | fn disarm() -> AudioTrack - AudioTrack.set_monitor | fn set_monitor(mode: Monitor) -> AudioTrack - AudioTrack.is_armed | fn is_armed() -> Boolean - AudioTrack.is_recording | fn is_recording() -> Boolean - AudioTrack.take | fn take() -> AudioClip? - AudioTrack.reset_routing | fn reset_routing() -> AudioTrack - AudioTrack.save | fn save(path: String) -> AudioTrack - AudioTrack.punch | fn punch(in_cycle: Number, out_cycle: Number) -> AudioTrack - AudioTrack.punch_in | fn punch_in(cycle: Number) -> AudioTrack - AudioTrack.punch_out | fn punch_out(cycle: Number) -> AudioTrack - AudioTrack.clear_punch | fn clear_punch() -> AudioTrack - AudioTrack.is_punched | fn is_punched() -> Boolean - AudioTrack.set_velocity | fn set_velocity(vel: Number | Signal | Pattern) -> AudioTrack - AudioTrack.set_tuning | fn set_tuning(bend_range: Number? = NUL) -> AudioTrack - AudioTrack.set_mpe | fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> AudioTrack - AudioTrack.set_key | fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> AudioTrack - Master | class Master - Master.volume | fn volume() -> Number - Master.pan | fn pan() -> Number - Master.output | fn output() -> String - Master.set_effects | fn set_effects(effects: Array<Effect>) -> Master - Master.effects | fn effects() -> Array<Effect> - Master.effect | fn effect(name: String) -> Effect - Master.set_volume | fn set_volume(value: Number) -> Master - Master.set_pan | fn set_pan(value: Number) -> Master - MeterFeed | class MeterFeed - MeterFeed.get | fn get() -> Number - MeterFeed.smooth | fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> MeterFeed - MeterFeed.range | fn range(min: Number, max: Number) -> MeterFeed - Nowhere | class Nowhere - SpectrumFeed | class SpectrumFeed - SpectrumFeed.smooth | fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> SpectrumFeed - SpectrumFeed.band | fn band(low_hz: Number, high_hz: Number) -> MeterFeed - Monitor | enum Monitor { off, input, auto } - Bezier | class Bezier - EffectParam | class EffectParam - InstrumentParam | class InstrumentParam - MasterParam | class MasterParam - ParamList | class ParamList - ParamList.filter | fn filter(name: String) -> ParamList - ParamList.length | fn length() -> Number - ParamList.get | fn get(index: Number) -> Dict<String, Any> - ParamList.json | fn json() -> Array<Dict<String, Any>> - Parameter | class Parameter - Parameter.get | fn get() -> Number | Variant - Parameter.get_norm | fn get_norm() -> Number - Parameter.text | fn text() -> String - Parameter.set | fn set(values: Number | Signal | Pattern | Array<Number | Curve | Bezier> | Variant) -> Parameter - Parameter.set_norm | fn set_norm(value: Number) -> Parameter - Parameter.set_text | fn set_text(text: String) -> Parameter - SendParam | class SendParam - TrackParam | class TrackParam - Curve | enum Curve { linear, step, exp, smooth, ease_in, ease_out, ease_in_out, ease } - DspInstrument | class DspInstrument - DspInstrument.set_parameter | fn set_parameter(name: String, value: Number) -> DspInstrument - DspInstrument.parameters | fn parameters(filter: String? = NUL) -> ParamList - Effect | fn Effect(name: String, plugin: String, plugin_id: String? = NUL) -> Effect - Effect.inputs | fn inputs() -> Array<Dict<String, Any>> - Effect.program | fn program() -> Number? - Effect.name | fn name() -> String - Effect.parameter | fn parameter(name: String) -> EffectParam - Effect.set_parameter | fn set_parameter(name: String, value: Number | Variant) -> Effect - Effect.parameters | fn parameters(filter: String? = NUL) -> ParamList - Effect.supports_gui | fn supports_gui() -> Boolean - Effect.show_gui | fn show_gui() -> NUL - Effect.hide_gui | fn hide_gui() -> NUL - Effect.save_state | fn save_state(path: String) -> Effect - Effect.load_state | fn load_state(path: String) -> Effect - Effect.connect_input | fn connect_input(name: String, source: AudioTrack) -> Effect - Effect.programs | fn programs() -> Array<String> - Effect.set_program | fn set_program(index: Number) -> Effect - Effect.backend | fn backend() -> String - Instrument.name | fn name() -> String - Instrument.parameter | fn parameter(name: String) -> InstrumentParam - Instrument.set_parameter | fn set_parameter(name: String, value: Number) -> Instrument - Instrument.parameters | fn parameters(filter: String? = NUL) -> ParamList - PluginInstrument | class PluginInstrument - PluginInstrument.set_parameter | fn set_parameter(name: String, value: Number) -> PluginInstrument - PluginInstrument.parameters | fn parameters(filter: String? = NUL) -> ParamList - PluginInstrument.backend | fn backend() -> String - PluginInstrument.supports_gui | fn supports_gui() -> Boolean - PluginInstrument.show_gui | fn show_gui() -> NUL - PluginInstrument.hide_gui | fn hide_gui() -> NUL - PluginInstrument.save_state | fn save_state(path: String) -> PluginInstrument - PluginInstrument.load_state | fn load_state(path: String) -> PluginInstrument - PluginInstrument.programs | fn programs() -> Array<String> - PluginInstrument.program | fn program() -> Number? - PluginInstrument.set_program | fn set_program(index: Number) -> PluginInstrument - PluginList | class PluginList - PluginList.filter | fn filter(name: String) -> PluginList - PluginList.length | fn length() -> Number - PluginList.get | fn get(index: Number) -> Dict<String, Any> - PluginList.json | fn json() -> Array<Dict<String, Any>> - Instrument | fn Instrument(name: String, plugin_id: String? = NUL) -> PluginInstrument - plugin_rescan | fn plugin_rescan(path: String) -> PluginList - plugin_scan | fn plugin_scan(force: Boolean = false) -> PluginList - AudioClip | class AudioClip - AudioClip.save | fn save(path: String) -> AudioClip - AudioClip.duration | fn duration() -> Number - AudioClip.samples | fn samples() -> Number - AudioClip.sample_rate | fn sample_rate() -> Number - AudioClip.position | fn position() -> Number? - AudioClip.left | fn left() -> Array<Number> - AudioClip.right | fn right() -> Array<Number> - AudioClip.mono | fn mono() -> Array<Number> - Event | class Event - Event.note | fn note() -> Number - Event.velocity | fn velocity() -> Number - Event.start | fn start() -> Number - Event.duration | fn duration() -> Number - Event.end | fn end() -> Number - Event.transpose | fn transpose(semitones: Number) -> Event - Event.detune | fn detune(cents: Number) -> Event - Event.ratio | fn ratio(ratio: Number) -> Event - Note | class Note - Note.from | fn from(n: Number) -> Note - Note.transpose | fn transpose(semitones: Number) -> Note - Note.detune | fn detune(cents: Number) -> Note - Note.ratio | fn ratio(ratio: Number) -> Note - Clip | class Clip - Clip.query | fn query(cycle: Number) -> Pattern - ClipNote | class ClipNote - clip | fn clip(bars: Number, notes: Array<ClipNote>) -> Clip - note | fn note(pitch: Note | Number, start: Number, length: Number, velocity: Number? = NUL, muted: Boolean = false) -> ClipNote - Output | fn Output(left: Number, right: Number? = NUL) -> Output - arrange | fn arrange(sections: Array<Pattern | Timeline | Section>) -> Timeline | Section - audio_buffer_size | fn audio_buffer_size() -> Number - audio_cpu_load | fn audio_cpu_load() -> Dict<String, Any> - audio_input_devices | fn audio_input_devices() -> Array<Dict<String, Any>> - audio_latency | fn audio_latency() -> Dict<String, Any> - audio_output_devices | fn audio_output_devices() -> Array<Dict<String, Any>> - audio_sample_rate | fn audio_sample_rate() -> Number - beats_per_cycle | fn beats_per_cycle() -> Number - bpm | fn bpm() -> Number - cycle | fn cycle() -> Number - is_playing | fn is_playing() -> Boolean - midi_export | fn midi_export(source: Pattern | Timeline | MidiTrack | Array<MidiTrack>, cycles: Number, path: String? = NUL) -> String - mixer_hide | fn mixer_hide() -> NUL - mixer_show | fn mixer_show() -> NUL - notes | fn notes(source: Pattern | Timeline | MidiTrack | Array<MidiTrack> | Section, cycles: Number, start_cycle: Number? = NUL) -> Array<Dict<String, Any>> - project_artist | fn project_artist() -> String? - project_title | fn project_title() -> String? - recording_offset | fn recording_offset() -> Number - render | fn render(target: AudioTrack | Master | Screen | Array<AudioTrack | Master | Screen> | Number, cycles: Number? = NUL) -> NUL - render_master | fn render_master(cycles: Number) -> NUL - routing_report | fn routing_report(...tracks: AudioTrack) -> NUL - scope | fn scope(signal: Signal, label: String = "") -> NUL - scope_clear | fn scope_clear() -> NUL - scope_remove | fn scope_remove(signal: Signal) -> NUL - scope_show | fn scope_show(min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL - scope_snap | fn scope_snap(path: String, min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL - scope_values | fn scope_values() -> Array<Dict<String, Any>> - section | fn section(length: Number) -> Section - set_bpm | fn set_bpm(bpm: Number, beats_per_cycle: Number? = NUL) -> NUL - set_project_artist | fn set_project_artist(artist: String) -> NUL - set_project_title | fn set_project_title(title: String) -> NUL - timeline | fn timeline(length: Number) -> Timeline - window_hide | fn window_hide() -> NUL - window_show | fn window_show() -> NUL - window_snapshot | fn window_snapshot(path: String, scale: Number? = NUL) -> NUL - LaneLayer | class LaneLayer - LaneLayer.at | fn at(start: Number, duration: Number) -> TimelineSlot | SectionParam | SectionVisual - LaneLayer.mute | fn mute() -> LaneLayer - LaneLayer.unmute | fn unmute() -> LaneLayer - LaneLayer.clear | fn clear() -> LaneLayer - Timeline | class Timeline - Timeline.at | fn at(start: Number, duration: Number) -> TimelineSlot - Timeline.length | fn length() -> Number - Timeline.entry_count | fn entry_count() -> Number - Timeline.entries | fn entries() -> Array<Dict<String, Any>> - Timeline.repeat | fn repeat(n: Number) -> Timeline - Timeline.layer | fn layer(name: String) -> LaneLayer - Timeline.layers | fn layers() -> Array<Dict<String, Any>> - Timeline.set_layer_order | fn set_layer_order(names: Array<String>) -> Timeline - Timeline.clear | fn clear() -> Timeline - Timeline.clear_all | fn clear_all() -> Timeline - TimelineSlot | class TimelineSlot - TimelineSlot.clear | fn clear() -> TimelineSlot - Section | class Section - Section.length | fn length() -> Number - Section.track_count | fn track_count() -> Number - Section.tracks | fn tracks() -> Array<Number> - Section.repeat | fn repeat(n: Number) -> Section - Section.play | fn play() -> Section - SectionEffect | class SectionEffect - SectionEffect.parameter | fn parameter(name: String) -> SectionParam - SectionLane | class SectionLane - SectionLane.at | fn at(start: Number, duration: Number) -> TimelineSlot - SectionLane.entry_count | fn entry_count() -> Number - SectionLane.entries | fn entries() -> Array<Dict<String, Any>> - SectionLane.effect | fn effect(name: String) -> SectionEffect - SectionLane.layer | fn layer(name: String) -> LaneLayer - SectionLane.layers | fn layers() -> Array<Dict<String, Any>> - SectionLane.set_layer_order | fn set_layer_order(names: Array<String>) -> SectionLane - SectionLane.clear | fn clear() -> SectionLane - SectionLane.clear_all | fn clear_all() -> SectionLane - SectionParam | class SectionParam - SectionParam.at | fn at(start: Number, duration: Number) -> SectionParam - SectionParam.entry_count | fn entry_count() -> Number - SectionParam.entries | fn entries() -> Array<Dict<String, Any>> - SectionParam.layer | fn layer(name: String) -> LaneLayer - SectionParam.layers | fn layers() -> Array<Dict<String, Any>> - SectionParam.set_layer_order | fn set_layer_order(names: Array<String>) -> SectionParam - SectionParam.clear | fn clear() -> SectionParam - SectionParam.clear_all | fn clear_all() -> SectionParam - SectionVisual | class SectionVisual - SectionVisual.at | fn at(start: Number, duration: Number) -> SectionVisual - SectionVisual.entry_count | fn entry_count() -> Number - SectionVisual.entries | fn entries() -> Array<Dict<String, Any>> - SectionVisual.layer | fn layer(name: String) -> LaneLayer - SectionVisual.layers | fn layers() -> Array<Dict<String, Any>> - SectionVisual.set_layer_order | fn set_layer_order(names: Array<String>) -> SectionVisual - SectionVisual.clear | fn clear() -> SectionVisual - SectionVisual.clear_all | fn clear_all() -> SectionVisual Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/ --- <!-- ID: reference/stdlib/core --> std/core [reference] The core data types with their methods, durations, scalar math, and the global utility and transport functions. Sections: - Array | class Array - Array.length | fn length() -> Number - Array.push | fn push(value: Any) -> Array<Any> - Array.pop | fn pop() -> Any - Array.get | fn get(index: Number) -> Any - Array.slice | fn slice(start: Number, end: Number) -> Array<Any> - Array.concat | fn concat(other: Array<Any>) -> Array<Any> - Array.reverse | fn reverse() -> Array<Any> - Array.contains | fn contains(value: Any) -> Boolean - Array.map | fn map(func: Function) -> Array<Any> - Array.filter | fn filter(func: Function) -> Array<Any> - Array.reduce | fn reduce(func: Function, initial: Any) -> Any - Array.iter | fn iter() -> Iterator<Any> - concat | fn concat(array1: Array<Any>, array2: Array<Any>) -> Array<Any> - filter | fn filter(array: Array<Any>, func: Function) -> Array<Any> - fold | fn fold(array: Array<Any>, initial: Any, func: Function) -> Any - length | fn length(array: Array<Any>) -> Number - map | fn map(array: Array<Any>, func: Function) -> Array<Any> - range | fn range(start_or_end: Number, end: Number? = NUL) -> Array<Number> - slice | fn slice(array: Array<Any>, start: Number, end: Number) -> Array<Any> - String | class String - String.length | fn length() -> Number - String.uppercase | fn uppercase() -> String - String.lowercase | fn lowercase() -> String - String.substring | fn substring(start: Number, end: Number) -> String - String.split | fn split(delimiter: String) -> Array<String> - String.contains | fn contains(needle: String) -> Boolean - String.trim | fn trim() -> String - String.replace | fn replace(old: String, new: String) -> String - String.starts_with | fn starts_with(prefix: String) -> Boolean - String.ends_with | fn ends_with(suffix: String) -> Boolean - String.repeat | fn repeat(n: Number) -> String - String.iter | fn iter() -> Iterator<String> - Dict | class Dict - Dict.get | fn get(key: String | Number) -> Any - Dict.set | fn set(key: String | Number, value: Any) -> Dict<String | Number, Any> - Dict.remove | fn remove(key: String | Number) -> Any - Dict.keys | fn keys() -> Array<String | Number> - Dict.values | fn values() -> Array<Any> - Dict.length | fn length() -> Number - Dict.contains_key | fn contains_key(key: String | Number) -> Boolean - Dict.entries | fn entries() -> Array<Array<Any>> - Dict.merge | fn merge(other: Dict<String | Number, Any>) -> Dict<String | Number, Any> - Dict.map | fn map(func: Function) -> Dict<String | Number, Any> - Dict.filter | fn filter(func: Function) -> Dict<String | Number, Any> - Dict.reduce | fn reduce(func: Function, initial: Any) -> Any - Dict.iter | fn iter() -> Iterator<String | Number> - Iterator | class Iterator - Iterator.next | fn next() -> Any - Iterator.take | fn take(n: Number) -> Iterator<Any> - Iterator.collect | fn collect() -> Array<Any> - Iterator.skip | fn skip(n: Number) -> Iterator<Any> - Iterator.count | fn count() -> Number - Iterator.step_by | fn step_by(step: Number) -> Iterator<Any> - Iterator.enumerate | fn enumerate() -> Iterator<Any> - Iterator.first | fn first() -> Any - Iterator.last | fn last() -> Any - Iterator.map | fn map(func: Function) -> Iterator<Any> - Iterator.filter | fn filter(func: Function) -> Iterator<Any> - Iterator.find | fn find(func: Function) -> Any - Iterator.any | fn any(func: Function) -> Boolean - Iterator.all | fn all(func: Function) -> Boolean - Iterator.fold | fn fold(initial: Any, func: Function) -> Any - Iterator.zip | fn zip(other: Iterator<Any>) -> Iterator<Any> - Iterator.chain | fn chain(other: Iterator<Any>) -> Iterator<Any> - Iterator.flatten | fn flatten() -> Array<Any> - Tuple | class Tuple - Tuple.length | fn length() -> Number - Tuple.get | fn get(index: Number) -> Any - Clone | class Clone - Clone.clone | fn clone() -> Self - Json | class Json - Json.json | fn json() -> Any - Format | class Format - format | fn format(value: Any) -> String - Variant | class Variant - clock | fn clock() -> Number - hostname | fn hostname() -> String - load_file | fn load_file(path: String) -> String - print | fn print(value: Any, newline: Boolean = true) -> NUL - put | fn put(value: Any) -> NUL - reload_ext | fn reload_ext(name: String) -> NUL - reload_preferences | fn reload_preferences() -> NUL - show | fn show(value: Any = NUL) -> NUL - sleep | fn sleep(seconds: Number) -> NUL - to_json | fn to_json(value: MeterFeed | Boolean | Number | String | Array<Any> | Tuple | Dict<String | Number, Any> | Json?) -> String - type | fn type(value: Any = NUL) -> String - std/core::abs | fn abs(x: Number) -> Number - std/core::ceil | fn ceil(x: Number) -> Number - std/core::clamp | fn clamp(x: Number, lo: Number, hi: Number) -> Number - std/core::cos | fn cos(x: Number) -> Number - std/core::exp | fn exp(x: Number) -> Number - std/core::floor | fn floor(x: Number) -> Number - std/core::fract | fn fract(x: Number) -> Number - std/core::ftom | fn ftom(freq: Number) -> Number - std/core::lerp | fn lerp(a: Number, b: Number, t: Number) -> Number - std/core::log | fn log(x: Number) -> Number - std/core::log10 | fn log10(x: Number) -> Number - std/core::log2 | fn log2(x: Number) -> Number - std/core::max | fn max(a: Number, b: Number) -> Number - std/core::min | fn min(a: Number, b: Number) -> Number - std/core::mtof | fn mtof(note: Number) -> Number - std/core::pow | fn pow(base: Number, exponent: Number) -> Number - std/core::round | fn round(value: Number, places: Number = 0) -> Number - std/core::sin | fn sin(x: Number) -> Number - std/core::sqrt | fn sqrt(x: Number) -> Number - std/core::tan | fn tan(x: Number) -> Number - std/core::tanh | fn tanh(x: Number) -> Number - Duration | class Duration - Duration.dotted | fn dotted() -> Duration - Duration.triplet | fn triplet() -> Duration - beats | fn beats(n: Number) -> Duration - cycles | fn cycles(n: Number) -> Duration - ms | fn ms(n: Number) -> Duration - note_value | fn note_value(num: Number, den: Number) -> Duration - seconds | fn seconds(n: Number) -> Duration Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/ --- <!-- ID: reference/stdlib/dsp-builtins --> DSP Builtins [reference] Native (`__native`) constants and functions usable inside `dsp` blocks. Sections: - SR | SR: Number - PI | PI: Number - TWOPI | TWOPI: Number - INV_SR | INV_SR: Number - CYCLE | CYCLE: Number - CPS | CPS: Number - BPC | BPC: Number - CYCLE_PHASE | CYCLE_PHASE: Number - BEAT_PHASE | BEAT_PHASE: Number - CYCLE_EDGE | CYCLE_EDGE: Number - BEAT_EDGE | BEAT_EDGE: Number - TIME | TIME: Number - CYCLES | CYCLES: Number - POSITION | POSITION: Number - dsp::sin | sin(x) -> Number - dsp::cos | cos(x) -> Number - dsp::tan | tan(x) -> Number - dsp::tanh | tanh(x) -> Number - dsp::exp | exp(x) -> Number - dsp::log | log(x) -> Number - dsp::log2 | log2(x) -> Number - dsp::log10 | log10(x) -> Number - dsp::sqrt | sqrt(x) -> Number - dsp::abs | abs(x) -> Number - dsp::floor | floor(x) -> Number - dsp::ceil | ceil(x) -> Number - dsp::round | round(x) -> Number - dsp::fract | fract(x) -> Number - dsp::mtof | mtof(midi) -> Number - dsp::ftom | ftom(freq) -> Number - dsp::pow | pow(base, exp) -> Number - dsp::min | min(a, b) -> Number - dsp::max | max(a, b) -> Number - dsp::clamp | clamp(value, min, max) -> Number - dsp::lerp | lerp(a, b, t) -> Number - svf_lp | svf_lp(input, cutoff, resonance) -> Number - svf_hp | svf_hp(input, cutoff, resonance) -> Number - svf_bp | svf_bp(input, cutoff, resonance) -> Number - svf_notch | svf_notch(input, cutoff, resonance) -> Number - svf_allpass | svf_allpass(input, cutoff, resonance) -> Number - svf_peak | svf_peak(input, cutoff, resonance) -> Number - onepole | onepole(input, coeff) -> Number - delay | delay(input, time) -> Number - delay_interp | delay_interp(input, time) -> Number - noise | noise() -> Number - sample_hold | sample_hold(input, trigger) -> Number - cc | cc(cc_num, channel) -> Number - aftertouch | aftertouch(channel) -> Number - pitchbend | pitchbend(channel) -> Number Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/ --- <!-- ID: reference/stdlib/effects --> std/effects [reference] Effect constructors for use with `track.set_effects(#[...])`. Sections: - FilterType | enum FilterType { lowpass, highpass, bandpass, notch, allpass, peak } - Filter | fn Filter(name: String, type: FilterType? = NUL, cutoff: Number? = NUL, resonance: Number? = NUL, gain: Number? = NUL) -> Effect - Delay | fn Delay(name: String, time: Number? = NUL, feedback: Number? = NUL) -> Effect - PlateReverb | fn PlateReverb(name: String, size: Number? = NUL, damping: Number? = NUL, diffusion: Number? = NUL, predelay: Number? = NUL, mix: Number? = NUL) -> Effect - Reverb | fn Reverb(name: String, room: Number? = NUL, damp: Number? = NUL, width: Number? = NUL, mix: Number? = NUL) -> Effect - Distortion | fn Distortion(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect - Overdrive | fn Overdrive(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: reference/stdlib/generative --> std/generative [reference] Stateful generative pattern sources. The cycle-callback helpers are part of the prelude (always in scope); the stream and Markov sources need `use "std/generative";`. Sections: - off_cycle | fn off_cycle() -> NUL - on_cycle | fn on_cycle(callback: Function) -> NUL - prime_cycles | fn prime_cycles() -> NUL - markov | fn markov(num_states: Number, transitions: Array<Array<Number>>, initial: Number) -> Pattern - stream | fn stream(initial: Note | Number | Array<Any> | Pattern, next_fn: Function) -> Pattern Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/ --- <!-- ID: reference/stdlib/instruments --> std/instruments [reference] Load and play audio samples as drum kits or melodic instruments. Sections: - Kit | fn Kit(kit_name: String? = NUL) -> Kit - Kit.samples | fn samples() -> Array<String> - Kit.sample_info | fn sample_info() -> Array<Array<String | Number>> - Kit.name | fn name() -> String - Kit.mode | fn mode() -> String - Kit.author | fn author() -> String - Sample | fn Sample(path: String) -> AudioClip - DrumSample | class DrumSample - DrumSample.envelope | fn envelope() -> Array<Number?> - DrumSample.parameter | fn parameter(name: String) -> InstrumentParam - DrumSample.set_parameter | fn set_parameter(name: String, value: Number) -> DrumSample - DrumSample.parameters | fn parameters(filter: String? = NUL) -> ParamList - DrumSample.set_envelope | fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSample - DrumSample.name | fn name() -> String - DrumSample.note | fn note() -> Number - Sampler | fn Sampler(kit: Kit? = NUL) -> Sampler - Sampler.choke_group | fn choke_group(name: String) -> Number? - Sampler.samples | fn samples() -> Array<String> - Sampler.sample_info | fn sample_info() -> Array<Array<String | Number>> - Sampler.note | fn note(name: String) -> Number - Sampler.set_note | fn set_note(name: String, new_note: Note) -> Sampler - Sampler.parameter | fn parameter(name: String) -> InstrumentParam - Sampler.set_parameter | fn set_parameter(name: String, value: Number) -> Sampler - Sampler.parameters | fn parameters(filter: String? = NUL) -> ParamList - Sampler.sample | fn sample(name: String) -> AudioClip - Sampler.set_choke_group | fn set_choke_group(group: Number, samples: Array<String>) -> Sampler - Sampler.load_kit | fn load_kit(kit: Kit) -> Sampler - Sampler.slot | fn slot(name_or_note: String | Note) -> DrumSample - SamplerMelodic | fn SamplerMelodic(kit: Kit? = NUL) -> SamplerMelodic - SamplerMelodic.envelope | fn envelope() -> Array<Number?> - SamplerMelodic.loop_normalized | fn loop_normalized() -> Array<Number?> - SamplerMelodic.loop_region | fn loop_region() -> Array<Number?>? - SamplerMelodic.load_sample | fn load_sample(name: String, root_note: Note? = NUL) -> SamplerMelodic - SamplerMelodic.set_envelope | fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodic - SamplerMelodic.set_root | fn set_root(note: Note) -> SamplerMelodic - SamplerMelodic.samples | fn samples() -> Array<String> - SamplerMelodic.sample_info | fn sample_info() -> Array<Array<String | Number?>> - SamplerMelodic.root | fn root(name: String) -> Number? - SamplerMelodic.set_parameter | fn set_parameter(name: String, value: Number) -> SamplerMelodic - SamplerMelodic.parameters | fn parameters(filter: String? = NUL) -> ParamList - SamplerMelodic.sample | fn sample(name: String) -> AudioClip - SamplerMelodic.load_kit | fn load_kit(kit: Kit) -> SamplerMelodic - SamplerMelodic.set_loop | fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodic - SamplerMelodic.set_loop_normalized | fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodic Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/ --- <!-- ID: reference/stdlib/midi --> std/midi [reference] MIDI output: tracks, control-change lanes, and port management. Sections: - CcOutput | class CcOutput - CcOutput.send_rate | fn send_rate() -> Number - CcOutput.set_send_rate | fn set_send_rate(hz: Number) -> CcOutput - MidiOutput | fn MidiOutput(alias: String, channel: Number? = NUL) -> MidiOutput - MidiTrack | class MidiTrack - MidiTrack.delete | fn delete() -> NUL - MidiTrack.set_name | fn set_name(name: String) -> MidiTrack - MidiTrack.set_color | fn set_color(index: Number) -> MidiTrack - MidiTrack.color | fn color() -> Number - MidiTrack.name | fn name() -> String - MidiTrack.output | fn output() -> Dict<String | Number, Any>? - MidiTrack.input | fn input() -> Dict<String | Number, Any>? - MidiTrack.monitor | fn monitor() -> Monitor - MidiTrack.velocity | fn velocity() -> Number | Signal | Pattern - MidiTrack.tuning | fn tuning() -> Number? - MidiTrack.mpe | fn mpe() -> Dict<String | Number, Any>? - MidiTrack.key | fn key() -> Key? - MidiTrack.set_input | fn set_input(alias: String, channel: Number? = NUL) -> MidiTrack - MidiTrack.set_monitor | fn set_monitor(mode: Monitor) -> MidiTrack - MidiTrack.set_velocity | fn set_velocity(vel: Number | Signal | Pattern) -> MidiTrack - MidiTrack.cc | fn cc(cc_number: Number) -> CcOutput - MidiTrack.set_tuning | fn set_tuning(bend_range: Number? = NUL) -> MidiTrack - MidiTrack.set_mpe | fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> MidiTrack - MidiTrack.set_key | fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> MidiTrack - MidiTrack.mute | fn mute() -> MidiTrack - MidiTrack.unmute | fn unmute() -> MidiTrack - MidiTrack.is_muted | fn is_muted() -> Boolean - MidiTrack.solo | fn solo() -> MidiTrack - MidiTrack.add_solo | fn add_solo() -> MidiTrack - MidiTrack.unsolo | fn unsolo() -> MidiTrack - MidiTrack.is_soloed | fn is_soloed() -> Boolean - MidiLatency | enum MidiLatency { auto, manual } - midi_clock_report | fn midi_clock_report() -> NUL - midi_clock_send | fn midi_clock_send() -> Boolean - midi_clock_source | fn midi_clock_source() -> String? - midi_connected | fn midi_connected() -> Dict<String, String> - midi_disconnect | fn midi_disconnect(alias: String) -> NUL - midi_input_disconnect | fn midi_input_disconnect(alias: String) -> NUL - midi_input_events | fn midi_input_events(limit: Number = 100, port: String? = NUL) -> Array<Dict<String | Number, Any>> - midi_input_ports | fn midi_input_ports() -> Array<String> - midi_latency | fn midi_latency() -> MidiLatency - midi_latency_report | fn midi_latency_report() -> NUL - midi_output_ports | fn midi_output_ports() -> Array<String> - midi_port_clock | fn midi_port_clock(alias: String) -> Boolean - midi_port_clock_trim | fn midi_port_clock_trim(alias: String) -> Number - midi_port_trim | fn midi_port_trim(alias: String) -> Number - midi_routing_report | fn midi_routing_report() -> NUL - midi_trace | fn midi_trace() -> Boolean - midi_trace_report | fn midi_trace_report() -> NUL - set_midi_clock_send | fn set_midi_clock_send(enabled: Boolean) -> NUL - set_midi_clock_source | fn set_midi_clock_source(alias: String? = NUL) -> NUL - set_midi_latency | fn set_midi_latency(mode: MidiLatency) -> NUL - set_midi_trace | fn set_midi_trace(on: Boolean) -> NUL Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/ --- <!-- ID: reference/stdlib/patterns --> std/patterns [reference] The core sequencing type and its combinators. Sections: - Pattern | class Pattern - Pattern.query | fn query(cycle: Number) -> Note | Number | Rest | Array<Any> | Pattern? - Pattern.fast | fn fast(factor: Number | Pattern) -> Pattern - Pattern.slow | fn slow(factor: Number | Pattern) -> Pattern - Pattern.transpose | fn transpose(semitones: Number | Pattern) -> Pattern - Pattern.reverse | fn reverse() -> Pattern - Pattern.rotate | fn rotate(steps: Number) -> Pattern - Pattern.stack | fn stack(other: Pattern | Note | Array<Any>) -> Pattern - Pattern.concat | fn concat(other: Pattern | Note | Array<Any>) -> Pattern - Pattern.degrade | fn degrade(probability: Number | Pattern) -> Pattern - Pattern.describe | fn describe() -> String - Pattern.length | fn length() -> Number - Pattern.iter | fn iter() -> Iterator<Event> - Pattern.map | fn map(func: Function) -> Pattern - Pattern.map_with_timing | fn map_with_timing(func: Function) -> Pattern - Pattern.at | fn at(index: Number) -> Pattern - Pattern.euclid | fn euclid(hits: Number, steps: Number, rotation: Number? = NUL) -> Pattern - Pattern.nudge | fn nudge(offsets: Number | Array<Number> | Pattern) -> Pattern - Pattern.swing | fn swing(amount: Number | Pattern, grid: Number) -> Pattern - Pattern.humanize | fn humanize(amount: Number | Pattern) -> Pattern - Pattern.kind | fn kind() -> String - Pattern.elements | fn elements() -> Array<Pattern> - Pattern.in_key | fn in_key(key: Key) -> Pattern - Pattern.quantize | fn quantize(key: Key) -> Pattern - Alternating | fn Alternating(...elements: Pattern | Note | Array<Any>) -> Pattern - Sequence | fn Sequence(...notes: Pattern | Note | Array<Any>) -> Pattern - Stack | fn Stack(...notes: Pattern | Note | Array<Any>) -> Pattern - euclid | fn euclid(hits: Number, steps: Number, pattern: Pattern | Note | Array<Any>, rotation: Number? = NUL) -> Pattern - viz | fn viz(pattern: Pattern | Note | Array<Any>, cycles: Number? = NUL, start_cycle: Number? = NUL) -> NUL Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/ --- <!-- ID: reference/stdlib/random --> std/random [reference] Deterministic (seeded) and true random helpers. Sections: - choose | fn choose(seed: Number, array: Array<Any>) -> Any - choose_true | fn choose_true(array: Array<Any>) -> Any - choose_weighted | fn choose_weighted(seed: Number, array: Array<Any>, weights: Array<Number>) -> Any - rand | fn rand(seed: Number) -> Number - rand_true | fn rand_true() -> Number Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/ --- <!-- ID: reference/stdlib/signals --> std/signals [reference] Continuous control signals for driving parameters. Sections: - Signal | class Signal - Signal.get | fn get() -> Number - Signal.retrigger | fn retrigger() -> Array<Duration?> - Signal.timebase | fn timebase() -> Array<Duration> - Signal.parameter | fn parameter(name: String) -> Number - Signal.range | fn range(min: Number | Signal, max: Number | Signal) -> Signal - Signal.range_exp | fn range_exp(min: Number | Signal, max: Number | Signal) -> Signal - Signal.set_retrigger | fn set_retrigger(period: Duration) -> Signal - Signal.set_timebase | fn set_timebase(unit: Duration) -> Signal - Signal.smooth | fn smooth(time_ms: Number | Signal) -> Signal - Signal.continuous | fn continuous() -> Signal - Signal.at | fn at(time: Number, value: Number, curve: Curve | Bezier = Curve.linear) -> Signal - Signal.set_parameter | fn set_parameter(name: String, value: Number) -> Signal - Cc | fn Cc(cc_number: Number, channel: Number? = NUL) -> Signal - Cc_learn | fn Cc_learn() -> Signal - Perlin | fn Perlin(freq: Number | Signal = 1) -> Signal - std/signals::Ramp | fn Ramp(start: Signal | Number = 0.0, end: Signal | Number = 1.0, duration: Signal | Number = 1.0) -> Signal - Rand | fn Rand(freq: Number | Signal = 1) -> Signal - Saw | fn Saw(freq: Number | Signal = 1) -> Signal - Saw2 | fn Saw2(freq: Number | Signal = 1) -> Signal - Sine | fn Sine(freq: Number | Signal = 1) -> Signal - Sine2 | fn Sine2(freq: Number | Signal = 1) -> Signal - Square | fn Square(freq: Number | Signal = 1) -> Signal - Square2 | fn Square2(freq: Number | Signal = 1) -> Signal - Time | fn Time(rate: Number | Signal = 1) -> Signal - Tri | fn Tri(freq: Number | Signal = 1) -> Signal - Tri2 | fn Tri2(freq: Number | Signal = 1) -> Signal - automation | fn automation(...breakpoints: Array<Number | Curve | Bezier>) -> Signal - hz_to_periods | fn hz_to_periods(frequency: Number) -> Number - sec_to_periods | fn sec_to_periods(period: Number) -> Number - signal | fn signal(pattern: Pattern | Note | Array<Any>) -> Signal - signal_ramp | fn signal_ramp(start: Number, end: Number, duration: Number? = NUL) -> Signal Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/ --- <!-- ID: reference/stdlib/theory --> std/theory [reference] Scales, keys, chords, and interval helpers. Sections: - Key | fn Key(root: Note, name: String | Scale) -> Key - Key.degree | fn degree(n: Number) -> Note - Key.chord | fn chord(deg: Number, quality: String | Number? = NUL, inv: Number? = NUL) -> Array<Note> - Key.chord7 | fn chord7(deg: Number, inv: Number? = NUL) -> Array<Note> - Key.notes | fn notes() -> Array<Note> - Key.quantize | fn quantize(note: Note) -> Note - Key.transpose | fn transpose(semitones: Number) -> Key - Scale | fn Scale(arg: String | Array<Number>, period: Number? = NUL) -> Scale - Scale.name | fn name() -> String - Scale.intervals | fn intervals() -> Array<Number> - Scale.period | fn period() -> Number - Scale.length | fn length() -> Number - Scale.mode | fn mode(n: Number) -> Scale - Scale.contains | fn contains(semitones: Number) -> Boolean - chord | fn chord(root: Note, name: String, inversion: Number? = NUL) -> Array<Note> - chord_names | fn chord_names() -> Array<String> - interval | fn interval(note: Note, name: String) -> Note - load_scala | fn load_scala(name: String) -> Scale - scale_names | fn scale_names() -> Array<String> Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/ --- <!-- ID: reference/stdlib/visuals --> std/visuals [reference] GPU visual operators — generators, filters, and the raw-shader `Visual`. Wire nodes with `>>` (primary input; route to `screen` to display) and bind parameters or texture inputs with `node.parameter("name") << signal`. `screen` is a global output sink; the master bus is `session.master`. **Generators** (`Noise`, `Ramp`) have no primary input; **filters** take one via `src >> op`; **2-in** filters (`Composite`, `Displace`, `Lookup`) take a second via a named slot, `op.parameter("slot") << node`. Every pass clamps its output to `[0, 1]`. Vector parameters (`translate`, `scale`, `pivot`) bind from a 2–4-element array, e.g. `t.parameter("scale") << #[1.5, 1.5]`, and a table parameter (`Ramp`'s `keys`) from an array of rows. Sections: - Screen | class Screen - Screen.quality | fn quality() -> Number - Screen.set_quality | fn set_quality(n: Number) -> Screen - Screen.resolution | fn resolution(w: Number, h: Number) -> Screen - Screen.show | fn show() -> Screen - Screen.snap | fn snap(path: String) -> Screen - Visual | fn Visual(name: String, source: String) -> Visual - Visual.parameter | fn parameter(name: String) -> VisualParam - Visual.reset | fn reset() -> Visual - VisualParam | class VisualParam - BlurExtend | enum BlurExtend { hold, repeat, mirror } - BlurMethod | enum BlurMethod { horizontal_and_vertical, horizontal, vertical } - BlurType | enum BlurType { catmull_rom, gaussian, box, bartlett, sinc, hanning, blackman } - Extend | enum Extend { hold, zero, repeat, mirror } - LookupChannel | enum LookupChannel { luminance, red, green, blue, alpha, rgb_average, rgba_average, rgb_maximum, rgba_maximum, rgba_independent } - Operand | enum Operand { add, difference, maximum, minimum, multiply, over, screen, subtract, subtractive } - RampExtend | enum RampExtend { hold, black, zero, repeat, mirror } - RampExtendRight | enum RampExtendRight { same_as_left, hold, black, zero, repeat, mirror } - RampFit | enum RampFit { fill, fit_horizontal, fit_vertical, fit_best } - RampInterp | enum RampInterp { step, linear, ease_in_ease_out, hermite } - RampType | enum RampType { vertical, horizontal, radial, circular } - RgbOutput | enum RgbOutput { multiply_alpha, new_alpha } - Unit | enum Unit { pixels, fraction, fraction_aspect } - Blur | fn Blur(name: String) -> Visual - Composite | fn Composite(name: String) -> Visual - Displace | fn Displace(name: String) -> Visual - Edge | fn Edge(name: String) -> Visual - Lookup | fn Lookup(name: String) -> Visual - LumaLevel | fn LumaLevel(name: String) -> Visual - Noise | fn Noise(name: String) -> Visual - std/visuals::Ramp | fn Ramp(name: String) -> Visual - RgbKey | fn RgbKey(name: String) -> Visual - Slope | fn Slope(name: String) -> Visual - Transform | fn Transform(name: String) -> Visual - feedback | fn feedback(seed: Visual, build: Function) -> Visual - load_shader | fn load_shader(name: String, path: String) -> Visual Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/ --- <!-- ID: reference/visuals/01-shader-interface --> Shader Interface [reference] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: The operators, their uniforms and the built-in uniforms supplied to every shader are in the [`std/visuals` reference](/docs/reference/stdlib/visuals/#visual). Sections: - reference/visuals/01-shader-interface#shader-source | Shader source - reference/visuals/01-shader-interface#bound-values | Bound values - reference/visuals/01-shader-interface#spectrum-texture | Spectrum texture - reference/visuals/01-shader-interface#table-texture | Table texture - reference/visuals/01-shader-interface#related | Related Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/ --- <!-- ID: reference/visuals/01-shader-interface#bound-values --> Shader Interface > Bound values [reference] `v.parameter(name) << value` arrives in the shader as: | Value | GLSL declaration | | :-- | :-- | | a number, a signal, a meter feed (`.rms`, `.peak`, `.fft.band(…)`) | `uniform float name;` | | an array of 2, 3 or 4 numbers | `uniform vec2 name;`, `vec3`, `vec4` | | a spectrum feed (`.fft`, `.fft.smooth(…)`) | `uniform sampler2D name;` | | a table: an array of rows, each an array of numbers, all one length | `uniform sampler2D name;` | | a visual node | a texture input (`iChannel1`, …) | Binding a name again replaces what it was bound to. The built-in uniforms and the samplers `iChannel0`, `iChannel1`, … are supplied by the engine; binding one is an error. Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/#bound-values Previous: reference/visuals/01-shader-interface#shader-source Next: reference/visuals/01-shader-interface#spectrum-texture --- <!-- ID: reference/visuals/01-shader-interface#related --> Shader Interface > Related [reference] - [Bind Audio to a Shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/) — the feeds in use - [MeterFeed](/docs/reference/stdlib/audio/#meterfeed) and [SpectrumFeed](/docs/reference/stdlib/audio/#spectrumfeed) — their methods Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/#related Previous: reference/visuals/01-shader-interface#table-texture --- <!-- ID: reference/visuals/01-shader-interface#shader-source --> Shader Interface > Shader source [reference] A shader is a `.glsl` file loaded with `gfx.load_shader(name, path)`, or the same source given as a string to `gfx.Visual(name, source)`. It is a GLSL-ES 3.00 fragment shader: - It starts with `#version 300 es` and declares a default `precision`. - It writes its colour to an `out vec4`. - It reads its inputs as `uniform sampler2D iChannel0;`, `iChannel1`, …: the node fed in with `>>` is always `iChannel0`, and nodes bound to named inputs take the channels after it, in the order they were first bound. - Every `sampler2D` it declares must be bound. A graph with a shader that reads an input nothing is bound to is not drawn: routing it is an error, and the picture on screen stays. It is compiled by the renderer when something draws it — an open visuals window, `render(screen)` or `screen.snap()` — not when it is loaded. Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/#shader-source Next: reference/visuals/01-shader-interface#bound-values --- <!-- ID: reference/visuals/01-shader-interface#spectrum-texture --> Shader Interface > Spectrum texture [reference] | Property | Value | | :-- | :-- | | Size | 512 bins × 1 row, from a 1024-point FFT | | Layout | read it at `vec2(x, 0.5)`; `x` is `0` at the lowest bin and near `1` at the highest, linear in frequency | | Value | the bin's magnitude in `.r`; a full-scale sine reads about `0.5` at its bin | | Filtering | nearest — no interpolation between bins | Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/#spectrum-texture Previous: reference/visuals/01-shader-interface#bound-values Next: reference/visuals/01-shader-interface#table-texture --- <!-- ID: reference/visuals/01-shader-interface#table-texture --> Shader Interface > Table texture [reference] A table is a list of rows, such as the keys of a ramp: `#[#[0, 0, 0, 0, 1], #[1, 1, 1, 1, 1]]`. It holds 1 to 8192 rows, and every row has the same number of values. | Property | Value | | :-- | :-- | | Size | one texel across per row; one texel down per four values of a row | | Layout | `texelFetch(name, ivec2(i, 0), 0)` is values 0 to 3 of row `i`, `ivec2(i, 1)` values 4 to 7, …; a value past the end of the row reads `0` | | Rows | `textureSize(name, 0).x` | | Value | 32-bit float, as bound | The texture is uploaded when the table is bound, not on each frame. Page: reference/visuals/01-shader-interface URL: https://resonon.org/docs/reference/visuals/01-shader-interface/#table-texture Previous: reference/visuals/01-shader-interface#spectrum-texture Next: reference/visuals/01-shader-interface#related --- <!-- ID: reload_ext --> reload_ext [function] fn reload_ext(name: String) -> NUL Reloads a native extension from disk. Fails if any objects from the extension still exist — drop them first. Parameters: name: String — extension name to reload Returns: NUL — nothing Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#reload_ext --- <!-- ID: reload_preferences --> reload_preferences [function] fn reload_preferences() -> NUL Re-reads `~/.resonon/preferences.toml` and applies whatever changed. The one gesture that puts a hand-edited or command-written file in force without restarting: nothing else re-reads it, so an editor save cannot reopen the audio device under a take. Only differences are applied, so calling it on an unchanged file costs nothing and makes no gap in the sound. A file that will not parse changes nothing and says why. While a take is recording, `[audio]` is left alone and the rest still applies. A live session is where it matters: `resonon run` reads the file once, when it starts. Returns: NUL — nothing; what changed goes to the activity feed Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#reload_preferences --- <!-- ID: render --> render [function] fn render(target: AudioTrack | Master | Screen | Array<AudioTrack | Master | Screen> | Number, cycles: Number? = NUL) -> NUL Renders audio and/or the routed visual offline for the given number of cycles. The target selects what is written: a track/bus → its WAV, `session.master` → master.wav, `screen` → screen.mp4 on macOS (H.264 video + the master mix as AAC), or a PNG frame sequence on other platforms (frames/frame_00000.png …), of the visual routed with `v >> screen`. An array combines targets: `#[session.master, screen]` also writes master.wav; `#[drums, screen]` also writes drums.wav. `screen` always bounces the master internally so audio-reactive visuals see real meters/FFT, even without a WAV. Video is 60 fps at the composition size. On macOS, both dimensions must be even. A track's WAV is the track as it sounds in the mix, post-fader: the rest of the project keeps playing behind it, so its sidechains are keyed as in the mix (a key is read post-fader, before mute and solo), and it lines up with master.wav. Each track is a pass of the whole session. With one argument, renders the master output for that many cycles. Starts at cycle 0, whatever the play head is doing, and pauses live output while it runs. Stops at the last cycle: to keep a reverb or delay tail, render past the song's end. Output path: `<project>/renders/{name}_{datetime}/`. Parameters: target: AudioTrack | Master | Screen | Array | Number — what to render, OR (when `cycles` is omitted) the number of cycles to render the master for cycles: Number? — number of cycles to render (optional; omit to render the master for `target` cycles) Returns: NUL — nothing; writes the WAV file(s) and/or screen export Examples: `render(8)`, `render(drums, 8)`, `render(screen, 8)`, `render(#[session.master, screen], 8)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#render --- <!-- ID: render_master --> render_master [function] fn render_master(cycles: Number) -> NUL Renders the master output to a WAV file. Mixes all tracks through the audio graph. Output path: `<project>/renders/{name}_{datetime}/master.wav` Parameters: cycles: Number — number of cycles to render (>= 1) Returns: NUL — nothing; writes the WAV file Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#render_master --- <!-- ID: routing_report --> routing_report [function] fn routing_report(...tracks: AudioTrack) -> NUL Displays the current audio routing graph. With no arguments, shows all tracks and routing chains. With track arguments, shows detailed per-track routing info. Sends are post-fader: they tap the signal after volume and pan. Parameters: tracks: AudioTrack — the tracks to detail (zero or more) Returns: NUL — nothing; prints the routing graph Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#routing_report-1 --- <!-- ID: sample_hold --> sample_hold [dsp-builtin] sample_hold(input, trigger) -> Number Sample and hold — captures input on rising edge of trigger. Parameters: input — signal to sample trigger — gate signal (captures on transition from `<= 0` to `> 0`) Returns: held value until next trigger Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#sample_hold --- <!-- ID: scale_names --> scale_names [function] fn scale_names() -> Array<String> Returns an array of all available scale names. Returns: Array — the built-in scale names as Strings Module: std/theory (prelude) Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/#scale_names --- <!-- ID: scope --> scope [function] fn scope(signal: Signal, label: String = "") -> NUL Registers a signal for visualization in the scope. Parameters: signal: Signal — the signal to visualize label: String — display label (optional; defaults to the signal description) Returns: NUL — nothing Examples: `scope(Sine(2))` or `scope(lfo, "tempo LFO")` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope --- <!-- ID: scope_clear --> scope_clear [function] fn scope_clear() -> NUL Removes all signals from the scope view. Returns: NUL — nothing Examples: `scope_clear()` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope_clear --- <!-- ID: scope_remove --> scope_remove [function] fn scope_remove(signal: Signal) -> NUL Removes a signal from the scope view. Parameters: signal: Signal — the signal to remove (must be the same instance passed to scope()) Returns: NUL — nothing Examples: `lfo = Sine(2); scope(lfo); scope_remove(lfo)` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope_remove --- <!-- ID: scope_show --> scope_show [function] fn scope_show(min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL Opens the scope window: every signal registered with `scope()` as a lane, its trace scrolling in from the right. Called again while the window is open, it brings the window to the front with the new settings. Parameters: min: Number? — the value at the bottom of every lane (optional; defaults to each signal's own range) max: Number? — the value at the top of every lane (optional; defaults to each signal's own range) length: Duration — how much time the trace spans, ending now (optional; defaults to one cycle; at most two minutes at the current tempo) Returns: NUL — nothing Examples: `scope(lfo); scope_show(length: cycles(4))` or `scope_show(0, 1, seconds(10))` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope_show --- <!-- ID: scope_snap --> scope_snap [function] fn scope_snap(path: String, min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL Draws the scope as the window would show it and writes it to a PNG at the given path, whether or not the window is open: look at a signal without showing it to anyone. Every signal registered with `scope()` is a lane, as in `scope_show()`, whose `min`, `max` and `length` it takes; it does not copy an open window's. The picture is the window's default size at twice its density. An absolute path is taken as typed; a relative one lands under the project the piece belongs to, and any directory it names is created. Parameters: path: String — output PNG path min: Number? — the value at the bottom of every lane (optional; defaults to each signal's own range) max: Number? — the value at the top of every lane (optional; defaults to each signal's own range) length: Duration — how much time the trace spans, ending now (optional; defaults to one cycle; at most two minutes at the current tempo) Returns: NUL — nothing Examples: `scope(lfo); scope_snap("scope.png", length: cycles(4))` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope_snap --- <!-- ID: scope_values --> scope_values [function] fn scope_values() -> Array<Dict<String, Any>> The current scope probes as serializable values, without waiting for samples. Each entry is {label, value, range: [min, max]} with the displayed range and current value. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#scope_values --- <!-- ID: sec_to_periods --> sec_to_periods [function] fn sec_to_periods(period: Number) -> Number Converts a period in seconds to periods per cycle at the current tempo. The result is a plain number: a later tempo change does not update it. For a signal timed in seconds at any tempo, use `.set_timebase(seconds(...))`. Parameters: period: Number — period duration in seconds (positive) Returns: Number — the equivalent rate in periods per cycle at the current tempo Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#sec_to_periods --- <!-- ID: seconds --> seconds [function] fn seconds(n: Number) -> Duration A duration in seconds. Tempo never changes it. Parameters: n: Number — how many seconds (positive) Returns: Duration — `n` seconds Examples: `Sine(2).set_timebase(seconds(1))` — 2 Hz at any tempo Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#seconds --- <!-- ID: section --> section [function] fn section(length: Number) -> Section Creates a multi-track section: lanes keyed by track, assigned with `sec[track] << clip` (whole lane) or `sec[track].at(start, dur) << clip`. A section also carries automation lanes (`sec[track].volume << curve`, `sec[track].effect("filt").parameter("cutoff") << curve`) and a visual lane: `sec[screen] << visual` puts that visual on screen for the section's whole span, so sequencing sections with `arrange` cuts the picture on section boundaries (a section without one renders black). `.at(start, dur)` positions any of them — notes, automation, visuals — within the lane instead of covering the whole section, so per-lane overrides coexist with the structure `arrange` laid down. A section's length is a whole number of cycles, but a position inside it is not: `.at(2.5, 1.25)` places between the lines, the same rule on every lane kind. Every lane is a stack of layers: `base` (what `section`/`arrange` laid down, or a bare `sec[track] << clip`) with named layers above it, `main` by default. Later wins — the entry underneath is MASKED, not cut, and resumes in its own phase when the mask ends, so an override reaching across a section boundary plays through it. A write upserts by start, so editing a `.at` line and re-executing reshapes that one mask instead of stacking duplicates, and `.clear()` lifts a mask to bring back exactly what was underneath. An edit to a playing section's automation or screen lane lands live — no second `play()`, no rewind. Parameters: length: Number — section length in cycles (must be > 0) Returns: Section — a section accepting per-track lanes; index it with a track value (or with `screen` for the visual lane) Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#section --- <!-- ID: set_bpm --> set_bpm [function] fn set_bpm(bpm: Number, beats_per_cycle: Number? = NUL) -> NUL Sets the tempo, and records it as the project's tempo in render metadata. Formula: cps = bpm / 60 / beats_per_cycle. Ignored while following an external MIDI clock (`set_midi_clock_source`). Parameters: bpm: Number — beats per minute (positive) beats_per_cycle: Number? — beats in one cycle (optional, 4 when omitted) Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_bpm --- <!-- ID: set_midi_clock_send --> set_midi_clock_send [function] fn set_midi_clock_send(enabled: Boolean) -> NUL Enable/disable MIDI clock output (master mode). Sends 24 PPQ clock ticks plus Start/Continue/Stop to every output port whose `[[midi.outputs]]` entry says `send_clock = true`. This is the master switch; ports opt in separately. Parameters: enabled: Boolean — `true` to enable, `false` to disable Returns: NUL — nothing Examples: `set_midi_clock_send(true)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_midi_clock_send --- <!-- ID: set_midi_clock_source --> set_midi_clock_source [function] fn set_midi_clock_source(alias: String? = NUL) -> NUL Sets where the tempo and transport come from: an external MIDI clock on an input port (follower mode), or resonon's own clock. Parameters: alias: String? — input port alias to follow, as a `[[midi.inputs]]` entry declares it; omit for resonon's own clock Returns: NUL — nothing Examples: `set_midi_clock_source("daw")`, `set_midi_clock_source()` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_midi_clock_source --- <!-- ID: set_midi_latency --> set_midi_latency [function] fn set_midi_latency(mode: MidiLatency) -> NUL Sets how outgoing MIDI is aligned with the audio output. Parameters: mode: MidiLatency — the alignment; `MidiLatency.auto` is the default Returns: NUL — nothing Examples: `set_midi_latency(MidiLatency.manual)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_midi_latency --- <!-- ID: set_midi_trace --> set_midi_trace [function] fn set_midi_trace(on: Boolean) -> NUL Start or stop the MIDI timing trace. `true` clears the buffer and begins recording; `false` stops and prints what was captured. Parameters: on: Boolean — `true` to start recording, `false` to stop and report Returns: NUL — nothing Examples: `set_midi_trace(true)`, `set_midi_trace(false)` Module: std/midi (prelude) Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/#set_midi_trace --- <!-- ID: set_project_artist --> set_project_artist [function] fn set_project_artist(artist: String) -> NUL Sets the project artist name. Used in render metadata. Parameters: artist: String — artist name Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_project_artist --- <!-- ID: set_project_title --> set_project_title [function] fn set_project_title(title: String) -> NUL Sets the project title. Used in render output paths and metadata. Parameters: title: String — project title Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#set_project_title --- <!-- ID: show --> show [function] fn show(value: Any = NUL) -> NUL Displays detailed information about a value. For modules: name, path, exports, and documentation. For functions: the full typed signature, parameter types, and doc comments. For enums: the enum's documentation and each variant with its own. For sections and timelines: the resolved layer stack — one block per lane, one row per visible interval, so it reads as what the arrangement will sound like rather than what was authored. For other values: the runtime type and representation. Parameters: value: Any — any resonon value Returns: NUL — nothing; prints the information Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#show --- <!-- ID: signal --> signal [function] fn signal(pattern: Pattern | Note | Array<Any>) -> Signal Creates a signal from a pattern, or from an array played as one cycle's sequence. A pattern cycle lasts one unit of the signal's timebase. The pattern plays as it would on a track; where events overlap, the one that started last holds. A rest keeps the last value, and before its first event the signal already has that event's value. Parameters: pattern: Pattern | Note | Array — the values to step through Returns: Signal — emits the active event's value — a number, or a note's MIDI number — and keeps it through rests Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#signal-1 --- <!-- ID: signal_ramp --> signal_ramp [function] fn signal_ramp(start: Number, end: Number, duration: Number? = NUL) -> Signal Creates a linear ramp signal that clamps at its endpoints. Holds at `start` before t=0 and at `end` after t=duration. Parameters: start: Number — value at the start of the ramp end: Number — value at the end of the ramp duration: Number? — ramp length in units of the timebase, cycles by default (optional, defaults to 1) Returns: Signal — the clamped linear ramp signal Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#signal_ramp --- <!-- ID: sleep --> sleep [function] fn sleep(seconds: Number) -> NUL Lets the piece play for the given number of seconds before the next statement runs. Everything evaluated before the sleep is heard from its start. While it lasts, the session runs as it does between evaluations: `on_cycle` callbacks fire every cycle, and `print()` output appears as it is printed. Inside an `on_cycle` callback it only waits, holding up that cycle. Useful for timed recording, waiting for hardware, or a file run that plays for a set time. Parameters: seconds: Number — how long to play (e.g. 1.5 for 1500ms); negative is no time Returns: NUL — nothing Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#sleep --- <!-- ID: slice --> slice [function] fn slice(array: Array<Any>, start: Number, end: Number) -> Array<Any> Extracts a subarray from start index to end index. Parameters: array: Array — the source array start: Number — start index (inclusive, 0-based) end: Number — end index (exclusive) Returns: Array — the subarray Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#slice-1 --- <!-- ID: std/audio --> std/audio [module] Import: use "std/audio"; Track routing, instrument and effect hosting, parameter access, recording, events, and the audio-engine functions. class Session — The session: the tracks, the master bus and the routing targets of the piece. master: Master — The master output bus. nowhere: Nowhere — A routing target that sends no output. fn create_track(name: String) -> AudioTrack — Creates an audio track with the given name. fn create_midi_track(name: String) -> MidiTrack — Creates a MIDI track with the given name. fn track(name: String) -> AudioTrack — The audio track with the given name. fn midi_track(name: String) -> MidiTrack — The MIDI track with the given name. fn delete_track(name: String) -> NUL — Deletes the audio or MIDI track with the given name, as Delete Track in the mixer does. fn tracks() -> Array<AudioTrack | MidiTrack> — Every track in the session, audio and MIDI, in mixer order. fn modulations() -> Array<Dict<String, Any>> — Every parameter in the session that a signal, an automation lane or a pattern drives: device parameters, track and master volume and pan, and sends. class AudioTrack — A track in the audio engine for sample playback and routing. fn set_name(name: String) -> AudioTrack — Changes the track name. fn set_color(index: Number) -> AudioTrack — Sets the track colour. fn color() -> Number — The track colour. fn name() -> String — The name identifying this track. fn volume() -> Number — The track fader setting in dB. fn pan() -> Number — The track pan setting, from -1 to 1. fn output() -> Dict<String, Any>? — The selected output: kind, label and amount when routed to a track or master. fn sends() -> Array<Dict<String, Any>> — The auxiliary sends, each with dest and amount; the selected output is separate. fn input() -> Array<Number>? — The configured input channels, or NUL when none is selected. fn monitor() -> Monitor — The input monitoring mode. fn velocity() -> Number | Signal | Pattern — The configured note velocity source; 100 until `set_velocity` changes it. fn tuning() -> Number? — The pitch bend range, or NUL when tuning is disabled. fn mpe() -> Array<Number>? — The MPE range and low/high member channels, or NUL when MPE is disabled. fn key() -> Key? — The track key, or NUL when none is configured. fn punch_points() -> Array<Number?> — The punch-in and punch-out cycles; an unset point is NUL. fn set_instrument(instrument: Instrument) -> AudioTrack — Sets the instrument on this track. fn instrument() -> Instrument? — Returns the instrument currently attached to this track. fn remove_instrument() -> AudioTrack — Detaches the instrument from this track, leaving it with none. fn set_effects(effects: Array<Effect>) -> AudioTrack — Declaratively sets the whole effect chain, reconciling the live graph. fn effects() -> Array<Effect> — Returns an array of all effects in chain order. fn effect(name: String) -> Effect — Returns a modulatable handle to an effect by its slot name. fn remove_send(destination: AudioTrack | Master) -> AudioTrack — Removes a parallel send. fn set_send(destination: AudioTrack | Master, amount: Number | Signal | Pattern) -> AudioTrack — Adds a parallel aux send to the given destination, leaving the output edge untouched. fn send(destination: AudioTrack | Master) -> SendParam — Returns a modulatable handle to an existing send's level. fn delete() -> NUL — Deletes the track and releases its resources, as `session.delete_track(name)` does. fn routing_report() -> NUL — Displays detailed routing info for this track. fn set_volume(value: Number) -> AudioTrack — Sets track volume. fn set_pan(value: Number) -> AudioTrack — Sets track pan. fn mute() -> AudioTrack — Mutes the track, like Live's Track Activator. fn unmute() -> AudioTrack — Unmutes the track. fn is_muted() -> Boolean — Returns whether the track is muted. fn solo() -> AudioTrack — Solos the track, and only this track: every other solo is released, as a plain click on Live's Solo button. fn add_solo() -> AudioTrack — Adds the track to the soloed tracks and keeps the others soloed, as a Cmd-click on Live's Solo button. fn unsolo() -> AudioTrack — Releases the track's solo. fn is_soloed() -> Boolean — Returns whether the track is soloed. fn set_input(channel: Number, right: Number? = NUL) -> AudioTrack — Sets the hardware input channels for monitoring and recording. fn set_delay(ms: Number) -> AudioTrack — Sets this track's output delay, to line it up with outboard gear. fn delay() -> Number — Returns this track's output delay in milliseconds, as set by `set_delay`. fn arm() -> AudioTrack — Arms the track for recording. fn disarm() -> AudioTrack — Disarms the track, stopping recording. fn set_monitor(mode: Monitor) -> AudioTrack — Sets the input monitoring mode. fn is_armed() -> Boolean — Returns true if this track is armed for recording. fn is_recording() -> Boolean — Returns true if this track is currently capturing audio. fn take() -> AudioClip? — Collects one recorded pass as an AudioClip. fn reset_routing() -> AudioTrack — Resets the track's routing: output back to master, every send removed. fn save(path: String) -> AudioTrack — Collects one recorded pass, as `take` does (the oldest pass not yet collected), and writes it to a WAV file. fn punch(in_cycle: Number, out_cycle: Number) -> AudioTrack — Sets punch-in and punch-out points for time-bounded recording. fn punch_in(cycle: Number) -> AudioTrack — Sets only the punch-in point. fn punch_out(cycle: Number) -> AudioTrack — Sets only the punch-out point. fn clear_punch() -> AudioTrack — Clears all punch points from this track. fn is_punched() -> Boolean — Returns true if this track has punch points configured. fn set_velocity(vel: Number | Signal | Pattern) -> AudioTrack — Sets the velocity for notes played on this track. fn set_tuning(bend_range: Number? = NUL) -> AudioTrack — Enable microtonal pitch bend output. fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> AudioTrack — Enable MPE (per-note channel allocation) for polyphonic microtonal output. fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> AudioTrack — Set a track-level key for degree resolution and auto-quantization. class Master — The master output bus. fn volume() -> Number — Returns the master fader setting in dB. fn pan() -> Number — Returns the master pan setting, from -1 to 1. fn output() -> String — Returns the selected hardware output, as Output(channel) or Output(left, right). fn set_effects(effects: Array<Effect>) -> Master — Declaratively sets the whole effect chain, reconciling the live graph. fn effects() -> Array<Effect> — Returns an array of all effects in chain order. fn effect(name: String) -> Effect — Returns a modulatable handle to an effect by its slot name. fn set_volume(value: Number) -> Master — Sets master volume. fn set_pan(value: Number) -> Master — Sets master pan. class MeterFeed — A live level from a track or the master: `track.rms`, `track.peak`, or a band of a spectrum (`session.master.fft.band(lo, hi)`). fn get() -> Number — Reads the session's display meter level at evaluation time, with the mixer's ballistics: the peak holds the highest value and falls back, the RMS rises and falls smoothly. fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> MeterFeed — Smooths the level so it glides instead of strobing. fn range(min: Number, max: Number) -> MeterFeed — Maps the 0-to-1 level linearly onto [min, max]. class Nowhere — Nowhere: a track's output that goes nowhere, `session.nowhere`. class SpectrumFeed — A live spectrum from a track or the master (`track.fft`), bound to a shader texture with `<<`. fn smooth(attack_ms: Number, release_ms: Number? = NUL) -> SpectrumFeed — Smooths every bin so the spectrum glides between analysis frames. fn band(low_hz: Number, high_hz: Number) -> MeterFeed — Reduces a frequency band to a single level. enum Monitor { off, input, auto } — When a track's input is heard: Live's Monitor In / Auto / Off. class Bezier — An automation segment shaped as a cubic Bezier curve, as CSS's `cubic-bezier()`. class EffectParam — A parameter of an effect, obtained via `effect.parameter("name")`. class InstrumentParam — A parameter of an instrument, obtained via `instrument.parameter("name")`. class MasterParam — The master bus fader, `session.master.volume` (in dB) or `session.master.pan`. class ParamList — Wraps an array of parameter dicts from `.parameters()`. fn filter(name: String) -> ParamList — Filters parameters by name substring, case-insensitive; returns a new ParamList. fn length() -> Number — Returns the number of parameters. fn get(index: Number) -> Dict<String, Any> — Returns the parameter dict at the given index. fn json() -> Array<Dict<String, Any>> — Returns the parameter dicts, which `to_json()` writes for the list. class Parameter — A parameter a musician sets, modulates and automates: an effect's or an instrument's, a track's or the master's fader, a send's level. fn get() -> Number | Variant — Gets the parameter's current value. fn get_norm() -> Number — Reads the current parameter as a fraction of its declared range. fn text() -> String — Gets the parameter's current value as its device shows it. fn set(values: Number | Signal | Pattern | Array<Number | Curve | Bezier> | Variant) -> Parameter — Sets the parameter's value. fn set_norm(value: Number) -> Parameter — Sets the parameter by a fraction of its range. fn set_text(text: String) -> Parameter — Sets the parameter from text, as typed into a parameter box: the inverse of `.text()`. class SendParam — The level of one send, from `track.send(destination)`: 0.0 to 1.0. class TrackParam — An audio track's fader, `track.volume` (in dB: 0 = unity, -70 = mute, +6 the most) or `track.pan` (-1.0 = hard left, 1.0 = hard right). enum Curve { linear, step, exp, smooth, ease_in, ease_out, ease_in_out, ease } — The shape of an automation segment, from its breakpoint to the next one. class DspInstrument — An instrument a `dsp instrument` definition makes: `Pad()` for `dsp instrument Pad { ... fn set_parameter(name: String, value: Number) -> DspInstrument — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList of the instrument's parameters, headed by its name. fn Effect(name: String, plugin: String, plugin_id: String? = NUL) -> Effect — An audio effect processor. fn inputs() -> Array<Dict<String, Any>> — Returns the placed effect's sidechain connections. fn program() -> Number? — Reads the selected VST3 program index, or NUL if unavailable. fn name() -> String — Returns the slot name of this effect. fn parameter(name: String) -> EffectParam — Returns a parameter reference for the named parameter. fn set_parameter(name: String, value: Number | Variant) -> Effect — Sets a parameter value by name in its native range. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList of all effect parameters. fn supports_gui() -> Boolean — Returns whether this effect supports a graphical user interface. fn show_gui() -> NUL — Opens the plugin GUI window. fn hide_gui() -> NUL — Closes the plugin GUI window. fn save_state(path: String) -> Effect — Saves the effect's state to a preset file. fn load_state(path: String) -> Effect — Loads a preset file into the effect. fn connect_input(name: String, source: AudioTrack) -> Effect — Connects a named sidechain input port to a source audio track. fn programs() -> Array<String> — Lists all program/preset names built into the plugin. fn set_program(index: Number) -> Effect — Selects a factory program/preset by index. fn backend() -> String — Returns the device backend type ("Built-in", "CLAP", "VST3", or "dsp"). fn name() -> String — Returns the instrument's name: a plugin's as written before placement and as the live instrument reports it after, a `dsp instrument`'s definition name, a sampler's kit name. fn parameter(name: String) -> InstrumentParam — Returns a parameter reference by name. fn set_parameter(name: String, value: Number) -> Instrument — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList of the instrument's parameters. class PluginInstrument — A plugin instrument, CLAP or VST3, from `Instrument("Surge XT")`. fn set_parameter(name: String, value: Number) -> PluginInstrument — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList of all instrument parameters. fn backend() -> String — Returns the plugin format ("CLAP" or "VST3"). fn supports_gui() -> Boolean — Returns true if the plugin supports a GUI window. fn show_gui() -> NUL — Opens the plugin GUI window. fn hide_gui() -> NUL — Closes the plugin GUI window. fn save_state(path: String) -> PluginInstrument — Saves the plugin state to a preset file. fn load_state(path: String) -> PluginInstrument — Loads a preset file into the plugin. fn programs() -> Array<String> — Lists all program/preset names built into the plugin. fn program() -> Number? — The current VST3 factory program index, or NUL when the plugin exposes no program selector or is not VST3. fn set_program(index: Number) -> PluginInstrument — Selects a factory program/preset by index. class PluginList — Wraps an array of plugin dicts from `plugin_scan()`. fn filter(name: String) -> PluginList — Filters plugins by name substring, returns a new PluginList. fn length() -> Number — Returns the number of plugins. fn get(index: Number) -> Dict<String, Any> — Returns the plugin dict at the given index. fn json() -> Array<Dict<String, Any>> — Returns the plugin dicts, which `to_json()` writes for the list. fn Instrument(name: String, plugin_id: String? = NUL) -> PluginInstrument — Describes an instrument plugin (CLAP or VST3). fn plugin_rescan(path: String) -> PluginList — Re-opens one plugin bundle, whatever the plugin cache already says about it. fn plugin_scan(force: Boolean = false) -> PluginList — Scans CLAP and VST3 plugin directories, updates the plugin cache, and returns a PluginList with keys: name, id, vendor, format. class AudioClip — A reference into recorded audio: marker, length and arrangement position. fn save(path: String) -> AudioClip — Saves the clip to a WAV file. fn duration() -> Number — Returns the duration of the clip in seconds. fn samples() -> Number — Returns the total number of samples in the clip. fn sample_rate() -> Number — Returns the sample rate of the clip's audio. fn position() -> Number? — Returns where the clip sits in the arrangement, in cycles. fn left() -> Array<Number> — Returns the left channel as an array of sample values. fn right() -> Array<Number> — Returns the right channel as an array of sample values. fn mono() -> Array<Number> — Returns a mono mixdown as an array of sample values. class Event — A single note with pitch, velocity, and timing. fn note() -> Number — Returns the MIDI note number. fn velocity() -> Number — Returns the velocity the note plays at (1-127). fn start() -> Number — Returns the start time in cycles. fn duration() -> Number — Returns the duration in cycles. fn end() -> Number — Returns the end time (start + duration). fn transpose(semitones: Number) -> Event — Returns a new event transposed by the given number of semitones. fn detune(cents: Number) -> Event — Returns a new event detuned by the given number of cents (100 = one semitone). fn ratio(ratio: Number) -> Event — Returns a new event with its note's frequency scaled by the given ratio. class Note — A single MIDI pitch in semitones, fractional for microtonal values. fn from(n: Number) -> Note — A MIDI note number is a Note wherever a Note is asked for: `chord(60, "maj")`, `let n: Note = 60.5`. fn transpose(semitones: Number) -> Note — Returns a new note transposed by the given number of semitones. fn detune(cents: Number) -> Note — Returns a new note detuned by the given number of cents (100 = one semitone). fn ratio(ratio: Number) -> Note — Returns a new note with its frequency scaled by the given ratio. class Clip — A MIDI clip that loops at its stored beat length. fn query(cycle: Number) -> Pattern — Returns the pattern for a cycle. class ClipNote — One authored MIDI clip note, including its mute state. fn clip(bars: Number, notes: Array<ClipNote>) -> Clip — Makes a MIDI clip. fn note(pitch: Note | Number, start: Number, length: Number, velocity: Number? = NUL, muted: Boolean = false) -> ClipNote — Makes a MIDI clip note. fn Output(left: Number, right: Number? = NUL) -> Output — Output: hardware output channels of the audio device, a destination for `>>`. fn arrange(sections: Array<Pattern | Timeline | Section>) -> Timeline | Section — Sequences clips and arrangements back-to-back into one Timeline, or sections into one Section. fn audio_buffer_size() -> Number — The number of frames the audio device delivers per callback. fn audio_cpu_load() -> Dict<String, Any> — Returns a dict with audio CPU load information. fn audio_input_devices() -> Array<Dict<String, Any>> — Lists the devices this machine can record from. fn audio_latency() -> Dict<String, Any> — Returns a dict with audio latency information. fn audio_output_devices() -> Array<Dict<String, Any>> — Lists the devices this machine can play through. fn audio_sample_rate() -> Number — The sample rate the audio output is running at, in Hz. fn beats_per_cycle() -> Number — The current number of beats in a cycle. fn bpm() -> Number — The current transport tempo in beats per minute, including external clock. fn cycle() -> Number — The current fractional cycle position. fn is_playing() -> Boolean — Whether the transport is playing. fn midi_export(source: Pattern | Timeline | MidiTrack | Array<MidiTrack>, cycles: Number, path: String? = NUL) -> String — Exports a pattern, timeline, MIDI track or array of MIDI tracks to a Standard MIDI File (.mid). fn mixer_hide() -> NUL — Collapses the Mixer panel in the main window. fn mixer_show() -> NUL — Opens the main window with its Mixer panel expanded. fn notes(source: Pattern | Timeline | MidiTrack | Array<MidiTrack> | Section, cycles: Number, start_cycle: Number? = NUL) -> Array<Dict<String, Any>> — Lists the notes a pattern, timeline, MIDI track, array of MIDI tracks or section plays, as data. fn project_artist() -> String? — The artist set for this piece, or NUL when unset. fn project_title() -> String? — The title set for this piece, or NUL when unset. fn recording_offset() -> Number — Returns the recording latency residual in milliseconds. fn render(target: AudioTrack | Master | Screen | Array<AudioTrack | Master | Screen> | Number, cycles: Number? = NUL) -> NUL — Renders audio and/or the routed visual offline for the given number of cycles. fn render_master(cycles: Number) -> NUL — Renders the master output to a WAV file. fn routing_report(...tracks: AudioTrack) -> NUL — Displays the current audio routing graph. fn scope(signal: Signal, label: String = "") -> NUL — Registers a signal for visualization in the scope. fn scope_clear() -> NUL — Removes all signals from the scope view. fn scope_remove(signal: Signal) -> NUL — Removes a signal from the scope view. fn scope_show(min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL — Opens the scope window: every signal registered with `scope()` as a lane, its trace scrolling in from the right. fn scope_snap(path: String, min: Number? = NUL, max: Number? = NUL, length: Duration = …) -> NUL — Draws the scope as the window would show it and writes it to a PNG at the given path, whether or not the window is open: look at a signal without showing it to anyone. fn scope_values() -> Array<Dict<String, Any>> — The current scope probes as serializable values, without waiting for samples. fn section(length: Number) -> Section — Creates a multi-track section: lanes keyed by track, assigned with `sec[track] << clip` (whole lane) or `sec[track].at(start, dur) << clip`. fn set_bpm(bpm: Number, beats_per_cycle: Number? = NUL) -> NUL — Sets the tempo, and records it as the project's tempo in render metadata. fn set_project_artist(artist: String) -> NUL — Sets the project artist name. fn set_project_title(title: String) -> NUL — Sets the project title. fn timeline(length: Number) -> Timeline — Creates a mutable timeline builder for placing patterns along a lane. fn window_hide() -> NUL — Hide the main Resonon window. fn window_show() -> NUL — Open or raise the main Resonon window. fn window_snapshot(path: String, scale: Number? = NUL) -> NUL — Writes a PNG of the main window as it is drawn at that moment: the panels, their sizes and the meters, whether or not other windows cover it. class LaneLayer — One named layer of a lane, from `.layer(name)` on any lane. fn at(start: Number, duration: Number) -> TimelineSlot | SectionParam | SectionVisual — Addresses a span of this layer for a `<<` write. fn mute() -> LaneLayer — Silences the whole layer without destroying it. fn unmute() -> LaneLayer — Brings a muted layer back. fn clear() -> LaneLayer — Drops every entry on this layer. class Timeline — A single lane of patterns placed at positions along it. fn at(start: Number, duration: Number) -> TimelineSlot — Addresses a span of the timeline for a `<<` write. fn length() -> Number — Returns the timeline length. fn entry_count() -> Number — Returns how many entries have been written, on every layer. fn entries() -> Array<Dict<String, Any>> — Returns the entries as written — the base first, then each layer — not the flattened result. fn repeat(n: Number) -> Timeline — Returns a new timeline holding `n` back-to-back copies of this one; the receiver is untouched. fn layer(name: String) -> LaneLayer — Addresses one named layer. fn layers() -> Array<Dict<String, Any>> — Returns the layer stack, bottom-to-top (`base` first). fn set_layer_order(names: Array<String>) -> Timeline — Restacks the layers above `base`, bottom-to-top. fn clear() -> Timeline — Drops every layer above `base`, leaving what `arrange` laid down. fn clear_all() -> Timeline — Empties the timeline: every layer, `base` included. class TimelineSlot — A span of a note lane, from `.at(start, duration)`. fn clear() -> TimelineSlot — Drops the entry that starts at this slot's start on this slot's layer, bringing back what it was masking. class Section — A multi-track arrangement: one lane per track, plus automation and screen lanes. fn length() -> Number — Returns the section length. fn track_count() -> Number — Returns how many tracks have a note lane. fn tracks() -> Array<Number> — Returns the tracks that have a note lane. fn repeat(n: Number) -> Section — Returns a new section holding `n` back-to-back copies of this one; the receiver is untouched. fn play() -> Section — Binds every lane — notes, automation, screen — and plays from the top. class SectionEffect — An effect on a section lane's track, from `sec[track].effect(name)`. fn parameter(name: String) -> SectionParam — Addresses one of the effect's parameters as an automation lane. class SectionLane — A track's note lane in a section, from `sec[track]`. fn at(start: Number, duration: Number) -> TimelineSlot — Addresses a span of the lane for a `<<` write. fn entry_count() -> Number — Returns how many entries have been written, on every layer. fn entries() -> Array<Dict<String, Any>> — Returns the entries as written — the base first, then each layer — not the flattened result. fn effect(name: String) -> SectionEffect — Addresses an effect on this lane's track, by slot name, for automation. fn layer(name: String) -> LaneLayer — Addresses one named layer. fn layers() -> Array<Dict<String, Any>> — Returns the layer stack, bottom-to-top (`base` first). fn set_layer_order(names: Array<String>) -> SectionLane — Restacks the layers above `base`, bottom-to-top. fn clear() -> SectionLane — Drops every layer above `base`, leaving what the section laid down. fn clear_all() -> SectionLane — Empties the lane: every layer, `base` included. class SectionParam — An automation lane in a section, from `sec[track].volume`, `.pan`, or `sec[track].effect(name).parameter(name)`. fn at(start: Number, duration: Number) -> SectionParam — Narrows the next `<<` write to a span of the lane. fn entry_count() -> Number — Returns how many curves have been written, on every layer. fn entries() -> Array<Dict<String, Any>> — Returns the curves as written — the base first, then each layer — not the flattened result. fn layer(name: String) -> LaneLayer — Addresses one named layer. fn layers() -> Array<Dict<String, Any>> — Returns the layer stack, bottom-to-top (`base` first). fn set_layer_order(names: Array<String>) -> SectionParam — Restacks the layers above `base`, bottom-to-top. fn clear() -> SectionParam — Drops every layer above `base` — or, after `.at(start, duration)`, just the curve that starts there. fn clear_all() -> SectionParam — Empties the lane: every layer, `base` included. class SectionVisual — The screen lane of a section, from `sec[screen]`. fn at(start: Number, duration: Number) -> SectionVisual — Narrows the next `<<` write to a span of the lane. fn entry_count() -> Number — Returns how many visuals have been written, on every layer. fn entries() -> Array<Dict<String, Any>> — Returns the visuals as written — the base first, then each layer — not the flattened result. fn layer(name: String) -> LaneLayer — Addresses one named layer. fn layers() -> Array<Dict<String, Any>> — Returns the layer stack, bottom-to-top (`base` first). fn set_layer_order(names: Array<String>) -> SectionVisual — Restacks the layers above `base`, bottom-to-top. fn clear() -> SectionVisual — Drops every layer above `base` — or, after `.at(start, duration)`, just the visual that starts there. fn clear_all() -> SectionVisual — Empties the lane: every layer, `base` included. Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/ --- <!-- ID: std/core --> std/core [module] Import: use "std/core"; The core data types with their methods, durations, scalar math, and the global utility and transport functions. class Array — Ordered collection of values. fn length() -> Number — Returns the number of elements. fn push(value: Any) -> Array<Any> — Adds an element to the end of the array. fn pop() -> Any — Removes and returns the last element. fn get(index: Number) -> Any — Returns the element at the given index. fn slice(start: Number, end: Number) -> Array<Any> — Returns a subarray from start (inclusive) to end (exclusive). fn concat(other: Array<Any>) -> Array<Any> — Returns a new array with elements from both arrays. fn reverse() -> Array<Any> — Returns a new array with elements in reverse order. fn contains(value: Any) -> Boolean — Returns true if the array contains the given value. fn map(func: Function) -> Array<Any> — Applies a function to each element, returns a new array. fn filter(func: Function) -> Array<Any> — Returns a new array with only elements satisfying the predicate. fn reduce(func: Function, initial: Any) -> Any — Reduces the array to a single value. fn iter() -> Iterator<Any> — Returns an iterator over the array elements. fn concat(array1: Array<Any>, array2: Array<Any>) -> Array<Any> — Concatenates two arrays. fn filter(array: Array<Any>, func: Function) -> Array<Any> — Selects elements from an array that satisfy a predicate. fn fold(array: Array<Any>, initial: Any, func: Function) -> Any — Reduces an array to a single value using an accumulator function. fn length(array: Array<Any>) -> Number — Returns the number of elements in an array. fn map(array: Array<Any>, func: Function) -> Array<Any> — Transforms each element of an array using a function. fn range(start_or_end: Number, end: Number? = NUL) -> Array<Number> — Generates an array of sequential numbers. fn slice(array: Array<Any>, start: Number, end: Number) -> Array<Any> — Extracts a subarray from start index to end index. class String — Text value with Unicode support. fn length() -> Number — Returns the character count (Unicode-aware). fn uppercase() -> String — Returns the string converted to uppercase. fn lowercase() -> String — Returns the string converted to lowercase. fn substring(start: Number, end: Number) -> String — Returns a substring from start to end (Unicode-aware). fn split(delimiter: String) -> Array<String> — Splits the string by a delimiter, returns an array of strings. fn contains(needle: String) -> Boolean — Returns true if the string contains the given substring. fn trim() -> String — Returns the string with leading and trailing whitespace removed. fn replace(old: String, new: String) -> String — Returns the string with all occurrences of old replaced with new. fn starts_with(prefix: String) -> Boolean — Returns true if the string starts with the given prefix. fn ends_with(suffix: String) -> Boolean — Returns true if the string ends with the given suffix. fn repeat(n: Number) -> String — Returns a new string by repeating this string n times. fn iter() -> Iterator<String> — Returns an iterator over the characters. class Dict — Key-value mapping with String or Number keys. fn get(key: String | Number) -> Any — Returns the value for the given key, or NUL if not found. fn set(key: String | Number, value: Any) -> Dict<String | Number, Any> — Sets a key-value pair in place. fn remove(key: String | Number) -> Any — Removes a key in place. fn keys() -> Array<String | Number> — Returns an Array of all keys. fn values() -> Array<Any> — Returns an Array of all values. fn length() -> Number — Returns the number of entries. fn contains_key(key: String | Number) -> Boolean — Returns true if the dict contains the given key. fn entries() -> Array<Array<Any>> — Returns an Array of [key, value] pairs. fn merge(other: Dict<String | Number, Any>) -> Dict<String | Number, Any> — Returns a new dict with entries from both dicts merged. fn map(func: Function) -> Dict<String | Number, Any> — Transforms values using a function. fn filter(func: Function) -> Dict<String | Number, Any> — Filters entries by predicate. fn reduce(func: Function, initial: Any) -> Any — Reduces entries to a single value. fn iter() -> Iterator<String | Number> — Returns an Iterator over the keys. class Iterator — Lazy sequence of values with chainable transformations. fn next() -> Any — Returns the next value, or `NUL` if exhausted. fn take(n: Number) -> Iterator<Any> — Returns a lazy iterator yielding the first n elements. fn collect() -> Array<Any> — Collects all remaining elements into an array. fn skip(n: Number) -> Iterator<Any> — Returns a lazy iterator that skips the first n elements. fn count() -> Number — Counts remaining elements (consumes the iterator). fn step_by(step: Number) -> Iterator<Any> — Returns a lazy iterator yielding every nth element. fn enumerate() -> Iterator<Any> — Returns a lazy iterator yielding [index, value] pairs. fn first() -> Any — Returns the first element, or `NUL` if empty. fn last() -> Any — Returns the last element, or `NUL` if empty. fn map(func: Function) -> Iterator<Any> — Returns a lazy iterator applying a function to each element. fn filter(func: Function) -> Iterator<Any> — Returns a lazy iterator yielding the elements that match the predicate. fn find(func: Function) -> Any — Returns the first element matching the predicate, or `NUL`. fn any(func: Function) -> Boolean — Returns true if any element matches the predicate. fn all(func: Function) -> Boolean — Returns true if all elements match the predicate. fn fold(initial: Any, func: Function) -> Any — Folds the iterator to a single value. fn zip(other: Iterator<Any>) -> Iterator<Any> — Zips this iterator with another, yielding [a, b] pairs. fn chain(other: Iterator<Any>) -> Iterator<Any> — Chains another iterator after this one. fn flatten() -> Array<Any> — Flattens nested arrays into a single array. class Tuple — Fixed-size, immutable, ordered group of values. fn length() -> Number — Returns the number of elements. fn get(index: Number) -> Any — Returns the element at the given index, like `t[index]`. class Clone — A value that can make an independent copy of itself with `.clone()`. fn clone() -> Self — Returns an independent copy: a change to the copy is not seen through the original, nor the other way round. class Json — A value with a JSON form: `to_json()` writes what `json()` returns in its place. fn json() -> Any — Returns the value that stands for this one in JSON: what `to_json()` writes in its place. class Format — A value with a canonical source form. fn format(value: Any) -> String — Returns canonical source text for a value. class Variant — A variant of any enum: `Curve.linear`, `Monitor.auto`. fn clock() -> Number — Returns time in nanoseconds from an arbitrary reference point. fn hostname() -> String — Returns this machine's hostname. fn load_file(path: String) -> String — Reads a text file and returns its contents as a String. fn print(value: Any, newline: Boolean = true) -> NUL — Writes a value to the output, followed by a newline. fn put(value: Any) -> NUL — Writes a value to the output with no trailing newline. fn reload_ext(name: String) -> NUL — Reloads a native extension from disk. fn reload_preferences() -> NUL — Re-reads `~/.resonon/preferences.toml` and applies whatever changed. fn show(value: Any = NUL) -> NUL — Displays detailed information about a value. fn sleep(seconds: Number) -> NUL — Lets the piece play for the given number of seconds before the next statement runs. fn to_json(value: MeterFeed | Boolean | Number | String | Array<Any> | Tuple | Dict<String | Number, Any> | Json?) -> String — Returns the JSON text of a value, on one line. fn type(value: Any = NUL) -> String — Returns the type name of a value as a string. fn abs(x: Number) -> Number — Absolute value. fn ceil(x: Number) -> Number — Smallest integer greater than or equal to the value. fn clamp(x: Number, lo: Number, hi: Number) -> Number — Constrains a value to the inclusive range [lo, hi]. fn cos(x: Number) -> Number — Cosine of an angle in radians. fn exp(x: Number) -> Number — Exponential function (e raised to the power x). fn floor(x: Number) -> Number — Largest integer less than or equal to the value. fn fract(x: Number) -> Number — Fractional part of the value (the part after the decimal point). fn ftom(freq: Number) -> Number — Converts a frequency in Hz to a MIDI note number. fn lerp(a: Number, b: Number, t: Number) -> Number — Linearly interpolates between two values. fn log(x: Number) -> Number — Natural logarithm (base e). fn log10(x: Number) -> Number — Base-10 logarithm. fn log2(x: Number) -> Number — Base-2 logarithm. fn max(a: Number, b: Number) -> Number — Larger of two numbers. fn min(a: Number, b: Number) -> Number — Smaller of two numbers. fn mtof(note: Number) -> Number — Converts a MIDI note number to frequency in Hz. fn pow(base: Number, exponent: Number) -> Number — Raises a base to a power. fn round(value: Number, places: Number = 0) -> Number — Rounds a number to the given number of decimal places. fn sin(x: Number) -> Number — Sine of an angle in radians. fn sqrt(x: Number) -> Number — Square root. fn tan(x: Number) -> Number — Tangent of an angle in radians. fn tanh(x: Number) -> Number — Hyperbolic tangent. class Duration — A length of time in the unit it was written in: cycles, beats or seconds. fn dotted() -> Duration — Returns the duration half again as long: a dotted note value. fn triplet() -> Duration — Returns the duration two thirds as long: a triplet note value, three in the space of two. fn beats(n: Number) -> Duration — A duration in beats. fn cycles(n: Number) -> Duration — A duration in cycles. fn ms(n: Number) -> Duration — A duration in milliseconds. fn note_value(num: Number, den: Number) -> Duration — A note value: `num / den` of a whole note, which is four beats. fn seconds(n: Number) -> Duration — A duration in seconds. Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/ --- <!-- ID: std/core::abs --> std/core::abs [function] fn abs(x: Number) -> Number Absolute value. Parameters: x: Number — the input value Returns: Number — the absolute value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#abs --- <!-- ID: std/core::ceil --> std/core::ceil [function] fn ceil(x: Number) -> Number Smallest integer greater than or equal to the value. Parameters: x: Number — the input value Returns: Number — the ceiling Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#ceil --- <!-- ID: std/core::clamp --> std/core::clamp [function] fn clamp(x: Number, lo: Number, hi: Number) -> Number Constrains a value to the inclusive range [lo, hi]. Parameters: x: Number — the value to constrain lo: Number — lower bound hi: Number — upper bound Returns: Number — the clamped value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#clamp --- <!-- ID: std/core::cos --> std/core::cos [function] fn cos(x: Number) -> Number Cosine of an angle in radians. Parameters: x: Number — angle in radians Returns: Number — the cosine Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#cos --- <!-- ID: std/core::exp --> std/core::exp [function] fn exp(x: Number) -> Number Exponential function (e raised to the power x). Parameters: x: Number — the exponent Returns: Number — e to the power x Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#exp --- <!-- ID: std/core::floor --> std/core::floor [function] fn floor(x: Number) -> Number Largest integer less than or equal to the value. Parameters: x: Number — the input value Returns: Number — the floor Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#floor --- <!-- ID: std/core::fract --> std/core::fract [function] fn fract(x: Number) -> Number Fractional part of the value (the part after the decimal point). Parameters: x: Number — the input value Returns: Number — the fractional part Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#fract --- <!-- ID: std/core::ftom --> std/core::ftom [function] fn ftom(freq: Number) -> Number Converts a frequency in Hz to a MIDI note number. Parameters: freq: Number — frequency in Hz Returns: Number — MIDI note number (may be fractional) Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#ftom --- <!-- ID: std/core::lerp --> std/core::lerp [function] fn lerp(a: Number, b: Number, t: Number) -> Number Linearly interpolates between two values. Parameters: a: Number — start value (t = 0) b: Number — end value (t = 1) t: Number — interpolation factor Returns: Number — the interpolated value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#lerp --- <!-- ID: std/core::log --> std/core::log [function] fn log(x: Number) -> Number Natural logarithm (base e). Parameters: x: Number — the input value Returns: Number — the natural logarithm Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#log --- <!-- ID: std/core::log10 --> std/core::log10 [function] fn log10(x: Number) -> Number Base-10 logarithm. Parameters: x: Number — the input value Returns: Number — the base-10 logarithm Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#log10 --- <!-- ID: std/core::log2 --> std/core::log2 [function] fn log2(x: Number) -> Number Base-2 logarithm. Parameters: x: Number — the input value Returns: Number — the base-2 logarithm Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#log2 --- <!-- ID: std/core::max --> std/core::max [function] fn max(a: Number, b: Number) -> Number Larger of two numbers. Parameters: a: Number — first value b: Number — second value Returns: Number — the larger value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#max --- <!-- ID: std/core::min --> std/core::min [function] fn min(a: Number, b: Number) -> Number Smaller of two numbers. Parameters: a: Number — first value b: Number — second value Returns: Number — the smaller value Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#min --- <!-- ID: std/core::mtof --> std/core::mtof [function] fn mtof(note: Number) -> Number Converts a MIDI note number to frequency in Hz. Parameters: note: Number — MIDI note number (69 = A4 = 440 Hz) Returns: Number — frequency in Hz Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#mtof --- <!-- ID: std/core::pow --> std/core::pow [function] fn pow(base: Number, exponent: Number) -> Number Raises a base to a power. Parameters: base: Number — the base exponent: Number — the exponent Returns: Number — base raised to the exponent Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#pow --- <!-- ID: std/core::round --> std/core::round [function] fn round(value: Number, places: Number = 0) -> Number Rounds a number to the given number of decimal places. Parameters: value: Number — the number to round places: Number — decimal places Returns: Number — the rounded number Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#round --- <!-- ID: std/core::sin --> std/core::sin [function] fn sin(x: Number) -> Number Sine of an angle in radians. Parameters: x: Number — angle in radians Returns: Number — the sine Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#sin --- <!-- ID: std/core::sqrt --> std/core::sqrt [function] fn sqrt(x: Number) -> Number Square root. Parameters: x: Number — the input value Returns: Number — the square root Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#sqrt --- <!-- ID: std/core::tan --> std/core::tan [function] fn tan(x: Number) -> Number Tangent of an angle in radians. Parameters: x: Number — angle in radians Returns: Number — the tangent Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#tan --- <!-- ID: std/core::tanh --> std/core::tanh [function] fn tanh(x: Number) -> Number Hyperbolic tangent. Parameters: x: Number — the input value Returns: Number — the hyperbolic tangent Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#tanh --- <!-- ID: std/effects --> std/effects [module] Import: use "std/effects"; Effect constructors for use with `track.set_effects(#[...])`. enum FilterType { lowpass, highpass, bandpass, notch, allpass, peak } — The response of a `Filter`: the steps of its Type parameter, in order. fn Filter(name: String, type: FilterType? = NUL, cutoff: Number? = NUL, resonance: Number? = NUL, gain: Number? = NUL) -> Effect — Creates a filter effect: one state-variable filter whose Type chooses the response, as Live's Auto Filter does. fn Delay(name: String, time: Number? = NUL, feedback: Number? = NUL) -> Effect — Creates a feedback delay, half dry and half wet by default, its time in seconds. fn PlateReverb(name: String, size: Number? = NUL, damping: Number? = NUL, diffusion: Number? = NUL, predelay: Number? = NUL, mix: Number? = NUL) -> Effect — Creates a plate reverb effect (Dattorro algorithm). fn Reverb(name: String, room: Number? = NUL, damp: Number? = NUL, width: Number? = NUL, mix: Number? = NUL) -> Effect — Creates a reverb effect (Freeverb algorithm). fn Distortion(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect — Creates a distortion effect (asymmetrical/transistor-style clipping). fn Overdrive(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect — Creates an overdrive effect (symmetrical/tube-style tanh clipping). Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: std/effects/delay --> std/effects/delay [module] Import: use "std/effects/delay"; The built-in delay effect: a stereo feedback delay for echo and slapback textures. It goes onto a track's chain with `track.set_effects(#[...])`. fn Delay(name: String, time: Number? = NUL, feedback: Number? = NUL) -> Effect — Creates a feedback delay, half dry and half wet by default, its time in seconds. Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: std/effects/distortion --> std/effects/distortion [module] Import: use "std/effects/distortion"; Built-in saturation effects — waveshaping drive for warmth and grit. fn Distortion(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect — Creates a distortion effect (asymmetrical/transistor-style clipping). fn Overdrive(name: String, drive: Number? = NUL, tone: Number? = NUL) -> Effect — Creates an overdrive effect (symmetrical/tube-style tanh clipping). Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: std/effects/filters --> std/effects/filters [module] Import: use "std/effects/filters"; The built-in filter effect: one state-variable filter whose `FilterType` chooses the response (lowpass, highpass, bandpass, notch, allpass or peak). It goes onto a track's chain with `track.set_effects(#[...])`. enum FilterType { lowpass, highpass, bandpass, notch, allpass, peak } — The response of a `Filter`: the steps of its Type parameter, in order. fn Filter(name: String, type: FilterType? = NUL, cutoff: Number? = NUL, resonance: Number? = NUL, gain: Number? = NUL) -> Effect — Creates a filter effect: one state-variable filter whose Type chooses the response, as Live's Auto Filter does. Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: std/effects/reverb --> std/effects/reverb [module] Import: use "std/effects/reverb"; Reverb effects. Freeverb (room) and Dattorro (plate) algorithms. fn PlateReverb(name: String, size: Number? = NUL, damping: Number? = NUL, diffusion: Number? = NUL, predelay: Number? = NUL, mix: Number? = NUL) -> Effect — Creates a plate reverb effect (Dattorro algorithm). fn Reverb(name: String, room: Number? = NUL, damp: Number? = NUL, width: Number? = NUL, mix: Number? = NUL) -> Effect — Creates a reverb effect (Freeverb algorithm). Page: reference/stdlib/effects URL: https://resonon.org/docs/reference/stdlib/effects/ --- <!-- ID: std/generative --> std/generative [module] Import: use "std/generative"; Stateful generative pattern sources. The cycle-callback helpers are part of the prelude (always in scope); the stream and Markov sources need `use "std/generative";`. fn off_cycle() -> NUL — Clear all per-cycle callbacks registered via on_cycle(). fn on_cycle(callback: Function) -> NUL — Register a per-cycle callback that runs on the interpreter thread. fn prime_cycles() -> NUL — Fire cycle callbacks once, for the cycle the playhead is on, so the pattern that plays next is ready before it is needed. fn markov(num_states: Number, transitions: Array<Array<Number>>, initial: Number) -> Pattern — Creates a Markov chain pattern with cycle-seeded transitions. fn stream(initial: Note | Number | Array<Any> | Pattern, next_fn: Function) -> Pattern — Creates a stateful stream pattern from an initial value and a next function. Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/ --- <!-- ID: std/instruments --> std/instruments [module] Import: use "std/instruments"; Load and play audio samples as drum kits or melodic instruments. fn Kit(kit_name: String? = NUL) -> Kit — A drum kit's metadata: its samples, the notes they sit on and their files. fn samples() -> Array<String> — Returns the kit's sample names. fn sample_info() -> Array<Array<String | Number>> — Returns each sample with its note and file, sorted by note. fn name() -> String — Returns the kit's display name. fn mode() -> String — Returns how the kit plays: "oneshot" or "melodic". fn author() -> String — Returns the kit's author. fn Sample(path: String) -> AudioClip — Loads a WAV file as an audio clip. class DrumSample — A reference to a single drum sample slot. fn envelope() -> Array<Number?> — The current [attack_ms, decay_ms, sustain, release_ms] envelope of this placed pad. fn parameter(name: String) -> InstrumentParam — Returns a parameter reference for this slot. fn set_parameter(name: String, value: Number) -> DrumSample — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with this slot's parameters. fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSample — Sets the ADSR envelope for this sample. fn name() -> String — Returns the sample name. fn note() -> Number — Returns the MIDI note number for this sample. fn Sampler(kit: Kit? = NUL) -> Sampler — A CLAP drum sampler plugin with per-sample note mapping. fn choke_group(name: String) -> Number? — The choke group assigned to a sound, or NUL when unassigned. fn samples() -> Array<String> — Returns an array of loaded sample names. fn sample_info() -> Array<Array<String | Number>> — Returns an array of [name, note, file] for each sample. fn note(name: String) -> Number — Returns the MIDI note number for the given sample name. fn set_note(name: String, new_note: Note) -> Sampler — Moves a sound to a different trigger note. fn parameter(name: String) -> InstrumentParam — Returns a parameter reference by raw path. fn set_parameter(name: String, value: Number) -> Sampler — Sets a parameter value by raw path. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with all sampler parameters. fn sample(name: String) -> AudioClip — Gets the audio behind a kit sound, as a clip. fn set_choke_group(group: Number, samples: Array<String>) -> Sampler — Assigns samples to a choke group. fn load_kit(kit: Kit) -> Sampler — Loads a kit into the sampler. fn slot(name_or_note: String | Note) -> DrumSample — Returns a reference to a drum sample slot. fn SamplerMelodic(kit: Kit? = NUL) -> SamplerMelodic — A CLAP melodic sampler plugin with pitch-shifting. fn envelope() -> Array<Number?> — The current [attack_ms, decay_ms, sustain, release_ms] envelope. fn loop_normalized() -> Array<Number?> — The current normalized [start, end] loop positions. fn loop_region() -> Array<Number?>? — The current [start, end] loop positions in seconds, or NUL with no loaded sample. fn load_sample(name: String, root_note: Note? = NUL) -> SamplerMelodic — Loads a sample from the kit directory. fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodic — Sets the ADSR envelope for the current sample. fn set_root(note: Note) -> SamplerMelodic — Overrides the root note for the current sample. fn samples() -> Array<String> — Returns an array of loaded sample names. fn sample_info() -> Array<Array<String | Number?>> — Returns an array of [name, root, file] for each sample, with root `NUL` if unset. fn root(name: String) -> Number? — Returns the root note for the given sample, or `NUL` if unset. fn set_parameter(name: String, value: Number) -> SamplerMelodic — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with all sampler parameters. fn sample(name: String) -> AudioClip — Gets the audio behind a kit sound, as a clip. fn load_kit(kit: Kit) -> SamplerMelodic — Loads a kit into the sampler. fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodic — Sets the loop region in seconds. fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodic — Sets the loop region using normalized [0,1] positions. Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/ --- <!-- ID: std/instruments/melodic --> std/instruments/melodic [module] Import: use "std/instruments/melodic"; The melodic sampler. `SamplerMelodic` pitch-shifts one sample across the keyboard, turning a single recording into a playable chromatic instrument. Load a sample, load it onto a track with `track.set_instrument(...)`, and let pattern notes set the pitch. fn SamplerMelodic(kit: Kit? = NUL) -> SamplerMelodic — A CLAP melodic sampler plugin with pitch-shifting. fn envelope() -> Array<Number?> — The current [attack_ms, decay_ms, sustain, release_ms] envelope. fn loop_normalized() -> Array<Number?> — The current normalized [start, end] loop positions. fn loop_region() -> Array<Number?>? — The current [start, end] loop positions in seconds, or NUL with no loaded sample. fn load_sample(name: String, root_note: Note? = NUL) -> SamplerMelodic — Loads a sample from the kit directory. fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodic — Sets the ADSR envelope for the current sample. fn set_root(note: Note) -> SamplerMelodic — Overrides the root note for the current sample. fn samples() -> Array<String> — Returns an array of loaded sample names. fn sample_info() -> Array<Array<String | Number?>> — Returns an array of [name, root, file] for each sample, with root `NUL` if unset. fn root(name: String) -> Number? — Returns the root note for the given sample, or `NUL` if unset. fn set_parameter(name: String, value: Number) -> SamplerMelodic — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with all sampler parameters. fn sample(name: String) -> AudioClip — Gets the audio behind a kit sound, as a clip. fn load_kit(kit: Kit) -> SamplerMelodic — Loads a kit into the sampler. fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodic — Sets the loop region in seconds. fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodic — Sets the loop region using normalized [0,1] positions. Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/ --- <!-- ID: std/instruments/sample --> std/instruments/sample [module] Import: use "std/instruments/sample"; Audio sources. A WAV file loaded as a clip, and the named collections of them that the samplers load. fn Kit(kit_name: String? = NUL) -> Kit — A drum kit's metadata: its samples, the notes they sit on and their files. fn samples() -> Array<String> — Returns the kit's sample names. fn sample_info() -> Array<Array<String | Number>> — Returns each sample with its note and file, sorted by note. fn name() -> String — Returns the kit's display name. fn mode() -> String — Returns how the kit plays: "oneshot" or "melodic". fn author() -> String — Returns the kit's author. fn Sample(path: String) -> AudioClip — Loads a WAV file as an audio clip. Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/ --- <!-- ID: std/instruments/sampler --> std/instruments/sampler [module] Import: use "std/instruments/sampler"; The drum sampler. `Sampler` triggers one sample per slot from a loaded kit, mapping incoming pattern notes to kit slots. Build one from a `Kit`, load it onto a track with `track.set_instrument(...)`, and drive it with a pattern. class DrumSample — A reference to a single drum sample slot. fn envelope() -> Array<Number?> — The current [attack_ms, decay_ms, sustain, release_ms] envelope of this placed pad. fn parameter(name: String) -> InstrumentParam — Returns a parameter reference for this slot. fn set_parameter(name: String, value: Number) -> DrumSample — Sets a parameter value by name. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with this slot's parameters. fn set_envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSample — Sets the ADSR envelope for this sample. fn name() -> String — Returns the sample name. fn note() -> Number — Returns the MIDI note number for this sample. fn Sampler(kit: Kit? = NUL) -> Sampler — A CLAP drum sampler plugin with per-sample note mapping. fn choke_group(name: String) -> Number? — The choke group assigned to a sound, or NUL when unassigned. fn samples() -> Array<String> — Returns an array of loaded sample names. fn sample_info() -> Array<Array<String | Number>> — Returns an array of [name, note, file] for each sample. fn note(name: String) -> Number — Returns the MIDI note number for the given sample name. fn set_note(name: String, new_note: Note) -> Sampler — Moves a sound to a different trigger note. fn parameter(name: String) -> InstrumentParam — Returns a parameter reference by raw path. fn set_parameter(name: String, value: Number) -> Sampler — Sets a parameter value by raw path. fn parameters(filter: String? = NUL) -> ParamList — Returns a ParamList with all sampler parameters. fn sample(name: String) -> AudioClip — Gets the audio behind a kit sound, as a clip. fn set_choke_group(group: Number, samples: Array<String>) -> Sampler — Assigns samples to a choke group. fn load_kit(kit: Kit) -> Sampler — Loads a kit into the sampler. fn slot(name_or_note: String | Note) -> DrumSample — Returns a reference to a drum sample slot. Page: reference/stdlib/instruments URL: https://resonon.org/docs/reference/stdlib/instruments/ --- <!-- ID: std/midi --> std/midi [module] Import: use "std/midi"; MIDI output: tracks, control-change lanes, and port management. class CcOutput — A MIDI track's CC lane, from `track.cc(number)`. fn send_rate() -> Number — The CC send rate in Hz. fn set_send_rate(hz: Number) -> CcOutput — Set the CC send rate in Hz (default 30). fn MidiOutput(alias: String, channel: Number? = NUL) -> MidiOutput — MidiOutput: a MIDI output port and channel, a destination for `>>` — Live's "MIDI To". class MidiTrack — A MIDI track: plays patterns and CC to a hardware or virtual MIDI port. fn delete() -> NUL — Deletes the track and disconnects its input and output. fn set_name(name: String) -> MidiTrack — Changes the track name. fn set_color(index: Number) -> MidiTrack — Sets the track colour. fn color() -> Number — The track colour. fn name() -> String — The track name. fn output() -> Dict<String | Number, Any>? — The output port and channel, or NUL for no output. fn input() -> Dict<String | Number, Any>? — The input port and channel (NUL for all channels), or NUL when unset. fn monitor() -> Monitor — The input monitoring mode. fn velocity() -> Number | Signal | Pattern — The configured velocity source; 100 until `set_velocity` changes it. fn tuning() -> Number? — The pitch-bend range in semitones, or NUL when disabled. fn mpe() -> Dict<String | Number, Any>? — The MPE range and member channel bounds, or NUL when disabled. fn key() -> Key? — The track key, or NUL when unset. fn set_input(alias: String, channel: Number? = NUL) -> MidiTrack — Set the MIDI input port and optional channel. fn set_monitor(mode: Monitor) -> MidiTrack — Set the monitor mode: whether what is played on the input passes through to the output. fn set_velocity(vel: Number | Signal | Pattern) -> MidiTrack — Set the default velocity for this track. fn cc(cc_number: Number) -> CcOutput — Get a CC output handle for the given controller number. fn set_tuning(bend_range: Number? = NUL) -> MidiTrack — Enable microtonal pitch bend output. fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> MidiTrack — Enable MPE (per-note channel allocation) for polyphonic microtonal output. fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> MidiTrack — Set a track-level key for degree resolution and auto-quantization. fn mute() -> MidiTrack — Mutes the track, like Live's Track Activator: its notes and CC stop at once, and the notes it holds get their note-offs. fn unmute() -> MidiTrack — Unmutes the track. fn is_muted() -> Boolean — Returns whether the track is muted. fn solo() -> MidiTrack — Solos the track, and only this track: every other solo is released and every other track — audio and MIDI — falls silent, as a plain click on Live's Solo button. fn add_solo() -> MidiTrack — Adds the track to the soloed tracks and keeps the others soloed, as a Cmd-click on Live's Solo button. fn unsolo() -> MidiTrack — Releases the track's solo. fn is_soloed() -> Boolean — Returns whether the track is soloed. enum MidiLatency { auto, manual } — How outgoing MIDI is aligned with the audio output. fn midi_clock_report() -> NUL — Print MIDI clock status: source, BPM, transport state, and PLL diagnostics. fn midi_clock_send() -> Boolean — Whether outgoing MIDI clock is enabled. fn midi_clock_source() -> String? — The followed input alias, or NUL for the internal clock. fn midi_connected() -> Dict<String, String> — Checks the current MIDI connection status. fn midi_disconnect(alias: String) -> NUL — Disconnects a MIDI output port. fn midi_input_disconnect(alias: String) -> NUL — Disconnects a MIDI input port by alias. fn midi_input_events(limit: Number = 100, port: String? = NUL) -> Array<Dict<String | Number, Any>> — Recent input messages, oldest first, from connected input ports. fn midi_input_ports() -> Array<String> — Lists all available MIDI input ports. fn midi_latency() -> MidiLatency — The outgoing MIDI alignment mode. fn midi_latency_report() -> NUL — Print the MIDI output alignment report. fn midi_output_ports() -> Array<String> — Lists all available MIDI output ports. fn midi_port_clock(alias: String) -> Boolean — Returns whether a MIDI output port is opted in to receiving clock. fn midi_port_clock_trim(alias: String) -> Number — Returns a MIDI output port's clock-only trim in milliseconds. fn midi_port_trim(alias: String) -> Number — Returns a MIDI output port's timing trim in milliseconds. fn midi_routing_report() -> NUL — Displays the current MIDI routing: connected output/input ports and active slots. fn midi_trace() -> Boolean — Whether MIDI timing trace recording is enabled. fn midi_trace_report() -> NUL — Print the MIDI timing trace: clock tick spacing, note dispatch, phase errors. fn set_midi_clock_send(enabled: Boolean) -> NUL — Enable/disable MIDI clock output (master mode). fn set_midi_clock_source(alias: String? = NUL) -> NUL — Sets where the tempo and transport come from: an external MIDI clock on an input port (follower mode), or resonon's own clock. fn set_midi_latency(mode: MidiLatency) -> NUL — Sets how outgoing MIDI is aligned with the audio output. fn set_midi_trace(on: Boolean) -> NUL — Start or stop the MIDI timing trace. Page: reference/stdlib/midi URL: https://resonon.org/docs/reference/stdlib/midi/ --- <!-- ID: std/patterns --> std/patterns [module] Import: use "std/patterns"; The core sequencing type and its combinators. class Pattern — A MIDI note pattern for sequencing. fn query(cycle: Number) -> Note | Number | Rest | Array<Any> | Pattern? — Returns what the pattern plays in one cycle. fn fast(factor: Number | Pattern) -> Pattern — Speeds up the pattern by the given factor. fn slow(factor: Number | Pattern) -> Pattern — Slows down the pattern by the given factor. fn transpose(semitones: Number | Pattern) -> Pattern — Transposes all notes by the given number of semitones. fn reverse() -> Pattern — Reverses the pattern playback order. fn rotate(steps: Number) -> Pattern — Rotates the pattern by the given number of steps. fn stack(other: Pattern | Note | Array<Any>) -> Pattern — Stacks this pattern with another (polyphonic layering). fn concat(other: Pattern | Note | Array<Any>) -> Pattern — Concatenates this pattern with another sequentially. fn degrade(probability: Number | Pattern) -> Pattern — Randomly removes events with the given probability. fn describe() -> String — Returns a string description of the pattern structure. fn length() -> Number — Returns the number of events in cycle 0. fn iter() -> Iterator<Event> — Returns an infinite iterator over pattern events. fn map(func: Function) -> Pattern — Transforms each event using a function. fn map_with_timing(func: Function) -> Pattern — Transforms events with timing information. fn at(index: Number) -> Pattern — Returns the element at the given index (for indexable patterns). fn euclid(hits: Number, steps: Number, rotation: Number? = NUL) -> Pattern — Applies a Euclidean rhythm to the pattern. fn nudge(offsets: Number | Array<Number> | Pattern) -> Pattern — Shifts individual events by per-event offsets. fn swing(amount: Number | Pattern, grid: Number) -> Pattern — Delays every second slot of a grid, like a drum machine's swing: whatever plays on the off-beat 8th or 16th plays late, and what plays on the beat stays. fn humanize(amount: Number | Pattern) -> Pattern — Adds slight random timing variations for human feel. fn kind() -> String — Returns the concrete pattern kind ("Sequence", "Stack", "Fast", etc.). fn elements() -> Array<Pattern> — Returns sub-patterns as an array. fn in_key(key: Key) -> Pattern — Resolves degree elements (^N, ^N:quality) to MIDI notes using a Key. fn quantize(key: Key) -> Pattern — Snaps all MIDI pitches to the nearest tone in the key's scale. fn Alternating(...elements: Pattern | Note | Array<Any>) -> Pattern — Creates an alternating pattern (one element per cycle). fn Sequence(...notes: Pattern | Note | Array<Any>) -> Pattern — Creates a sequential pattern that plays notes one after another. fn Stack(...notes: Pattern | Note | Array<Any>) -> Pattern — Creates a stacked/layered pattern (chord). fn euclid(hits: Number, steps: Number, pattern: Pattern | Note | Array<Any>, rotation: Number? = NUL) -> Pattern — Creates a Euclidean rhythm pattern. fn viz(pattern: Pattern | Note | Array<Any>, cycles: Number? = NUL, start_cycle: Number? = NUL) -> NUL — Displays an ASCII visualization of a pattern. Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/ --- <!-- ID: std/random --> std/random [module] Import: use "std/random"; Deterministic (seeded) and true random helpers. fn choose(seed: Number, array: Array<Any>) -> Any — Deterministic element selection from an array. fn choose_true(array: Array<Any>) -> Any — True random element selection from an array, drawn from the operating system's entropy. fn choose_weighted(seed: Number, array: Array<Any>, weights: Array<Number>) -> Any — Deterministic weighted element selection from an array. fn rand(seed: Number) -> Number — Deterministic random number from a seed. fn rand_true() -> Number — True random number, drawn from the operating system's entropy. Page: reference/stdlib/random URL: https://resonon.org/docs/reference/stdlib/random/ --- <!-- ID: std/signals --> std/signals [module] Import: use "std/signals"; Continuous control signals for driving parameters. class Signal — A continuous control signal for modulation. fn get() -> Number — Reads the signal at the current transport position without advancing DSP or waiting. fn retrigger() -> Array<Duration?> — Returns each source clock's configured retrigger period, in graph order. fn timebase() -> Array<Duration> — Returns each source clock's timebase, in graph order. fn parameter(name: String) -> Number — Reads a dsp signal's scalar parameter by its declared name. fn range(min: Number | Signal, max: Number | Signal) -> Signal — Maps the signal output to a linear range [min, max]. fn range_exp(min: Number | Signal, max: Number | Signal) -> Signal — Maps the signal output to an exponential range [min, max]. fn set_retrigger(period: Duration) -> Signal — Resets the signal's phase every `period`. fn set_timebase(unit: Duration) -> Signal — Sets the unit the signal counts time in: an oscillator's rate is periods per unit, and automation breakpoint times are in units. fn smooth(time_ms: Number | Signal) -> Signal — Applies one-pole lowpass smoothing to the signal. fn continuous() -> Signal — Opt out of bind-time re-anchoring. fn at(time: Number, value: Number, curve: Curve | Bezier = Curve.linear) -> Signal — Adds a breakpoint to an automation signal (builder pattern). fn set_parameter(name: String, value: Number) -> Signal — Sets a named parameter on the signal. fn Cc(cc_number: Number, channel: Number? = NUL) -> Signal — Creates a MIDI CC input signal (0 to 1 output). fn Cc_learn() -> Signal — MIDI learn: waits for a CC knob/fader to be moved, then returns a Signal bound to that CC channel and number. fn Perlin(freq: Number | Signal = 1) -> Signal — Unipolar Perlin noise signal (0 to 1). fn Ramp(start: Signal | Number = 0.0, end: Signal | Number = 1.0, duration: Signal | Number = 1.0) -> Signal — Linear ramp signal — rises from `start` to `end` over `duration` units of its timebase (cycles by default), then clamps at both ends. fn Rand(freq: Number | Signal = 1) -> Signal — Unipolar random sample-and-hold signal (0 to 1). fn Saw(freq: Number | Signal = 1) -> Signal — Unipolar sawtooth signal (0 to 1). fn Saw2(freq: Number | Signal = 1) -> Signal — Bipolar sawtooth signal (-1 to 1). fn Sine(freq: Number | Signal = 1) -> Signal — Unipolar sine wave signal (0 to 1). fn Sine2(freq: Number | Signal = 1) -> Signal — Bipolar sine wave signal (-1 to 1). fn Square(freq: Number | Signal = 1) -> Signal — Unipolar square wave signal (0 or 1). fn Square2(freq: Number | Signal = 1) -> Signal — Bipolar square wave signal (-1 or 1). fn Time(rate: Number | Signal = 1) -> Signal — Elapsed time in units of the timebase, times `rate`: the phase the other oscillators wrap, left unwrapped, so it keeps rising until a retrigger. fn Tri(freq: Number | Signal = 1) -> Signal — Unipolar triangle wave signal (0 to 1). fn Tri2(freq: Number | Signal = 1) -> Signal — Bipolar triangle wave signal (-1 to 1). fn automation(...breakpoints: Array<Number | Curve | Bezier>) -> Signal — Creates an automation signal with breakpoint-based modulation. fn hz_to_periods(frequency: Number) -> Number — Converts a frequency in Hertz to periods per cycle at the current tempo. fn sec_to_periods(period: Number) -> Number — Converts a period in seconds to periods per cycle at the current tempo. fn signal(pattern: Pattern | Note | Array<Any>) -> Signal — Creates a signal from a pattern, or from an array played as one cycle's sequence. fn signal_ramp(start: Number, end: Number, duration: Number? = NUL) -> Signal — Creates a linear ramp signal that clamps at its endpoints. Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/ --- <!-- ID: std/signals::Ramp --> std/signals::Ramp [function] fn Ramp(start: Signal | Number = 0.0, end: Signal | Number = 1.0, duration: Signal | Number = 1.0) -> Signal Linear ramp signal — rises from `start` to `end` over `duration` units of its timebase (cycles by default), then clamps at both ends. Set the params after construction, or use the `signal_ramp()` wrapper to pass them positionally. Returns: Signal — the clamped linear ramp signal Examples: `let r = Ramp(); r.set_parameter("end", 4.0);` Parameters: start: Signal | Number — value at the start of the ramp end: Signal | Number — value at the end of the ramp duration: Signal | Number — ramp length in units of the timebase Module: std/signals Page: reference/stdlib/signals URL: https://resonon.org/docs/reference/stdlib/signals/#ramp --- <!-- ID: std/theory --> std/theory [module] Import: use "std/theory"; Scales, keys, chords, and interval helpers. fn Key(root: Note, name: String | Scale) -> Key — A Key — a Scale rooted at a note, for scale-relative composition. fn degree(n: Number) -> Note — Returns the Note at the given scale degree. fn chord(deg: Number, quality: String | Number? = NUL, inv: Number? = NUL) -> Array<Note> — Returns a chord (array of Notes) built on the given scale degree. fn chord7(deg: Number, inv: Number? = NUL) -> Array<Note> — Returns a diatonic 7th chord (4 Notes) on the given scale degree. fn notes() -> Array<Note> — Returns one octave of the key's scale as an array of Notes (rooted). fn quantize(note: Note) -> Note — Snaps a note to the nearest tone in this key's scale. fn transpose(semitones: Number) -> Key — Returns a new Key with the root shifted by the given semitones. fn Scale(arg: String | Array<Number>, period: Number? = NUL) -> Scale — A musical scale — a rootless, ordered set of pitch intervals. fn name() -> String — Returns the scale's name. fn intervals() -> Array<Number> — Returns the interval array (semitones from root). fn period() -> Number — Returns the period in semitones (12 for a standard octave). fn length() -> Number — Returns the number of scale degrees. fn mode(n: Number) -> Scale — Returns a new Scale rotated to the nth mode (1-indexed). fn contains(semitones: Number) -> Boolean — Returns true if the scale contains the given interval (in semitones). fn chord(root: Note, name: String, inversion: Number? = NUL) -> Array<Note> — Returns an array of Notes forming a chord, optionally inverted. fn chord_names() -> Array<String> — Returns an array of all available chord names. fn interval(note: Note, name: String) -> Note — Returns a single Note at the given interval above the input note. fn load_scala(name: String) -> Scale — Load a Scala (.scl) tuning file and return a Scale value. fn scale_names() -> Array<String> — Returns an array of all available scale names. Page: reference/stdlib/theory URL: https://resonon.org/docs/reference/stdlib/theory/ --- <!-- ID: std/visuals --> std/visuals [module] Import: use "std/visuals"; GPU visual operators — generators, filters, and the raw-shader `Visual`. Wire nodes with `>>` (primary input; route to `screen` to display) and bind parameters or texture inputs with `node.parameter("name") << signal`. `screen` is a global output sink; the master bus is `session.master`. **Generators** (`Noise`, `Ramp`) have no primary input; **filters** take one via `src >> op`; **2-in** filters (`Composite`, `Displace`, `Lookup`) take a second via a named slot, `op.parameter("slot") << node`. Every pass clamps its output to `[0, 1]`. Vector parameters (`translate`, `scale`, `pivot`) bind from a 2–4-element array, e.g. `t.parameter("scale") << #[1.5, 1.5]`, and a table parameter (`Ramp`'s `keys`) from an array of rows. class Screen — The display output sink. fn quality() -> Number — The screen rendering quality scale. fn set_quality(n: Number) -> Screen — Sets the supersampling (SSAA) quality — the internal render resolution as a multiple of the composition size (default 1, one sample per pixel). fn resolution(w: Number, h: Number) -> Screen — Sets the composition size in pixels (default 1920 × 1080). fn show() -> Screen — Opens the native live-rendering window for the routed visual, rendered on the GPU in-process from the routed graph, the transport and the live audio meter feeds. fn snap(path: String) -> Screen — Renders the routed visual off-screen on the GPU and writes it to a PNG at the given path. fn Visual(name: String, source: String) -> Visual — A node in the GPU visual graph: a built-in operator (`Noise`, `Blur`, `Displace`, …) or a compiled shader (`Visual(name, source)`). fn parameter(name: String) -> VisualParam — Binds a uniform to a signal or value (`v.parameter("period") << sig`), or wires a texture input slot with a node (`c.parameter("b") << node` on Composite, `d.parameter("by") << field` on Displace, `l.parameter("table") << ramp` on Lookup). fn reset() -> Visual — Clears the operator's render state on the next frame — TouchDesigner's Reset pulse. class VisualParam — A reference to a visual operator's parameter, produced by `node.parameter("name")` and consumed by `<<` (`v.parameter("period") << sig`). enum BlurExtend { hold, repeat, mirror } — What a `Blur` sees beyond the image edges: TD's Blur Extend menu. enum BlurMethod { horizontal_and_vertical, horizontal, vertical } — The axes a `Blur` blurs along: TD's Blur Method menu. enum BlurType { catmull_rom, gaussian, box, bartlett, sinc, hanning, blackman } — The kernel shape of a `Blur`: TD's Blur Type menu. enum Extend { hold, zero, repeat, mirror } — What is read beyond the image edges: TD's Extend menu. enum LookupChannel { luminance, red, green, blue, alpha, rgb_average, rgba_average, rgb_maximum, rgba_maximum, rgba_independent } — How a `Lookup` index colour picks from the table: TD's Lookup Index Channel menu. enum Operand { add, difference, maximum, minimum, multiply, over, screen, subtract, subtractive } — How a `Composite` combines its inputs A and B: TD's Composite Operation menu. enum RampExtend { hold, black, zero, repeat, mirror } — What a `Ramp` draws below 0: TD's Ramp Extend Left menu. enum RampExtendRight { same_as_left, hold, black, zero, repeat, mirror } — What a `Ramp` draws above 1: TD's Ramp Extend Right menu. enum RampFit { fill, fit_horizontal, fit_vertical, fit_best } — How a radial or circular `Ramp` fits a non-square image: TD's Ramp Fit Aspect menu. enum RampInterp { step, linear, ease_in_ease_out, hermite } — The curve between the keys of a `Ramp`: TD's Ramp Interpolate Notches menu. enum RampType { vertical, horizontal, radial, circular } — The shape of a `Ramp`: TD's Ramp Type menu. enum RgbOutput { multiply_alpha, new_alpha } — The colour an `RgbKey` draws: TD's RGB Key RGB Output menu. enum Unit { pixels, fraction, fraction_aspect } — The unit of a distance on an image: TouchDesigner's Pixels, Fraction and Fraction Aspect. fn Blur(name: String) -> Visual — A blur visual: TouchDesigner's Blur TOP. fn Composite(name: String) -> Visual — A composite visual: TouchDesigner's Composite TOP. fn Displace(name: String) -> Visual — A displace visual: TouchDesigner's Displace TOP. fn Edge(name: String) -> Visual — An edge visual: TouchDesigner's Edge TOP. fn Lookup(name: String) -> Visual — A lookup visual: TouchDesigner's Lookup TOP. fn LumaLevel(name: String) -> Visual — A luma-level visual: TouchDesigner's Luma Level TOP. fn Noise(name: String) -> Visual — A noise generator: TouchDesigner's Noise TOP with type Simplex 3D, monochrome, aspect corrected, alpha one. fn Ramp(name: String) -> Visual — A ramp visual: TouchDesigner's Ramp TOP. fn RgbKey(name: String) -> Visual — An RGB-key visual: TouchDesigner's RGB Key TOP. fn Slope(name: String) -> Visual — A slope visual: TouchDesigner's Slope TOP. fn Transform(name: String) -> Visual — A transform visual: a TouchDesigner-style Transform TOP that translates, rotates and scales its primary input (set via `src >> Transform("…")`) about a pivot. fn feedback(seed: Visual, build: Function) -> Visual — Builds a feedback group: TouchDesigner's Feedback TOP, with the group output as its Target TOP. fn load_shader(name: String, path: String) -> Visual — Loads a fragment shader from an external .glsl file and compiles it. Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/ --- <!-- ID: std/visuals::Ramp --> std/visuals::Ramp [function] fn Ramp(name: String) -> Visual A ramp visual: TouchDesigner's Ramp TOP. A generator (no input) that draws a gradient through `keys`, a table with a row per key, any number of them, as TD's Ramp reads its DAT: `#[pos, r, g, b, a]`, the position along the ramp and the key's colour and alpha. As in TD, positions are clamped to 0..1 and the keys are taken in order of position, a tie in table order; where no key sits at 0 or 1, the ramp wraps around from its last key to its first. Bind a table of your own: `r.parameter("keys") << #[#[0, 0, 0, 0, 1], #[0.5, 0.3, 0.4, 0.7, 1], #[1, 1, 1, 1, 1]]`. As in TD, `phase` moves the start of the ramp and `period` sets its length: a vertical or horizontal ramp reads position `(x − phase) ÷ period` at `x` across the image (0 to 1), and a radial or circular ramp reads its angle or distance `÷ period − phase`. `position_x` and `position_y` move the centre of a radial or circular ramp, in fractions of the image. Radial and circular ramps take `antialias × antialias` samples a pixel (1 to 4). With `premultiply`, the colour is multiplied by the alpha. Checked against TD's float exports: exact to float32, except ease in ease out (within 1.5e-4) and hermite with no key at 0 or 1. TD's Dither is left out: it only matters for 8-bit images, and visuals are 16-bit float. The alpha is 1, where TD's is the ramp's. Parameters: name: String — the operator's name; its identity on screen Uniforms: keys — the keys, a table of `#[pos, r, g, b, a]` rows (default black at 0, white at 1) type — the shape of the ramp, a `RampType` (default horizontal) position_x — the centre of radial and circular across, from the image centre (default 0) position_y — the centre of radial and circular up, from the image centre (default 0) phase — where the ramp starts (default 0) period — the length of the ramp (default 1) extend_left — the ramp below 0, a `RampExtend` (default repeat) extend_right — the ramp above 1, a `RampExtendRight` (default same_as_left) interp — the curve between keys, a `RampInterp` (default linear) tension — hermite's flattening at each key (default 0) antialias — samples per axis for radial and circular, 1 to 4 (default 4) fit_aspect — how radial and circular fit the image, a `RampFit` (default fit_horizontal) premultiply — 1 multiplies the colour by the alpha, 0 does not (default 1) Returns: Visual — a generator node, routable with `>>` and bindable with `.parameter` Experimental: Expect breaking changes to shaders, operators and the visuals window. Module: std/visuals Page: reference/stdlib/visuals URL: https://resonon.org/docs/reference/stdlib/visuals/#ramp --- <!-- ID: stream --> stream [function] fn stream(initial: Note | Number | Array<Any> | Pattern, next_fn: Function) -> Pattern Creates a stateful stream pattern from an initial value and a next function. Each cycle's output depends on the previous cycle's state, enabling "walking" patterns like melodic random walks. Parameters: initial: Note | Number | Array | Pattern — initial value next_fn: Function — takes (prev, cycle) and returns the next value Returns: Pattern — a pattern that evolves its state once per cycle Module: std/generative Page: reference/stdlib/generative URL: https://resonon.org/docs/reference/stdlib/generative/#stream --- <!-- ID: svf_allpass --> svf_allpass [dsp-builtin] svf_allpass(input, cutoff, resonance) -> Number State variable filter — allpass. Parameters: input — audio signal cutoff — frequency in Hz (20–20000) resonance — filter Q Returns: phase-shifted signal (flat magnitude response) Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_allpass --- <!-- ID: svf_bp --> svf_bp [dsp-builtin] svf_bp(input, cutoff, resonance) -> Number State variable filter — bandpass. Parameters: input — audio signal cutoff — center frequency in Hz (20–20000) resonance — filter Q / bandwidth Returns: filtered signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_bp --- <!-- ID: svf_hp --> svf_hp [dsp-builtin] svf_hp(input, cutoff, resonance) -> Number State variable filter — highpass. Parameters: input — audio signal cutoff — cutoff frequency in Hz (20–20000) resonance — filter Q (0.707 = Butterworth) Returns: filtered signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_hp --- <!-- ID: svf_lp --> svf_lp [dsp-builtin] svf_lp(input, cutoff, resonance) -> Number State variable filter — lowpass (Zavalishin topology-preserving transform). Parameters: input — audio signal cutoff — cutoff frequency in Hz (20–20000) resonance — filter Q (0.707 = Butterworth, higher = more resonant) Returns: filtered signal Example: `__native("svf_lp", input, 1000.0, 0.707)` Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_lp --- <!-- ID: svf_notch --> svf_notch [dsp-builtin] svf_notch(input, cutoff, resonance) -> Number State variable filter — notch (band-reject). Parameters: input — audio signal cutoff — notch frequency in Hz (20–20000) resonance — filter Q / notch width Returns: filtered signal Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_notch --- <!-- ID: svf_peak --> svf_peak [dsp-builtin] svf_peak(input, cutoff, resonance) -> Number State variable filter — peak (bell). Parameters: input — audio signal cutoff — center frequency in Hz (20–20000) resonance — filter Q / bell width Returns: filtered signal with boost around cutoff Module: DSP Builtins Page: reference/stdlib/dsp-builtins URL: https://resonon.org/docs/reference/stdlib/dsp-builtins/#svf_peak --- <!-- ID: timeline --> timeline [function] fn timeline(length: Number) -> Timeline Creates a mutable timeline builder for placing patterns along a lane. A timeline is a single lane, so it carries the same layer surface a section's lanes do: `.layer(name)`, `.mute()`, `.set_layer_order(#[..])`, `.clear()`. The length is a whole number of cycles — the ruler — but `.at(..)` is not bound to it: `start` and `duration` may be any position, so `.at(2.5, 1.25)` means exactly that. The grid is what you snap to, not what you are limited to, which is what lets recorded material sit where it was performed. Parameters: length: Number — timeline length in cycles (must be > 0) Returns: Timeline — a timeline accepting entries via `.at(start, duration) << pattern` Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#timeline --- <!-- ID: to_json --> to_json [function] fn to_json(value: MeterFeed | Boolean | Number | String | Array<Any> | Tuple | Dict<String | Number, Any> | Json?) -> String Returns the JSON text of a value, on one line. For a tool that reads what a piece prints: `print(to_json(notes(bass, 4)))`. Meter feeds read the session display level at evaluation time, without waiting. NUL, Boolean, Number, String, Array, Tuple and Dict are written as they are; a Tuple is written as an array, a whole number without a fraction, and dictionary keys in sorted order, so the same value always gives the same text. An enum variant is written as its name, and a `Json` value as what its `json()` returns: a track as its name, `plugin_scan()` and `.parameters()` as their dicts. A Note writes {name, note}, a Scale {name, intervals, period}, and a Duration {length, unit}, with unit cycles, beats or seconds. Devices write {name, backend, id}, using their name and device identity (backend dsp/CLAP/VST3). A value inside one without a JSON form, a NaN or infinite number, or a value that contains itself is an error. Signal and Pattern sources have no JSON form: read `signal.get()` for a signal's current value or `notes()` for a pattern's notes. Parameters: value: MeterFeed | Boolean | Number | String | Array | Tuple | Dict | Json? — the value to write Returns: String — the JSON text Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#to_json --- <!-- ID: tutorials/audio/01-your-first-mix --> Your First Mix [tutorial] On this page you build a small mix from nothing: three drum tracks, a filter, a shared reverb, and the master fader. At the end, you put the whole rig into one function that you can edit while it plays. Work in a project, as in [Your First Sound](/docs/tutorials/getting-started/02-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. Sections: - tutorials/audio/01-your-first-mix#before-you-start | Before you start - tutorials/audio/01-your-first-mix#make-a-track | Make a track - tutorials/audio/01-your-first-mix#set-the-volume-and-pan | Set the volume and pan - tutorials/audio/01-your-first-mix#add-more-tracks | Add more tracks - tutorials/audio/01-your-first-mix#add-an-effect-chain | Add an effect chain - tutorials/audio/01-your-first-mix#share-a-reverb | Share a reverb - tutorials/audio/01-your-first-mix#mute-and-solo | Mute and solo - tutorials/audio/01-your-first-mix#ride-the-master | Ride the master - tutorials/audio/01-your-first-mix#write-a-track-as-one-chain | Write a track as one chain - tutorials/audio/01-your-first-mix#put-the-rig-in-a-function | Put the rig in a function - tutorials/audio/01-your-first-mix#stop | Stop - tutorials/audio/01-your-first-mix#next-steps | Next steps Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/ --- <!-- ID: tutorials/audio/01-your-first-mix#add-an-effect-chain --> Your First Mix > Add an effect chain [tutorial] **Effects** process a track's sound after the instrument. `set_effects` sets a track's effect chain, as a list. The sound goes through the list in order: ```resonon continue use "std/effects" { Filter, FilterType, Delay }; hats.set_effects(#[Filter("highpass", FilterType.highpass, 2000), Delay("delay", 0.125, 0.3)]); ``` The hats are thinner, and they echo. The first argument of each effect is its name in the chain. Now change one setting. Keep a handle to the effect, put it on the track, and set a parameter through the handle: ```resonon continue let echo = Delay("delay", 0.125, 0.3); hats.set_effects(#[Filter("highpass", FilterType.highpass, 2000), echo]); echo.parameter("Feedback") << 0.6; ``` The echoes last longer. The chain was not rebuilt: the delay called `"delay"` was already there, so it kept playing. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#add-an-effect-chain Previous: tutorials/audio/01-your-first-mix#add-more-tracks Next: tutorials/audio/01-your-first-mix#share-a-reverb --- <!-- ID: tutorials/audio/01-your-first-mix#add-more-tracks --> Your First Mix > Add more tracks [tutorial] Give every track its own name. Replace the combined beat with three separate parts. First send silence to the earlier `drums` track so it does not double the new kick and snare: ```resonon continue drums << [_]; let kick = session.create_track("kick"); let snare = session.create_track("snare"); let hats = session.create_track("hats"); kick.set_instrument(Sampler(Kit("CR-78"))); snare.set_instrument(Sampler(Kit("CR-78"))); hats.set_instrument(Sampler(Kit("CR-78"))); kick.volume << -9; snare.volume << -9; hats.volume << -15; kick << [bd*4]; snare << [_ sd _ sd]; hats << [hh*8]; PLAY; ``` Three tracks play together. You can change each one without touching the others. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#add-more-tracks Previous: tutorials/audio/01-your-first-mix#set-the-volume-and-pan Next: tutorials/audio/01-your-first-mix#add-an-effect-chain --- <!-- ID: tutorials/audio/01-your-first-mix#before-you-start --> Your First Mix > Before you start [tutorial] Finish [Language for a Reusable Piece](/docs/tutorials/language/01-language-for-a-piece/) so that `fn`, `return` and tuple unpacking are familiar. Open your project's `src/main.non`, evaluate `RESET;` on its own, then remove that line. Check that all earlier tracks are silent. This page builds a new mix with bundled kits; evaluate the blocks in order. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#before-you-start Next: tutorials/audio/01-your-first-mix#make-a-track --- <!-- ID: tutorials/audio/01-your-first-mix#make-a-track --> Your First Mix > Make a track [tutorial] A **track** is a channel on a mixer. It holds one instrument, has a fader, and sends its sound to the master. ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; PLAY; ``` You hear a kick and a snare, looping. - `session.create_track("drums")` makes a track called `drums`. A name has one track: run the line again and you get an error. `session.track("drums")` gives you the track that exists. - `set_instrument(...)` puts an instrument on it — here a `Sampler` with the built-in CR-78 drum kit. - `<<` sends a pattern to the track. The track plays it every cycle until you send another one. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#make-a-track Previous: tutorials/audio/01-your-first-mix#before-you-start Next: tutorials/audio/01-your-first-mix#set-the-volume-and-pan --- <!-- ID: tutorials/audio/01-your-first-mix#mute-and-solo --> Your First Mix > Mute and solo [tutorial] Mute a track to take it out of the mix. Solo a track to hear only that track: ```resonon continue hats.mute(); snare.solo(); ``` The hats stop, and only the snare plays — with its reverb, because a solo keeps the tracks it sends to. `solo()` releases every other solo. `add_solo()` adds a track to the soloed tracks instead. Bring everything back: ```resonon continue hats.unmute(); snare.unsolo(); ``` Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#mute-and-solo Previous: tutorials/audio/01-your-first-mix#share-a-reverb Next: tutorials/audio/01-your-first-mix#ride-the-master --- <!-- ID: tutorials/audio/01-your-first-mix#next-steps --> Your First Mix > Next steps [tutorial] - [Play Samples](/docs/how-to/audio/01-play-samples/) — drum kits, melodic samples, and shaping each hit - [Group Tracks on a Bus](/docs/how-to/audio/04-group-tracks-on-a-bus/) — one fader and shared effects for a group - [Share an Effect with a Send](/docs/how-to/audio/05-share-an-effect-with-a-send/) — return tracks and send levels - [Signals and Modulation](/docs/tutorials/audio/02-signals-and-modulation/) — the next tutorial: make parameters move - [Descriptions & Slots](/docs/explanation/audio/02-descriptions-and-slots/) — why re-running the layout keeps what is playing Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#next-steps Previous: tutorials/audio/01-your-first-mix#stop --- <!-- ID: tutorials/audio/01-your-first-mix#put-the-rig-in-a-function --> Your First Mix > Put the rig in a function [tutorial] A function that builds tracks and returns them is a **layout**. This last exercise returns to one drums track and the shared reverb. Send silence to the separate parts and the bass first; otherwise those tracks would keep playing under the new layout: ```resonon continue kick << [_]; snare << [_]; hats << [_]; bass << [_]; fn stage() { let verb = session.track("verb") .set_effects(#[Reverb("room", 0.8, 0.3)]); let drums = session.track("drums") .set_instrument(Sampler(Kit("CR-78"))) .set_effects(#[Filter("lowpass", FilterType.lowpass, 4000)]) .set_volume(-9) .set_pan(0) .set_send(verb, 0.3); return (drums, verb); } let (drums, verb) = stage(); drums << [bd sd bd sd]; PLAY; ``` The earlier tracks no longer trigger notes; their existing tails can finish. The drums fader and pan are set explicitly so the first exercise's left pan does not carry into this layout. While it plays, add an effect to the drums' `.set_effects(#[...])` list and run the whole block again. The new effect is inserted, and nothing else stops: the tracks and effects with the same names are kept. Remove the effect and run it again, and it is gone. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#put-the-rig-in-a-function Previous: tutorials/audio/01-your-first-mix#write-a-track-as-one-chain Next: tutorials/audio/01-your-first-mix#stop --- <!-- ID: tutorials/audio/01-your-first-mix#ride-the-master --> Your First Mix > Ride the master [tutorial] Every track reaches `session.master`, the last fader before your speakers. You never made it; it is always there. Turn the whole mix down: ```resonon continue session.master.volume << -2; ``` Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#ride-the-master Previous: tutorials/audio/01-your-first-mix#mute-and-solo Next: tutorials/audio/01-your-first-mix#write-a-track-as-one-chain --- <!-- ID: tutorials/audio/01-your-first-mix#set-the-volume-and-pan --> Your First Mix > Set the volume and pan [tutorial] Every track has a `volume` in decibels and a `pan` from `-1` (left) to `1` (right). Set them with `<<`: ```resonon continue drums.volume << -6; drums.pan << -0.5; ``` The drums are quieter, and to the left. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#set-the-volume-and-pan Previous: tutorials/audio/01-your-first-mix#make-a-track Next: tutorials/audio/01-your-first-mix#add-more-tracks --- <!-- ID: tutorials/audio/01-your-first-mix#share-a-reverb --> Your First Mix > Share a reverb [tutorial] A reverb for every track would be wasteful. Make one reverb track, and **send** a copy of the snare to it: ```resonon continue use "std/effects" { Reverb }; let verb = session.create_track("verb"); verb.set_effects(#[Reverb("room", 0.8, 0.3)]); snare.set_send(verb, 0.3); ``` The snare plays dry as before, and 30% of it also goes through the reverb. The `verb` track has no instrument — it only processes what other tracks send to it. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#share-a-reverb Previous: tutorials/audio/01-your-first-mix#add-an-effect-chain Next: tutorials/audio/01-your-first-mix#mute-and-solo --- <!-- ID: tutorials/audio/01-your-first-mix#stop --> Your First Mix > Stop [tutorial] `STOP;` stops playback and goes back to the start. In VSCode, `Shift+F5` does the same, and `F5` toggles play and pause. ```resonon continue STOP; ``` Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#stop Previous: tutorials/audio/01-your-first-mix#put-the-rig-in-a-function Next: tutorials/audio/01-your-first-mix#next-steps --- <!-- ID: tutorials/audio/01-your-first-mix#write-a-track-as-one-chain --> Your First Mix > Write a track as one chain [tutorial] Every setter returns the track, so a whole channel strip can be one expression. Read it from top to bottom: what makes the sound, what processes it, how loud. ```resonon continue let bass = session.create_track("bass") .set_instrument(Sampler(Kit("CR-78"))) .set_effects(#[Filter("lowpass", FilterType.lowpass, 400)]) .set_volume(-4); bass << [bd _ _ bd _ _ bd _]; ``` `.set_volume(-4)` is the same as `bass.volume << -4`. Where the track goes is a statement of its own: a new track goes to `session.master`, and `bass >> verb;` would route it through the reverb instead. Page: tutorials/audio/01-your-first-mix URL: https://resonon.org/docs/tutorials/audio/01-your-first-mix/#write-a-track-as-one-chain Previous: tutorials/audio/01-your-first-mix#ride-the-master Next: tutorials/audio/01-your-first-mix#put-the-rig-in-a-function --- <!-- ID: tutorials/audio/02-signals-and-modulation --> Signals and Modulation [tutorial] On this page you turn a fixed drum filter into a moving one, then move the drums across the stereo field. A **signal** is a value that changes over time; **modulation** uses it to move a parameter for you. Sections: - tutorials/audio/02-signals-and-modulation#before-you-start | Before you start - tutorials/audio/02-signals-and-modulation#start-with-a-fixed-filter | Start with a fixed filter - tutorials/audio/02-signals-and-modulation#make-the-filter-breathe | Make the filter breathe - tutorials/audio/02-signals-and-modulation#change-the-speed | Change the speed - tutorials/audio/02-signals-and-modulation#move-the-pan | Move the pan - tutorials/audio/02-signals-and-modulation#take-the-controls-back | Take the controls back - tutorials/audio/02-signals-and-modulation#next-steps | Next steps Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/ --- <!-- ID: tutorials/audio/02-signals-and-modulation#before-you-start --> Signals and Modulation > Before you start [tutorial] Finish [Your First Mix](/docs/tutorials/audio/01-your-first-mix/). Open `src/main.non` in your project. Evaluate `RESET;` **on its own**, then remove it from the file. Check that the earlier mix is silent. Select and evaluate each block below in order. You need only the bundled CR-78 kit and your audio output. Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#before-you-start Next: tutorials/audio/02-signals-and-modulation#start-with-a-fixed-filter --- <!-- ID: tutorials/audio/02-signals-and-modulation#change-the-speed --> Signals and Modulation > Change the speed [tutorial] ```resonon continue filter.parameter("Cutoff") << Sine(4).range_exp(300, 6000); ``` There are now four sweeps per cycle: one per beat with the default four-beat cycle. Slow it down: ```resonon continue filter.parameter("Cutoff") << Sine(0.25).range_exp(300, 6000); ``` One sweep now takes four cycles. Change tempo and listen: ```resonon continue set_bpm(90); ``` The sweep slows with the music. Its speed is in cycles, not seconds. Return to 120 BPM: ```resonon continue set_bpm(120); ``` Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#change-the-speed Previous: tutorials/audio/02-signals-and-modulation#make-the-filter-breathe Next: tutorials/audio/02-signals-and-modulation#move-the-pan --- <!-- ID: tutorials/audio/02-signals-and-modulation#make-the-filter-breathe --> Signals and Modulation > Make the filter breathe [tutorial] ```resonon continue use "std/signals" { Sine, Sine2 }; let sweep = Sine(1).range_exp(300, 6000); filter.parameter("Cutoff") << sweep; ``` Wait for the next cycle, then listen. The drums brighten and darken once each bar. `Sine(1)` rises and falls between 0 and 1 once per cycle. `.range_exp(300, 6000)` converts that motion into a cutoff between 300 Hz and 6000 Hz. For frequency, an exponential range spreads motion evenly across octaves. Compare it with a linear range, then return to the exponential one: ```resonon continue filter.parameter("Cutoff") << Sine(1).range(300, 6000); ``` ```resonon continue filter.parameter("Cutoff") << sweep; ``` Listen for where the sweep spends its time: the linear version spends more of it at high frequencies. `sweep` stores the moving signal, rather than a snapshot of its current value. Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#make-the-filter-breathe Previous: tutorials/audio/02-signals-and-modulation#start-with-a-fixed-filter Next: tutorials/audio/02-signals-and-modulation#change-the-speed --- <!-- ID: tutorials/audio/02-signals-and-modulation#move-the-pan --> Signals and Modulation > Move the pan [tutorial] Pan runs from −1 (left) to 1 (right), so use a signal that already covers both sides: ```resonon continue drums.pan << Sine2(0.5) * 0.6; ``` The drums cross the stereo field once every two cycles. `Sine2` swings from −1 to 1; multiplying by `0.6` narrows the movement to −0.6 through 0.6. Use headphones or a stereo pair to hear the movement. Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#move-the-pan Previous: tutorials/audio/02-signals-and-modulation#change-the-speed Next: tutorials/audio/02-signals-and-modulation#take-the-controls-back --- <!-- ID: tutorials/audio/02-signals-and-modulation#next-steps --> Signals and Modulation > Next steps [tutorial] - [Sweep a Parameter with an LFO](/docs/how-to/audio/09-sweep-a-parameter-with-an-lfo/) — other shapes and phase controls - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — write a particular movement along a timeline - [Signals & Time](/docs/explanation/audio/03-signals-and-time/) — how signals follow the transport - [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/) — write an effect with knobs you can modulate Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#next-steps Previous: tutorials/audio/02-signals-and-modulation#take-the-controls-back --- <!-- ID: tutorials/audio/02-signals-and-modulation#start-with-a-fixed-filter --> Signals and Modulation > Start with a fixed filter [tutorial] ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; set_bpm(120); let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums.volume << -9; drums << [bd _ sd _, hh*8]; let filter = Filter("filter", FilterType.lowpass, 1200); drums.set_effects(#[filter]); filter.parameter("Cutoff") << 1200; PLAY; ``` The drums sound dark. `Cutoff` is a frequency in hertz; `1200` holds it steady. The effect is on the track before you address its parameter. Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#start-with-a-fixed-filter Previous: tutorials/audio/02-signals-and-modulation#before-you-start Next: tutorials/audio/02-signals-and-modulation#make-the-filter-breathe --- <!-- ID: tutorials/audio/02-signals-and-modulation#take-the-controls-back --> Signals and Modulation > Take the controls back [tutorial] Send fixed values to replace the moving bindings: ```resonon continue filter.parameter("Cutoff") << 1200; drums.pan << 0; ``` The filter holds steady again, and the drums return to the centre. You do not need to remove the effect or recreate the track. Finish with: ```resonon continue STOP; ``` Page: tutorials/audio/02-signals-and-modulation URL: https://resonon.org/docs/tutorials/audio/02-signals-and-modulation/#take-the-controls-back Previous: tutorials/audio/02-signals-and-modulation#move-the-pan Next: tutorials/audio/02-signals-and-modulation#next-steps --- <!-- ID: tutorials/dsp/01-your-first-effect --> Your First Effect [tutorial] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: On this page you write your own audio effects in the resonon language: a gain stage, a tremolo, an echo and a drive. At the end, you change an effect while you hear it. An effect changes the audio that goes through a track. In a DAW, it is an insert on a channel strip. Here, you write what it does to each sample. Work in a project, as in [Your First Sound](/docs/tutorials/getting-started/02-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. Sections: - tutorials/dsp/01-your-first-effect#before-you-start | Before you start - tutorials/dsp/01-your-first-effect#write-a-gain-stage | Write a gain stage - tutorials/dsp/01-your-first-effect#turn-the-knob | Turn the knob - tutorials/dsp/01-your-first-effect#remember-a-value-between-samples | Remember a value between samples - tutorials/dsp/01-your-first-effect#delay-the-signal | Delay the signal - tutorials/dsp/01-your-first-effect#split-out-a-helper | Split out a helper - tutorials/dsp/01-your-first-effect#change-it-while-it-plays | Change it while it plays - tutorials/dsp/01-your-first-effect#next-steps | Next steps Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/ --- <!-- ID: tutorials/dsp/01-your-first-effect#before-you-start --> Your First Effect > Before you start [tutorial] Finish [Language for a Reusable Piece](/docs/tutorials/language/01-language-for-a-piece/) and [Signals and Modulation](/docs/tutorials/audio/02-signals-and-modulation/). Open `src/main.non`, evaluate `RESET;` on its own, then remove that line. The session should be silent before you create the drums and gain stage. No plugin is needed. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#before-you-start Next: tutorials/dsp/01-your-first-effect#write-a-gain-stage --- <!-- ID: tutorials/dsp/01-your-first-effect#change-it-while-it-plays --> Your First Effect > Change it while it plays [tutorial] Turn the tone down first: ```resonon continue drive.parameter("tone") << 800; ``` Now edit the effect itself. Change the `soft_clip` line to a harder clip, then select only the `dsp effect Drive { … }` block and run it: ```resonon parse-only dsp effect Drive { param drive: 4.0 range(1, 10); param tone: 3000 range(200, 12000); fn soft_clip(x) -> out { return __native("clamp", x, -0.5, 0.5); } fn process(left, right) -> (out_l, out_r) { let l = soft_clip(left * drive); let r = soft_clip(right * drive); return (__native("svf_lp", l, tone, 0.7), __native("svf_lp", r, tone, 0.7)); } } ``` The sound changes with no click, and the beat does not stop. The tone is still at `800`: an edit changes the code, not the knobs you have turned. If you add or remove a `param`, the knobs no longer match — run the `set_effects` line again to build the effect again from its defaults. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#change-it-while-it-plays Previous: tutorials/dsp/01-your-first-effect#split-out-a-helper Next: tutorials/dsp/01-your-first-effect#next-steps --- <!-- ID: tutorials/dsp/01-your-first-effect#delay-the-signal --> Your First Effect > Delay the signal [tutorial] An echo must keep a lot of samples. A `buffer` is a fixed-size array for that, and its index wraps around by itself, so it works as a circular delay line: ```resonon continue dsp effect Echo { param time: 0.25 range(0.001, 1.0); param feedback: 0.5 range(0, 0.99); param mix: 0.4 range(0, 1); buffer buf_l(48000); buffer buf_r(48000); state wp: 0; fn process(left, right) -> (out_l, out_r) { let rp = wp + 48000.0 - time * SR; let delayed_l = buf_l[rp]; let delayed_r = buf_r[rp]; buf_l[wp] = left + delayed_l * feedback; buf_r[wp] = right + delayed_r * feedback; wp = (wp + 1.0) % 48000.0; return (left + delayed_l * mix, right + delayed_r * mix); } } drums.set_effects(#[gain, Echo("echo")]); ``` Each hit now repeats a quarter of a second later, and fades out. `wp` is where the effect writes, and `rp` is where it reads, `time * SR` samples back. `SR` is the sample rate. The chain is now the gain stage and the echo: the tremolo is gone, because `set_effects` sets the whole chain. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#delay-the-signal Previous: tutorials/dsp/01-your-first-effect#remember-a-value-between-samples Next: tutorials/dsp/01-your-first-effect#split-out-a-helper --- <!-- ID: tutorials/dsp/01-your-first-effect#next-steps --> Your First Effect > Next steps [tutorial] You wrote an effect, gave it knobs, state and a buffer, and changed it while it played. - [Your First Instrument](/docs/tutorials/dsp/02-your-first-instrument/) — make sound from notes - [Sidechain a Custom Effect](/docs/how-to/dsp/01-sidechain-a-custom-effect/) — give an effect a second input - [Share DSP Code](/docs/how-to/dsp/03-share-dsp-code/) — use one helper in many blocks - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) — everything a `dsp effect` can declare Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#next-steps Previous: tutorials/dsp/01-your-first-effect#change-it-while-it-plays --- <!-- ID: tutorials/dsp/01-your-first-effect#remember-a-value-between-samples --> Your First Effect > Remember a value between samples [tutorial] `process` forgets everything between two samples. A `state` variable keeps its value. A tremolo needs one, to know where its wobble is: ```resonon continue dsp effect Tremolo { param speed: 4.0 range(0.1, 20); param depth: 0.5 range(0, 1); state phase: 0.0; fn process(left, right) -> (out_l, out_r) { phase = __native("fract", phase + speed * INV_SR); let wobble = 1.0 - depth * (0.5 + 0.5 * __native("sin", phase * TWOPI)); return (left * wobble, right * wobble); } } drums.set_effects(#[gain, Tremolo("tremolo")]); ``` The beat pulses four times a second, after the gain stage. - `phase` goes from `0` to `1`, and moves on by `speed * INV_SR` in each sample. `INV_SR` is one divided by the sample rate, so `phase` goes around `speed` times each second. - `__native("fract", …)` keeps it between `0` and `1`, and `__native("sin", …)` turns it into a wave. `__native` calls resonon's built-in DSP functions. Hover a name in your editor to see what it does. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#remember-a-value-between-samples Previous: tutorials/dsp/01-your-first-effect#turn-the-knob Next: tutorials/dsp/01-your-first-effect#delay-the-signal --- <!-- ID: tutorials/dsp/01-your-first-effect#split-out-a-helper --> Your First Effect > Split out a helper [tutorial] A long `process` is hard to read. Put a part of it into its own function, in the same block: ```resonon continue dsp effect Drive { param drive: 4.0 range(1, 10); param tone: 3000 range(200, 12000); fn soft_clip(x) -> out { return x / (1.0 + __native("abs", x)); } fn process(left, right) -> (out_l, out_r) { let l = soft_clip(left * drive); let r = soft_clip(right * drive); return (__native("svf_lp", l, tone, 0.7), __native("svf_lp", r, tone, 0.7)); } } let drive = Drive("drive"); drums.set_effects(#[drive, Echo("echo")]); ``` The drums are louder and rougher, and the echo is still there. `soft_clip` pushes a loud signal smoothly toward `-1` and `1`. `__native("svf_lp", input, cutoff, resonance)` is a built-in lowpass filter that takes away the harsh top. The [DSP builtins](/docs/reference/stdlib/dsp-builtins/) list every function you can call like this. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#split-out-a-helper Previous: tutorials/dsp/01-your-first-effect#delay-the-signal Next: tutorials/dsp/01-your-first-effect#change-it-while-it-plays --- <!-- ID: tutorials/dsp/01-your-first-effect#turn-the-knob --> Your First Effect > Turn the knob [tutorial] The knob is on the effect you kept in `gain`. Set it with `<<`: ```resonon continue gain.parameter("level") << 0.3; ``` The beat is quieter. A knob also takes a signal, so it can move by itself: ```resonon continue use "std/signals" { Sine }; gain.parameter("level") << Sine(1).range(0.2, 1.0); ``` The volume now swells up and down once in each cycle. You did not write that into the effect: any knob that you declare with `param` can be set and modulated from outside. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#turn-the-knob Previous: tutorials/dsp/01-your-first-effect#write-a-gain-stage Next: tutorials/dsp/01-your-first-effect#remember-a-value-between-samples --- <!-- ID: tutorials/dsp/01-your-first-effect#write-a-gain-stage --> Your First Effect > Write a gain stage [tutorial] The simplest effect changes the volume: ```resonon use "std/instruments" { Sampler, Kit }; dsp effect Gain { param level: 1.0 range(0, 2); fn process(left, right) -> (out_l, out_r) { return (left * level, right * level); } } let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; let gain = Gain("gain"); drums.set_effects(#[gain]); PLAY; ``` You hear the beat, and it goes through the effect that you wrote. - `dsp effect Gain { … }` defines a new effect called `Gain`. - `param level: 1.0 range(0, 2);` is a knob. Its default is `1.0`, and it goes from `0` to `2`. In the effect, you read it like a variable. - `fn process(left, right) -> (out_l, out_r)` runs **one time for each sample** — 48,000 times each second at 48 kHz. It gets the left and right input sample and returns the left and right output sample. - `Gain("gain")` makes one of these effects, with the name `gain`. `set_effects` puts it on the track, the same as a built-in effect. Page: tutorials/dsp/01-your-first-effect URL: https://resonon.org/docs/tutorials/dsp/01-your-first-effect/#write-a-gain-stage Previous: tutorials/dsp/01-your-first-effect#before-you-start Next: tutorials/dsp/01-your-first-effect#turn-the-knob --- <!-- ID: tutorials/dsp/02-your-first-instrument --> Your First Instrument [tutorial] :::caution[Experimental] The DSP language is experimental. Expect breaking changes to `dsp` blocks and the code inside them. ::: On this page you write a synthesizer in the resonon language. You start with a sine wave and end with a filtered synth that you change while it plays. An effect changes audio that already exists. An **instrument** makes audio from notes: a pattern sends it notes, and it turns each one into sound. Work in a project, as in [Your First Sound](/docs/tutorials/getting-started/02-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. Sections: - tutorials/dsp/02-your-first-instrument#before-you-start | Before you start - tutorials/dsp/02-your-first-instrument#play-a-sine-wave | Play a sine wave - tutorials/dsp/02-your-first-instrument#play-a-chord | Play a chord - tutorials/dsp/02-your-first-instrument#shape-each-note | Shape each note - tutorials/dsp/02-your-first-instrument#add-a-filter | Add a filter - tutorials/dsp/02-your-first-instrument#turn-the-knobs | Turn the knobs - tutorials/dsp/02-your-first-instrument#change-it-while-it-plays | Change it while it plays - tutorials/dsp/02-your-first-instrument#next-steps | Next steps Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/ --- <!-- ID: tutorials/dsp/02-your-first-instrument#add-a-filter --> Your First Instrument > Add a filter [tutorial] Write a second instrument, `FilteredSynth`. It is the same as `Synth`, but its oscillator is a sawtooth, which has a lot of high harmonics, and a lowpass filter follows it: ```resonon continue dsp instrument FilteredSynth { param attack: 0.002 range(0.0001, 0.1); param release: 0.001 range(0.0001, 0.1); param cutoff: 1200 range(20, 20000); voice state phase: 0.0; voice state env: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { let freq = __native("mtof", note); phase = __native("fract", phase + freq * INV_SR); let osc = phase * 2.0 - 1.0; let target = gate * velocity; if gate > 0.0 { env = env + (target - env) * attack; } else { env = env + (target - env) * release; } let sample = __native("svf_lp", osc * env, cutoff, 1.5); return (sample, sample); } } let lead = FilteredSynth(); synth.set_instrument(lead); ``` `__native("svf_lp", input, cutoff, resonance)` is a built-in lowpass filter. The [DSP builtins](/docs/reference/stdlib/dsp-builtins/) list every function you can call like this. This time you kept the instrument in `lead`, so you can reach its knobs. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#add-a-filter Previous: tutorials/dsp/02-your-first-instrument#shape-each-note Next: tutorials/dsp/02-your-first-instrument#turn-the-knobs --- <!-- ID: tutorials/dsp/02-your-first-instrument#before-you-start --> Your First Instrument > Before you start [tutorial] Finish [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/). Open `src/main.non`, evaluate `RESET;` on its own, then remove that line. Check that the earlier drum track is silent. The synth below makes its own sound; it needs no samples or plugin. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#before-you-start Next: tutorials/dsp/02-your-first-instrument#play-a-sine-wave --- <!-- ID: tutorials/dsp/02-your-first-instrument#change-it-while-it-plays --> Your First Instrument > Change it while it plays [tutorial] Change the waveform line to a square wave, then select only the `dsp instrument FilteredSynth { … }` block and run it: ```resonon parse-only dsp instrument FilteredSynth { param attack: 0.002 range(0.0001, 0.1); param release: 0.001 range(0.0001, 0.1); param cutoff: 1200 range(20, 20000); voice state phase: 0.0; voice state env: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { let freq = __native("mtof", note); phase = __native("fract", phase + freq * INV_SR); let osc = if phase < 0.5 { 1.0 } else { -1.0 }; let target = gate * velocity; if gate > 0.0 { env = env + (target - env) * attack; } else { env = env + (target - env) * release; } let sample = __native("svf_lp", osc * env, cutoff, 1.5); return (sample, sample); } } ``` The sound changes with no click, and notes that are playing fade into the new version. The filter sweep and the longer release are still there: an edit changes the code, not the knobs. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#change-it-while-it-plays Previous: tutorials/dsp/02-your-first-instrument#turn-the-knobs Next: tutorials/dsp/02-your-first-instrument#next-steps --- <!-- ID: tutorials/dsp/02-your-first-instrument#next-steps --> Your First Instrument > Next steps [tutorial] You wrote a polyphonic synth with an envelope and a filter, and changed it while it played. - [Write a Modulation Source](/docs/how-to/dsp/04-write-a-modulation-source/) — write the signal that turns a knob - [Voices](/docs/explanation/dsp/01-voices/) — how notes get voices, and what happens when they run out - [DSP Blocks](/docs/reference/dsp/01-dsp-blocks/) — everything a `dsp instrument` can declare Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#next-steps Previous: tutorials/dsp/02-your-first-instrument#change-it-while-it-plays --- <!-- ID: tutorials/dsp/02-your-first-instrument#play-a-chord --> Your First Instrument > Play a chord [tutorial] Send the track a chord: ```resonon continue synth << [c4:maj e4:min]; ``` You hear three notes at the same time. The instrument gives each note its own **voice**: its own copy of `render`, with its own `phase`. That is what `voice state` means. Each voice starts again from `0.0` when its note starts, so the notes don't get in each other's way. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#play-a-chord Previous: tutorials/dsp/02-your-first-instrument#play-a-sine-wave Next: tutorials/dsp/02-your-first-instrument#shape-each-note --- <!-- ID: tutorials/dsp/02-your-first-instrument#play-a-sine-wave --> Your First Instrument > Play a sine wave [tutorial] ```resonon dsp instrument SineOsc { voice state phase: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { let freq = __native("mtof", note); phase = __native("fract", phase + freq * INV_SR); let sample = __native("sin", phase * TWOPI) * velocity * gate; return (sample, sample); } } let synth = session.create_track("synth"); synth.set_instrument(SineOsc()); synth << [c4 e4 g4 c5]; PLAY; ``` You hear four notes, played by a synth that you wrote. - `dsp instrument SineOsc { … }` defines a new instrument called `SineOsc`. - `fn render(note, velocity, gate)` runs **one time for each sample**, and returns a left and a right sample. `note` is the MIDI note number, `velocity` is how hard it was played (`0` to `1`), and `gate` is `1` while the note is held and `0` after it is released. - `__native("mtof", note)` changes the note number into a frequency in Hz. `phase` goes from `0` to `1` once for each period of that frequency, and `sin` turns it into a wave. - `SineOsc()` makes one of these instruments, and `set_instrument` puts it on the track. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#play-a-sine-wave Previous: tutorials/dsp/02-your-first-instrument#before-you-start Next: tutorials/dsp/02-your-first-instrument#play-a-chord --- <!-- ID: tutorials/dsp/02-your-first-instrument#shape-each-note --> Your First Instrument > Shape each note [tutorial] A sine that starts and stops at full level clicks. Give each voice an envelope, which fades the note in while it is held and out after it is released: ```resonon continue dsp instrument Synth { param attack: 0.002 range(0.0001, 0.1); param release: 0.001 range(0.0001, 0.1); voice state phase: 0.0; voice state env: 0.0; fn render(note, velocity, gate) -> (out_l, out_r) { let freq = __native("mtof", note); phase = __native("fract", phase + freq * INV_SR); let osc = __native("sin", phase * TWOPI); let target = gate * velocity; if gate > 0.0 { env = env + (target - env) * attack; } else { env = env + (target - env) * release; } let sample = osc * env; return (sample, sample); } } synth.set_instrument(Synth()); synth << [c4 _ e4 _ g4 _ c5 _]; ``` The notes are softer at the start and ring out at the end. `env` moves a small step toward `target` in each sample. While the note is held, `target` is the velocity and the step is `attack`; after the release, `target` is `0` and the step is `release`. A smaller step is a slower fade. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#shape-each-note Previous: tutorials/dsp/02-your-first-instrument#play-a-chord Next: tutorials/dsp/02-your-first-instrument#add-a-filter --- <!-- ID: tutorials/dsp/02-your-first-instrument#turn-the-knobs --> Your First Instrument > Turn the knobs [tutorial] Set a knob by name, or send it a signal: ```resonon continue use "std/signals" { Sine }; print(lead.parameters()); lead.set_parameter("release", 0.0002); lead.parameter("cutoff") << Sine(2).range_exp(300, 6000); ``` `parameters()` returns every knob with its range and value, and `print` shows them as a table. The notes now ring longer, and the filter opens and closes twice every cycle. The instrument must be on the track before you can read its knobs: `FilteredSynth()` only describes it, and `set_instrument` builds it. Page: tutorials/dsp/02-your-first-instrument URL: https://resonon.org/docs/tutorials/dsp/02-your-first-instrument/#turn-the-knobs Previous: tutorials/dsp/02-your-first-instrument#add-a-filter Next: tutorials/dsp/02-your-first-instrument#change-it-while-it-plays --- <!-- ID: tutorials/getting-started/01-installation --> Installation [tutorial] On this page you install resonon and the VSCode extension, and check that both work. Sections: - tutorials/getting-started/01-installation#before-you-start | Before you start - tutorials/getting-started/01-installation#what-youre-installing | What You're Installing - tutorials/getting-started/01-installation#system-requirements | System Requirements - tutorials/getting-started/01-installation#installation | Installation - tutorials/getting-started/01-installation#resonon--lsp | Resonon + LSP - tutorials/getting-started/01-installation#ide-support | IDE Support - tutorials/getting-started/01-installation#verify-installation | Verify Installation - tutorials/getting-started/01-installation#next-steps | Next Steps Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/ --- <!-- ID: tutorials/getting-started/01-installation#before-you-start --> Installation > Before you start [tutorial] You need a macOS machine and VSCode installed. No resonon project or running session is needed yet. Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#before-you-start Next: tutorials/getting-started/01-installation#what-youre-installing --- <!-- ID: tutorials/getting-started/01-installation#ide-support --> Installation > IDE Support [tutorial] Download the [latest extension](https://github.com/WARNS-AUDIO/RESONON/releases) (**.vsix**). Then, within Visual Studio Code open the command palette using `Cmd+Shift+P` and choose **Extensions: Install from VSIX...**. Select the downloaded file when prompted. Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#ide-support Previous: tutorials/getting-started/01-installation#resonon--lsp Next: tutorials/getting-started/01-installation#verify-installation --- <!-- ID: tutorials/getting-started/01-installation#installation --> Installation > Installation [tutorial] Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#installation Previous: tutorials/getting-started/01-installation#system-requirements Next: tutorials/getting-started/01-installation#resonon--lsp --- <!-- ID: tutorials/getting-started/01-installation#next-steps --> Installation > Next Steps [tutorial] - [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/) — the next tutorial: make a project and play a beat - [Fix Install and Project Problems](/docs/how-to/setup/06-fix-install-and-project-problems/) — if something did not install cleanly Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#next-steps Previous: tutorials/getting-started/01-installation#verify-installation --- <!-- ID: tutorials/getting-started/01-installation#resonon--lsp --> Installation > Resonon + LSP [tutorial] Download the [latest installer](https://github.com/WARNS-AUDIO/RESONON/releases) (**.pkg**). The program will guide you through the automatic installation of the resonon language and LSP. Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#resonon--lsp Previous: tutorials/getting-started/01-installation#installation Next: tutorials/getting-started/01-installation#ide-support --- <!-- ID: tutorials/getting-started/01-installation#system-requirements --> Installation > System Requirements [tutorial] - macOS Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#system-requirements Previous: tutorials/getting-started/01-installation#what-youre-installing Next: tutorials/getting-started/01-installation#installation --- <!-- ID: tutorials/getting-started/01-installation#verify-installation --> Installation > Verify Installation [tutorial] ```bash resonon --version ``` If the current version is printed in the terminal, the resonon language is correctly installed. In VSCode the extension should show up in the "Extensions" panel. To quickly verify, just open any `.non` file and see the **LSP** and **RESONON** buttons in the footer appear. (The LSP should show a checkmark to the left side.) If both check out, you are ready to make your first sound. :::tip Building resonon yourself? See [Build Resonon from Source](/docs/how-to/setup/01-build-from-source/). ::: Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#verify-installation Previous: tutorials/getting-started/01-installation#ide-support Next: tutorials/getting-started/01-installation#next-steps --- <!-- ID: tutorials/getting-started/01-installation#what-youre-installing --> Installation > What You're Installing [tutorial] A resonon coding environment has three main components: - **Resonon** — The core binary of the system. Think of it as the language itself — it includes the interpreter, audio and MIDI engine, and the server for live-coding. - **LSP** — [Language server protocol](https://en.wikipedia.org/wiki/Language_Server_Protocol) (LSP) support for resonon. This provides code completion, hover hints, go-to-definition, and other useful features. - **IDE Support** — The convenience layer for resonon user-interaction. Currently the standard integration comes in the form of an extension for _Visual Studio Code_, that connects to the resonon server and lets you evaluate selected code with `Cmd+Enter`. It provides controls for sessions and transport, gives quick access to helpful TUI windows, and more. Internally, the extension uses the resonon LSP. With these you run a piece two ways. Live, from VSCode: you evaluate code into a running session and hear each change as it plays. Or with `resonon run` in a terminal: it runs a project's piece from top to bottom and renders it to files. The next tutorials start live; [Your First Project](/docs/tutorials/getting-started/04-your-first-project/) renders. Page: tutorials/getting-started/01-installation URL: https://resonon.org/docs/tutorials/getting-started/01-installation/#what-youre-installing Previous: tutorials/getting-started/01-installation#before-you-start Next: tutorials/getting-started/01-installation#system-requirements --- <!-- ID: tutorials/getting-started/02-your-first-sound --> Your First Sound [tutorial] On this page you make a project, play a drum beat from VSCode, and change it while it plays. You need resonon and the VSCode extension installed — see [Installation](/docs/tutorials/getting-started/01-installation/). Sections: - tutorials/getting-started/02-your-first-sound#before-you-start | Before you start - tutorials/getting-started/02-your-first-sound#make-a-project | Make a project - tutorials/getting-started/02-your-first-sound#run-a-line | Run a line - tutorials/getting-started/02-your-first-sound#play-a-beat | Play a beat - tutorials/getting-started/02-your-first-sound#change-the-beat | Change the beat - tutorials/getting-started/02-your-first-sound#stop | Stop - tutorials/getting-started/02-your-first-sound#next-steps | Next steps - tutorials/getting-started/02-your-first-sound#keep-the-session-and-code-together | Keep the session and code together Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/ --- <!-- ID: tutorials/getting-started/02-your-first-sound#before-you-start --> Your First Sound > Before you start [tutorial] Check `resonon --version` and that the extension is enabled. Use a new `hello` project for this page. If you already have a live session, evaluate `RESET;` on its own before the first beat, then remove that line. The session should be silent. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#before-you-start Next: tutorials/getting-started/02-your-first-sound#make-a-project --- <!-- ID: tutorials/getting-started/02-your-first-sound#change-the-beat --> Your First Sound > Change the beat [tutorial] The server keeps everything you run, so `drums` is still there. Send it a new pattern: ```resonon continue drums << [bd _ sd _, ch ch ch ch]; ``` `_` is a rest. The comma plays two patterns at the same time: the kick and snare, and four hi-hats over them. You did not stop the music and you did not make the track again. This is live coding: change a line, run it, listen. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#change-the-beat Previous: tutorials/getting-started/02-your-first-sound#play-a-beat Next: tutorials/getting-started/02-your-first-sound#stop --- <!-- ID: tutorials/getting-started/02-your-first-sound#keep-the-session-and-code-together --> Your First Sound > Keep the session and code together [tutorial] The session is the document; code and the UI edit it together. Save the project session to keep tracks, device chains, mixer settings and arrangement. Put patterns and callbacks at the top level of the entry file, so that opening the project attaches them again after it restores the saved session. Run Selection Live evaluates only the selection. Run File Live evaluates the whole entry file into the running session. Session undo covers UI gestures. Code evaluations are not undo steps: correct the source and run it again. Use text undo in the editor to change the source. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#keep-the-session-and-code-together Previous: tutorials/getting-started/02-your-first-sound#next-steps --- <!-- ID: tutorials/getting-started/02-your-first-sound#make-a-project --> Your First Sound > Make a project [tutorial] A piece lives in a project: a folder with a `resonon.toml` in it. Open a terminal and make one: ```bash resonon new hello ``` Open the `hello` folder in VSCode, and open `src/main.non`. The generated piece is ready to play: ```resonon use "std/instruments" { Sampler, Kit }; // Set up the piece. It runs when the project opens and on Reset Project. // Create each track here, once: a name that exists is an error. fn setup() { set_bpm(120); session.create_track("drums"); } // The rest of the file runs after setup(), and again on each file run. // session.track() looks up a track that setup() created. let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("TR-909"))); drums << [bd _ bd _, _ sd _ sd, ch*8]; ``` Press `Cmd+Shift+Enter` (`Ctrl+Shift+Enter` on Windows and Linux). This is **Run File Live**: it evaluates the whole file into the session. The first time, the extension starts a resonon server and connects to it. Then press `F5` to play. You hear a kick, a snare and hi-hats repeat each bar. To change the loop, edit the `drums << [...]` line and execute that line with `Cmd+Enter`. `fn setup()` runs when the project opens, and on **RESONON: Reset Project**. Run File Live does not call it. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). The following steps build a beat one line at a time. Evaluate `RESET;` on its own to stop and clear the first loop. Then delete the file contents and write the following steps into it. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#make-a-project Previous: tutorials/getting-started/02-your-first-sound#before-you-start Next: tutorials/getting-started/02-your-first-sound#run-a-line --- <!-- ID: tutorials/getting-started/02-your-first-sound#next-steps --> Your First Sound > Next steps [tutorial] - [Patterns, Tracks & Effects](/docs/tutorials/getting-started/03-patterns-tracks-effects/) — the next tutorial: more patterns, a second track, and an effect chain - [Sessions & Servers](/docs/explanation/running/03-sessions-and-servers/) — why the session keeps what you run Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#next-steps Previous: tutorials/getting-started/02-your-first-sound#stop Next: tutorials/getting-started/02-your-first-sound#keep-the-session-and-code-together --- <!-- ID: tutorials/getting-started/02-your-first-sound#play-a-beat --> Your First Sound > Play a beat [tutorial] Write these lines under the first one, select them, and press `Cmd+Enter`: ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("TR-909"))); drums << [bd sd bd sd]; PLAY; ``` You hear a kick and a snare, looping. - `use` brings `Sampler` and `Kit` in from the standard library. - `session.create_track("drums")` makes a track, like a channel on a mixer. Its sound goes to the master output. `session` is the running session: it holds every track. - `Sampler(Kit("TR-909"))` is a drum sampler loaded with the TR-909 kit, which comes with resonon. `.set_instrument()` puts it on the track. - `[bd sd bd sd]` is a **pattern**: bass drum, snare, bass drum, snare. `<<` sends it to the track. The pattern fills one cycle — one bar — and repeats. - `PLAY;` starts the transport. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#play-a-beat Previous: tutorials/getting-started/02-your-first-sound#run-a-line Next: tutorials/getting-started/02-your-first-sound#change-the-beat --- <!-- ID: tutorials/getting-started/02-your-first-sound#run-a-line --> Your First Sound > Run a line [tutorial] Write this line, put the cursor on it, and press `Cmd+Enter`: ```resonon print("Hello, RESONON!"); ``` The **RESONON** item in the status bar shows the server it is connected to. The text appears in the **Output** panel: press `Cmd+Shift+U` and pick **RESONON**. `Cmd+Enter` runs the lines you select. With nothing selected, it runs the line the cursor is on. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#run-a-line Previous: tutorials/getting-started/02-your-first-sound#make-a-project Next: tutorials/getting-started/02-your-first-sound#play-a-beat --- <!-- ID: tutorials/getting-started/02-your-first-sound#stop --> Your First Sound > Stop [tutorial] ```resonon continue STOP; ``` The beat stops, and the play head goes back to the start. `Shift+F5` does the same from the keyboard. Press `F5` and the beat plays again from the start. Page: tutorials/getting-started/02-your-first-sound URL: https://resonon.org/docs/tutorials/getting-started/02-your-first-sound/#stop Previous: tutorials/getting-started/02-your-first-sound#change-the-beat Next: tutorials/getting-started/02-your-first-sound#next-steps --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects --> Patterns, Tracks & Effects [tutorial] 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](/docs/tutorials/getting-started/02-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. Sections: - tutorials/getting-started/03-patterns-tracks-effects#before-you-start | Before you start - tutorials/getting-started/03-patterns-tracks-effects#start-the-beat | Start the beat - tutorials/getting-started/03-patterns-tracks-effects#change-it-on-the-beat | Change it on the beat - tutorials/getting-started/03-patterns-tracks-effects#add-a-track | Add a track - tutorials/getting-started/03-patterns-tracks-effects#add-an-effect | Add an effect - tutorials/getting-started/03-patterns-tracks-effects#use-the-transport-keys | Use the transport keys - tutorials/getting-started/03-patterns-tracks-effects#next-steps | Next steps Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/ --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#add-a-track --> Patterns, Tracks & Effects > Add a track [tutorial] A second track plays next to the first one, in time with it: ```resonon continue let bass = session.create_track("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. Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#add-a-track Previous: tutorials/getting-started/03-patterns-tracks-effects#change-it-on-the-beat Next: tutorials/getting-started/03-patterns-tracks-effects#add-an-effect --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#add-an-effect --> Patterns, Tracks & Effects > Add an effect [tutorial] An effect processes the sound of a track, like an insert on a mixer channel. Put a lowpass filter on the drums: ```resonon continue use "std/effects" { Filter, FilterType, Delay }; drums.set_effects(#[Filter("lowpass", FilterType.lowpass, 1200)]); ``` The drums sound darker. Now run the same line with a delay after the filter: ```resonon continue drums.set_effects(#[Filter("lowpass", FilterType.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. Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#add-an-effect Previous: tutorials/getting-started/03-patterns-tracks-effects#add-a-track Next: tutorials/getting-started/03-patterns-tracks-effects#use-the-transport-keys --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#before-you-start --> Patterns, Tracks & Effects > Before you start [tutorial] 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. Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#before-you-start Next: tutorials/getting-started/03-patterns-tracks-effects#start-the-beat --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#change-it-on-the-beat --> Patterns, Tracks & Effects > Change it on the beat [tutorial] Run this line early in the bar, and then run it late in the bar: ```resonon continue 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. Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#change-it-on-the-beat Previous: tutorials/getting-started/03-patterns-tracks-effects#start-the-beat Next: tutorials/getting-started/03-patterns-tracks-effects#add-a-track --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#next-steps --> Patterns, Tracks & Effects > Next steps [tutorial] - [Your First Project](/docs/tutorials/getting-started/04-your-first-project/) — the next tutorial: save the beat as a piece and run it from the terminal - [Transport](/docs/reference/running/02-transport/) — exactly what `PLAY`, `PAUSE`, `STOP` and `RESET` do - [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/) — after Getting Started, explore step lengths, pitches and variations Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#next-steps Previous: tutorials/getting-started/03-patterns-tracks-effects#use-the-transport-keys --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#start-the-beat --> Patterns, Tracks & Effects > Start the beat [tutorial] ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd sd bd sd]; PLAY; ``` Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#start-the-beat Previous: tutorials/getting-started/03-patterns-tracks-effects#before-you-start Next: tutorials/getting-started/03-patterns-tracks-effects#change-it-on-the-beat --- <!-- ID: tutorials/getting-started/03-patterns-tracks-effects#use-the-transport-keys --> Patterns, Tracks & Effects > Use the transport keys [tutorial] 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. Page: tutorials/getting-started/03-patterns-tracks-effects URL: https://resonon.org/docs/tutorials/getting-started/03-patterns-tracks-effects/#use-the-transport-keys Previous: tutorials/getting-started/03-patterns-tracks-effects#add-an-effect Next: tutorials/getting-started/03-patterns-tracks-effects#next-steps --- <!-- ID: tutorials/getting-started/04-your-first-project --> Your First Project [tutorial] On this page you turn the beat from the last pages into a piece: a file that plays the same every time, which you run from the terminal and get as a WAV file. Work in the `hello` project from [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/). Sections: - tutorials/getting-started/04-your-first-project#before-you-start | Before you start - tutorials/getting-started/04-your-first-project#look-at-the-project | Look at the project - tutorials/getting-started/04-your-first-project#write-the-piece | Write the piece - tutorials/getting-started/04-your-first-project#write-a-bounce-script | Write a bounce script - tutorials/getting-started/04-your-first-project#run-it | Run it - tutorials/getting-started/04-your-first-project#bounce-each-track | Bounce each track - tutorials/getting-started/04-your-first-project#next-steps | Next steps Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/ --- <!-- ID: tutorials/getting-started/04-your-first-project#before-you-start --> Your First Project > Before you start [tutorial] Open the `hello` folder and check that it contains `resonon.toml` and `src/main.non`. Evaluate `STOP;` in VSCode if the earlier beat is playing. The terminal run starts independently of that live session; it needs no variables from previous evaluations. Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#before-you-start Next: tutorials/getting-started/04-your-first-project#look-at-the-project --- <!-- ID: tutorials/getting-started/04-your-first-project#bounce-each-track --> Your First Project > Bounce each track [tutorial] The script can use the names that `src/main.non` defines. Change the line in `scripts/bounce.non` so that each track gets its own file, next to the mix: ```resonon parse-only render(#[drums, bass, session.master], 8); ``` Run `resonon run scripts/bounce.non` again. A new folder has `drums.wav`, `bass.wav` and `master.wav`. Every run makes a new folder, so a render never writes over another one. Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#bounce-each-track Previous: tutorials/getting-started/04-your-first-project#run-it Next: tutorials/getting-started/04-your-first-project#next-steps --- <!-- ID: tutorials/getting-started/04-your-first-project#look-at-the-project --> Your First Project > Look at the project [tutorial] `resonon new hello` made this folder: ``` hello/ ├── resonon.toml ├── src/ │ └── main.non ├── README.md ├── LICENSE ├── AGENTS.md └── .gitignore ``` - `resonon.toml` names the project and the version of resonon it is written for. Resonon finds a project by this file, so the code in `src/` can find its kits and packages on any machine. - `src/main.non` is the piece. It runs when the project opens, in the editor and in `resonon run`. - `AGENTS.md` tells a coding agent where to start. See [Work with Coding Agents](/docs/how-to/running/11-work-with-coding-agents/). Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#look-at-the-project Previous: tutorials/getting-started/04-your-first-project#before-you-start Next: tutorials/getting-started/04-your-first-project#write-the-piece --- <!-- ID: tutorials/getting-started/04-your-first-project#next-steps --> Your First Project > Next steps [tutorial] - [Arrange a Song](/docs/tutorials/getting-started/05-arrange-a-song/) — the next tutorial: give the beat a form, from intro to chorus - [Render a Project](/docs/how-to/running/02-render-a-project/) — every way to render - [Two Ways to Run a Piece](/docs/explanation/running/01-two-ways-to-run-a-piece/) — why resonon has two ways to run a piece - [resonon.toml](/docs/reference/setup/04-resonon-toml/) — every key of the project file Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#next-steps Previous: tutorials/getting-started/04-your-first-project#bounce-each-track --- <!-- ID: tutorials/getting-started/04-your-first-project#run-it --> Your First Project > Run it [tutorial] Save both files. In a terminal, in the `hello` folder, run: ```bash resonon run scripts/bounce.non ``` Resonon opens the project as the editor does: it restores the saved session if present, calls `setup()` and runs `src/main.non`. Then it evaluates `scripts/bounce.non` and exits. The file is in a new folder in the project: ``` renders/hello_<date>_<time>/master.wav ``` Open it in any audio player. It is 16 seconds long: 8 cycles of 2 seconds. The script path is relative to the folder you run the command in. `resonon run` stops after the script, so a line like `PLAY;` in a script plays nothing that you can hear: the program ends at once. To hear a piece while you work on it, use VSCode, as before. Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#run-it Previous: tutorials/getting-started/04-your-first-project#write-a-bounce-script Next: tutorials/getting-started/04-your-first-project#bounce-each-track --- <!-- ID: tutorials/getting-started/04-your-first-project#write-a-bounce-script --> Your First Project > Write a bounce script [tutorial] Put the render in a script, not in the piece. The piece runs again each time the project opens, and a render in it runs each time too. Make a folder `scripts` in the project, and in it a file `bounce.non` with this line: ```resonon continue render(8); ``` `render(8)` plays 8 cycles of the master output into a WAV file, faster than real time. Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#write-a-bounce-script Previous: tutorials/getting-started/04-your-first-project#write-the-piece Next: tutorials/getting-started/04-your-first-project#run-it --- <!-- ID: tutorials/getting-started/04-your-first-project#write-the-piece --> Your First Project > Write the piece [tutorial] Until now you ran lines one at a time, and the session kept them. A piece is a file that makes the session again each time the project opens. Replace what is in `src/main.non` with this: ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType, Delay }; fn setup() { set_project_title("hello"); set_bpm(120); session.create_track("drums"); session.create_track("bass"); } let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd _ sd _, hh hh hh hh]; drums.set_effects(#[Filter("lowpass", FilterType.lowpass, 1200), Delay("delay", 0.25, 0.4)]); let bass = session.track("bass"); bass.set_instrument(Sampler(Kit("TR-808"))); bass << [bd _ _ bd, _ _ bd _]; ``` It is the beat you built, with a `setup()` function at the top: - `set_project_title("hello")` names the piece. `set_bpm(120)` sets its tempo: 120 BPM, and four beats in each cycle. - `setup()` runs when the project opens, before the rest of the file. The tracks are at the top level, so that their names stay defined after `setup()` returns. Page: tutorials/getting-started/04-your-first-project URL: https://resonon.org/docs/tutorials/getting-started/04-your-first-project/#write-the-piece Previous: tutorials/getting-started/04-your-first-project#look-at-the-project Next: tutorials/getting-started/04-your-first-project#write-a-bounce-script --- <!-- ID: tutorials/getting-started/05-arrange-a-song --> Arrange a Song [tutorial] In the previous pages, each pattern played in a loop. A finished song has a form. It has an intro, verses and a chorus. On this page, you arrange a short song from start to end, and bounce it to a WAV file. You make three **sections**: an intro, a verse and a chorus. Then you put them in sequence. Then you add a drum fill and a fade-in on top of the song. Work in the `hello` project from [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/). The song is 28 cycles long: | Cycles | Part | | ------- | -------- | | 0–3 | intro | | 4–11 | verse | | 12–19 | verse | | 20–27 | chorus | Sections: - tutorials/getting-started/05-arrange-a-song#before-you-start | Before you start - tutorials/getting-started/05-arrange-a-song#set-up-the-tracks | Set Up the Tracks - tutorials/getting-started/05-arrange-a-song#write-the-verse | Write the Verse - tutorials/getting-started/05-arrange-a-song#write-the-chorus | Write the Chorus - tutorials/getting-started/05-arrange-a-song#write-the-intro | Write the Intro - tutorials/getting-started/05-arrange-a-song#put-the-sections-in-sequence | Put the Sections in Sequence - tutorials/getting-started/05-arrange-a-song#look-at-the-song | Look at the Song - tutorials/getting-started/05-arrange-a-song#add-a-drum-fill | Add a Drum Fill - tutorials/getting-started/05-arrange-a-song#fade-in-the-keys | Fade In the Keys - tutorials/getting-started/05-arrange-a-song#change-the-song-while-it-plays | Change the Song While It Plays - tutorials/getting-started/05-arrange-a-song#bounce-the-song | Bounce the Song - tutorials/getting-started/05-arrange-a-song#learning-path-after-getting-started | Learning path after Getting Started Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/ --- <!-- ID: tutorials/getting-started/05-arrange-a-song#add-a-drum-fill --> Arrange a Song > Add a Drum Fill [tutorial] Add a fill at the last cycle of the second verse. The second verse ends at cycle 20. Thus, the fill starts at cycle 19 and is 1 cycle long: ```resonon continue song[drums].layer("fills").at(19, 1) << [sd*8]; ``` `.at(19, 1)` selects a range in the lane. The fill goes on top of the verse. It does not delete the verse. It only hides the verse for 1 cycle. The fill is on a layer with the name `fills`. A layer is a group of changes. You can turn off all the changes on a layer, and then turn them on again: ```resonon continue song[drums].layer("fills").mute(); // no fill song[drums].layer("fills").unmute(); // the fill is back ``` Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#add-a-drum-fill Previous: tutorials/getting-started/05-arrange-a-song#look-at-the-song Next: tutorials/getting-started/05-arrange-a-song#fade-in-the-keys --- <!-- ID: tutorials/getting-started/05-arrange-a-song#before-you-start --> Arrange a Song > Before you start [tutorial] Finish [Your First Project](/docs/tutorials/getting-started/04-your-first-project/), and open `hello/src/main.non`. Evaluate `RESET;` on its own, then remove that line. Check that the previous beat is silent before setting up the song. Select and evaluate each live block in order. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#before-you-start Next: tutorials/getting-started/05-arrange-a-song#set-up-the-tracks --- <!-- ID: tutorials/getting-started/05-arrange-a-song#bounce-the-song --> Arrange a Song > Bounce the Song [tutorial] Now make the song a piece that [`resonon run`](/docs/tutorials/getting-started/04-your-first-project/) can bounce. The piece is every step of this page, without the lines that you ran only to try something. Put this in `src/main.non`, in place of what is there: ```resonon use "std/instruments" { Sampler, SamplerMelodic, Kit }; use "std/signals" { automation }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("drums"); session.create_track("hats"); session.create_track("keys"); } set_project_title("My Song"); set_bpm(120); let drums = session.track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let hats = session.track("hats"); hats.set_instrument(Sampler(Kit("CR-78"))); let keys = session.track("keys"); keys.set_instrument(SamplerMelodic(Kit("keys"))); drums.volume << -6; hats.volume << -6; let verse = section(8); verse[drums] << [bd _ sd _]; verse[keys] << [c3 _ eb3 _ g3 _ bb3 _]; let chorus = verse.clone(); chorus[drums] << [bd sd bd sd]; chorus[hats] << [_ hh _ hh _ hh _ hh]; let intro = section(4); intro[keys] << [c3 _ eb3 _ g3 _ bb3 _]; let song = arrange(#[intro, verse * 2, chorus]); song[drums].layer("fills").at(19, 1) << [sd*8]; song[drums].at(20, 8) << [bd bd sd bd]; song[keys].volume << -6; song[keys].volume.at(0, 4) << automation().at(0, -36).at(4, -6); song.play(); render(#[session.master], song.length()); ``` `song.play()` puts the song on the tracks. `render()` then plays it from the start, for as many cycles as the song is long, into a WAV file. In a terminal, in the project folder, run: ```bash resonon run ``` The file is in `renders/my_song_<date>_<time>/master.wav`: 56 seconds, from the fade-in to the last chorus. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#bounce-the-song Previous: tutorials/getting-started/05-arrange-a-song#change-the-song-while-it-plays Next: tutorials/getting-started/05-arrange-a-song#learning-path-after-getting-started --- <!-- ID: tutorials/getting-started/05-arrange-a-song#change-the-song-while-it-plays --> Arrange a Song > Change the Song While It Plays [tutorial] You can change a song while it plays. You do not have to call `play()` again. 1. Execute `song.play();`. 2. While the intro plays, execute this line: ```resonon continue song[drums].at(20, 8) << [bd bd sd bd]; ``` This line puts new drums on top of the chorus. When the playhead gets to the chorus, you hear them. A change to notes starts at the next cycle. A change to automation starts almost immediately. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#change-the-song-while-it-plays Previous: tutorials/getting-started/05-arrange-a-song#fade-in-the-keys Next: tutorials/getting-started/05-arrange-a-song#bounce-the-song --- <!-- ID: tutorials/getting-started/05-arrange-a-song#fade-in-the-keys --> Arrange a Song > Fade In the Keys [tutorial] A track parameter also has a lane. Use `.volume` to get the volume lane of a track. Put an automation curve into it. This curve fades the keys in during the intro, from −36 dB to −6 dB: ```resonon continue song[keys].volume << -6; song[keys].volume.at(0, 4) << automation().at(0, -36).at(4, -6); song.play(); ``` The first line sets the volume to −6 dB for the full song. The second line puts the fade on top of it, in cycles 0–3. The positions in the curve start at the start of its range. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#fade-in-the-keys Previous: tutorials/getting-started/05-arrange-a-song#add-a-drum-fill Next: tutorials/getting-started/05-arrange-a-song#change-the-song-while-it-plays --- <!-- ID: tutorials/getting-started/05-arrange-a-song#learning-path-after-getting-started --> Arrange a Song > Learning path after Getting Started [tutorial] You arranged a song from sections, edited it as one piece, and bounced it. Continue in this order; each tutorial says what to have ready and starts its own exercise: 1. [Live Coding Workflow](/docs/tutorials/running/01-live-coding-workflow/) — evaluate changes, recover from errors, inspect the set, and rebuild a session 2. [Language for a Reusable Piece](/docs/tutorials/language/01-language-for-a-piece/) — variables, functions, classes and modules 3. [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/) — step lengths, rests, notes and cycle-to-cycle variation 4. [Your First Groove](/docs/tutorials/patterns/02-your-first-groove/) — nested rhythms, layers, repeats and accents 5. [Melody and Harmony in a Key](/docs/tutorials/patterns/03-melody-and-harmony/) — scale degrees, chords and changing key 6. [Your First Mix](/docs/tutorials/audio/01-your-first-mix/) — volume, pan, effects, sends and a reusable mixer layout 7. [Signals and Modulation](/docs/tutorials/audio/02-signals-and-modulation/) — moving filters and pan, tempo and ranges Then choose a direction: - [Play Your MIDI Gear](/docs/tutorials/midi/01-play-your-midi-gear/) — connect a synth and controller; requires MIDI gear or a DAW instrument - [Your First Effect](/docs/tutorials/dsp/01-your-first-effect/), then [Your First Instrument](/docs/tutorials/dsp/02-your-first-instrument/) — write your own audio processors - [Your First Shader](/docs/tutorials/visuals/01-your-first-shader/) — make visuals that move with the music To go further with the song: - [Arrange a Song from Sections](/docs/how-to/audio/17-arrange-a-song-from-sections/) — sections, variations and sequencing - [Add Fills to a Song](/docs/how-to/audio/18-add-fills-to-a-song/) — fills and layers over the sections - [The Arrangement Model](/docs/explanation/audio/04-the-arrangement-model/) — layers, masks and positions that are not on the grid - [Draw an Automation Curve](/docs/how-to/audio/11-draw-an-automation-curve/) — the curves that you put into an automation lane - [Render a Project](/docs/how-to/running/02-render-a-project/) — write tracks and stems to WAV files Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#learning-path-after-getting-started Previous: tutorials/getting-started/05-arrange-a-song#bounce-the-song --- <!-- ID: tutorials/getting-started/05-arrange-a-song#look-at-the-song --> Arrange a Song > Look at the Song [tutorial] `show()` gives the lanes of the song. Each line is a range of cycles and the pattern that plays there: ```resonon continue show(song); ``` ```text section — 28 cycles, 3 lanes keys layers: base 0..4 [C3 _ D#3 _ G3 _ A#3 _] 4..12 [C3 _ D#3 _ G3 _ A#3 _] 12..20 [C3 _ D#3 _ G3 _ A#3 _] 20..28 [C3 _ D#3 _ G3 _ A#3 _] drums layers: base 4..12 [bd _ sd _] 12..20 [bd _ sd _] 20..28 [bd sd bd sd] hats layers: base 20..28 [_ hh _ hh _ hh _ hh] ``` Use `show()` each time that you are not sure what the song will do. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#look-at-the-song Previous: tutorials/getting-started/05-arrange-a-song#put-the-sections-in-sequence Next: tutorials/getting-started/05-arrange-a-song#add-a-drum-fill --- <!-- ID: tutorials/getting-started/05-arrange-a-song#put-the-sections-in-sequence --> Arrange a Song > Put the Sections in Sequence [tutorial] Use `arrange()` to put the sections one after the other. To repeat a section, multiply it by a number: ```resonon continue let song = arrange(#[intro, verse * 2, chorus]); print(song.length()); // 28 song.play(); ``` `song` is also a section. It is 28 cycles long. `song.play()` plays the song one time from the start: the intro, the verse two times, and then the chorus. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#put-the-sections-in-sequence Previous: tutorials/getting-started/05-arrange-a-song#write-the-intro Next: tutorials/getting-started/05-arrange-a-song#look-at-the-song --- <!-- ID: tutorials/getting-started/05-arrange-a-song#set-up-the-tracks --> Arrange a Song > Set Up the Tracks [tutorial] The song has three tracks: drums, hi-hats and keys. 1. Write this code into `src/main.non`, in place of what is there. 2. Select the code. 3. Push `Cmd+Enter`. ```resonon use "std/instruments" { Sampler, SamplerMelodic, Kit }; use "std/signals" { automation }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); let hats = session.create_track("hats"); hats.set_instrument(Sampler(Kit("CR-78"))); let keys = session.create_track("keys"); keys.set_instrument(SamplerMelodic(Kit("keys"))); drums.volume << -6; hats.volume << -6; ``` You do not hear a sound yet. The tracks have instruments, but they do not have patterns. The drums and the hi-hats are 6 dB down, so that the three tracks together do not get too loud for the master. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#set-up-the-tracks Previous: tutorials/getting-started/05-arrange-a-song#before-you-start Next: tutorials/getting-started/05-arrange-a-song#write-the-verse --- <!-- ID: tutorials/getting-started/05-arrange-a-song#write-the-chorus --> Arrange a Song > Write the Chorus [tutorial] The chorus is almost the same as the verse. It has more drums and it adds the hi-hats. Do not write the chorus again. Copy the verse, and then change the copy: ```resonon continue let chorus = verse.clone(); chorus[drums] << [bd sd bd sd]; chorus[hats] << [_ hh _ hh _ hh _ hh]; chorus.play(); ``` `.clone()` makes an independent copy. The keys in the chorus are the same as in the verse. A change to `chorus` does not change `verse`. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#write-the-chorus Previous: tutorials/getting-started/05-arrange-a-song#write-the-verse Next: tutorials/getting-started/05-arrange-a-song#write-the-intro --- <!-- ID: tutorials/getting-started/05-arrange-a-song#write-the-intro --> Arrange a Song > Write the Intro [tutorial] The intro is 4 cycles long. It has only the keys: ```resonon continue let intro = section(4); intro[keys] << [c3 _ eb3 _ g3 _ bb3 _]; ``` The intro has no drums lane and no hats lane. In the intro, these tracks are silent. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#write-the-intro Previous: tutorials/getting-started/05-arrange-a-song#write-the-chorus Next: tutorials/getting-started/05-arrange-a-song#put-the-sections-in-sequence --- <!-- ID: tutorials/getting-started/05-arrange-a-song#write-the-verse --> Arrange a Song > Write the Verse [tutorial] A section is one part of the song. All the tracks in a section have the same length. Thus, the tracks always stay aligned. Make an 8-cycle section for the verse. Give a pattern to the drums and to the keys: ```resonon continue let verse = section(8); verse[drums] << [bd _ sd _]; verse[keys] << [c3 _ eb3 _ g3 _ bb3 _]; verse.play(); ``` `verse[drums]` is the **lane** of the drums track in this section. The `<<` operator puts a pattern into the lane. This is the same operator that you use to send a pattern to a track. `verse.play()` plays the section one time from the start. Then it stops. It does not loop. Page: tutorials/getting-started/05-arrange-a-song URL: https://resonon.org/docs/tutorials/getting-started/05-arrange-a-song/#write-the-verse Previous: tutorials/getting-started/05-arrange-a-song#set-up-the-tracks Next: tutorials/getting-started/05-arrange-a-song#write-the-chorus --- <!-- ID: tutorials/language/01-language-for-a-piece --> Language for a Reusable Piece [tutorial] On this page you turn a drum part into code you can reuse. You name values, write a function, keep a phrase in an object, and move a helper into another file. Sections: - tutorials/language/01-language-for-a-piece#before-you-start | Before you start - tutorials/language/01-language-for-a-piece#name-the-part | Name the part - tutorials/language/01-language-for-a-piece#write-a-function | Write a function - tutorials/language/01-language-for-a-piece#return-two-things | Return two things - tutorials/language/01-language-for-a-piece#keep-a-phrase-in-a-class | Keep a phrase in a class - tutorials/language/01-language-for-a-piece#move-a-helper-into-a-module | Move a helper into a module - tutorials/language/01-language-for-a-piece#next-steps | Next steps Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/ --- <!-- ID: tutorials/language/01-language-for-a-piece#before-you-start --> Language for a Reusable Piece > Before you start [tutorial] Finish [Live Coding Workflow](/docs/tutorials/running/01-live-coding-workflow/). Open your project's `src/main.non`. Evaluate `RESET;` **on its own**, then remove it from the file. You should have an empty, silent session. Select and evaluate each block below in order. Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#before-you-start Next: tutorials/language/01-language-for-a-piece#name-the-part --- <!-- ID: tutorials/language/01-language-for-a-piece#keep-a-phrase-in-a-class --> Language for a Reusable Piece > Keep a phrase in a class [tutorial] A class groups stored values (**fields**) and functions that use them (**methods**). Write this definition below your functions: ```resonon continue class Phrase { let pattern; let level; fn new(pattern, level = -9) { this.pattern = pattern; this.level = level; } fn play_on(track) { track.volume << this.level; track << this.pattern; } } let fill = Phrase([sd*8], -12); fill.play_on(drums); ``` `Phrase(...)` creates an instance and calls `new`. `this` is that instance. You hear a snare roll, with the hats still playing. Change a field, then call the method again: ```resonon continue fill.pattern = [bd _ sd _]; fill.play_on(drums); ``` The kick and snare return. Editing the field stores a new pattern; calling `play_on` sends it. Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#keep-a-phrase-in-a-class Previous: tutorials/language/01-language-for-a-piece#return-two-things Next: tutorials/language/01-language-for-a-piece#move-a-helper-into-a-module --- <!-- ID: tutorials/language/01-language-for-a-piece#move-a-helper-into-a-module --> Language for a Reusable Piece > Move a helper into a module [tutorial] Create `src/drum_parts.non`. Copy **only the `drum_part` function definition** into it, with its import, and save: ```resonon use "std/instruments" { Sampler, Kit }; fn drum_part(name, pattern, level = -9) { let track = session.track(name); track.set_instrument(Sampler(Kit("CR-78"))); track.volume << level; track << pattern; return track; } ``` A `.non` file imported with `use` is a module. Its top-level functions are available to the importing file. Replace `src/main.non` with this smaller piece, save, then evaluate it: ```resonon parse-only use "./drum_parts" as drum_parts; let drums = drum_parts.drum_part("drums", [bd _ sd _]); let hats = drum_parts.drum_part("hats", [hh*8], -18); PLAY; ``` `./drum_parts` is relative to `src/main.non`; the `.non` extension is optional. `as drum_parts` names the module, and `drum_parts.drum_part` calls its function. The two existing tracks keep playing with the new settings. Change the default level in `drum_parts.non` to `-12`, save it, and reevaluate `main.non`. The drums get quieter; the hats keep their explicit `-18`. You have one helper to edit for all parts that use it. Finish by evaluating `STOP;` on its own. Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#move-a-helper-into-a-module Previous: tutorials/language/01-language-for-a-piece#keep-a-phrase-in-a-class Next: tutorials/language/01-language-for-a-piece#next-steps --- <!-- ID: tutorials/language/01-language-for-a-piece#name-the-part --> Language for a Reusable Piece > Name the part [tutorial] ```resonon use "std/instruments" { Sampler, Kit }; let level = -9; let rhythm = [bd _ sd _, hh*8]; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums.volume << level; drums << rhythm; PLAY; ``` `let` gives a value a name. Here the values are a number, a pattern, and a track. A semicolon finishes a statement; `//` starts a comment. `<<` sends a value to a track or parameter. It differs from `=`, which changes a variable: ```resonon continue level = -12; print(level); drums.volume << level; ``` The Output panel prints `-12` and the drums get quieter. Assigning `level` alone would not turn the fader: you send the new value with the last line. Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#name-the-part Previous: tutorials/language/01-language-for-a-piece#before-you-start Next: tutorials/language/01-language-for-a-piece#write-a-function --- <!-- ID: tutorials/language/01-language-for-a-piece#next-steps --> Language for a Reusable Piece > Next steps [tutorial] - [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/) — develop the phrases you send to tracks - [Your First Mix](/docs/tutorials/audio/01-your-first-mix/) — build a mixer layout with a function - [Functions](/docs/reference/language/06-functions/), [Classes](/docs/reference/language/07-classes/) and [Modules](/docs/reference/language/09-modules/) — look up the syntax as you need it Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#next-steps Previous: tutorials/language/01-language-for-a-piece#move-a-helper-into-a-module --- <!-- ID: tutorials/language/01-language-for-a-piece#return-two-things --> Language for a Reusable Piece > Return two things [tutorial] A tuple groups values; a destructuring `let` unpacks them into names: ```resonon continue fn parts() { return ([bd _ sd _], [hh*8]); } let (beat, ticking) = parts(); drums << beat; hats << ticking; ``` The beat returns to its earlier shape. You will use the same `(drums, verb)` return and `let (drums, verb)` unpacking in [Your First Mix](/docs/tutorials/audio/01-your-first-mix/). Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#return-two-things Previous: tutorials/language/01-language-for-a-piece#write-a-function Next: tutorials/language/01-language-for-a-piece#keep-a-phrase-in-a-class --- <!-- ID: tutorials/language/01-language-for-a-piece#write-a-function --> Language for a Reusable Piece > Write a function [tutorial] A function names a set of steps. Define one at the top level of the file, outside other blocks: ```resonon continue fn drum_part(name, pattern, level = -9) { let track = session.track(name); track.set_instrument(Sampler(Kit("CR-78"))); track.volume << level; track << pattern; return track; } session.create_track("hats"); let hats = drum_part("hats", [hh*8], -18); drums << [bd _ sd _]; ``` You now hear the hats on their own quieter track. `session.create_track("hats")` makes the track, and `drum_part` finds it by its name with `session.track(name)`. `name`, `pattern` and `level` are parameters: values passed into the function. The local `track` name exists only inside it. `return` gives the track back to the caller, who keeps it in `hats`. The default `level = -9` lets you omit the last argument. Try `drum_part("hats", [hh*4], -15);` on its own. It updates the same named track. Page: tutorials/language/01-language-for-a-piece URL: https://resonon.org/docs/tutorials/language/01-language-for-a-piece/#write-a-function Previous: tutorials/language/01-language-for-a-piece#name-the-part Next: tutorials/language/01-language-for-a-piece#return-two-things --- <!-- ID: tutorials/midi/01-play-your-midi-gear --> Play Your MIDI Gear [tutorial] On this page you connect resonon to your MIDI gear. Resonon plays a bass line on a synth, you play along on a keyboard, and a knob on the keyboard turns a filter on the drums. You need a synth that takes MIDI — hardware, or an instrument in a DAW — and a MIDI keyboard with at least one knob. Work in a project, as in [Your First Sound](/docs/tutorials/getting-started/02-your-first-sound/). :::note To play a DAW instrument, turn on a virtual port first. On macOS, open **Audio MIDI Setup**, choose **Window → Show MIDI Studio**, double-click **IAC Driver**, and check **Device is online**. In the DAW, make an instrument track that takes MIDI from that port, and turn on its input monitoring. ::: Sections: - tutorials/midi/01-play-your-midi-gear#before-you-start | Before you start - tutorials/midi/01-play-your-midi-gear#declare-the-ports | Declare the ports - tutorials/midi/01-play-your-midi-gear#play-a-pattern-on-the-synth | Play a pattern on the synth - tutorials/midi/01-play-your-midi-gear#play-the-synth-from-your-keyboard | Play the synth from your keyboard - tutorials/midi/01-play-your-midi-gear#learn-a-knob | Learn a knob - tutorials/midi/01-play-your-midi-gear#turn-a-filter-with-the-knob | Turn a filter with the knob - tutorials/midi/01-play-your-midi-gear#stop | Stop - tutorials/midi/01-play-your-midi-gear#next-steps | Next steps Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/ --- <!-- ID: tutorials/midi/01-play-your-midi-gear#before-you-start --> Play Your MIDI Gear > Before you start [tutorial] Finish [Signals and Modulation](/docs/tutorials/audio/02-signals-and-modulation/). Open your project's `src/main.non`, evaluate `RESET;` on its own, then remove that line. Check that earlier audio and MIDI tracks are silent. Turn down the synth's output before testing the connections, then raise it to a comfortable listening level. Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#before-you-start Next: tutorials/midi/01-play-your-midi-gear#declare-the-ports --- <!-- ID: tutorials/midi/01-play-your-midi-gear#declare-the-ports --> Play Your MIDI Gear > Declare the ports [tutorial] Which ports your machine has is a fact about the machine, not about the music. So you do not write them into the piece. You declare them once in the preferences, and each one gets a short name, an **alias**. In a terminal, run: ```bash resonon setup ``` On the MIDI pages, pick the port of your synth as the output and give it the alias `synth`. Pick your keyboard as an input and give it the alias `kb`. On the last page, confirm. The file `~/.resonon/preferences.toml` now has two entries like these: ```toml [[midi.outputs]] alias = "synth" port = "IAC Driver Bus 1" [[midi.inputs]] alias = "kb" port = "KeyStep" ``` If a server is already running, run this line in VSCode so that it opens the new ports: ```resonon parse-only reload_preferences(); ``` Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#declare-the-ports Previous: tutorials/midi/01-play-your-midi-gear#before-you-start Next: tutorials/midi/01-play-your-midi-gear#play-a-pattern-on-the-synth --- <!-- ID: tutorials/midi/01-play-your-midi-gear#learn-a-knob --> Play Your MIDI Gear > Learn a knob [tutorial] A knob on your keyboard sends **CC** messages, each with a number. Let resonon find the number: run this line, and turn the knob within ten seconds. ```resonon parse-only use "std/signals" { Cc_learn }; let knob = Cc_learn(); ``` The Output panel prints the knob's call, for example `Learned: Cc(74, 1)`: CC 74 on channel 1. `knob` is now a signal that follows the knob, from `0` to `1`. Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#learn-a-knob Previous: tutorials/midi/01-play-your-midi-gear#play-the-synth-from-your-keyboard Next: tutorials/midi/01-play-your-midi-gear#turn-a-filter-with-the-knob --- <!-- ID: tutorials/midi/01-play-your-midi-gear#next-steps --> Play Your MIDI Gear > Next steps [tutorial] - [Send MIDI to a Synth or DAW](/docs/how-to/midi/01-send-midi-to-a-synth-or-daw/) — channels, several ports, velocity - [Map a Controller](/docs/how-to/midi/03-map-a-controller/) — more ways to use knobs and faders - [Sync to a MIDI Clock](/docs/how-to/midi/05-sync-to-a-midi-clock/) — lock your gear's tempo to resonon - [MIDI Tracks & Time](/docs/explanation/midi/01-midi-tracks-and-time/) — how a MIDI track fits in the session Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#next-steps Previous: tutorials/midi/01-play-your-midi-gear#stop --- <!-- ID: tutorials/midi/01-play-your-midi-gear#play-a-pattern-on-the-synth --> Play Your MIDI Gear > Play a pattern on the synth [tutorial] A `MidiTrack` is like an `AudioTrack`, but its notes go out of a MIDI port instead of into an instrument. Write this into `src/main.non`, select it, and press `Cmd+Enter`: ```resonon parse-only let bass = session.create_midi_track("bass"); bass >> MidiOutput("synth"); bass << [C2 _ C2 G2]; PLAY; ``` Your synth plays the bass line. `>>` picks the track's output, as it does for an `AudioTrack`: here the `synth` port, on channel 1. A new track has no output until you route it. Everything you know about patterns works the same way here: only where the notes go is different. Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#play-a-pattern-on-the-synth Previous: tutorials/midi/01-play-your-midi-gear#declare-the-ports Next: tutorials/midi/01-play-your-midi-gear#play-the-synth-from-your-keyboard --- <!-- ID: tutorials/midi/01-play-your-midi-gear#play-the-synth-from-your-keyboard --> Play Your MIDI Gear > Play the synth from your keyboard [tutorial] Make a second track that takes its notes from the keyboard: ```resonon parse-only let keys = session.create_midi_track("keys") .set_input("kb") .set_monitor(Monitor.input); keys >> MidiOutput("synth", 2); ``` Play a few notes. They go through resonon to the synth, on channel 2, over the bass line. - `.set_input("kb")` connects the keyboard to the track. - `.set_monitor(Monitor.input)` passes what comes in on to the track's output. Without it, the track listens but does not play what you play. Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#play-the-synth-from-your-keyboard Previous: tutorials/midi/01-play-your-midi-gear#play-a-pattern-on-the-synth Next: tutorials/midi/01-play-your-midi-gear#learn-a-knob --- <!-- ID: tutorials/midi/01-play-your-midi-gear#stop --> Play Your MIDI Gear > Stop [tutorial] ```resonon parse-only STOP; ``` Every sounding note gets a note-off, so nothing hangs on the synth. Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#stop Previous: tutorials/midi/01-play-your-midi-gear#turn-a-filter-with-the-knob Next: tutorials/midi/01-play-your-midi-gear#next-steps --- <!-- ID: tutorials/midi/01-play-your-midi-gear#turn-a-filter-with-the-knob --> Play Your MIDI Gear > Turn a filter with the knob [tutorial] Add drums with a filter, and send the knob into the filter's cutoff: ```resonon continue parse-only use "std/instruments" { Sampler, Kit }; use "std/effects" { Filter, FilterType }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd hh sd hh]; let filter = Filter("lowpass", FilterType.lowpass, 2000); drums.set_effects(#[filter]); filter.parameter("Cutoff") << knob.smooth(50).range_exp(200, 8000); ``` Turn the knob. The drums go from dark to bright. - `.smooth(50)` smooths the knob's 128 steps over 50 ms, so the filter does not click. - `.range_exp(200, 8000)` maps `0`–`1` onto 200 Hz to 8000 Hz. It spreads the range the way the ear hears pitch. `Cc_learn()` waits for a knob each time it runs. When you save the piece, write the call it printed instead: ```resonon parse-only use "std/signals" { Cc }; let knob = Cc(74, 1); ``` Page: tutorials/midi/01-play-your-midi-gear URL: https://resonon.org/docs/tutorials/midi/01-play-your-midi-gear/#turn-a-filter-with-the-knob Previous: tutorials/midi/01-play-your-midi-gear#learn-a-knob Next: tutorials/midi/01-play-your-midi-gear#stop --- <!-- ID: tutorials/patterns/01-pattern-basics --> Pattern Basics [tutorial] On this page you write a drum beat and a bass line, one pattern at a time. You learn how a pattern divides time, and you hear each change as you make it. Work in a project, as in [Your First Sound](/docs/tutorials/getting-started/02-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. Sections: - tutorials/patterns/01-pattern-basics#before-you-start | Before you start - tutorials/patterns/01-pattern-basics#play-a-pattern | Play a pattern - tutorials/patterns/01-pattern-basics#divide-the-cycle | Divide the cycle - tutorials/patterns/01-pattern-basics#leave-a-rest | Leave a rest - tutorials/patterns/01-pattern-basics#change-the-tempo | Change the tempo - tutorials/patterns/01-pattern-basics#play-notes | Play notes - tutorials/patterns/01-pattern-basics#play-a-chord | Play a chord - tutorials/patterns/01-pattern-basics#vary-it-from-cycle-to-cycle | Vary it from cycle to cycle - tutorials/patterns/01-pattern-basics#stop | Stop - tutorials/patterns/01-pattern-basics#next-steps | Next steps Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/ --- <!-- ID: tutorials/patterns/01-pattern-basics#before-you-start --> Pattern Basics > Before you start [tutorial] Finish [Language for a Reusable Piece](/docs/tutorials/language/01-language-for-a-piece/), and open your project's `src/main.non`. Evaluate `RESET;` on its own, then remove that line. The session should be silent. This page starts a new beat with bundled kits and no earlier tracks. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#before-you-start Next: tutorials/patterns/01-pattern-basics#play-a-pattern --- <!-- ID: tutorials/patterns/01-pattern-basics#change-the-tempo --> Pattern Basics > Change the tempo [tutorial] ```resonon continue set_bpm(140); ``` The beat is faster, and every pattern keeps its shape. By default a cycle is four beats, so at 120 BPM it lasts two seconds; at 140 it is shorter. Go back: ```resonon continue set_bpm(120); ``` Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#change-the-tempo Previous: tutorials/patterns/01-pattern-basics#leave-a-rest Next: tutorials/patterns/01-pattern-basics#play-notes --- <!-- ID: tutorials/patterns/01-pattern-basics#divide-the-cycle --> Pattern Basics > Divide the cycle [tutorial] Give the same cycle eight steps: ```resonon continue drums << [bd ch sd ch bd ch sd ch]; ``` The pattern is not longer: the cycle is as long as before, and each step takes half the time. The number of steps sets their length. Three steps divide the cycle into exact thirds: ```resonon continue drums << [bd bd sd]; ``` Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#divide-the-cycle Previous: tutorials/patterns/01-pattern-basics#play-a-pattern Next: tutorials/patterns/01-pattern-basics#leave-a-rest --- <!-- ID: tutorials/patterns/01-pattern-basics#leave-a-rest --> Pattern Basics > Leave a rest [tutorial] `_` is a step with no sound: ```resonon continue drums << [bd _ _ bd _ _ sd _]; ``` A rest takes a step, the same as a sound. Here it leaves space between the hits. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#leave-a-rest Previous: tutorials/patterns/01-pattern-basics#divide-the-cycle Next: tutorials/patterns/01-pattern-basics#change-the-tempo --- <!-- ID: tutorials/patterns/01-pattern-basics#next-steps --> Pattern Basics > Next steps [tutorial] - [Your First Groove](/docs/tutorials/patterns/02-your-first-groove/) — the next tutorial: nesting, layers of different lengths, and modifiers - [How Patterns Work](/docs/explanation/patterns/02-how-patterns-work/) — why a pattern divides its cycle - [Cycles & Time](/docs/explanation/patterns/01-cycles-and-time/) — how the tempo turns cycles into seconds - [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/) — every symbol Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#next-steps Previous: tutorials/patterns/01-pattern-basics#stop --- <!-- ID: tutorials/patterns/01-pattern-basics#play-a-chord --> Pattern Basics > Play a chord [tutorial] A comma in a pattern plays what is on both sides at the same time: ```resonon continue bass << [[C2, G2] _ [Eb2, Bb2] _]; ``` Two notes sound together on each hit. The same comma layers drums: ```resonon continue drums << [bd _ sd _, ch ch ch ch]; ``` The kick and snare play in one layer, the hi-hats in another, both in the same cycle. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#play-a-chord Previous: tutorials/patterns/01-pattern-basics#play-notes Next: tutorials/patterns/01-pattern-basics#vary-it-from-cycle-to-cycle --- <!-- ID: tutorials/patterns/01-pattern-basics#play-a-pattern --> Pattern Basics > Play a pattern [tutorial] ```resonon use "std/instruments" { Sampler, SamplerMelodic, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("TR-808"))); drums << [bd sd bd sd]; PLAY; ``` You hear a kick and a snare, in turn. `[bd sd bd sd]` is a **pattern**: four steps in square brackets. It fills one **cycle** — think of one bar — and repeats. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#play-a-pattern Previous: tutorials/patterns/01-pattern-basics#before-you-start Next: tutorials/patterns/01-pattern-basics#divide-the-cycle --- <!-- ID: tutorials/patterns/01-pattern-basics#play-notes --> Pattern Basics > Play notes [tutorial] Notes need an instrument that plays pitches. Make a bass track with the keys kit, and send it note names: ```resonon continue let bass = session.create_track("bass"); bass.set_instrument(SamplerMelodic(Kit("keys"))); bass << [C2 _ Eb2 _ G2 _ Bb2 _]; ``` A note name is a letter, an optional `#` or `b`, and an octave: `C2`, `F#3`, `Bb2`. A number is a MIDI note: `[36 _ 39 _ 43 _ 46 _]` plays the same line. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#play-notes Previous: tutorials/patterns/01-pattern-basics#change-the-tempo Next: tutorials/patterns/01-pattern-basics#play-a-chord --- <!-- ID: tutorials/patterns/01-pattern-basics#stop --> Pattern Basics > Stop [tutorial] ```resonon continue STOP; ``` Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#stop Previous: tutorials/patterns/01-pattern-basics#vary-it-from-cycle-to-cycle Next: tutorials/patterns/01-pattern-basics#next-steps --- <!-- ID: tutorials/patterns/01-pattern-basics#vary-it-from-cycle-to-cycle --> Pattern Basics > Vary it from cycle to cycle [tutorial] Angle brackets play one of their elements in each cycle, in turn: ```resonon continue bass << [<C2 Ab1> _ Eb2 _ G2 _ Bb2 _]; ``` The first note is `C2` in one cycle and `Ab1` in the next. The rest of the line stays the same. Page: tutorials/patterns/01-pattern-basics URL: https://resonon.org/docs/tutorials/patterns/01-pattern-basics/#vary-it-from-cycle-to-cycle Previous: tutorials/patterns/01-pattern-basics#play-a-chord Next: tutorials/patterns/01-pattern-basics#stop --- <!-- ID: tutorials/patterns/02-your-first-groove --> Your First Groove [tutorial] On this page you build one drum groove with the rest of mini-notation — the symbols inside a pattern's brackets. At the end, you read a dense pattern at a glance. Start with [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/). Write each step into `src/main.non`, select it, and press `Cmd+Enter`. Every step adds to what the previous one built. Sections: - tutorials/patterns/02-your-first-groove#before-you-start | Before you start - tutorials/patterns/02-your-first-groove#start-the-groove | Start the groove - tutorials/patterns/02-your-first-groove#divide-one-step | Divide one step - tutorials/patterns/02-your-first-groove#layer-different-lengths | Layer different lengths - tutorials/patterns/02-your-first-groove#change-one-step-each-cycle | Change one step each cycle - tutorials/patterns/02-your-first-groove#play-a-step-faster | Play a step faster - tutorials/patterns/02-your-first-groove#make-a-step-longer | Make a step longer - tutorials/patterns/02-your-first-groove#repeat-a-step | Repeat a step - tutorials/patterns/02-your-first-groove#slow-a-group-down | Slow a group down - tutorials/patterns/02-your-first-groove#accent-a-hit | Accent a hit - tutorials/patterns/02-your-first-groove#read-it-all | Read it all - tutorials/patterns/02-your-first-groove#next-steps | Next steps Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/ --- <!-- ID: tutorials/patterns/02-your-first-groove#accent-a-hit --> Your First Groove > Accent a hit [tutorial] `^` sets a hit's velocity, from 1 to 127: ```resonon continue drums << [bd sd, ch^120 ch^60 ch^80 ch^60 ch^120 ch^60 ch^80 ch^60]; ``` The hi-hats get louder and softer in a pattern of their own. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#accent-a-hit Previous: tutorials/patterns/02-your-first-groove#slow-a-group-down Next: tutorials/patterns/02-your-first-groove#read-it-all --- <!-- ID: tutorials/patterns/02-your-first-groove#before-you-start --> Your First Groove > Before you start [tutorial] Finish [Pattern Basics](/docs/tutorials/patterns/01-pattern-basics/). Open `src/main.non`, evaluate `RESET;` on its own, then remove that line. Check that the earlier drums and bass are silent. The setup below makes a new drums track; evaluate later blocks in order. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#before-you-start Next: tutorials/patterns/02-your-first-groove#start-the-groove --- <!-- ID: tutorials/patterns/02-your-first-groove#change-one-step-each-cycle --> Your First Groove > Change one step each cycle [tutorial] Angle brackets inside a step change only that step, cycle by cycle: ```resonon continue drums << [bd _ bd _, _ sd _ <sd [sd sd]>, ch ch ch ch]; ``` The last snare is single in one cycle and double in the next. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#change-one-step-each-cycle Previous: tutorials/patterns/02-your-first-groove#layer-different-lengths Next: tutorials/patterns/02-your-first-groove#play-a-step-faster --- <!-- ID: tutorials/patterns/02-your-first-groove#divide-one-step --> Your First Groove > Divide one step [tutorial] Put a pattern inside a step, and it divides only that step: ```resonon continue drums << [bd sd bd [sd sd]]; ``` The last step plays two snares, each half as long. Go one level deeper: ```resonon continue drums << [bd sd bd [sd [sd sd]]]; ``` The last half of the last step divides again: a small roll into the next bar. The groups need not be the same size — `[bd [sd sd sd]]` puts a triplet in the second half. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#divide-one-step Previous: tutorials/patterns/02-your-first-groove#start-the-groove Next: tutorials/patterns/02-your-first-groove#layer-different-lengths --- <!-- ID: tutorials/patterns/02-your-first-groove#layer-different-lengths --> Your First Groove > Layer different lengths [tutorial] Each layer of a comma divides the cycle by its own number of steps: ```resonon continue drums << [bd bd bd, cp cp]; ``` Three kicks against two claps: they meet only on the downbeat. Now a real groove in three layers: ```resonon continue drums << [bd _ bd _, _ sd _ sd, ch ch ch ch]; ``` Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#layer-different-lengths Previous: tutorials/patterns/02-your-first-groove#divide-one-step Next: tutorials/patterns/02-your-first-groove#change-one-step-each-cycle --- <!-- ID: tutorials/patterns/02-your-first-groove#make-a-step-longer --> Your First Groove > Make a step longer [tutorial] `@n` gives a step `n` shares of the cycle instead of one: ```resonon continue drums << [bd@3 sd, ch*8]; ``` The kick holds three quarters of the cycle, and the snare comes late, on the last quarter. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#make-a-step-longer Previous: tutorials/patterns/02-your-first-groove#play-a-step-faster Next: tutorials/patterns/02-your-first-groove#repeat-a-step --- <!-- ID: tutorials/patterns/02-your-first-groove#next-steps --> Your First Groove > Next steps [tutorial] - [Melody and Harmony in a Key](/docs/tutorials/patterns/03-melody-and-harmony/) — the next tutorial: degrees, chords and changing key - [Transform a Pattern](/docs/how-to/patterns/01-transform-a-pattern/) — make variations with `.fast()`, `.reverse()`, `.transpose()` and more - [Write Polymetric and Euclidean Rhythms](/docs/how-to/patterns/09-write-polymetric-and-euclidean-rhythms/) — loops that drift, and rhythms from two numbers - [Mini-Notation Grammar](/docs/reference/patterns/01-mini-notation-grammar/) — every symbol, and the order they combine in Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#next-steps Previous: tutorials/patterns/02-your-first-groove#read-it-all --- <!-- ID: tutorials/patterns/02-your-first-groove#play-a-step-faster --> Your First Groove > Play a step faster [tutorial] `*n` plays a step `n` times in its own slot: ```resonon continue drums << [bd _ bd _, _ sd _ <sd [sd sd]>, ch*8]; ``` Eight hi-hats, with one symbol instead of eight steps. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#play-a-step-faster Previous: tutorials/patterns/02-your-first-groove#change-one-step-each-cycle Next: tutorials/patterns/02-your-first-groove#make-a-step-longer --- <!-- ID: tutorials/patterns/02-your-first-groove#read-it-all --> Your First Groove > Read it all [tutorial] ```resonon continue drums << [bd <sd [sd sd]>, ch*8, <_ oh>]; ``` Read it comma by comma: - `bd <sd [sd sd]>` — a kick, then a snare that is single in one cycle and double in the next. - `ch*8` — eight closed hi-hats. - `<_ oh>` — an open hi-hat in every second cycle. ```resonon continue STOP; ``` Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#read-it-all Previous: tutorials/patterns/02-your-first-groove#accent-a-hit Next: tutorials/patterns/02-your-first-groove#next-steps --- <!-- ID: tutorials/patterns/02-your-first-groove#repeat-a-step --> Your First Groove > Repeat a step [tutorial] `!n` writes a step `n` times, as if you had typed it out: ```resonon continue drums << [bd!3 sd, ch*8]; ``` `[bd!3 sd]` expands to `[bd bd bd sd]`: four equal steps. Unlike `*`, `!` adds steps to the sequence, so all four divide the cycle anew. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#repeat-a-step Previous: tutorials/patterns/02-your-first-groove#make-a-step-longer Next: tutorials/patterns/02-your-first-groove#slow-a-group-down --- <!-- ID: tutorials/patterns/02-your-first-groove#slow-a-group-down --> Your First Groove > Slow a group down [tutorial] `/n` stretches a step over `n` cycles: ```resonon continue drums << [bd sd, ch*8, <_ oh>/2]; ``` The open hat alternates with silence, but each choice now lasts two cycles. Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#slow-a-group-down Previous: tutorials/patterns/02-your-first-groove#repeat-a-step Next: tutorials/patterns/02-your-first-groove#accent-a-hit --- <!-- ID: tutorials/patterns/02-your-first-groove#start-the-groove --> Your First Groove > Start the groove [tutorial] ```resonon use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("TR-808"))); drums << [bd sd bd sd]; PLAY; ``` Page: tutorials/patterns/02-your-first-groove URL: https://resonon.org/docs/tutorials/patterns/02-your-first-groove/#start-the-groove Previous: tutorials/patterns/02-your-first-groove#before-you-start Next: tutorials/patterns/02-your-first-groove#divide-one-step --- <!-- ID: tutorials/patterns/03-melody-and-harmony --> Melody and Harmony in a Key [tutorial] On this page you write a melody and chord accompaniment in C major, then move both to a new key without rewriting the notes. Sections: - tutorials/patterns/03-melody-and-harmony#before-you-start | Before you start - tutorials/patterns/03-melody-and-harmony#hear-a-melody | Hear a melody - tutorials/patterns/03-melody-and-harmony#write-degrees-instead-of-pitches | Write degrees instead of pitches - tutorials/patterns/03-melody-and-harmony#add-harmony | Add harmony - tutorials/patterns/03-melody-and-harmony#change-the-key | Change the key - tutorials/patterns/03-melody-and-harmony#save-and-bounce-it | Save and bounce it - tutorials/patterns/03-melody-and-harmony#next-steps | Next steps Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/ --- <!-- ID: tutorials/patterns/03-melody-and-harmony#add-harmony --> Melody and Harmony in a Key > Add harmony [tutorial] Make a second track one octave below the melody. Give it one chord per cycle: ```resonon continue let harmony = session.create_track("harmony"); harmony.set_instrument(SamplerMelodic(Kit("keys"))); harmony.volume << -18; harmony.set_key(Key(C3, "major")); harmony << <^1: ^4: ^5: ^1:>; ``` Listen for four cycles. The chords are C major, F major, G major and C major: I–IV–V–I. A trailing `:` asks the key to build a three-note chord on that degree. Angle brackets choose one element per cycle, so this accompaniment takes four cycles to repeat. Its lower register and quieter level leave room for the melody. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#add-harmony Previous: tutorials/patterns/03-melody-and-harmony#write-degrees-instead-of-pitches Next: tutorials/patterns/03-melody-and-harmony#change-the-key --- <!-- ID: tutorials/patterns/03-melody-and-harmony#before-you-start --> Melody and Harmony in a Key > Before you start [tutorial] Finish [Your First Groove](/docs/tutorials/patterns/02-your-first-groove/). Open `src/main.non` in your project. Evaluate `RESET;` **on its own**, then remove it from the file. The session should be silent, with no tracks from earlier tutorials. Evaluate each block in order. The bundled `keys` kit supplies the pitched instrument; no plugin or MIDI synth is needed. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#before-you-start Next: tutorials/patterns/03-melody-and-harmony#hear-a-melody --- <!-- ID: tutorials/patterns/03-melody-and-harmony#change-the-key --> Melody and Harmony in a Key > Change the key [tutorial] Move the roots from C to D, keeping the major scale: ```resonon continue melody.set_key(Key(D4, "major")); harmony.set_key(Key(D3, "major")); ``` The melody and harmony follow together. Now keep D as the root but change to minor: ```resonon continue melody.set_key(Key(D4, "minor")); harmony.set_key(Key(D3, "minor")); ``` The lowered third gives the phrase a different colour. The chords are now D minor, G minor, A minor and D minor. You changed the key, not the rhythm or the degree patterns. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#change-the-key Previous: tutorials/patterns/03-melody-and-harmony#add-harmony Next: tutorials/patterns/03-melody-and-harmony#save-and-bounce-it --- <!-- ID: tutorials/patterns/03-melody-and-harmony#hear-a-melody --> Melody and Harmony in a Key > Hear a melody [tutorial] ```resonon use "std/instruments" { SamplerMelodic, Kit }; set_bpm(120); let melody = session.create_track("melody"); melody.set_instrument(SamplerMelodic(Kit("keys"))); melody.volume << -12; melody << [C4 D4 E4 G4 E4 D4 C4 _]; PLAY; ``` You hear a rising and falling melody. C major contains C, D, E, F, G, A and B. The octave number sets the register; `C5` is one octave above `C4`. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#hear-a-melody Previous: tutorials/patterns/03-melody-and-harmony#before-you-start Next: tutorials/patterns/03-melody-and-harmony#write-degrees-instead-of-pitches --- <!-- ID: tutorials/patterns/03-melody-and-harmony#next-steps --> Melody and Harmony in a Key > Next steps [tutorial] - [Your First Mix](/docs/tutorials/audio/01-your-first-mix/) — balance tracks and add shared effects - [Write in a Key](/docs/how-to/patterns/08-write-in-a-key/) — chord qualities, inversions and your own scales - [Events & Notes](/docs/explanation/patterns/03-events-and-notes/) — how degrees become pitches Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#next-steps Previous: tutorials/patterns/03-melody-and-harmony#save-and-bounce-it --- <!-- ID: tutorials/patterns/03-melody-and-harmony#save-and-bounce-it --> Melody and Harmony in a Key > Save and bounce it [tutorial] Replace `src/main.non` with the final version: ```resonon use "std/instruments" { SamplerMelodic, Kit }; // Create the tracks once. setup() runs when the project opens and on Reset Project. fn setup() { session.create_track("melody"); session.create_track("harmony"); } set_project_title("Melody and Harmony"); set_bpm(120); let melody = session.track("melody"); melody.set_instrument(SamplerMelodic(Kit("keys"))); melody.volume << -12; melody.set_key(Key(D4, "minor")); melody << [^1 ^3 ^5 ^8 ^5 ^3 ^2 _]; let harmony = session.track("harmony"); harmony.set_instrument(SamplerMelodic(Kit("keys"))); harmony.volume << -18; harmony.set_key(Key(D3, "minor")); harmony << <^1: ^4: ^5: ^1:>; render(8); ``` Save and run `resonon run` in the project folder. Open `renders/melody_and_harmony_<date>_<time>/master.wav`. You hear the four-chord progression twice. In VSCode, evaluate `STOP;` on its own to finish the live exercise. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#save-and-bounce-it Previous: tutorials/patterns/03-melody-and-harmony#change-the-key Next: tutorials/patterns/03-melody-and-harmony#next-steps --- <!-- ID: tutorials/patterns/03-melody-and-harmony#write-degrees-instead-of-pitches --> Melody and Harmony in a Key > Write degrees instead of pitches [tutorial] Set the track's key, then replace the notes with positions in its scale: ```resonon continue let home = Key(C4, "major"); melody.set_key(home); melody << [^1 ^2 ^3 ^5 ^3 ^2 ^1 _]; ``` It sounds the same. `^1` is the root C4, `^2` is D4, and `^3` is E4. These are **scale degrees**, not semitone distances. In C major the first step spans two semitones, but the step from degree 3 to degree 4 spans only one. Try a phrase with an octave leap: ```resonon continue melody << [^1 ^3 ^5 ^8 ^5 ^3 ^2 _]; ``` `^8` is the root an octave up. The rhythm still fits one cycle. Page: tutorials/patterns/03-melody-and-harmony URL: https://resonon.org/docs/tutorials/patterns/03-melody-and-harmony/#write-degrees-instead-of-pitches Previous: tutorials/patterns/03-melody-and-harmony#hear-a-melody Next: tutorials/patterns/03-melody-and-harmony#add-harmony --- <!-- ID: tutorials/running/01-live-coding-workflow --> Live Coding Workflow [tutorial] On this page you rehearse a short live set: start a beat, change it, recover from a mistake, and rebuild it from saved code. Sections: - tutorials/running/01-live-coding-workflow#before-you-start | Before you start - tutorials/running/01-live-coding-workflow#save-a-starting-point | Save a starting point - tutorials/running/01-live-coding-workflow#evaluate-only-the-change | Evaluate only the change - tutorials/running/01-live-coding-workflow#recover-without-stopping | Recover without stopping - tutorials/running/01-live-coding-workflow#inspect-what-is-playing | Inspect what is playing - tutorials/running/01-live-coding-workflow#pause-stop-and-cut-tails | Pause, stop, and cut tails - tutorials/running/01-live-coding-workflow#rebuild-the-session | Rebuild the session - tutorials/running/01-live-coding-workflow#next-steps | Next steps Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/ --- <!-- ID: tutorials/running/01-live-coding-workflow#before-you-start --> Live Coding Workflow > Before you start [tutorial] Finish [Getting Started](/docs/tutorials/getting-started/05-arrange-a-song/). Open your project's `src/main.non` in VSCode. These exercises run live; do not use `resonon run` for them. Check the **RESONON** status item to see which server will receive your code. Begin with an empty session. Evaluate this line **by itself**, then remove it from the file: ```resonon parse-only RESET; ``` RESET discards the session. Code selected after it in the same evaluation does not run. Keep reset and setup as separate evaluations throughout these tutorials. Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#before-you-start Next: tutorials/running/01-live-coding-workflow#save-a-starting-point --- <!-- ID: tutorials/running/01-live-coding-workflow#evaluate-only-the-change --> Live Coding Workflow > Evaluate only the change [tutorial] Add this line below the block. Put the cursor on it, with nothing selected, and press `Cmd+Enter`: ```resonon continue drums << [bd bd sd _, hh*8]; ``` The new rhythm starts at the next cycle boundary. Now select just the following two lines and evaluate them together: ```resonon continue drums.volume << -9; drums.pan << 0.25; ``` The level and pan change without restarting the beat. **RESONON: Run Selection Live** evaluates only the selected code. **RESONON: Run File Live** (`Cmd+Shift+Enter`) saves edited files and evaluates the whole entry file into the running session. **RESONON: Reset Project** opens the project again from its files. See [The entry file's lifecycle](/docs/explanation/running/05-session-document/#the-entry-files-lifecycle). Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#evaluate-only-the-change Previous: tutorials/running/01-live-coding-workflow#save-a-starting-point Next: tutorials/running/01-live-coding-workflow#recover-without-stopping --- <!-- ID: tutorials/running/01-live-coding-workflow#inspect-what-is-playing --> Live Coding Workflow > Inspect what is playing [tutorial] Click the resonon icon in the activity bar. In **Views**, open **Mixer**, then **Routing**. Find `drums` and `master` in the mixer and check that drums route to master in the routing view. Open **Scope** to see the master waveform, and **Console** to see server output. Return focus to `src/main.non` before using the transport keys. Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#inspect-what-is-playing Previous: tutorials/running/01-live-coding-workflow#recover-without-stopping Next: tutorials/running/01-live-coding-workflow#pause-stop-and-cut-tails --- <!-- ID: tutorials/running/01-live-coding-workflow#next-steps --> Live Coding Workflow > Next steps [tutorial] - [Language for a Reusable Piece](/docs/tutorials/language/01-language-for-a-piece/) — put repeated code into functions and modules - [Transport](/docs/reference/running/02-transport/) — all transport statements - [The Evaluation Model](/docs/explanation/running/02-the-evaluation-model/) — what is kept between evaluations Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#next-steps Previous: tutorials/running/01-live-coding-workflow#rebuild-the-session --- <!-- ID: tutorials/running/01-live-coding-workflow#pause-stop-and-cut-tails --> Live Coding Workflow > Pause, stop, and cut tails [tutorial] Press **F5** to pause. Wait, then press it again: playback resumes from the same position. Press **Shift+F5** to stop: the playhead returns to the beginning, but echoes ring out. Press **F5** to play from the beginning. While it plays, press **Shift+F5** three times in a row. The third stop cuts remaining sound, including delay and reverb tails. Press **F5**: the saved tracks and patterns still play. You can also evaluate transport statements: ```resonon continue PAUSE; PLAY; STOP; STOP; STOP; ``` Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#pause-stop-and-cut-tails Previous: tutorials/running/01-live-coding-workflow#inspect-what-is-playing Next: tutorials/running/01-live-coding-workflow#rebuild-the-session --- <!-- ID: tutorials/running/01-live-coding-workflow#rebuild-the-session --> Live Coding Workflow > Rebuild the session [tutorial] Evaluate `RESET;` by itself again. The sound stops and your variables and tracks are gone. Select only the saved starting block and evaluate it. The beat returns with the original rhythm, level and pan. To keep a change for the next set, edit it into that starting block and save. Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#rebuild-the-session Previous: tutorials/running/01-live-coding-workflow#pause-stop-and-cut-tails Next: tutorials/running/01-live-coding-workflow#next-steps --- <!-- ID: tutorials/running/01-live-coding-workflow#recover-without-stopping --> Live Coding Workflow > Recover without stopping [tutorial] Evaluate this deliberately misspelled line on its own: ```resonon no-check drumz << [bd sd]; ``` The Output and Problems panels report an undefined name. The last good beat keeps playing. Correct the name to `drums` and evaluate the line again: ```resonon continue drums << [bd sd]; ``` You hear the correction on the next downbeat. A parse error runs none of the selection. A runtime error stops at the failing statement; earlier statements may already have changed the session. When fixing a multi-line change, inspect what ran and reevaluate the corrected change. Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#recover-without-stopping Previous: tutorials/running/01-live-coding-workflow#evaluate-only-the-change Next: tutorials/running/01-live-coding-workflow#inspect-what-is-playing --- <!-- ID: tutorials/running/01-live-coding-workflow#save-a-starting-point --> Live Coding Workflow > Save a starting point [tutorial] Replace the file with this block, save it, select the whole block, and press `Cmd+Enter` (`Ctrl+Enter` on Windows and Linux): ```resonon use "std/instruments" { Sampler, Kit }; use "std/effects" { Delay }; set_bpm(120); let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums.volume << -6; drums.set_effects(#[Delay("echo", 0.25, 0.3)]); drums << [bd _ sd _, hh*8]; PLAY; ``` You hear drums and echoes. Open **View → Output**, choose **RESONON**, and keep it visible. The saved block is your starting point if you need to rebuild the set. Page: tutorials/running/01-live-coding-workflow URL: https://resonon.org/docs/tutorials/running/01-live-coding-workflow/#save-a-starting-point Previous: tutorials/running/01-live-coding-workflow#before-you-start Next: tutorials/running/01-live-coding-workflow#evaluate-only-the-change --- <!-- ID: tutorials/visuals/01-your-first-shader --> Your First Shader [tutorial] :::caution[Experimental] Visuals are experimental. Expect breaking changes to shaders, operators and the visuals window. ::: On this page you write a fragment shader — a small program that the GPU runs for every pixel — and make it move with your music. At the end, you change it while it plays. You need VSCode with the resonon extension, as in [Patterns, Tracks & Effects](/docs/tutorials/getting-started/03-patterns-tracks-effects/). Write each step into a **.non** file, select it, and press `Cmd+Enter`. Every step adds to what the previous one built. Sections: - tutorials/visuals/01-your-first-shader#before-you-start | Before you start - tutorials/visuals/01-your-first-shader#open-the-visuals-window | Open the visuals window - tutorials/visuals/01-your-first-shader#draw-a-gradient | Draw a gradient - tutorials/visuals/01-your-first-shader#make-it-move | Make it move - tutorials/visuals/01-your-first-shader#give-it-a-knob | Give it a knob - tutorials/visuals/01-your-first-shader#react-to-the-drums | React to the drums - tutorials/visuals/01-your-first-shader#change-it-while-it-plays | Change it while it plays - tutorials/visuals/01-your-first-shader#next-steps | Next steps Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/ --- <!-- ID: tutorials/visuals/01-your-first-shader#before-you-start --> Your First Shader > Before you start [tutorial] Finish [Signals and Modulation](/docs/tutorials/audio/02-signals-and-modulation/). Open your project's `src/main.non`, evaluate `RESET;` on its own, then remove that line. The session should be silent with no earlier visuals routed to screen. You need a working audio output and graphics display; the drums use a bundled kit. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#before-you-start Next: tutorials/visuals/01-your-first-shader#open-the-visuals-window --- <!-- ID: tutorials/visuals/01-your-first-shader#change-it-while-it-plays --> Your First Shader > Change it while it plays [tutorial] Change the shader: make the wave move faster and draw rings instead of stripes. ```glsl title="shaders/plasma.glsl" #version 300 es precision highp float; uniform float iTime; uniform vec2 iResolution; uniform float brightness; out vec4 fragColor; void main() { vec2 uv = (gl_FragCoord.xy * 2.0 - iResolution) / min(iResolution.x, iResolution.y); float rings = 0.5 + 0.5 * sin(length(uv) * 10.0 - iTime * 4.0); fragColor = vec4(vec3(rings, rings * 0.5, 1.0 - rings) * brightness, 1.0); } ``` Save it, and run the `load_shader` line again: ```resonon continue let v = gfx.load_shader("plasma", "shaders/plasma.glsl"); ``` The rings replace the stripes, and they still flash with the drums: the new shader kept the knob and what it is connected to. The music did not stop. Now make a mistake: delete a `;` in `plasma.glsl`, save it and run the line again. The last good picture stays on the screen, the music plays on, and VSCode marks the error in `plasma.glsl`, on the line you broke. Put the `;` back, save, and run the line again. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#change-it-while-it-plays Previous: tutorials/visuals/01-your-first-shader#react-to-the-drums Next: tutorials/visuals/01-your-first-shader#next-steps --- <!-- ID: tutorials/visuals/01-your-first-shader#draw-a-gradient --> Your First Shader > Draw a gradient [tutorial] A shader lives in a file of its own. Make a folder `shaders` beside `main.non`, and in it a file `plasma.glsl`: ```glsl title="shaders/plasma.glsl" #version 300 es precision highp float; uniform vec2 iResolution; out vec4 fragColor; void main() { vec2 uv = gl_FragCoord.xy / iResolution; fragColor = vec4(uv.x, uv.y, 0.5, 1.0); } ``` Save it, and run this in `main.non`: ```resonon use "std/visuals" as gfx; let v = gfx.load_shader("plasma", "shaders/plasma.glsl"); v >> screen; ``` The window fills with a gradient: red to the right, green to the top. - The file is the shader, in GLSL. `main` runs once for every pixel and writes its colour to `fragColor`. - `iResolution` is the size of the window in pixels. resonon gives it to every shader, so `uv` goes from `0` to `1` across the window. - `gfx.load_shader("plasma", "shaders/plasma.glsl")` makes a visual from the file, with the name `plasma`. The path is relative to `main.non`. - `v >> screen` shows it in the window, the way `>> session.master` sends a track to the master. In VSCode, a GLSL extension such as [Shader languages support](https://marketplace.visualstudio.com/items?itemName=slevesque.shader) highlights the file. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#draw-a-gradient Previous: tutorials/visuals/01-your-first-shader#open-the-visuals-window Next: tutorials/visuals/01-your-first-shader#make-it-move --- <!-- ID: tutorials/visuals/01-your-first-shader#give-it-a-knob --> Your First Shader > Give it a knob [tutorial] Any other `uniform` that you declare is a knob that you set from resonon. Add a `brightness`: ```glsl title="shaders/plasma.glsl" #version 300 es precision highp float; uniform float iTime; uniform vec2 iResolution; uniform float brightness; out vec4 fragColor; void main() { vec2 uv = gl_FragCoord.xy / iResolution; float wave = 0.5 + 0.5 * sin(iTime + uv.x * 6.2831); fragColor = vec4(vec3(uv.x, uv.y, wave) * brightness, 1.0); } ``` Save it, load it again, and set the knob: ```resonon continue let v = gfx.load_shader("plasma", "shaders/plasma.glsl"); v.parameter("brightness") << 0.4; ``` The picture is darker. As with an effect's knob, `<<` also takes a signal: ```resonon continue use "std/signals" { Sine }; v.parameter("brightness") << Sine(4).range(0.2, 1.0); ``` The picture now fades up and down four times every cycle. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#give-it-a-knob Previous: tutorials/visuals/01-your-first-shader#make-it-move Next: tutorials/visuals/01-your-first-shader#react-to-the-drums --- <!-- ID: tutorials/visuals/01-your-first-shader#make-it-move --> Your First Shader > Make it move [tutorial] `iTime` is the playhead's position in seconds. Add it to the shader: ```glsl title="shaders/plasma.glsl" #version 300 es precision highp float; uniform float iTime; uniform vec2 iResolution; out vec4 fragColor; void main() { vec2 uv = gl_FragCoord.xy / iResolution; float wave = 0.5 + 0.5 * sin(iTime + uv.x * 6.2831); fragColor = vec4(uv.x, uv.y, wave, 1.0); } ``` Save the file. Nothing watches it, so run the `load_shader` line again, and start the transport: ```resonon continue let v = gfx.load_shader("plasma", "shaders/plasma.glsl"); PLAY; ``` A blue wave moves across the gradient. You did not route it again: the visual with the name `plasma` is already on the screen, and it took the new shader. `iTime` moves with the playhead, as the music does: `PAUSE;` holds the wave where it is, and `STOP;` puts it back where it started. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#make-it-move Previous: tutorials/visuals/01-your-first-shader#draw-a-gradient Next: tutorials/visuals/01-your-first-shader#give-it-a-knob --- <!-- ID: tutorials/visuals/01-your-first-shader#next-steps --> Your First Shader > Next steps [tutorial] You wrote a shader, gave it knobs, connected it to the drums, and changed it while it played. - [Bind Audio to a Shader](/docs/how-to/visuals/01-bind-audio-to-a-shader/) — levels, envelopes and the frequency spectrum - [Load a Shader From a File](/docs/how-to/visuals/02-load-a-shader-from-a-file/) — reload a file and share GLSL between shaders - [Build an Operator Graph](/docs/how-to/visuals/03-build-an-operator-graph/) — make pictures from ready-made operators instead of GLSL Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#next-steps Previous: tutorials/visuals/01-your-first-shader#change-it-while-it-plays --- <!-- ID: tutorials/visuals/01-your-first-shader#open-the-visuals-window --> Your First Shader > Open the visuals window [tutorial] Visuals are drawn in a window that resonon's server opens. Run any line first, so that VSCode starts the server and connects to it: ```resonon print("Hello, screen!"); ``` Then open the resonon sidebar and click **Visuals** in the **Views** section — or run the command **Open Visuals**. An empty window opens. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#open-the-visuals-window Previous: tutorials/visuals/01-your-first-shader#before-you-start Next: tutorials/visuals/01-your-first-shader#draw-a-gradient --- <!-- ID: tutorials/visuals/01-your-first-shader#react-to-the-drums --> Your First Shader > React to the drums [tutorial] Every track tells you how loud it is, as `.rms`. Add a beat, and send its level to the knob: ```resonon continue use "std/instruments" { Sampler, Kit }; let drums = session.create_track("drums"); drums.set_instrument(Sampler(Kit("CR-78"))); drums << [bd [sd _ _ bd] bd sd]; v.parameter("brightness") << drums.rms.smooth(20, 300).range(0.2, 3.0); ``` The picture flashes on every hit and fades out after it. - `drums.rms` goes from `0` (silent) to `1` (full scale). On its own, it jumps from one frame to the next, so the picture flickers. - `.smooth(20, 300)` makes it rise in 20 ms and fall over 300 ms. - `.range(0.2, 3.0)` maps `0`–`1` to `0.2`–`3.0`, because a drum track is seldom near full scale. Page: tutorials/visuals/01-your-first-shader URL: https://resonon.org/docs/tutorials/visuals/01-your-first-shader/#react-to-the-drums Previous: tutorials/visuals/01-your-first-shader#give-it-a-knob Next: tutorials/visuals/01-your-first-shader#change-it-while-it-plays --- <!-- ID: type --> type [function] fn type(value: Any = NUL) -> String Returns the type name of a value as a string. Parameters: value: Any — any resonon value Returns: String — the value's type name Module: std/core (prelude) Page: reference/stdlib/core URL: https://resonon.org/docs/reference/stdlib/core/#type --- <!-- ID: viz --> viz [function] fn viz(pattern: Pattern | Note | Array<Any>, cycles: Number? = NUL, start_cycle: Number? = NUL) -> NUL Displays an ASCII visualization of a pattern. Parameters: pattern: Pattern | Note | Array — the pattern to visualize; a note or an array of notes as a sequence cycles: Number? — number of cycles to display (optional, defaults to 4) start_cycle: Number? — first cycle to display (optional, defaults to 0) Returns: NUL — nothing; prints the visualization Module: std/patterns (prelude) Page: reference/stdlib/patterns URL: https://resonon.org/docs/reference/stdlib/patterns/#viz --- <!-- ID: window_hide --> window_hide [function] fn window_hide() -> NUL Hide the main Resonon window. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#window_hide --- <!-- ID: window_show --> window_show [function] fn window_show() -> NUL Open or raise the main Resonon window. Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#window_show --- <!-- ID: window_snapshot --> window_snapshot [function] fn window_snapshot(path: String, scale: Number? = NUL) -> NUL Writes a PNG of the main window as it is drawn at that moment: the panels, their sizes and the meters, whether or not other windows cover it. Only Resonon's own window is in the picture; plugin editor windows are not included. An absolute path is taken as typed; a relative one lands under the project the piece belongs to, and any directory it names is created. Fails, and the session goes on, when the main window is not open. Parameters: path: String — output PNG path scale: Number? — pixels per point (optional; defaults to the screen's pixel density, the pixels the window shows) Returns: NUL — nothing Module: std/audio (prelude) Page: reference/stdlib/audio URL: https://resonon.org/docs/reference/stdlib/audio/#window_snapshot ---