ArkencyMaciej Korsan7 min readintermediate
TERAZ - live collective ambient experience made with Rails & Tone.js
Summary
TERAZ is a live ambient music piece where each audience member's phone plays a locally generated instrument via Tone.js, coordinated by a Rails Action Cable server that only sends lightweight control messages. The author shares practical lessons about mobile audio quirks, device heterogeneity, and scaling the system to dozens of phones.
- Use Rails Action Cable + Hotwire to broadcast minimal control data (track activation, volume) instead of streaming audio.
- Generate sound on each device with Tone.js; reserve pre‑loaded samples (e.g., piano) for CPU‑heavy instruments.
- A silent MP3 loop can keep the JavaScript audio context alive on mobile browsers, though it may introduce artifacts.
- Android phones often lack low‑frequency output; monitor device OS and reassign instruments (e.g., move bass off Android).
Engineers building real‑time, collaborative web experiences on heterogeneous mobile devices will benefit from the practical scaling and audio‑handling lessons.
6/10

