This project is an experiment in real-time music collaboration, leveraging the Web MIDI API and Web Audio API.
The stack uses WebSockets via Node.js to stream data from client to client. However, a faster P2P connection via WebRTC may be necessary (and is feasible now that Firefox and Chrome 31+ support SCTP-based reliable DataChannels[1]). The goal would be to reach a latency of less than 30ms, the bound of human perception.[2] Initial informal tests with WebSockets and Heroku do not meet this requirement due to latency and jitter, so stricter requirements may be necessary, e.g. WebRTC, low latency connections, P2P within a metropolitan area network or Internet2, etc.
+---------------------------+ +--------------+ +---------------------------+
| Client 1 | | Server | | Client 2 |
|---------------------------| |--------------| |---------------------------|
| +-------------+ | | | | +--------+ +-------+ |
| | Web MIDI IN |------------------------------------->| Soft |--->| DAC | |
| | Drum machine| | | | | | | synths | | OUT | |
| +-------------+ | | | | | +--------+ +------ + |
| v | | WebSockets | | ^ |
| +-------+ +--------+ | | | | | +-------------+ |
| | DAC |<---| Soft | | | | | | | Web MIDI IN | |
| | OUT | | synths |<-------------------------------------| Keyboard | |
| +-------+ +--------+ | | | | +-------------+ |
+---------------------------+ +--------------+ +---------------------------+
- Clone repository:
git clone https://github.com/vine77/midisocket.git; cd midisocket;
- Install dependencies:
npm install
- Start server:
node server
- Plug in a MIDI controller
- Browse to http://localhost:5000 with Google Chrome