web: the browser pages
This page is web/README.md from the repository.
The three pages run here as they are in the repository. Links below join the relay
wss://ws.positron.studio in room vg-..., picked at random for you; open
send and receive with the same room.
- Send a test signal or a MIDI input
- Receive play it out to a MIDI output
- Pico cable to a Pico on USB, Chrome or Edge on a desktop
Two pages, no build step, nothing to install beyond Chrome:
send.htmlsends a test signal or a MIDI input (CCs, 14-bit CC pairs, pitch bend, notes) as voltergeist frames.receive.htmlplays frames out a fixed delay after their clock and sends them to a MIDI output: each channel as a 14-bit CC pair (coarse CC n, fine CC n + 32), a 7-bit CC or pitch bend, chosen per channel; notes and gates as notes. At most 500 values a second per channel (the "Max rate" box), and only when a value changes.
Both pages connect to their own origin's /ws by default, or to a relay room with
?relay=wss://ws.positron.studio&room=<room>. So they work from any static host, and from node web/serve.mjs.
| parameter | page | meaning |
|---|---|---|
relay | both | a relay base URL (wss://ws.positron.studio), or a full ws://host:port/ws |
room | both | the relay room; both pages must use the same one. Anybody who knows the name can join it |
delay | receive | playout delay in ms; default 20, or 80 over a relay |
cap | receive | max values a second per channel, default 500 |
mode | receive | hold (default) or interpolate across a lost sample |
source=midi | send | start with the MIDI input chosen |
start | send | start sending on load |
Before any test:
- Switch the IAC Driver on on the Mac that runs Live or VCV: Audio MIDI Setup, Window, Show MIDI Studio,
double-click IAC Driver, tick Device is online. Its port is
IAC Driver Bus 1. - Open the pages from https or from 127.0.0.1. Chrome gives Web MIDI only to a secure page, and asks once for
permission. In a clone of this repository,
node web/serve.mjsserves both pages athttp://127.0.0.1:8091/. - An output named Circuit is never listed, so the receive page cannot send to the Novation Circuit.
- One receive page per room. Every receive page answers the sender's clock pings, so a second one on another machine would mix its answers into the first one's clock.
- Watch age p95 and age max on the receive page: the delay must be above them, or late climbs and those samples
are not played. Raise
delayif it does.
Below, ROOM is any name you choose, for example vg-studio-7f3k.
a. Laptop test signal into Live on the M1, over the Cloudflare relay
- On the laptop:
node web/serve.mjs, then openhttp://127.0.0.1:8091/web/send.html?relay=wss://ws.positron.studio&room=ROOM&start. It sends four channels (ramp1, sine2, square3, ramp4), 1000 Hz. - On the M1:
node web/serve.mjs, then openhttp://127.0.0.1:8091/web/receive.html?relay=wss://ws.positron.studio&room=ROOM, allow MIDI, and choose IAC Driver Bus 1 as the MIDI output. The four bars move; ramp1 goes out on CC 1 and 33, sine2 on CC 2 and 34, and so on, MIDI channel 1. - In Live: Settings, Link Tempo MIDI, turn Remote on for the input IAC Driver (Bus 1).
- Map a knob. Press Cmd+M, click the device knob, press learn next to sine2 on the receive page (only that channel is sent while learn is on), press Cmd+M again, then press learn again to send every channel. If the knob moves in coarse steps, set that row to CC 7-bit on the page and map it again.
b. Live to the world: Live's MIDI out into the send page on the M1
- In Live, set a MIDI track's MIDI To to IAC Driver (Bus 1). Its clip's notes, CC envelopes and pitch bend go to the IAC bus.
- On the M1: open
http://127.0.0.1:8091/web/send.html?relay=wss://ws.positron.studio&room=ROOM&source=midi, choose the MIDI input IAC Driver Bus 1, press Start. Each CC becomes a channelcc<n>as it is first moved (14-bit when Live sends the fine CC n + 32 too), pitch bend becomesbend, notes become events. MIDI messages in counts what arrives. - On the laptop: open
http://127.0.0.1:8091/web/receive.html?relay=wss://ws.positron.studio&room=ROOM. The channels and the notes appear; a MIDI output there plays them on the laptop. A channel namedcc<n>goes back out as CC n. - Or into the Pi instead of the laptop. The relay is WebSocket and
tools/receive.mjsis UDP, so use the bridge. On the Pi runnode tools/receive.mjs --port 9100andnode tools/bridge.mjs --host 0.0.0.0 --to 127.0.0.1:9100. On the M1 openhttp://127.0.0.1:8091/web/send.html?relay=ws://<pi address>:8090/ws&source=midi.
c. Into VCV Rack on the M1
- Run the receive page on the M1 as in a, step 2, with IAC Driver Bus 1 as the output (the sender can be the laptop's test signal, or Live as in b).
- In VCV Rack, add the Core module MIDI-CC to CV: driver Core MIDI, device IAC Driver Bus 1. Click a slot, then press learn next to a channel on the receive page; the slot takes that CC. Each output is 0 to 10 V. If the module's right-click menu offers 14-bit CC, switch it on for the fine steps.
- Add MIDI to CV on the same device for notes (V/OCT, GATE, VEL) and pitch bend (PW).
d. Local only, one machine
node web/serve.mjs, then openhttp://127.0.0.1:8091/web/send.html?startandhttp://127.0.0.1:8091/web/receive.html. With norelayboth pages meet in the room local at/ws.- Or the UDP path:
node tools/receive.mjsandnode tools/bridge.mjs, then openhttp://127.0.0.1:8090/. The bridge carries one browser to one UDP receiver, soreceive.htmlopened from the bridge receives nothing.
Checking the pages
node web/check.mjs drives both pages in headless Chrome (muted, a temp profile it deletes) and checks the bytes
they produce, with no MIDI port: both pages through web/serve.mjs, the send page through tools/bridge.mjs to a
UDP socket, and both pages through the Cloudflare relay in a random room for a few seconds. --only local,
--only bridge or --only relay runs one of them, and --delay <ms> sets the relay run's delay.
../src/midi-encode.mjs holds the MIDI encoders and the input parser. src/midi.mjs imports Node modules, so a browser cannot
load it. The pure encoders belong in a browser-safe module that both import.