SPB Git

Repository Public

compiler.md 3.0 KB

# Compiler

The Compiler space shows what the last compilation did and produced. Nothing here is decorative: every number comes from that compilation.

# Pipeline

source → tokens → AST → symbols and types → Musical IR → DSP IR → execution plan

The plan is interpreted by the runtime; no machine code is generated.

Figure Meaning
Lexer, Parser, Semantics, Graph Time spent in each phase, measured by the compiler for this compilation (not an average).
Total Wall-clock time of the whole call, including what is outside the four phases (studio overrides, JSON, cache lookup).
Cache hit The result came from the content-hash cache: same module texts and options as a previous compilation.
Note events, tracks, maximum polyphony Counted on the Musical IR. Polyphony is the largest number of notes sounding at once, release tails excluded.
DSP nodes Nodes of the mixing graph at the project sample rate.
Estimated memory An estimate of the runtime working set (events, voices, buffers). It is not a measurement.

A failed compilation keeps the previous valid program: it is what plays and what the other spaces show. Diagnostics are grouped by code; click a group to go to its first occurrence.

# AST, Musical IR, DSP IR

The three artefacts as trees. Rows exist only for what is open, so a composition with hundreds of thousands of notes stays usable; a container shows its first 500 children and says how many it does not show.

  • Search matches keys and scalar values, case-insensitive (first 1 000 matches); Return and the arrows walk through them, opening the path to each.
  • Keyboard: ↑ ↓ move, → opens, ← closes, Return shows the node in the code.
  • The arrow button on a node with a source span selects that span in the editor. Spans of the main source are addressable; nodes that come from an imported module are not, yet.
  • Export JSON… writes exactly what the compiler returned, atomically.

The same artefacts on the command line: sonata build piece.sonata --emit ast|ir|graph.

# Graph

The mixing graph for the project sample rate, laid out left to right in topological columns: instruments and audio clips, insert effects, faders, sends, bus and master sums, the master chain, the limiter and the output. Compensation delays (amber) are the pure delays the compiler inserts so parallel paths arrive aligned; the header gives the total latency of the graph. Click a node for its channel counts, its own latency and the latency accumulated up to it.

The engine rebuilds this graph at the rate of the audio device when that differs from the project rate, so the latency in samples can differ there.

# Tempo map

Tempo points, time signatures and markers with their time in seconds and their musical position in whole notes. Seconds come from the tempo map (a ramp is linear in seconds per whole note); samples are floor(seconds × rate + 0.5) everywhere.

Files main
Menu

Theme