voltergeist, draft v1
This page is SPEC.md from the repository.
A binary wire format for control voltage (continuous sampled signals) and events (gates, triggers, notes) between machines, over UDP datagrams or WebSocket binary messages. One frame is one datagram or one message. On a byte stream (TCP, serial) each frame carries a length prefix (section 1.1).
Status: draft v1, 2026-12-06; the owner's answers to the open questions are in section 10, six rules the C core asked to have stated are in section 11, and two v1.x additions (MIDI frames, safety limits) in section 12. Nothing is frozen until the owner says so. There is no negotiation: a reader accepts version 1 and rejects anything else (section 2.3).
The words MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119.
1. Conventions
- Every multi-byte number is little endian.
u8 u16 u32are unsigned,i16 i24 i32are two's complement signed,f32 f64are IEEE 754.i24is three bytes, least significant first, sign in the top bit of the third byte.- Clocks are
f64microseconds on the sender's own clock. The epoch is the sender's business (the reference library uses Unix time); only differences and the offset between two clocks matter. - Offsets in a frame are
i32microseconds relative to the head's clock. - A frame's length is known from the transport (the datagram or message length, or on a byte stream the prefix of section 1.1). A frame MUST be exactly the length its fields say; a byte more or a byte less is a reject, also on a WebSocket relay. Nothing pads a frame.
1.1 Byte streams
A transport that carries bytes rather than messages (TCP without WebSocket, a serial line) puts each frame's length in
front of it as a u16, little endian, and the frame follows:
| offset | size | field |
|---|---|---|
| 0 | u16 | L, the frame's length in bytes, 16 to 65535 |
| 2 | L bytes | one frame, read exactly as a datagram of length L |
A reader collects bytes until it has L of them, whatever the chunks the transport hands it. An L under 16 cannot be a frame, and a byte stream cannot be resynchronised after one, so the reader stops reading that connection. A frame longer than 65535 bytes does not exist (section 1.2). Datagrams and WebSocket messages never carry the prefix.
1.2 Frame size
A frame is at most 65535 bytes, on every transport, so that every frame fits the byte stream's prefix. A writer
MUST NOT produce a longer one and a reader rejects one (the reference says length), whatever its type, unknown
types included. The fields allow more (a SAMPLES frame of 255 channels and 255 samples of f32 would be 260,124
bytes); such a frame is split into several.
Advice, not a rule: on UDP keep a frame under about 1,200 bytes, so that it fits one datagram on any path without IP fragmentation (a fragmented datagram is lost when any fragment is). Section 7 gives the sizes that fit.
2. The head (every frame, 16 bytes)
| offset | size | field | meaning |
|---|---|---|---|
| 0 | u8 | version and flags | high 4 bits: version, 1. Low 4 bits: flags, below |
| 1 | u8 | type | the frame type, section 3 |
| 2 | u16 | stream | the stream id. One per stream, as RTP's SSRC. A sender MAY have several streams, and picks each id at random when it starts |
| 4 | u32 | seq | for SAMPLES the index of the first sample in the frame, for EVENTS of the first event; samples and events are numbered one by one and wrap at 2^32 (49.7 days at 1 kHz; a receiver extends it past the wrap). Other types say what they put here |
| 8 | f64 | clock | for SAMPLES and EVENTS the clock of the first sample or event in the frame, on the sender's clock, in microseconds. Other types say what they put here. MUST be finite |
Stream ids. A sender picks each stream id at random from 1 to 65535 when it starts. A receiver keys streams by source and id, so two senders on one id only clash where sources merge, at a relay or at a receiver that is told one source. A receiver or relay that sees two senders on one id tells the later one by means outside v1 (a relay's own message, or a type added in v1.x), and that sender picks a new id and sends its MAP again.
Flags (byte 0, low nibble):
| bit | value | name | meaning |
|---|---|---|---|
| 0 | 0x1 | X | an extension follows the head (section 2.1) |
| 1 | 0x2 | I | irregular timing: a SAMPLES frame carries one offset per sample |
| 2 | 0x4 | R | redundant: the first r samples or events repeat the end of the previous frame |
| 3 | 0x8 | reserved | MUST be 0. A reader rejects a frame with it set |
I is allowed only on SAMPLES, R only on SAMPLES and EVENTS. Either flag on another known type is a reject.
On a type the reader does not know (section 2.2) the reader checks the head and nothing after it: the frame size
(section 1.2), the version, the reserved bit 3 (a reject), the clock (finite), and with X the extension's length (its
words must fit in the frame, else a reject). I and R are not checked and the body is not read.
So byte 0 reads 0x10 for a plain frame, 0x12 irregular, 0x14 redundant, 0x16 both, 0x11 with an extension.
2.1 Extension (only when X is set)
| offset | size | field |
|---|---|---|
| 16 | u16 | extension type |
| 18 | u16 | length in 32 bit words, w |
| 20 | 4w bytes | extension data |
The body starts at B = 20 + 4w. A reader that does not know the extension type skips its data and reads the body as
usual (RTP's idea, RFC 3550 5.3.1). There is at most one extension block per frame; an extension type that needs
several items defines its own layout inside its data. Without X, B = 16.
| extension type | name | status |
|---|---|---|
| 0 | unassigned | |
| 1 | auth | reserved: a key id and a MAC over the frame. The layout is not defined yet |
| 2 to 65535 | unassigned |
Authentication. v1 has none and no encryption. Type 1 is reserved so that a key id and a MAC can be added in v1.x without a version change; a reader that does not implement it skips it like any extension and reads the frame. Until it is defined, senders and receivers run on trusted networks, or behind a relay that holds keys of its own outside the frame (the v2in relay put an 8 byte key in front of each datagram).
2.2 Unknown types
A frame whose version is 1 and whose type the reader does not know is skipped, not rejected: the reader ignores it and keeps the connection. This lets v1.x add types without a version change.
2.3 Versions
- v1.x is any addition an old v1 reader can skip without misreading: a new type (skipped, section 2.2), a new extension type (skipped, section 2.1), a new MAP key (ignored), a new event kind (ignored by a player). A new flag comes only as an extension type, because flag bit 3 is a reject.
- v2 is any change to the meaning of bytes v1 already defines: a field moved, widened or reinterpreted, a rule relaxed in a way an old reader would reject or misread.
- A reader rejects a frame whose version it does not know, whatever follows the head.
3. Types
| type | name | section | kind |
|---|---|---|---|
| 0 | reserved | ||
| 1 | SAMPLES | 4.1 | data |
| 2 | EVENTS | 4.2 | data |
| 3 | MAP | 4.3 | data |
| 4 | MIDI | 4.4 | data, v1.x |
| 5 to 15 | unassigned data types | ||
| 16 | HELLO | 5.1 | transport |
| 17 | PING | 5.2 | transport |
| 18 | PONG | 5.3 | transport |
| 19 | CLOCK | 5.4 | transport |
| 20 | REPORT | 5.5 | transport |
| 21 to 255 | unassigned |
The data types are the format. The transport messages (section 5) are a separate, optional layer: a relay, a file recorder or a receiver that is told its offset another way does not need them.
4. Data types
4.1 SAMPLES (type 1)
k consecutive samples of n channels. Body at B:
| offset | size | field | rule |
|---|---|---|---|
| B+0 | u8 | n, channels | 1 to 255 |
| B+1 | u8 | format | 1 f32, 2 i16, 3 i24; anything else is a reject |
| B+2 | u16 | map id | 1 to 65535 names a MAP; 0 means no map, raw values (below) |
| B+4 | u8 | k, samples in this frame, repeats included | 1 to 255 |
| B+5 | u8 | r, how many of the k are repeats | 0 unless R; with R, 1 to floor(k/2) |
| B+6 | u16 | reserved | MUST be 0 on send; a reader ignores it |
| B+8 | 4k bytes, only with I | k x i32 offsets | the first MUST be 0; never decreasing |
| then | k x n x size | values | sample major: sample 0 channel 0, sample 0 channel 1, ... |
The length MUST be exactly B + 8 + (I ? 4k : 0) + k x n x size, where size is 4, 2 or 3.
- Numbering. Sample i of the frame is
seq + i(mod 2^32). - Timing. Without I, sample i is at
clock + i x 1e6 / rate, withratefrom the stream's map. With I, sample i is atclock + offset[i]. With map id 0 there is no rate: the sample period is the clock difference of two frames of the stream divided by their seq difference, so a receiver holds a regular frame of k > 1 until a second frame gives it (k 1 and irregular frames need no period). A sender of map id 0 that wants its first frame timed sets I. - Redundancy (R). The first r samples repeat the last r samples of the stream's previous frame, so
seqandclockare those of the first repeated sample. r MUST NOT exceed the new samples (2r <= k): redundancy never costs more than the new data (RFC 2198's rule). A receiver keeps the first copy of each seq and drops the rest. - Values.
f32carries the value in the channel's unit and MUST be finite (NaN and infinity are rejects).i16andi24carry a normalised value:x = raw / 32767orraw / 8388607, clamped to -1; withminandmaxin the map the value ismin + (x + 1) / 2 x (max - min), otherwise (no min and max, or map id 0) it is x, in -1..1. - n and format repeat what the map says, so a frame can be parsed and skipped with no map. A frame whose map id, n or format does not match the receiver's current map for the stream is held until a matching map arrives (bounded; the reference keeps 64 frames per stream and drops the oldest, counting them stale). This is how a stale map is detected.
- No map (map id 0). The frame is played without a map and never held for one:
f32values as they are,i16andi24scaled to -1..1. Channels are known by their index from 0, the stream by its id (the OSC bridge sends/<stream id>/<channel index>). A MAP that arrives later for the stream takes over from its first matching frame.
Size at 1 kHz, 4 channels f32, k 10: 16 + 8 + 160 = 184 bytes a frame, 100 frames a second.
4.2 EVENTS (type 2)
Gates, triggers and notes at exact times, on their own stream id. Body at B:
| offset | size | field | rule |
|---|---|---|---|
| B+0 | u8 | m, events in this frame, repeats included | 1 to 255 |
| B+1 | u8 | r, repeats | as for SAMPLES: 0 unless R; with R 1 to floor(m/2) |
| B+2 | u16 | map id | 1 to 65535 names a MAP; 0 means no map, and the channel is just an index |
| B+4 | m x 12 | events | below |
Each event, 12 bytes:
| offset | size | field | rule |
|---|---|---|---|
| 0 | i32 | offset, microseconds from the head clock | 0 or more, never decreasing within the frame |
| 4 | u8 | channel | index into the map's channels |
| 5 | u8 | kind | 1 gate, 2 trigger, 3 note on, 4 note off; 0 is a reject; 5 to 255 are valid and ignored by a player that does not know them |
| 6 | u16 | note | the note number for kinds 3 and 4, else 0 |
| 8 | f32 | value | gate: 0 off, anything else on at that level; trigger: amplitude; note on: velocity 0 to 1; note off: release velocity. MUST be finite |
The length MUST be exactly B + 4 + 12m. Event i is number seq + i, at clock + offset. The I flag is a reject.
There are four kinds and no more are planned for v1. Any other MIDI message travels in a MIDI frame (section 4.4), not as an event kind. A value that steps at an exact time is not an event: it is a SAMPLES frame with I set and k 1 (one sample, its offset 0, its clock the step's time). The note field is a u16 so a note number can index an MPE or microtonal table.
Redundancy. A single event cannot carry a repeat under 2r <= m, so a sender SHOULD send every EVENTS frame twice,
a few milliseconds apart, on a datagram transport; the copy carries the same seq and the receiver drops it. This is the
recommended practice (the reference sender does it with a 5 ms gap). R on EVENTS keeps the 2r <= m rule and stays
available for frames of several events.
Events are sent when they happen, so a receiver cannot see a lost last event until the next one, or until the next MAP of the stream (its seq is the next event number, section 4.3).
4.3 MAP (type 3)
What a stream is. Sent when a stream starts, when it changes (with a new map id), and re-sent periodically for UDP (the
reference sends it every second). Body at B:
| offset | size | field | rule |
|---|---|---|---|
| B+0 | u16 | map id | 1 to 65535; 0 is a reject, since 0 means no map |
| B+2 | u16 | L, JSON length in bytes | |
| B+4 | L bytes | UTF-8 JSON object | MUST be valid UTF-8 and a JSON object (RFC 8259), with no byte order mark |
The length MUST be exactly B + 4 + L. The head's stream is the stream described, seq is the stream's next sample
or event number at the time of sending (so a receiver counts trailing loss), and clock is the sender's clock when sent.
The JSON:
{ "name": "desk", "kind": "samples", "rate": 1000, "format": "f32",
"channels": [
{ "name": "pitch", "node": "keys", "port": "cv-out", "unit": "V", "min": -5, "max": 5, "voct": 1 },
{ "name": "cutoff", "unit": "V", "min": 0, "max": 10 } ] }
| key | required | meaning |
|---|---|---|
| name | yes | the stream's name, a non empty string (the OSC bridge uses it as the first address part) |
| kind | yes | "samples" or "events" |
| rate | samples | samples per second, a finite number above 0 (a JSON number too large for a double, such as 1e999, is infinite and a reject) |
| format | samples | "f32", "i16" or "i24" |
| channels | yes | 1 to 255 objects; for samples their count is n |
| channels[].name | yes | non empty string |
| channels[].node, port, unit | no | strings: where the channel comes from, and its unit |
| channels[].min, max | no | numbers: the channel's range in its unit (and the integer formats' scale) |
| channels[].voct | no | volts per octave, a number |
| channels[].clamp | no | [lo, hi], two finite numbers with lo <= hi, in the channel's unit: a safety limit (section 6.1) |
| channels[].slew | no | a finite number above 0: the most the channel may change per second, in its unit (section 6.1) |
A MAP that breaks a rule in this table is a reject. Keys not listed are allowed and ignored, so a studio can add its own.
clamp and slew were added in v1.x: a reader that predates them ignores them as unknown keys and limits nothing; a
reader that knows them rejects a MAP whose clamp or slew breaks its rule, because a safety limit that cannot be read
must not be dropped quietly.
- A key given twice in one object keeps its last value, at every level (the map and each channel), as
JSON.parsedoes; RFC 8259 section 4 leaves it open. A scanner records each key it cares about as it passes and overwrites it, which needs no memory of the other keys. A writer SHOULD NOT write a key twice. - A byte order mark has no special meaning. U+FEFF (
EF BB BF) is not JSON whitespace, so a MAP whose JSON starts with one is a reject (json); RFC 8259 section 8.1 says a writer MUST NOT add one. Nothing has to strip it. The map id changes whenever the JSON changes; re-sending the same map keeps its id.
4.4 MIDI (type 4, v1.x)
Any MIDI 1.0 message, timed on the shared clock, on its own stream id. An old v1 reader skips the type (section 2.2).
Body at B:
| offset | size | field | rule |
|---|---|---|---|
| B+0 | u8 | m, messages in this frame, repeats included | 1 to 255 |
| B+1 | u8 | r, repeats | as for EVENTS: 0 unless R; with R 1 to floor(m/2) |
| B+2 | u16 | reserved | MUST be 0 on send; a reader ignores it |
| B+4 | m records | messages | below, one after another, no padding |
Each record, 6 + L bytes:
| offset | size | field | rule |
|---|---|---|---|
| 0 | i32 | offset, microseconds from the head clock | 0 or more, never decreasing within the frame |
| 4 | u16 | L, the message's length in bytes | 1 to 1024 |
| 6 | L bytes | one whole MIDI 1.0 message | below |
The length MUST be exactly B + 4 + sum(6 + L). Message i is number seq + i, at clock + offset. The I flag is a
reject. A frame of 1024 byte messages holds at most 63 of them (section 1.2).
A message is one complete MIDI message, as the MIDI 1.0 Detailed Specification defines it:
- It starts with its status byte (80 to FF). Running status is not allowed: a record whose first byte is a
data byte (00 to 7F) is a reject (
status), and so is an undefined status (F4, F5, F9, FD) or a lone F7. - Its length is the status's: 3 for 8n, 9n, An, Bn, En and F2; 2 for Cn, Dn, F1 and F3; 1 for F6 and the real-time
bytes F8, FA, FB, FC, FE, FF. Every byte after the status is a data byte. Anything else is a reject (
midi), so two messages in one record are a reject. - SysEx starts with F0, ends with F7, holds only data bytes between them and is at most 1024 bytes, F0 and F7
included. Anything else is a reject (
sysex). A real-time byte goes in a record of its own, never inside a SysEx.
SysEx is off by default in every receiver. A receiver drops a valid SysEx message and counts it unless its owner
allowed SysEx (the reference: receive --midi-sysex). SysEx can overwrite an instrument's memory: patches, sessions,
firmware. The 1024 byte limit keeps a frame small and still carries a patch dump of most instruments; a larger dump is
not a live control and does not belong on this wire.
A receiver plays MIDI out as it plays events (section 6): each message at clock + offset + D on the shared clock,
late ones by the same rule, repeats (by seq) dropped. A MIDI output passes the bytes through unchanged; an output that
cannot carry MIDI (OSC, a DAC) ignores the stream. On UDP a sender SHOULD send each MIDI frame twice, as EVENTS.
Why this layout. The 12 byte event slot holds at most 3 MIDI bytes (channel and note), and an f32 value cannot carry raw bytes because it must be finite. The alternative, a MIDI event kind for 3 byte messages plus a second frame type for SysEx, gives a C implementer two paths and two sets of rules for one stream. One record shape (offset, length, bytes) carries every MIDI message: a reader walks the records with one loop, checks each message with one function, and skips a frame without knowing MIDI. The length is a u16 because a u8 cannot hold a 1024 byte SysEx. No padding, because nothing in a frame is padded (section 1) and every field is read byte by byte. A MIDI frame needs no MAP: the bytes describe themselves, and a stream's id names it.
5. Transport messages (optional)
These carry the clock and the receiver's feedback. They are not needed to read data frames. Each has a fixed length (except HELLO); the X flag is allowed, I and R are rejects.
5.1 HELLO (type 16)
| offset | size | field |
|---|---|---|
| B+0 | u8 | role: 1 sender, 2 receiver, 3 both; 0 is a reject |
| B+1 | 3 bytes | reserved, 0 |
| B+4 | rest | a name, UTF-8 (may be empty; invalid UTF-8 is a reject; a leading U+FEFF is part of the name, not stripped) |
A receiver behind NAT sends HELLO to a relay or a sender so that frames can come back to it; a sender sends it to keep
its address fresh at a relay. stream, seq and clock are the sender's choice (the reference sends 0, 0, now).
5.2 PING (type 17)
The head alone (16 bytes, or 16 plus an extension). stream names the asker's stream (or 0), seq is the ping's
number, clock is the asker's send time t0.
5.3 PONG (type 18)
| offset | size | field |
|---|---|---|
| B+0 | f64 | t0, the ping's clock, copied |
| B+8 | f64 | t1, when the ping arrived, on the answerer's clock |
The head's stream and seq are the ping's; its clock is t2, when the answer left. With t3 the arrival of the PONG
on the asker's clock (NTP, RFC 5905):
rtt = (t3 - t0) - (t2 - t1) offset = ((t1 - t0) + (t2 - t3)) / 2 the answerer's clock minus the asker's
Estimator. Keep the last 120 results; take the third with the smallest rtt; the offset is the median of their offsets. The single fastest ping is not used alone: with jitter in both directions it is often fast one way only, which v2in measured as a -3.1 to +10.6 ms error on a jittered line where the truth was 0.05 ms.
5.4 CLOCK (type 19)
| offset | size | field |
|---|---|---|
| B+0 | f64 | offset, microseconds: the peer's clock minus this sender's clock |
| B+8 | f64 | rtt, microseconds, of the fastest ping the estimate used |
A sender that pinged a receiver (or a relay) tells it the result, so the receiver can put the sender's clocks on its
own: receiver time = sender clock + offset. stream 0 means every stream from this source; another value applies to
that stream only. seq counts CLOCK messages; clock is the send time. Sent after the first estimate and then every
second in the reference.
Through a relay the clock has two legs: the sender pings the relay and the relay pings the receiver (or each end pings the relay), and the receiver adds the two offsets. A relay never rewrites a frame, clocks included, so a frame is the same bytes at both ends and a MAC over it (section 2.1) can survive the relay.
5.5 REPORT (type 20)
A receiver's report on one stream (the head's stream), sent back to its sender, as RTCP's receiver report (RFC 3550
6.4.1), so a sender can raise its batching or redundancy when a line gets worse.
| offset | size | field | meaning | ||
|---|---|---|---|---|---|
| B+0 | u8 | fraction lost | samples lost since the previous report, in 1/256, 0 when none or when duplicates outnumber losses | ||
| B+1 | u8 | reserved, 0 | |||
| B+2 | u16 | late fired | events that arrived late but within the receiver's threshold and were still fired (section 6), cumulative, wraps at 2^16 | ||
| B+4 | i32 | cumulative lost | expected minus received since the stream began (signed, as RTCP's) | ||
| B+8 | u32 | highest seq | the extended highest sample or event number received, mod 2^32 | ||
| B+12 | u32 | jitter, microseconds | RFC 3550 A.8 on the transit of each frame's last sample: `J += ( | D | - J) / 16` |
| B+16 | u32 | late | samples that arrived after their playout time, and events dropped for arriving more than the threshold late, cumulative | ||
| B+20 | u32 | recovered | samples or events received only as a repeat, cumulative |
seq counts reports; clock is the receiver's send time. The reference sends one per stream twice a second.
6. Playout
A receiver plays a stream out a fixed delay D after its clock, on the shared clock:
play time (receiver clock) = sample clock + offset + D
offsetcomes from CLOCK. Until one arrives, a receiver MAY use the smallestarrival - clockseen on the stream (good on one machine, wrong by the line's minimum delay elsewhere), and SHOULD say so.- Between consecutive samples the value is interpolated linearly.
- On loss (a gap in seq at the playhead) the receiver either holds the last value or interpolates to the
next sample when that sample is already in the buffer. The reference does either (
--mode hold|interpolate; hold is the default because a held gate stays a gate). - Underrun (nothing after the playhead yet): hold the last value.
- Late: a sample whose arrival is after its play time is counted late (REPORT) and is not played if the playhead has passed it.
- Events fire when the playhead reaches their clock. An event that arrives after its play time fires on the next
read when it is at most 10 ms late, and is counted in REPORT's
late fired; later than that it is dropped and countedlate. A gate off or note off a few milliseconds late is better played than left stuck, and a trigger tens of milliseconds late is a wrong beat. The threshold is a receiver setting (the reference's--event-late, default 10 ms). - Choosing D. It has to cover the line's jitter, the batch wait ((k - 1) / rate for the first sample of a batch), and with redundancy the wait for the next frame (a repeated sample arrives up to one frame period later). On v2in's emulated lines, 20 ms of playout over the line's own delay left 0.80 % of arrived frames late on the worst (35 ms, 5 % loss), and 40 ms left 0.01 % or less on every line.
6.1 Safety limits
A channel MAY carry limits: clamp (a value outside [lo, hi] becomes lo or hi) and slew (the most the value may
change per second, in the channel's unit). A receiver applies them to every samples channel before any output
(a DAC, MIDI, OSC, anything), after the playout of section 6 and on the receiver's clock:
y = the previous output moved toward x by at most slew x (now - then) (no previous output, or no slew: y = x) y = min(hi, max(lo, y)) (with clamp)
So a step becomes a ramp, the clamp is the hard bound, and a channel without limits passes unchanged. Limits apply to samples channels only; an event's value is not limited (a clamp would turn a gate off into a gate on).
The instrument's owner decides, not the remote player. A receiver MAY be given limits of its own (the reference:
receive --limit <channel>:<lo>..<hi>[@<slew>], the channel by index or name). For a channel it names, the receiver's
limit replaces the map's clamp and slew together; the map's limits apply only to channels the receiver did not name.
A receiver keeps each channel's last output when a MAP is re-sent or its limits change, so a new limit slews on from
where the channel is and never lets a step through.
7. Senders
- Pick each stream id at random when starting (section 2), and pick again on a clash.
- Number samples one by one per stream from any start; the reference starts at 0.
- Stamp each sample with its own clock. For a regular stream, the sample's nominal time (start + i / rate), so the rate in the map is exact; for an irregular one (a sensor read when it reads), set I.
- Send MAP first, again a few times in the first 100 ms on UDP, then periodically. A stream without a map uses map id 0 and sends none.
- On UDP send every EVENTS frame twice (section 4.2).
- Keep a frame under about 1200 bytes so it fits one datagram on any path without fragmentation (section 1.2; never over 65535). At 8 channels f32, k up to 36 fits.
8. Conformance
A reader conforms when, for the files in vectors/:
- every entry of
valid.jsondecodes to exactly itsframe(an extension's data written ashex), - every entry of
skip.jsonis skipped as an unknown type, not rejected, - every entry of
reject.jsonis rejected. Theerrorfield is the reason the reference reader gives; matching it is recommended, not required.
The order of the checks is not normative. A frame with several faults may be rejected for any of them, so two conforming readers can give different reasons for one frame. For EVENTS the reference checks the flags, the count, the repeats, the length, then each event's kind and value in order, then the offsets; a reader that checks the offsets first conforms. The vectors carry one fault each where it matters.
A valid.json entry marked decodeOnly holds bytes no writer produces (a MAP key given twice): it is decoded, not
encoded.
A writer conforms when encoding each valid.json frame (except decodeOnly ones) gives its hex. For MAP the JSON is written compactly with
the keys in the vector's order; a writer that orders keys differently conforms when its MAP decodes to the same object.
The vectors are built by vectors/make.mjs from this document's tables with a byte writer of its own, so they are not
the reference encoder's output checked against itself.
9. What was taken from existing specs
- RTP (RFC 3550): the head's shape (version, flags, type, a stream id per stream, sequence, timestamp of the first sample), the extension with a length in 32 bit words, and the receiver report's fields. Not taken: big endian, the separate RTCP protocol and port, one session per medium.
- RFC 2198: redundancy as earlier data repeated in a later packet, never more than the primary.
- NTP (RFC 5905): the four timestamp offset and round trip.
- OSC 1.0: not on the wire. The kit's OSC bridge (
src/osc.mjs) hands played out values to any OSC host: by default a value only when it changed (at most 200 Hz per address), with--osc-steady <Hz>every channel's current value every period; events at once.
10. Decided (2026-12-06)
The thirteen questions this draft left open, as the owner answered them, each with its reason.
- Stream id stays u16, picked at random by the sender at start and picked again on a clash (section 2). The head stays 16 bytes, and a clash only matters where sources merge, which a relay can see and report.
- n and format stay in every SAMPLES frame. Two bytes buy a frame that parses with no map and a stale map caught even when a map id was reused.
- Map id 0 means no map, raw values (section 4.1), no longer a reject; EVENTS too, the channel being an index. A quick sender or a sensor can stream without writing a map; a MAP still cannot use id 0.
- Integer scaling is by the map's min and max, and to -1..1 without them or without a map. Symmetric and already implemented; an explicit scale and offset would be a second way to say the same thing.
- Exact length stays strict for datagrams and WebSocket messages; byte streams get a u16 length prefix (section 1.1). Padding hides bugs, and TCP or serial needs framing that the datagram does not.
- Event redundancy is sending each EVENTS frame twice, now the recommended practice (section 4.2); r for events is unchanged. A copy costs one small frame and needs no new rule.
- No fifth event kind, note stays u16. A value step at an exact time is an irregular SAMPLES frame of one sample.
- Late events fire if at most 10 ms late and are dropped if later, both counted in REPORT (
late firedin the reserved bytes,latefor drops; section 6), the threshold a receiver setting. A slightly late gate off must still close the gate; a trigger far too late is a wrong beat. - Clock through a relay is two legs, and the relay never rewrites frames (section 5.4). Frames stay the same bytes end to end, which a MAC will need.
- Versions (section 2.3): what an old reader can skip is v1.x, any change to the meaning of existing bytes is v2, and a reader rejects an unknown version.
- Seq wraps at 2^32, extended by the receiver. 49.7 days at 1 kHz is longer than a session, and REPORT's highest seq mod 2^32 is RTCP's choice too.
- Extension type 1 is reserved for authentication (a key id and a MAC, layout not defined; section 2.1). Until it is defined, run on trusted networks or behind a relay with keys; a reader that does not implement it skips it.
- Steady OSC is an option:
receive --osc host:port --osc-steady <Hz>sends every channel's current value every period; changes only stays the default. Some hosts want a steady stream, most want less traffic.
11. Stated for the C core (2026-12-06)
Writing c/voltergeist.h from this document found six places where only the JavaScript said what happens. Each is now
a rule; where the JavaScript was not clearly wrong, its behaviour became the rule.
- An unknown type's flags (section 2): the head is checked (size, version, reserved bit 3, finite clock, the
extension's length with X);
I,Rand the body are not. This is what the JavaScript did. - A byte order mark (sections 4.3 and 5.1) has no special meaning: a MAP starting with one is not JSON, a HELLO
name keeps it. The JavaScript used to drop it (
TextDecoder's default) and now does not; this is the choice that needs no code in C. - A JSON key given twice keeps its last value (section 4.3), as
JSON.parseand the C scanner already did; forbidding duplicates would make a C reader remember every key. - rate is a finite number above 0 (section 4.3), as both implementations already checked.
- A frame is at most 65535 bytes (section 1.2), so every frame fits the byte stream prefix; new in both. UDP's 1,200 bytes stays advice.
- The order of reject checks is not normative (section 8); a frame with several faults may report any of them.
12. Added in v1.x (2026-12-06)
Both are additions an old v1 reader skips or ignores (section 2.3).
- MIDI frames (type 4, section 4.4). voltergeist can carry any MIDI 1.0 message timed on the shared clock, so a remote player's controller or sequencer reaches an instrument with its timing intact. Every message carries its status byte, SysEx is off by default in every receiver and at most 1024 bytes, and real-time bytes are allowed.
- Safety limits (
clampandslewin a MAP channel, section 6.1), enforced by the receiver before every output, with the receiver's own limits winning. Historic instruments need a bound on what a remote sender can do to a voltage. Patchwerk (MIT, 2012) set each patch's voltage ranges in a configuration file on the instrument's side, and the 20N02 (NIME 2019) named a security layer as future work (research/prior-art-2026-12-06.md).