Skip to content

Mixer on Linux (PulseAudio / PipeWire-Pulse) - #14

Merged
PalmarHealer merged 1 commit into
mainfrom
feature/linux-mixer
Nov 12, 2026
Merged

PalmarHealer merged 1 commit into
mainfrom
feature/linux-mixer

Conversation

@PalmarHealer

Copy link
Copy Markdown
Contributor

What this adds

The software mixer from #13 now runs on Linux (PulseAudio and PipeWire-Pulse). It needs no virtual-cable driver.

It uses pactl, parec and pacat, which come in the same pulseaudio-utils package Slidr already requires. This keeps the binary free of native audio libraries, in line with the existing audio/pulse.rs.

Windows Linux
Process loopback per program Each channel is a null sink slidr_mixer_ch_<id>. Its programs are moved there with move-sink-input, and its monitor is recorded with parec.
Reroute to a silent output Moving the program into the channel's sink already takes it off the speakers. With "Replace original" off, a module-loopback also plays the original.
VB-CABLE as the Slidr Mic A null sink the mic bus plays into, plus a module-remap-source named Slidr Mic.
WASAPI output on the default device One pacat stream on the default output, which follows default changes.

Clocking. The played streams run on the wall clock. Each pactl list sink-inputs scan (once a second) reads their "Buffer Latency". When a stream drifts, Slidr drops or doubles a block to keep it about 40 ms ahead of the device.

Restore and crash safety. Every module Slidr loads has slidr_mixer in its arguments. Unloading a null sink moves its streams back to the default output, so all of these are "unload ours":

  • switching the mixer off (after the power-off sound)
  • quitting
  • cleaning up at the next start after a crash

Shared with Windows. The engine, effects, switch sounds and microphone channels are shared code. The Settings "Mixer devices" card and the VB-CABLE hint only show on Windows.

How it is built and tested

  • Builds everywhere. src/mixer/pulse_io.rs uses only std::process, so it compiles on every platform. It is type-checked and unit-tested on Windows too; only Linux starts it (mixer::spawn).
  • New unit tests:
    • parsing sink-input sink, media.name and buffer latency
    • short lists, and finding leftover modules
    • stream ↔ program matching
    • never moving Slidr's own streams
    • module arguments
    • the drift controller
  • Totals. cargo test: 101 pass, 1 ignored.
  • Not yet run on a real Linux desktop. I only had a Windows machine. Before merging, someone should check on Linux (PipeWire and, ideally, plain PulseAudio):
    • switching the mixer on creates the "Slidr " outputs and the "Slidr Mic" input
    • programs move into their channel and are heard through the mix
    • levels, mutes, effects and the Slidr Mic work in a voice chat app
    • with "Replace original" off, the original plays and the mix is used only for the Slidr Mic
    • a microphone channel records the chosen mic
    • switching off and quitting put everything back
    • after kill -9, the next start removes the leftover devices
    • the mix doesn't drift out of sync over a longer session

🤖 Generated with Claude Code

The mixer now runs on Linux too, driven through pactl, parec and pacat
(pulseaudio-utils, already required), so the binary links no audio library.

- Each channel is a null sink; its programs' streams are moved there and its
  monitor is recorded. With "Replace original" off a loopback plays the
  original as well.
- The mix plays on the default output and follows it; a null sink plus a
  remapped source named "Slidr Mic" replace VB-CABLE.
- Played streams run on the wall clock and hold ~40 ms of lead from their
  reported buffer latency.
- Everything Slidr loads carries `slidr_mixer` in its arguments: switching
  off, quitting and cleaning up after a crash unload it, and the sound server
  moves the programs back to the default output.
- Engine, effects and switch sounds are shared with Windows. The Mixer
  devices card and the VB-CABLE hint are Windows-only.

The module builds on every platform (std::process only) so it is
type-checked and unit-tested on any host; only Linux starts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PalmarHealer
PalmarHealer merged commit 12534d1 into main Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant