- Rust 97.3%
- Shell 2.7%
Cargo.toml has said MIT all along, but there was no LICENSE file to carry the notice; the PKGBUILD now installs it where Arch expects licenses. The starter config pointed new installs at 192.168.1.100, an address on a network that no longer exists and means nothing to anyone else. It is a placeholder the README says to fill in, so it now reads as one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| packaging | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| PLAN.md | ||
| README.md | ||
AudioSBC desktop
Streams this machine's audio to the STM32MP157 whole-house audio board, and drives the board's MQTT control surface: which rooms play it, their volume and mute, plus a click-to-talk intercom.
It replaces rtp-send.sh, and configures itself. Room names, volume ceilings,
the board's address, the RTP format and which UDP port to send to are all
discovered from the board at runtime — the only thing you have to supply is
how to reach the MQTT broker.
What it does
applications ──► "AudioSBC" virtual sink ──► Opus ──► RTP ──► board:50xx
│
MQTT ◄── rooms, volume, mute, health, receiver slot ──────────────┘
- Self-configuring. Subscribes to the board's topic tree and builds its whole picture from retained state.
- Claims a receiver. The board keeps a pool of five receivers rather than one hardwired per machine. The app claims one on connect and gives it back when it closes — or when it crashes, via an MQTT last will, so a slot is never stranded.
- A real virtual sink. "AudioSBC" appears in your sound settings like any
other output; route any application to it. It is a
module-null-sink, unloaded when streaming stops, and any left behind by a crash are swept up on the next start. - Buffer for WiFi. A tickbox that asks the board how much to buffer our receiver: 20 ms on a wired link, which is about 115 ms end to end, or 800 ms to ride out the radio dropping out while you carry a laptop downstairs. It is per machine, so one laptop choosing a deep buffer does not slow anyone else down. Switching restarts the receiver, so expect a short gap.
- Intercom. Pick a room, click Talk, speak, click again. The button
latches down and turns red while the microphone is open. Music playing into
that room ducks while you speak and returns to exactly its previous level.
Turn the whole feature off with
intercom.enabled = false, which also stops the app claiming a second receiver slot it would never use.
Installing
Arch
cd packaging && makepkg -si
Debian 12+ / Ubuntu 22.04+
./packaging/build-deb.sh # needs podman or docker
sudo apt install ./dist/audiosbc_*.deb
The .deb is deliberately built inside a debian:12 container. A binary
linked against Arch's much newer glibc will not start on Debian or Ubuntu;
building against the oldest glibc in scope means one package runs on all of
them.
From source
cargo build --release && ./target/release/audiosbc
Needs GTK 4.6+, GStreamer with gst-plugins-base, gst-plugins-good, and
gst-plugin-pipewire — that last one provides pipewiresrc, which is
what creates the virtual sink. Without it the app starts but can never stream.
First run
A starter config is written to ~/.config/audiosbc/config.toml (mode 0600).
Fill in the broker details and restart:
[broker]
host = "mqtt.local"
username = "..."
password = "..."
Everything else has a working default. The broker password is stored in the
clear, matching how the board's own homeaudio.yml treats it — scope that
account to the homeaudio/# tree and do not reuse the password.
Checking it without a GUI
audiosbc --probe # claim a slot, print what the board advertises
audiosbc --stream 30 # claim, create the sink, stream for 30 seconds
--stream deliberately does not route to any room, so testing never
switches an amplifier on. Play something into the "AudioSBC" sink while it
runs to push real audio through.
Only one instance at a time
Two copies sharing a config share its client.uuid, and everything hangs off
that: the MQTT client id, the presence topic, and the receiver slot the board
grants. Two instances therefore fight over one broker session and stream RTP
to the same UDP port, which the board's receiver hears as two interleaved
packet streams — it sounds like the audio is falling apart.
So a second copy refuses to start and says so. Launching the app again just raises the window that is already open.
To run a genuine second instance — testing, or a second identity on one machine — give it its own config:
AUDIOSBC_CONFIG=~/other.toml audiosbc
Advanced settings
Everything tunable lives in config.toml. The defaults match the values
rtp-send.sh used, which are known to work on this hardware.
| Key | Default | What it does |
|---|---|---|
encoder.bitrate |
500000 |
Opus bitrate, bits/s |
encoder.frame_size_ms |
10 |
Opus frame size; smaller is lower latency |
encoder.queue_ms |
10 |
buffering ahead of the encoder |
encoder.latency_offset_ns |
25000000 |
latency the virtual sink reports |
latency.low_ms |
20 |
board jitter buffer in "low latency" mode |
latency.buffered_ms |
800 |
board jitter buffer with "Buffer for WiFi" ticked |
intercom.enabled |
true |
offer the intercom at all; off hides the section |
intercom.bitrate |
64000 |
voice needs far less than music |
intercom.duck_by |
10 |
volume points to drop while talking |
intercom.duck_enabled |
true |
duck the music at all |
client.name |
hostname | becomes the device id on the board |
client.name is worth setting to something you will recognise: the board
names your receiver after it, so it is what shows up in hactl slots and in
anyone else's copy of this app.
Volume, and why the sliders stop early
Each room has a max_volume ceiling on the board (currently 50) and the
board silently clamps anything above it. The sliders here stop at the
discovered ceiling instead, so a control never looks like it is being ignored.
The scale is steeply non-linear, which is worth knowing before raising a ceiling:
| volume | 0 | 5 | 15 | 25 | 40 | 50 | 75 | 100 |
|---|---|---|---|---|---|---|---|---|
| dB | mute | −78 | −49 | −36 | −25 | −18 | −7 | 0 |
50 → 75 is 25 points but 11 dB.
How it talks to the board
The claim protocol and every topic are documented in the board repository's docs/mqtt.md. The short version:
client/{uuid}/status retained presence, and the connection's LAST WILL
client/{uuid}/claim {"name": ..., "roles": ["stream", "intercom"]}
client/{uuid}/grant {"stream": {"device": ..., "udp_port": ..., "slot": ...}}
device/{id}/zones the rooms to play into - a replace, not an add
device/{id}/start "1" / "0"
zone/{id}/volume a bare integer
The will sits on the presence topic rather than on the claim because MQTT fixes the will at connect time, and you cannot know which slot you will be given until after you have connected.
Status
Working: discovery, slot claiming, streaming, room routing, volume and mute, click-to-talk intercom with ducking (optional), health display, a tray icon with start-on-login, and packaging for Arch, Debian and Ubuntu.
Not done yet: a preferences dialog. Advanced settings are edited in
config.toml for now, and take effect on restart.
The tray uses StatusNotifierItem, which Plasma supports natively. On GNOME it needs the AppIndicator extension; without a status-notifier host the icon simply does not appear and everything else still works.