The RCWeb Drums App (app/drums) is a real-time collaborative drum machine within the RCWeb ecosystem. It demonstrates the Symmetric Pattern, allowing multiple users in the same virtual room to simultaneously view and edit a shared 16-step sequencer.


The core logic is structured inside script.js which integrates comms.js with the standard browser Web Audio API.
XMLHttpRequest and decoded into audioContext. Playback is precisely managed using a "lookahead" timer (scheduler and scheduleNote methods) which queues audio sources slightly ahead of real-time to avoid browser-related timing glitches.toggleBeatAndBroadcast), the UI updates locally immediately. The app then invokes a remote function call (rc.sendFunctionCall("drums", "drums.setBeatNetwork", row, col, newState)) which triggers the identical grid update on remote peers.receivePing / receivePong) to measure the round-trip latency of all connected clients. It calculates the maximum delay and issues a delayed start command (remotePlay(waitTime)) so that devices further away start immediately while local devices wait, aligning the first beat.handleClientUpdate() block maintains an alphabetically-sorted list of peers (connectedPeers). When an audio note triggers, scheduleNote checks if (instrumentIndex % N === myIndex) (where N is the number of users). If true, the note plays on the local device; otherwise, it is skipped.