Hey all, I put this together over the holidays after initial tests showed that delay around 10-20ms was achievable with WebRTC. The jams are only 2 person and only MIDI, but for that reason it's also fairly flexible and requires little set up compared to other options (see https://github.com/jminjie/fourhands for discussion on prior art)
Nice! Really similar to something I’m working on, though I am targeting music lessons instead of jam sessions. I decided to add delay to schedule note rendering as you mentioned you do for another project of yours, since “near real time” has proven useful enough for quick communication during lessons.
I think it’s cool we had the same idea, very validating and p2p is such an interesting technology to me!
This seems to be using a central server as a relay (which is why they can have n participants). It works pretty well but the latency tends to be too high to actually jam. (Similar to my toy example at piano.jminjie.com)
After months of really bad audio in teleconferencing calls, hearing crisp keyboard playback was a refreshing experience. Highly recommend to check out the demo!
Since webrtc uses UDP jitter is occasionally an issue. If you monitor the ping on the site you'll likely see occasional jumps to 100-200ms every once in a while. These can cause irregularities in the rhythms but for the most part you can still make out the phrase even when there's jitter. (I think this is kind of like how we can read those scrambled word sentences because we read not letter-by-letter, but word-by-word.)
For a jitterlesss demo you can also check out piano.jminjie.com (central server, not p2p), where I've introduced an artificial delay so that the notes can be snet with timing info, and scheduled ahead of time to avoid jitter.
Latency can also impede a smooth jamming experience, but seems to be manageable in general when it's under 20ms one-way delay (I have been able to achieve this on a wired connection at 50 miles distance in the middle of the day). There's also relationship between bpm of the song and acceptable latency similar to the concept behind sampling frequencies (https://en.wikipedia.org/wiki/Sampling_(signal_processing)). The faster you're playing, the more latency matters.
Given that MIDI expects 100% reliable delivery, I'm curious to know if there's any special technique used here to prevent (e.g.) intermittent packet loss causing stuck notes.
From testing you don't tend to get stuck notes (though in theory this could happen if a note-up command was lost forever and never sent), though you do see some jitter.