feat(client): synthesized notification sounds with settings

Short tones for joining and leaving a voice room, other participants
joining and leaving, new messages outside the viewed chat, mentions,
microphone mute and unmute, deafen and undeafen, server connection and
loss, and errors. The tones are generated at runtime (rising motifs for
arrival or enable, falling for leave or disable) with an attack and a
fade-out so they never click; no third-party audio is bundled.

Inside a voice room the sound is mixed into the open playback stream,
otherwise a short one-shot stream is opened on the selected output device
off the UI thread, capped at two at a time. While deafened nothing plays
except the undeafen sound. Settings: master switch, volume and separate
switches for voice room, messages and mentions, stored with the audio
preferences, with a new settings section and a test button.
This commit is contained in:
Loki 2026-10-25 10:01:38 +01:00
parent bf485720f5
commit eed3e28c63
Signed by: boba
GPG key ID: 253067914055423B
19 changed files with 1142 additions and 4 deletions

View file

@ -11,6 +11,7 @@ use tracing::info;
use tracing_subscriber::EnvFilter;
use vnox_client::audio::AudioPipeline;
use vnox_client::audio::PipelineConfig;
use vnox_client::audio::sounds::SoundEvent;
use vnox_client::identity;
use vnox_client::net;
use vnox_client::net::NetCommand;
@ -154,7 +155,7 @@ fn refresh_devices(window: &MainWindow, ui: &mut UiState) {
.map(|(index, label)| {
// Position 0 is always the system default.
slint::SharedString::from(if index == 0 {
crate::ui::i18n::text("System default")
crate::ui::i18n::text("Default audio device")
} else {
label
})
@ -570,11 +571,41 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
});
}
{
let state = state.clone();
window.on_sound_settings_changed(move |enabled, volume, voice_room, messages, mentions| {
let mut s = state.borrow_mut();
s.ui.sounds = vnox_client::audio::sounds::SoundSettings {
enabled,
volume: volume.clamp(0.0, 100.0),
voice_room,
messages,
mentions,
};
if let Err(error) = crate::ui::preferences::save(&s.ui) {
s.ui.status_msg = Some(ui::i18n::Message::with(
"Cannot save audio settings: {error}",
vec![("error", error.to_string())],
));
}
});
}
{
let state = state.clone();
window.on_preview_sound(move || crate::ui::sounds::preview(&state.borrow()));
}
{
let state = state.clone();
window.on_toggle_mic(move || {
let mut s = state.borrow_mut();
s.ui.mic_enabled = !s.ui.mic_enabled;
let event = if s.ui.mic_enabled {
SoundEvent::MicUnmuted
} else {
SoundEvent::MicMuted
};
crate::ui::sounds::play(&s, event);
});
}
@ -583,6 +614,12 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
window.on_toggle_deafen(move || {
let mut s = state.borrow_mut();
s.ui.deafen = !s.ui.deafen;
let event = if s.ui.deafen {
SoundEvent::Deafened
} else {
SoundEvent::Undeafened
};
crate::ui::sounds::play(&s, event);
});
}
@ -591,7 +628,11 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
window.on_leave_voice(move || {
let mut s = state.borrow_mut();
let voice_channel = s.ui.voice_target.take();
let was_in_voice = s.audio.is_some();
crate::ui::update::stop_voice(&mut s);
if was_in_voice {
crate::ui::sounds::play(&s, SoundEvent::VoiceLeft);
}
s.ui.showing_voice = false;
s.ui.ptt_held = false;
let net = s.net.clone();