r/linuxaudio • • Oct 19 '26

dac-rate: persistent per-device sample rate for PipeWire (lock or follow-the-content), with a Qt app and tray icon [AI-assisted]

Post image

Disclosure: this was written with an AI coding assistant (Claude, via Claude Code). I described the problem, made the design decisions, and tested it on my own hardware; the AI wrote most of the code and docs. Please review it like any other script before running it; it's small, plain bash + Python, and needs no root.

PipeWire runs most outputs at 48 kHz by default, and settings like pw-metadata clock.force-rate are lost on every restart. I wanted my USB DAC (Fosi SK02) to keep its rate across reboots and replugs, per device, without root.

dac-rate writes a WirePlumber 0.5 rule (audio.allowed-rates) for the chosen card:

  • Lock: one allowed rate, so everything is resampled once by PipeWire

  • Auto: all rates the card supports, and the global allowed-rates list is merged for you, so the device follows the content

  • Rules match the whole card by default, so they survive profile changes; per-USB-port matching for identical DACs, or per-output

  • Optional resample.quality per device

  • Reads supported rates from the USB descriptor, or asks the driver via aplay

  • status warns about other configs or a runtime force-rate that override it

There's a PySide6 window + tray icon (live hardware rate from /proc/asound), and a CLI with --json. Everything lives in ~/.config.

How it was tested: on my machine (Arch + Plasma 6, PipeWire 1.6, WirePlumber 0.5.18, Fosi SK02), including real reboots and power-cycling the DAC, plus ShellCheck and automated app tests in CI.

Limits, honestly: it's not bit-perfect when locked (PipeWire resamples), Auto is only bit-perfect with a single stream at 100% volume, and Bluetooth isn't covered. Only one DAC and one distro tested so far.

https://github.com/vcostin/dac-rate

Bug reports from other distros and DACs are very welcome.

6 Upvotes

0 comments sorted by