Show HN: Roc – Real-Time streaming over the network
gavv.github.io
gavv.github.io
I'll definitely be giving this a go!
[0] https://github.com/badaix/snapcast [1] https://github.com/librespot-org/librespot
> Research. Learn to measure the full network latency, test Roc on different network types and conditions, determine the minimum possible latency that we can handle on different channels.
It sounds like latency is unknown, but my guess is that it’s comparable to RTP plus a few extra milliseconds to handle error correction and a constant latency.
Most likely you will be able to achieve lower latencies on a better channel, but I did no serious testing for lower latencies yet. This is in my to-do list.
You could connect multiple clients to stream music to a single server (or multiple servers if you wanted to); the server kept a list of pending audio buffers for each client, mixing them all together into a ring buffer that gets spat out to portaudio. If a client underran, it simply missed that ring buffer rotation, and it "fell behind" by one buffer length (we request the minimum latency from portaudio, so this is usually measured in single-digit milliseconds). That would cause a few crackles and pops in the first second or two as the natural jitter of the network caused the client to underrun a few times, but then it would stabilize. (This didn't bother me much, as I usually was playing silence when I first connected it in any case).
In my experiments, the overall system latency was pretty close to the perceptual limit, I would estimate around 10ms, streaming over wifi from my laptop to a raspberry pi.
https://roc-project.github.io/roc/docs/manuals/roc_recv.html
You can as well configure the FEC block size (it should be smaller than the target latency), the length of network packets, the length of internal audio frames in the pipeline, and the resampler window. And also the I/O latency, e.g.PulseAudio buffer size. So basically you can configure all (or almost all) parameters that can affect the resulting latency.
I'll document these parameters and their configuration a bit later. (Currently you can find all of them in the man-page in in the API, but there is no overview page that explains how exactly do they affect the total latency).
It's actually pretty great, most of the time there's no need for a separate API just to handle streaming. It "just works."
My guess is that this is more an application toolkit for home/consumer applications instead of professional use, but a lot of the problems they have listed on their roadmap are already solved through a family of open* standards. The name escapes me but there's an industry initiative to provide FOSS APIs on top of web tech to build these kinds of applications. Engineering manager from Fox/Disney gave a talk about it last month (maybe it was march?) at the LA SMPTE meeting. Lots of money is going into this domain.
* with an AES membership, but you should have that for this kind of project anyway