Aratu music written to play, and to change while it plays

6. The data: what comes out of the compiler

▶ Open in Aratu to hear and change the examples

The IDE talks to the compiler through a few functions the WebAssembly exports (aratu_compile, aratu_render, aratu_check, aratu_grid, aratu_voices), exchanging text as JSON. Compiling returns the messages, the parts, the knobs, the lists, the rows and the lines written live. Asking for bars returns the events. A note event looks like this:

{"bar": 3, "beat": 1.5, "time": 4.75, "dur": 0.24, "part": "bass",
 "line": "bass", "vel": 80, "note": 45, "from": 120, "to": 123}
Field What it is
bar, beat the bar and the beat within it, as written
time, dur when it sounds and how long, in seconds from the start
part, line the part and the line that play it
vel its strength, from 0 to 127, as in MIDI
note the note, as a MIDI number (60 is middle C)
drum in place of note, the drum: kick, snare, closed-hat…
acc 1 when the note was written in upper case
param, value, glide in place of a note, a parameter change; glide is the seconds over which the sound slides to the value
from, to where the symbol is written in the text, to light it when it sounds

Messages are data too: each has its severity (error or warning), the stretch of text and the text in the chosen language. An error does not stop the music: while the text has an error, the last good version keeps playing, like a hot reload that refuses a broken build.