Sessions & Servers
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.
The session outlives each evaluation
Section titled “The session outlives each evaluation”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.
Several clients, one session
Section titled “Several clients, one session”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 for the trust limits.
A session runs one version of the language
Section titled “A session runs one version of the language”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.
Typed session commands
Section titled “Typed session commands”Clients can send a command message instead of generating source code. Each message has a UUID
id and a typed command. For example:
{"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.
Related
Section titled “Related”- Patterns, Tracks & Effects — the loop, hands-on
- Run a Shared Server — start, protect and join a server
- The Evaluation Model — what one evaluation does
- Two Ways to Run a Piece — live, or a file run that renders