Skip to content

Audio groups, stage 1: Discord as a stream of its own (server 0.3.37, client 0.1.37) - #93

Merged
NickMarcha merged 1 commit into
mainfrom
audio-groups-comms
Nov 23, 2026
Merged

NickMarcha merged 1 commit into
mainfrom
audio-groups-comms

Conversation

@NickMarcha

Copy link
Copy Markdown
Owner

Stage 1 of audio groups: Discord can go to the hub as its own stream, so stage 2 can give it its own volume, mute and pan, and stage 4 can record it as its own track.

Windows tray (0.1.37)

  • Audio/AppCapture.cs: Windows' process loopback (ActivateAudioInterfaceAsync on VAD\Process_Loopback, Windows 10 2004+). NAudio 2.2.1 has the types but no public way in, so it's direct interop.
    • It finds Discord's root process (a Discord.exe whose parent isn't one) every 2 s and captures that process and its children.
    • It downmixes to mono, about 0.8 Mbit/s, and sends VBAN as <main stream>Comms (SageAudioComms on sage).
    • It notes which devices Discord has active sound sessions on.
  • Audio menu:
    • "Send Discord on its own (mono)", off by default.
    • A status line: "Discord ■■□□□ on its own" / "silent" / "not running".
    • A warning when Discord also plays on the device the desktop stream captures, or into Voicemeeter, so you'd hear it twice.
  • The tray sends audio_groups ({"comms": "SageAudioComms"}, or {}) after each hub message and whenever the setting changes.

Hub (0.3.37)

  • peers.set_group_streams stores group_streams per VBAN peer and validates the names: only known groups, VBAN's 16 bytes, and no clash with any stream.
  • The VBAN receiver gets a rule per group stream, which makes <name>-comms-incoming-source. WirePlumber plays it on the headset like the main stream. The config is rewritten only when the groups change.
  • load_peers skips keys it doesn't know, so an older Bragi still starts on a newer peers.yaml.

Checked before writing it, with a prototype on sage:

  • Process loopback caught a 440 Hz tone at full level from a device turned down to −96 dB (99% of the energy at 440 Hz).
  • With no tone, the capture was silent.
  • Capturing Discord's process works.
  • The exclude mode ("everything but X") also picks up Voicemeeter's replay of everything, so the desktop stream stays an endpoint loopback.

Tests

  • pytest 502 passed (Linux): the group stream and its node, validation, no rewrite when unchanged, audio_groups over the peer socket, and a peers.yaml with unknown keys.
  • dotnet test 145 passed: finding the root process and its tree, mono downmix and peak, stream name length, an older audio.json, and the menu lines.

Not yet heard end to end; that needs Discord playing something on sage.

🤖 Generated with Claude Code

Windows tray (0.1.37): "Send Discord on its own (mono)" captures Discord
by process (process loopback, Windows 10 2004+: what a process tree plays,
on any device, before the device's volume) and sends it as a second VBAN
stream, <main>Comms, in mono. Off by default. The menu shows its level
and warns when Discord also plays on the captured device or into
Voicemeeter, where it would reach the headset twice. The tray tells the
hub its groups with audio_groups after each hub message and on change.

Hub (0.3.37): peers.yaml keeps group_streams per VBAN peer, and the VBAN
receiver gets a rule per group stream, making <name>-comms-incoming-source,
which WirePlumber plays on the headset like the main stream. load_peers
now skips keys it doesn't know, so a downgrade still starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NickMarcha
NickMarcha merged commit b387b3f into main Nov 23, 2026
@NickMarcha
NickMarcha deleted the audio-groups-comms branch November 23, 2026 04:07
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