Start
This page is README.md from the repository.
Control voltage and events between machines, over UDP, WebSocket, or a byte stream such as TCP or serial: a small binary wire format (SPEC.md), golden
vectors any implementation checks itself against (vectors/), and a reference library for Node and the browser with
no dependencies (src/). A sender stamps every sample with its own clock and a number, and says once in a JSON map
what each channel means; a receiver puts that clock on its own and plays every sample out a fixed delay later, holding
or interpolating over what was lost. The kit sends test signals, receives them into a terminal or any OSC host, bridges
a browser in over WebSocket, and measures loss, delay and jitter.
Why a new format and not RTP, OSC or MIDI, and who did this before: WHY.md. The browser pages (Web MIDI in and out, for Ableton Live and VCV Rack): web/README.md. The C99 core: c/README.md.
Needs Node 22 or newer. Nothing to install.
node --test # 261 tests: the vectors both ways, round trips, rejects, playout, clock, the tools, MCP4728, MIDI, limits
Stage 1: one machine, over loopback
node tools/receive.mjs --port 9100 --delay 20 # terminal 1: prints each stream once a second
node tools/send.mjs --to 127.0.0.1:9100 --gate # terminal 2: ramp, sine, square on 4 channels at 1 kHz, a gate
node tools/measure.mjs --seconds 30 # or both at once, with a summary
node tools/measure.mjs --seconds 30 --loss 2 --redundant --delay 30 # drop 2 % of frames, watch redundancy recover them
Measured on an Apple M2 Pro laptop, Node 25.9, 2026-12-06, 30 s per run at 1 kHz, 4 channels f32, batch 10, playout delay 20 ms unless noted. Delay is from a sample's clock to its arrival, so it includes the batch wait (up to 9 ms):
| run | lost | recovered | late | delay p50 / p99 / max ms | jitter ms | bytes/s |
|---|---|---|---|---|---|---|
| clean | 0 of 30,007 | 0 | 4 | 5.81 / 10.90 / 22.89 | 0.54 | 19,018 |
--loss 2 | 530 (1.77 %) | 0 | 0 | 5.74 / 10.87 / 19.38 | 0.58 | 18,682 |
--loss 2 --redundant | 0 | 540 | 31 | 5.65 / 15.23 / 22.20 | 0.72 | 34,396 |
--loss 2 --redundant --delay 30 | 10 (0.03 %) | 550 | 0 | 5.66 / 15.15 / 22.03 | 0.68 | 34,500 |
A full batch of redundancy doubles the sample bytes and needs one more frame period of delay; the 10 lost in the last row are two consecutive frames dropped, which one frame of redundancy cannot cover.
To drive Max, Pure Data, TouchDesigner or VCV Rack (trowaSoft cvOSCcv), add --osc 127.0.0.1:9000 to the receiver.
Every channel arrives as /<stream name>/<channel name> ,f when it changes, at up to 200 Hz (--osc-rate); a host
that wants a steady stream gets every channel every period with --osc-steady 100 (Hz). Gates and triggers arrive as
,f, notes as ,if (note, velocity). A stream sent with map id 0 (no map) arrives as
/<stream id>/<channel index>, integer formats scaled to -1..1.
The sender picks a random stream id each run (--stream fixes one) and sends every event frame twice, 5 ms apart; the
receiver drops the copy. An event that reaches the receiver up to 10 ms after its play time still fires and is counted
fired late; later than that it is dropped and counted late (--event-late sets the threshold in ms).
From a browser, with no build step:
node tools/bridge.mjs --port 8090 --to 127.0.0.1:9100 # then open http://127.0.0.1:8090/ and press Start
Stage 2: a laptop to a Raspberry Pi on the same network, no relay
On the Pi (Node 22 or newer, then copy this folder over):
node tools/receive.mjs --port 9100 --delay 20 --osc 127.0.0.1:9000
On the laptop:
node tools/send.mjs --to <pi address>:9100 --rate 1000 --channels 8 --batch 10
The receiver answers the sender's PINGs, so the sender learns the offset between the two clocks and sends it in a CLOCK
frame; nothing else is needed. The sender prints the receiver's REPORT (loss, jitter, late, recovered) once a second. If
late climbs, raise --delay on the receiver; if lost climbs, add --redundant on the sender.
Out to hardware: an MCP4728 DAC, or MIDI
receive can drive a DAC or a MIDI port directly, beside or instead of OSC. Both follow one samples stream (the first
seen, or the one named), map each channel's value through the map's min and max (or -1..1 without them), clamp,
and write at most a set rate and only when a value changed.
| flag | what |
|---|---|
--mcp4728 [bus=1,addr=0x60,ref=vdd,channels=0-3,rate=200] | the stream's channels 0 to 3 to DAC A to D. ref is vdd, 2.048 or 4.096 (gain 2, needs 5 V); channels=2,3 routes channel 2 to A and 3 to B; min=, max= override the map; stream= names the stream |
--mcp4728-cmd path | the i2ctransfer to run (default: on PATH, else /usr/sbin/i2ctransfer) |
--midi /dev/snd/midiC1D0 | Linux: write raw MIDI to an ALSA rawmidi device, no dependency (ls /dev/snd/midi*, cat /proc/asound/cards). A device named Circuit is refused |
--midi-cmd "<command>" | any OS: a command that reads MIDI on stdin, held open for the run |
--midi-format raw|text | raw bytes (default), or text: the on, off, cc lines positron's rig/m1/midisend reads (no pitch bend there) |
--midi-map 0:cc1@1,1:pb@2,2:nrpn300@1 | per channel: a 14 bit CC pair (CC n and n + 32, n 0 to 31), pitch bend (all 14 bits in one message, a MIDI channel of its own) or NRPN n; @ the MIDI channel 1 to 16; [0..10] its own range. Default: channel i to CC i + 1 and i + 33 on MIDI channel 1 |
--midi-rate 500 | per output, messages a second at most (Hz) |
--midi-note 60, --midi-channel 1 | gates and triggers of an events stream play this note (plus the event's channel) on this MIDI channel; note events keep their note |
--midi-sysex | let SysEx in MIDI frames through. Off by default: SysEx can overwrite an instrument's memory, so without this flag it is dropped and counted. Other MIDI frame messages always pass through at their playout time (SPEC.md 4.4) |
--limit 0:0..5@20,cutoff:-1..1 | the owner's safety limits, per channel by index or name: clamp to lo..hi, and @ the most change per second, in the channel's unit. They replace the sender's map clamp and slew for those channels, and apply before every output, OSC too (SPEC.md 6.1) |
MCP4728 on a Pi. Wire the board (Electrokit EKM016, Adafruit 4470, or an MCP4728 board with an op-amp stage) to the Pi's header: pin 1
3V3 to VCC, pin 3 SDA to SDA, pin 5 SCL to SCL, pin 6 GND to GND. LDAC may stay unconnected: the writes below do not
need it (mcp4728Out takes an ldac pulse function for UDAC 1, with no GPIO backend in the kit yet). At 3V3 the
reference is vdd (0 to 3.3 V) or 2.048; 4.096 needs the board on 5 V, and a board on 5 V whose I2C pull-ups go to its
supply (usual on Qwiic boards, not checked on this one) puts 5 V on the Pi's SDA and SCL, which they do not tolerate. Enable I2C (sudo raspi-config, Interface Options, I2C), install i2c-tools, check the chip answers with
/usr/sbin/i2cdetect -y 1 (a 60 in the grid), then:
node tools/receive.mjs --port 9100 --delay 20 --mcp4728 bus=1,addr=0x60,ref=vdd,channels=0-3
Each write is a Multi-Write command (MCP4728 datasheet DS22187E, section 5.6.2) carrying VREF, gain and the 12 bit
code for every routed channel, with UDAC 0: each output updates as its own three bytes arrive, so the LDAC pin is not
needed and a chip that lost power comes back with the right reference on the next write. The four outputs update up to
about 0.2 ms apart at 400 kHz (0.8 ms at 100 kHz), well under a sample at 1 kHz. Node cannot issue the I2C_SLAVE
ioctl without a native module, so each write spawns i2ctransfer, one at a time, and writes that arrive while one
runs are coalesced to the latest. MEASURED on the Pi 4 (2026-12-06, bus at 400 kHz, nothing attached at 0x60): about
236 processes a second completed, against 257 a second spawning /bin/true, so the process is the limit, not the
bus (13 bytes take 0.3 ms at 400 kHz). The default cap of 200 writes a second sits under it. A missing i2ctransfer,
a missing /dev/i2c-N, no chip answering or a hung bus is printed once, in words, and playout carries on.
MIDI to VCV Rack on macOS. VCV's MIDI-CC > CV module reads 14 bit CC pairs when its 14 bit option is on, from the
IAC Driver bus (Audio MIDI Setup, IAC Driver, Device is online). macOS has no device file for MIDI, so Node cannot reach
CoreMIDI without a native module: --midi-cmd hands the bytes to a program that can. positron's rig/m1/midisend
reads text lines: --midi-cmd "./midisend 'IAC Driver Bus 1'" --midi-format text with CC or NRPN outputs (it has no
pitch bend line). A tool that reads raw MIDI on stdin takes --midi-format raw; none ships with macOS.
Stage 3: across the internet, through a relay
A sender and a receiver behind two home routers cannot reach each other directly; a relay with a public address forwards frames between them unchanged. Neither relay below is required, and the frame does not know which one it rides. They are adapters:
- positron's Cloudflare relay (a WebSocket room on a Durable Object, the edge nearest each end). Frames ride as binary WebSocket messages, one frame per message; MAP rides the same socket. Browser friendly, TCP only, so a lost packet delays everything behind it.
- v2in's UDP relay (one Node process on a server that takes UDP; each datagram carries the relay's own 8 byte key in front). The transport the measurements favour on a lossy line. Today it parses v2in's older frame (it reads the clock for its stale check and counts samples for its rate limit), so it needs this head before it can carry these frames.
An adapter is a few lines: open the relay's socket, send encode(frame) bytes, hand received bytes to decode. Over a
plain TCP socket or a serial line, wrap each frame with encodeStream and split the incoming bytes with
streamReader (SPEC.md 1.1). The relay never rewrites a frame, so the receiver's clock offset needs both legs (sender
to relay, relay to receiver; SPEC.md 5.4). The format has no authentication yet (extension type 1 is reserved for it),
so run on a trusted network or behind a relay that holds keys.
Layout
| path | what |
|---|---|
SPEC.md | the wire format, draft v1, and the owner's decisions on it (section 10) |
vectors/ | valid.json, skip.json, reject.json; make.mjs writes them from the spec's tables |
src/ | frame.mjs (encode, decode), map.mjs, batcher.mjs, clock.mjs, stats.mjs (REPORT), playout.mjs, receiver.mjs, osc.mjs, stream.mjs (byte stream framing), signals.mjs, limit.mjs (clamp and slew), midi-encode.mjs (MIDI bytes, the MIDI frame's message rules, raw MIDI input split into messages, the pages' parser); index.mjs exports these. Node only, not in index.mjs (the browser imports it): mcp4728.mjs (DAC over I2C), midi.mjs (MIDI out, the sinks) |
tools/ | send.mjs, receive.mjs, measure.mjs, bridge.mjs (with ws.mjs, a WebSocket server written by hand) |
web/send.html | the browser sender, served by the bridge |
test/ | node --test |
hardware/ | reference hardware for receivers and senders |
Hardware
DACs, ADCs and a reference board for turning samples into volts and back: hardware/README.md.
Licence
MIT, see LICENSE.
Homepage: https://voltergeist.positron.studio/, built from these files by node build.mjs into site/ and checked by node site-src/check.mjs.
Plugins
plugins/vcv/: VOLTERGEIST, a VCV Rack 2 receiver module on c/voltergeist.h, built in containers by plugins/vcv/build.sh.