@m4l-jweb/bridge
v1.6.1
Published
m4l-jweb: the browser-side bridge connecting a device's web UI to Max for Live.
Readme
@m4l-jweb/bridge
The browser half of a device. Your React UI runs inside [jweb~], Max's embedded Chromium; this is how it talks to the Max patcher around it - messages out, messages in, MIDI, clip I/O, and files.
Part of m4l-jweb - build Ableton Live devices (.amxd) from a TypeScript repo: React UI, LiveAPI glue, CI builds, no Max editor.
Install
pnpm add @m4l-jweb/bridgeUsage
import { bindInlet, outlet, onNote, onNoteOff, sendNote, uiReady } from "@m4l-jweb/bridge";
// Tell the wrapper the page is up, and ask for current state.
uiReady();
// Incoming MIDI (needs the `midiin` chain). Both binders share one subscription.
onNote((pitch, velocity) => voiceOn(pitch, velocity));
onNoteOff((pitch) => voiceOff(pitch));
// Outgoing MIDI (needs the `midiout` chain). Max applies the delay, not the browser,
// so note timing does not depend on a Chromium timer.
sendNote({ pitch: 60, velocity: 100, durationMs: 250, delayMs: 80 });
// Anything else you route yourself.
bindInlet("tick", (playing, beats) => setTransport(Boolean(playing), Number(beats)));
outlet("my_selector", 1, "two");Notes
- Audio does not go through here. Under
[jweb~]the page's Web Audio output is carried on the object's signal outlets, straight into the track. The bridge is a control plane; sound never crosses it as messages. fetchToFile()andsaveToFile()move bytes between the page and disk via Max's[maxurl], so large files never travel through the message bridge either.tapMessages()observes every message in both directions - the whole contract of a device, live.copyPath()answers "where did my file go". Nothing in Max can open a file manager, and inside[jweb~]a clipboard write can be claimed but never confirmed - so the result iscopied/manual/cancelled, never a boolean that might be lying.
Requirements
Ableton Live 12 with Max 9. Devices are built on [jweb~], the browser view with signal outlets; older hosts are unverified.
Links
License
MIT
