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

@ -9,6 +9,14 @@ use crate::AppState;
pub fn process_net_events(state: &mut AppState) {
while let Some(event) = state.net.try_recv() {
if let Some(sound) = crate::ui::sounds::sound_for_event(
&state.ui,
&state.identity.pubkey_hex,
&state.identity.nickname,
&event,
) {
crate::ui::sounds::play(state, sound);
}
match event {
NetEvent::VoiceRevoked { channel_id } => {
if state.voice_channel.as_deref() == Some(channel_id.as_str())
@ -895,6 +903,8 @@ pub fn start_voice(state: &mut AppState, channel_id: &str) {
match vnox_client::audio::start(cfg.clone()) {
Ok(pipeline) => {
tracing::info!("voice active on channel {channel_id}");
let newly_joined = !matches!(&state.ui.voice,
VoiceUiState::Active { channel } if channel == channel_id);
state.audio = Some(pipeline);
state.voice_channel = Some(channel_id.to_string());
state.last_pipeline_config = Some(cfg);
@ -905,6 +915,9 @@ pub fn start_voice(state: &mut AppState, channel_id: &str) {
state.ui.voice_joined_at = Some(std::time::Instant::now());
}
state.ui.status_msg = None;
if newly_joined {
crate::ui::sounds::play(state, vnox_client::audio::sounds::SoundEvent::VoiceJoined);
}
}
Err(e) => {
tracing::warn!("audio start failed: {e}");
@ -983,6 +996,7 @@ fn report_audio_issues(state: &mut AppState) {
),
};
state.ui.status_msg = Some(message);
crate::ui::sounds::play(state, vnox_client::audio::sounds::SoundEvent::Error);
}
if dead {
let reason = state