Two Ways to Run a Piece
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.
A server holds a session, and you send it code from VSCode or the REPL. Playback runs in real time, you drive it with the transport, and a new pattern lands on the next cycle, so edits stay in time. The session remembers everything evaluated into it, so the piece grows by evaluation (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
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.
File run
Section titled “File run”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:
resonon run scripts/bounce.nonThe 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.
What differs
Section titled “What differs”| 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 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.
Related
Section titled “Related”- The Evaluation Model — what a live evaluation does
- File Runs — what
resonon runopens, and its exit status - Render a Project —
render(), stems, and where files land