For the previous post of setup Karaoke with Sonos Beam, there’s a Raspberry with Behringer USB audio interface to do the ADC job. Because the digital Toslink only outputs signal when it’s driven to do so, some high level audio stack would be needed.
PulseAudio is the simplest option. Just install it and add a loopback module, which will automatically direct audio from input ports into output ports. But the audio latency is non-negligible, up to almost 600ms or more, causing some quite annoying echo effect. After some googling, there’s a startup param “latency_msec” to reduce it a bit. But the delay of the sound is still audible, as PA is stream based, so some stream buffer is always there.
Therefore, Jack audio system will be the final choice, which claims to be realtime. However, the qjackctl config app for Jack is QT based, requiring X window to show properly. This article guides how to autostart qjackctl with LXDE. And this one will auto run graph with patchbay upon qjackctl running.
Now the latency is much better. Although no measurement directly, it might be around 20ms, so that the voice sound seems instantly played.