“I was familiar with Voice over IP (VoIP) from previous experience and decided to try to build something with latency low enough to allow you to play as a group online,” says Mike. “When I saw that Raspberry Pi OS was just another Debian distro, I realised my laptop Linux code would compile and run on the Pi.”
To work properly, RT Jam would need a person-to-person latency of less than 25 milliseconds. “I was leery of a peer-to-peer product because of the many issues with network firewalls, so I decided to opt for a client/server type structure,” Mike explains. However, “large variances” in sound, the input-output performance on Linux, Windows, and macOS made a software-only solution “very troublesome”, he says. “Raspberry Pi gave me a turnkey solution.”
Mike realised his 4GB Raspberry Pi 4 could be also used to run the broadcast server, including NGINX, and applauds the ability to install so many standard packages so easily. “Compiling the code on Raspberry Pi was very straightforward.”
Sound and vision
Before he began working on RT Jam – he describes the “want level” as a silver lining born of necessity – Mike had tried out Raspberry Pi for a putative HearSee project (also on GitHub) in which ultrasonic range sensors on a handheld stick convert distance readings into a sound form that would allow you to ‘see’ with your ears. That project is on hold, but it acted as an excellent demonstration of Raspberry Pi sensors’ capabilities. “Raspberry Pi worked great for hooking up the sensors and creating the sound,” he says. However, low-latency audio would work with Raspberry Pi only when using a USB 2.0 device for both input and output. He chose a FocusRite Scarlett controller, which he loves for its aesthetics as well as its performance.
Mike began by using DISTRHO/DPF, a software framework for audio plug-ins, using which he was able to program all the audio I/O via jack. He had help from falkTX who had been working on this framework for some time.
The design for the VoIP elements was Mike’s own. “I have done this kind of stuff before, so it was not too hard,” he says, “but I had not written any C++ code for 20 years, so I was a bit rusty. I’m sure if somebody looks at the code (it’s open-sourced), they will find lots of things to laugh at!”
“Once Mike realised that Raspberry Pi OS was simply a Debian distro, things slotted into place and RT Jam began to take shape.”
One of the challenges was to get Raspberry Pi’s touchscreen working right and to figure out the settings for real-time audio. Once he was happy with everything, Mike simply copied it all as a microSD image.
He’s keen to develop RT Jam, adding capacity for more musicians to jam along. “I also want to hook up an Icecast feed from the server so even people who don’t have the software can just listen to a live broadcast of the room feed.”