voelin-audio: dim everyone else while a priority speaker talks

The server sends virtualserver_priority_speaker_dimm_modificator (-18 dB
by default) but nothing read it. ServerDetails carries it now, the
session tells the audio thread the priority speakers when they or the
value change, and the mixer dims every other queue (watched streams too)
while an unmuted priority speaker has one, fading sample by sample over
5 frames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-06 18:59:23 +00:00
1 parent 8b605b5b45
commit 92f4416934
8 files changed
+364 -20

No files matched your search

+6 -5
View File
@@ -156,11 +156,12 @@ description, talk power, channel group, server groups, badges, icon, away
message, mute, talk, recording and stream flags; per server
(`Presence::server`, `ServerDetails`) the welcome and host message, host
banner (link, image, reload interval, scaling), host button, icon, unique id,
platform and version; the server and channel groups (name, icon, sort id,
naming mode, type). `Event::Presence` carries all of it; `Event::ServerDetails`
and `Event::Groups` come when those parts change. Gateway and query presence
fill what their rows have. The new fields are optional in JSON, so gateways
and clients of different versions still understand each other.
platform, version and priority speaker dimming; the server and channel groups
(name, icon, sort id, naming mode, type). `Event::Presence` carries all of it;
`Event::ServerDetails` and `Event::Groups` come when those parts change.
Gateway and query presence fill what their rows have. The new fields are
optional in JSON, so gateways and clients of different versions still
understand each other.
## Files, avatars and icons
+17 -6
View File
@@ -4,7 +4,8 @@
microphone ─ cpal ─ resample 48 kHz mono ─ Processor (AEC3, NS, AGC2) ─ 20 ms frames
─ Vad / push-to-talk / continuous ─ Opus ─ voice connection
voice connection ─ Mixer (jitter buffer, Opus decode, per-client volume/mute)
voice connection ─ Mixer (jitter buffer, Opus decode, per-client volume/mute,
priority speaker dimming)
─ output volume ─┬─ resample to device ─ cpal ─ speakers
└─ Processor::render (echo canceller reference)
```
@@ -51,11 +52,12 @@ two 20 ms frames before the gate opened are sent too, so onsets are not cut.
## Jitter buffer and clock drift
`Mixer` wraps the vendored `tsclientlib::audio::AudioHandler` (one queue per
talker) and adds per-client volume and mute. The handler absorbs sender clock
drift: an underrun plays Opus loss concealment for the missing frame (one inserted
frame, and the talker is dropped after three in a row), and when the smallest
queue length over the last 255 packets exceeds its spread, it drops every 100th
sample (1 % faster) until the surplus is gone; queues above 0.5 s are truncated.
talker) and adds per-client volume and mute, and priority speaker dimming. The
handler absorbs sender clock drift: an underrun plays Opus loss concealment for
the missing frame (one inserted frame, and the talker is dropped after three in a
row), and when the smallest queue length over the last 255 packets exceeds its
spread, it drops every 100th sample (1 % faster) until the surplus is gone;
queues above 0.5 s are truncated.
`crates/voelin-audio/tests/drift.rs` simulates one hour of continuous speech with
20–60 ms network jitter, reordering and 0.5 % loss, with the sender clock at
@@ -87,6 +89,15 @@ ids are reused, so the session forgets the settings of clients that left.
Watched streams play through the same mixer under made-up client ids (counting
down from 65535) with their own volume (`SetStreamVolume`).
While a priority speaker has a queue (talking, or buffering before it plays)
and we have not muted it, every other queue, streams included, is dimmed by the
server's `virtualserver_priority_speaker_dimm_modificator`
(`ServerDetails::priority_speaker_dimm_db`, usually -18 dB, clamped to
-60..=0). The dimming fades in and out sample by sample over 100 ms (5 frames),
so the gain does not jump; priority speakers are never dimmed. The session sends
the priority speakers and the server's value to the audio thread when either
changes (`Mixer::set_priority`).
Push-to-talk works with the button in the window and a global hotkey
(`voelin_platform::HotkeyManager`: the portal on Wayland, XInput2 on X11, a hook on
Windows), configurable as e.g. `Ctrl+Shift+T`.