Enabling Interactive Music Performance in Web Browsers

Charles Klippel Neimog

Rodolfo Coelho de Souza

Motivation

  • Complex setups: interfaces, mics, powerful computers
  • OS incompatibilities
  • Composer/tech must be present to fix issues
Motivation Image Motivation Image

Example: Eco (2022)

Reality: slow Wi‑Fi, slow machines == unstable rehearsal, bad concert

Goal: ease and reliable performance

How to solve these problems?

  • Attempt to concentrate on the app on the smartphone.
  • WebAssembly experiments (C in the browser)
  • Piece: Moteto → worked (4 performances; 3 without me)
  • Catch: reimplement DSP (FFT/partials) by hand in C

From Empd to Pd4web

  • Empd: Pd→WASM, no GUI, manual compile, no externals
  • Pd4web: makes it usable for musicians (not only programmers)
  • Pd4web makes empd usable for musicians and AS musicians
  • One‑click deploy of Pd patches in browsers

What does Pd4web do?

  • Automated compilation
  • Detects/installs externals used in the patch
  • GUI + ready website templates

In short: deploy Pd patches with externals + GUIs, fast.

Key Advances: 1) Externals

More than 1000+ externals
  • 12 major libraries (e.g., else, cyclone) → 1000+ externals
  • Complex libs compiled (spatialization, partial-tracking, spectrum analysis.) Sparta

Key Advances: 1) Externals

2) Graphics with pdlua

  • Responsive GUIs
  • Runs smoothly on low‑cost smartphones
GUI

Key Advances: 1) Externals

3) Easy Integration with personal projects

  • Share pieces for rehearsal without installing Pd
  • No dedicated/expensive hardware required

Smartphone

Key Advances: 2) Accessibility

  • Technical: open in a browser; install as PWA (offline, auto‑updates)
  • Financial: runs on regular smartphones
iPad 1 iPad 2

Key Advances: 3) Preservation

Patch + externals + code in a single repository → easier to rebuild works later

Who Is It For?

Three main groups

  • 1) Performers (not just professionals).
  • 2) Composers who use Pd.
  • 3) Composers + Web Developers

1) Performers

Performer Performer Phone

2) Composers who use Pd

  • Composers that work with Pd: build with pd4web.compiler.
pd4web compiler
Templates

3) Composers/Programmers

Init

var Pd4Web = null;
Pd4WebModule().then((Module) => {
  Pd4Web = new Module.Pd4Web();
  Pd4Web.openPatch("index.pd", {
    canvasId: "Pd4WebCanvas",
    soundToggleId: "Pd4WebAudioSwitch",
    patchZoom: 2,
    projectName: "MyProject",
    channelCountIn: 1,
    channelCountOut: 2,
    sampleRate: 48000,
    renderGui: true,
    requestMidi: false,
    fps: 0, // browser chooses
  });
});
              
JS ↔ Pd

// Receive
Pd4Web.onBangReceived("r-test", (r) => console.log("Bang from", r));
Pd4Web.onFloatReceived("r-test", (r,f) => console.log("Float:", f));
Pd4Web.onSymbolReceived("r-test", (r,s) => console.log("Symbol:", s));
Pd4Web.onListReceived("r-test", (r,l) => console.log("List:", l));

// Send
Pd4Web.sendBang("s-test");
Pd4Web.sendFloat("s-test", 42);
Pd4Web.sendSymbol("s-test", "test");
Pd4Web.sendList("s-test", [1, "hi", "message"]);
              

Limitations

  • WebAudio latency ≈ 2–40 ms (device‑dependent)
  • WASM slower than native C

Examples

Improviso I Improviso I

Charles K. Neimog

cartoP5 cartoP5

Jean‑Yves Gratius

Examples

BiA BiA | pd4web
ml5 ml5 | pd4web
p5js p5js | pd4web

Future Projects

  • GaiaSenses (climate sonification)
  • VSAT‑AUDIENCE, Virtual Storytelling Application
  • Educational: BiA & Cartilha

Future Directions

  • Lower‑latency WebAudio on smartphones
  • Direct device‑to‑device collaboration
  • More templates for composers

Conclusion

  • Pd4web lowers technical & financial barriers
  • Usability, accessibility, preservation for live‑electronics
  • Already useful in performance, rehearsal, education

Thank you!