Live Audio over SSH

Preface

Rather than having a second monitor connected to my laptop, I use 2 laptops simultaneously. The problem with this is if there is audio playing from both computers, it must be "down mixed" to play on, for instance, 1 pair of Bluetooth headphones.

This is a little driver I wrote as a Bash script to do just that. Of course, both computers are connected to the same LAN so initially it simply piped unencrypted audio using BSD's netcat tool, however later I made and tested a proof of concept that uses the SSH protocol encrypted over the internet to send live audio from one computer to another.

The result is I can now work on video editing on the main laptop while watching YouTube on the second laptop, and hear both at the same time in headphones connected to only the main laptop. In reality, there are countless uses for mixing down audio from two devices simultaneously.

Technologies

Source Code

The source code is dependent on the platform and audio hardware used, but can be easily modified to fit most configurations

Additional PipeWire arguments for latency, audio fidelity, device selection can be used to tweak the script

A virtual audio sink (output device) can be created on the second computer in order for each application to output the audio directly into this driver if all other audio output devices are turned off or don't exist

Efficiency: While running, the LAN version of this driver uses an incredible 0.2% of the CPU (or just 1% of a single core on this netbook) and around 1.7 MB of RAM
(The 2 pw-cat below are just diagnostic processes used to visually verify that audio is being sent, and do not have to run when using the driver normally)

Let's see it in action

In this video