Routing Linux audio between programs and computers

Summary

On Hackaday, Al Williams describes how he routes the audio output of one program into the audio input of another on Linux. The reason was remote operation of his amateur radio station, whose digital modes such as FT8 expect software with a sound card. With PipeWire, the qpwgraph interface and a device created with pw-loopback, he connects radio and decoder permanently.

Why a loopback device is needed

PipeWire and PulseAudio show an output only while a program actually produces sound; afterwards the source disappears from the graph. A permanent connection cannot be drawn that way. Williams therefore uses pw-loopback to create a device that appears as both a sink and a source and is always present.

The command pw-loopback -n radio-in -m '[FL FR]' --capture-props='[media.class=Audio/Sink]' --playback-props='[media.class=Audio/Source]' creates a stereo sink without connections. Whatever a program sends into it appears at the output and goes on to the radio.

The wiring in the graph

In qpwgraph, Williams draws lines between the blocks: the radio's speaker output goes both to his own speakers and to the input of JTDX, so he can listen while the program decodes FT8. When transmitting, the JTDX output appears only briefly and feeds the loopback sink.

Other routes lead to the same goal: pw-link on the command line, pactl with module-loopback under PulseAudio, or the ALSA module snd-aloop.

Ideas

  • Digital radio modes expect audio from a sound card, not from the network.
  • Transient audio streams disappear from the graph as soon as they fall silent.
  • A loopback device creates a fixed connection point for changing programs.
  • PipeWire presents itself to older programs as PulseAudio.
  • Named blocks in the graph make troubleshooting easier.
  • With socat, audio can also be routed across the network.

Insights

  • Fixed virtual devices make dynamic audio paths predictable.
  • Remote desktop access is often unsuitable for clean, low-latency audio.

Facts

  • ALSA is the lowest common layer of most Linux audio systems.
  • pw-loopback creates a pair of sink and source.
  • Under PulseAudio, module-loopback loaded via pactl does the same.
  • The kernel module snd-aloop provides loopback devices at ALSA level.

References

Critique

  • According to Williams, qpwgraph forgets assigned block names after disconnecting; the article does not describe a permanent configuration file, although the PipeWire wiki shows one.

Remarks

  • The bk99 project hAudio solves a related problem by routing audio between two computers (post “hAudio 0.04: audio routing for two computers”).

Recommendations

  • Create fixed loopback devices as PipeWire configuration so they survive a reboot.
  • Give nodes in the graph meaningful names before the wiring grows.
  • Test audio paths locally first before extending them across the network.

Read the original article

Search the Web Archive

Found a mistake or have something to add? Get in touch.