From eed3e28c638eda08c91b6bc4d4105103fb66acae Mon Sep 17 00:00:00 2001 From: loki5512344 Date: Sun, 25 Oct 2026 10:01:38 +0100 Subject: [PATCH] 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. --- docs/THIRD_PARTY.md | 12 + src/audio/mod.rs | 1 + src/audio/sounds/mod.rs | 247 +++++++++++++++++++++ src/audio/sounds/player.rs | 155 +++++++++++++ src/audio/sounds/synth.rs | 234 +++++++++++++++++++ src/main.rs | 43 +++- src/ui/bridge.rs | 5 + src/ui/mod.rs | 1 + src/ui/preferences.rs | 8 + src/ui/slint/main.slint | 14 ++ src/ui/slint/settings.slint | 17 ++ src/ui/slint/settings/sounds.slint | 86 +++++++ src/ui/sounds.rs | 217 ++++++++++++++++++ src/ui/state/default.rs | 1 + src/ui/state/types.rs | 1 + src/ui/update.rs | 14 ++ translations/en/LC_MESSAGES/vnox-client.po | 36 +++ translations/ru.json | 16 +- translations/ru/LC_MESSAGES/vnox-client.po | 38 +++- 19 files changed, 1142 insertions(+), 4 deletions(-) create mode 100644 docs/THIRD_PARTY.md create mode 100644 src/audio/sounds/mod.rs create mode 100644 src/audio/sounds/player.rs create mode 100644 src/audio/sounds/synth.rs create mode 100644 src/ui/slint/settings/sounds.slint create mode 100644 src/ui/sounds.rs diff --git a/docs/THIRD_PARTY.md b/docs/THIRD_PARTY.md new file mode 100644 index 0000000..03362d8 --- /dev/null +++ b/docs/THIRD_PARTY.md @@ -0,0 +1,12 @@ +# Third-party material + +## Notification sounds + +The notification sounds are not recordings. They are generated at runtime by +`src/audio/sounds/synth.rs` (sine tones with two quiet harmonics, a short attack, an +exponential decay and a fade-out). No third-party audio files, samples or presets are bundled, +so they carry no extra attribution or licence: they are part of VNOX-Client under GPL-3.0. + +## Interface icons + +Icon sets and their licences (Lucide, ISC) are documented with the icon assets. diff --git a/src/audio/mod.rs b/src/audio/mod.rs index 97b9b4e..1f272eb 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -3,6 +3,7 @@ pub mod devices; pub mod diagnostics; mod pipeline; mod processing; +pub mod sounds; pub use devices::{DeviceEntry, DeviceLists}; pub use diagnostics::{AudioIssue, AudioStage, AudioStats}; diff --git a/src/audio/sounds/mod.rs b/src/audio/sounds/mod.rs new file mode 100644 index 0000000..88fd4ce --- /dev/null +++ b/src/audio/sounds/mod.rs @@ -0,0 +1,247 @@ +//! Notification sounds: which events make a sound, settings, and the tones themselves. +//! +//! The tones are synthesized (see [`synth`]), so the repository carries no third-party audio +//! and no extra licence. Event selection is pure logic and is unit tested; playback lives in +//! [`player`]. + +mod player; +pub mod synth; + +pub use player::SoundPlayer; + +use serde::{Deserialize, Serialize}; + +/// Everything the client can announce with a sound. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum SoundEvent { + /// You entered a voice room. + VoiceJoined, + /// You left a voice room. + VoiceLeft, + PeerJoined, + PeerLeft, + /// A new message in a channel or conversation you are not looking at. + Message, + /// A message that mentions you. + Mention, + MicMuted, + MicUnmuted, + Deafened, + Undeafened, + Connected, + ConnectionLost, + Error, +} + +/// The settings group an event belongs to. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SoundCategory { + VoiceRoom, + Messages, + Mentions, + /// Connection and error sounds follow only the master switch. + System, +} + +impl SoundEvent { + pub fn category(self) -> SoundCategory { + match self { + Self::VoiceJoined + | Self::VoiceLeft + | Self::PeerJoined + | Self::PeerLeft + | Self::MicMuted + | Self::MicUnmuted + | Self::Deafened + | Self::Undeafened => SoundCategory::VoiceRoom, + Self::Message => SoundCategory::Messages, + Self::Mention => SoundCategory::Mentions, + Self::Connected | Self::ConnectionLost | Self::Error => SoundCategory::System, + } + } +} + +/// User-facing sound preferences, persisted with the audio settings. +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[serde(default)] +pub struct SoundSettings { + /// Master switch. + pub enabled: bool, + /// 0 to 100. + pub volume: f32, + pub voice_room: bool, + pub messages: bool, + pub mentions: bool, +} + +impl Default for SoundSettings { + fn default() -> Self { + Self { + enabled: true, + volume: 60.0, + voice_room: true, + messages: true, + mentions: true, + } + } +} + +impl SoundSettings { + /// Linear gain for the volume slider (perceptual curve, 0 is silent). + pub fn gain(&self) -> f32 { + let v = (self.volume / 100.0).clamp(0.0, 1.0); + v * v + } +} + +/// Decides whether `event` should be heard right now. `deafened` is the local deafen state. +/// +/// While deafened nothing plays except the sound announcing that you can hear again. +pub fn select(event: SoundEvent, settings: &SoundSettings, deafened: bool) -> Option { + if !settings.enabled || settings.gain() <= 0.0 { + return None; + } + if deafened && event != SoundEvent::Undeafened { + return None; + } + let allowed = match event.category() { + SoundCategory::VoiceRoom => settings.voice_room, + SoundCategory::Messages => settings.messages, + SoundCategory::Mentions => settings.mentions, + SoundCategory::System => true, + }; + allowed.then_some(event) +} + +/// Picks the sound for an incoming message, or `None` for silence. +/// +/// Your own messages are silent; a mention is announced even in the channel you are viewing +/// (it is addressed to you), an ordinary message only when you are looking elsewhere. +pub fn message_event(own: bool, mentions_me: bool, viewing_this_chat: bool) -> Option { + if own { + None + } else if mentions_me { + Some(SoundEvent::Mention) + } else if viewing_this_chat { + None + } else { + Some(SoundEvent::Message) + } +} + +/// True when `content` addresses this user: `@nickname` (case-insensitive, whole word), +/// `@everyone` or `@here`. +pub fn is_mention(content: &str, nickname: &str) -> bool { + let lowered = content.to_lowercase(); + let nick = nickname.trim().to_lowercase(); + lowered.match_indices('@').any(|(at, _)| { + let word: String = lowered[at + 1..] + .chars() + .take_while(|c| c.is_alphanumeric() || matches!(c, '_' | '-' | '.')) + .collect(); + let word = word.trim_end_matches('.'); + !word.is_empty() + && (word == "everyone" || word == "here" || (!nick.is_empty() && word == nick)) + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn master_switch_and_zero_volume_silence_everything() { + let off = SoundSettings { + enabled: false, + ..Default::default() + }; + assert_eq!(select(SoundEvent::Error, &off, false), None); + let quiet = SoundSettings { + volume: 0.0, + ..Default::default() + }; + assert_eq!(select(SoundEvent::Message, &quiet, false), None); + } + + #[test] + fn categories_are_switched_independently() { + let settings = SoundSettings { + voice_room: false, + messages: true, + mentions: false, + ..Default::default() + }; + assert_eq!(select(SoundEvent::PeerJoined, &settings, false), None); + assert_eq!(select(SoundEvent::MicMuted, &settings, false), None); + assert_eq!(select(SoundEvent::Mention, &settings, false), None); + assert_eq!( + select(SoundEvent::Message, &settings, false), + Some(SoundEvent::Message) + ); + // Connection and error sounds only depend on the master switch. + assert_eq!( + select(SoundEvent::ConnectionLost, &settings, false), + Some(SoundEvent::ConnectionLost) + ); + } + + #[test] + fn deafen_silences_everything_except_the_undeafen_sound() { + let settings = SoundSettings::default(); + for event in [ + SoundEvent::Message, + SoundEvent::Mention, + SoundEvent::PeerJoined, + SoundEvent::Deafened, + SoundEvent::Error, + SoundEvent::ConnectionLost, + ] { + assert_eq!(select(event, &settings, true), None, "{event:?}"); + } + assert_eq!( + select(SoundEvent::Undeafened, &settings, true), + Some(SoundEvent::Undeafened) + ); + assert_eq!( + select(SoundEvent::Undeafened, &settings, false), + Some(SoundEvent::Undeafened) + ); + } + + #[test] + fn message_sound_follows_focus_ownership_and_mentions() { + assert_eq!(message_event(true, true, false), None); + assert_eq!(message_event(false, false, true), None); + assert_eq!( + message_event(false, false, false), + Some(SoundEvent::Message) + ); + assert_eq!(message_event(false, true, true), Some(SoundEvent::Mention)); + assert_eq!(message_event(false, true, false), Some(SoundEvent::Mention)); + } + + #[test] + fn mentions_match_whole_words_only() { + assert!(is_mention("hey @Alice, look", "alice")); + assert!(is_mention("@alice", "Alice")); + assert!(is_mention("ping @everyone", "bob")); + assert!(is_mention("@here meeting", "bob")); + assert!(is_mention("thanks @alice.", "alice")); + assert!(!is_mention("hey @alicia", "alice")); + assert!(!is_mention("mail alice@example.com", "example")); + assert!(!is_mention("alice without at", "alice")); + assert!(!is_mention("@", "")); + } + + #[test] + fn settings_deserialize_with_defaults_and_clamp_volume_gain() { + let parsed: SoundSettings = serde_json::from_str(r#"{"volume":100.0}"#).unwrap(); + assert!(parsed.enabled && parsed.voice_room && parsed.messages && parsed.mentions); + assert!((parsed.gain() - 1.0).abs() < f32::EPSILON); + let loud = SoundSettings { + volume: 900.0, + ..Default::default() + }; + assert!((loud.gain() - 1.0).abs() < f32::EPSILON); + } +} diff --git a/src/audio/sounds/player.rs b/src/audio/sounds/player.rs new file mode 100644 index 0000000..d5914ec --- /dev/null +++ b/src/audio/sounds/player.rs @@ -0,0 +1,155 @@ +//! Plays a notification sound without blocking the UI thread. +//! +//! In a voice room the sound is mixed into the already open playback stream. Otherwise a +//! short-lived stream is opened on the selected output device in its own thread and closed +//! when the sound ends. A small cap on concurrent streams keeps a burst of events from +//! piling up devices. + +use std::sync::{ + Arc, + atomic::{AtomicUsize, Ordering}, +}; +use std::time::Duration; + +use anyhow::{Context, Result, anyhow}; +use cpal::traits::{DeviceTrait, StreamTrait}; +use tracing::warn; + +use super::{SoundEvent, synth}; +use crate::audio::{ + AudioPipeline, + config::{AudioConfig, OPUS_RATE, resample_rate}, + devices, +}; + +const MAX_CONCURRENT_STREAMS: usize = 2; +/// Silence appended after the sound so the device drains before the stream is dropped. +const TAIL: Duration = Duration::from_millis(80); + +/// Fire-and-forget sound playback. +#[derive(Clone, Default)] +pub struct SoundPlayer { + active_streams: Arc, +} + +impl SoundPlayer { + /// Plays `event` at `gain` (0.0 to 1.0). With a running `pipeline` the sound joins its + /// stream; otherwise a short stream is opened on `output_device_id` (empty is the default). + pub fn play( + &self, + event: SoundEvent, + gain: f32, + pipeline: Option<&AudioPipeline>, + output_device_id: &str, + ) { + let samples = scaled(synth::render(event), gain); + if let Some(pipeline) = pipeline { + pipeline.play_effect(&samples); + return; + } + if self.active_streams.fetch_add(1, Ordering::AcqRel) >= MAX_CONCURRENT_STREAMS { + self.active_streams.fetch_sub(1, Ordering::AcqRel); + return; + } + let counter = self.active_streams.clone(); + let device_id = output_device_id.to_string(); + let spawned = std::thread::Builder::new() + .name("vnox-sound".into()) + .spawn(move || { + if let Err(error) = play_once(&samples, &device_id) { + warn!(%error, "cannot play notification sound"); + } + counter.fetch_sub(1, Ordering::AcqRel); + }); + if let Err(error) = spawned { + self.active_streams.fetch_sub(1, Ordering::AcqRel); + warn!(%error, "cannot start the sound thread"); + } + } +} + +fn scaled(samples: &[f32], gain: f32) -> Vec { + let gain = gain.clamp(0.0, 1.0); + samples.iter().map(|s| s * gain).collect() +} + +/// Converts mono 48 kHz samples to an interleaved buffer for the device format. +pub(crate) fn to_device_buffer(mono_48k: &[f32], device_rate: u32, channels: usize) -> Vec { + let mono = if device_rate == OPUS_RATE { + mono_48k.to_vec() + } else { + resample_rate(mono_48k, OPUS_RATE, device_rate) + }; + let channels = channels.max(1); + let mut out = Vec::with_capacity(mono.len() * channels); + for sample in mono { + out.extend(std::iter::repeat_n(sample, channels)); + } + out +} + +fn play_once(mono_48k: &[f32], device_id: &str) -> Result<()> { + let device = devices::open_output(device_id)?; + let config = AudioConfig::find(&device, false)?; + let channels = usize::from(config.stream.channels); + let buffer = to_device_buffer(mono_48k, config.sample_rate, channels); + let duration = + Duration::from_secs_f32(buffer.len() as f32 / channels as f32 / config.sample_rate as f32) + + TAIL; + let mut position = 0usize; + let stream = device + .build_output_stream( + config.stream, + move |out: &mut [f32], _| { + let n = out.len().min(buffer.len().saturating_sub(position)); + out[..n].copy_from_slice(&buffer[position..position + n]); + out[n..].fill(0.0); + position += n; + }, + |error| warn!(%error, "notification sound stream"), + None, + ) + .map_err(|e| anyhow!("{e}")) + .context("cannot open the sound stream")?; + stream.play().context("cannot start the sound stream")?; + std::thread::sleep(duration); + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn device_buffer_duplicates_mono_across_channels() { + let buffer = to_device_buffer(&[0.1, 0.2], OPUS_RATE, 2); + assert_eq!(buffer, vec![0.1, 0.1, 0.2, 0.2]); + } + + #[test] + fn device_buffer_resamples_to_the_device_rate() { + let buffer = to_device_buffer(&vec![0.5; 4800], 24_000, 1); + assert_eq!(buffer.len(), 2400); + } + + #[test] + fn gain_scales_and_clamps() { + assert_eq!(scaled(&[0.5, -0.5], 0.5), vec![0.25, -0.25]); + assert_eq!(scaled(&[0.5], 7.0), vec![0.5]); + assert_eq!(scaled(&[0.5], -1.0), vec![0.0]); + } + + #[test] + fn concurrent_one_shot_streams_are_capped() { + let player = SoundPlayer::default(); + player + .active_streams + .store(MAX_CONCURRENT_STREAMS, Ordering::SeqCst); + // Over the cap the call returns immediately and leaves the counter unchanged. + player.play(SoundEvent::Message, 1.0, None, ""); + assert_eq!( + player.active_streams.load(Ordering::SeqCst), + MAX_CONCURRENT_STREAMS + ); + } +} diff --git a/src/audio/sounds/synth.rs b/src/audio/sounds/synth.rs new file mode 100644 index 0000000..dcf1c18 --- /dev/null +++ b/src/audio/sounds/synth.rs @@ -0,0 +1,234 @@ +//! Tone generator for the notification sounds. +//! +//! Every sound is a short motif of soft bell-like notes: a sine with two quiet harmonics, a +//! 6 ms attack, an exponential decay and a final fade to zero, so playback never clicks. +//! Rising motifs mean "arrived or enabled", falling motifs mean "left or disabled". +//! The output is mono 48 kHz f32 with a peak of 0.5 before the user volume is applied. + +use std::collections::HashMap; +use std::f32::consts::TAU; +use std::sync::OnceLock; + +use super::SoundEvent; +use crate::audio::config::OPUS_RATE; + +const ATTACK_MS: f32 = 6.0; +const RELEASE_MS: f32 = 12.0; +const PEAK: f32 = 0.5; + +/// One note of a motif. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Note { + pub hz: f32, + pub start_ms: f32, + pub duration_ms: f32, + pub amplitude: f32, +} + +const fn note(hz: f32, start_ms: f32, duration_ms: f32, amplitude: f32) -> Note { + Note { + hz, + start_ms, + duration_ms, + amplitude, + } +} + +// Pitches in Hz (equal temperament, A4 = 440). +const C5: f32 = 523.25; +const E5: f32 = 659.25; +const G5: f32 = 783.99; +const A5: f32 = 880.0; +const B5: f32 = 987.77; +const C6: f32 = 1046.5; +const E6: f32 = 1318.5; +const A4: f32 = 440.0; +const E4: f32 = 329.63; +const D4: f32 = 293.66; + +/// The motif for an event. +pub fn motif(event: SoundEvent) -> Vec { + match event { + SoundEvent::VoiceJoined => vec![note(C5, 0.0, 170.0, 0.9), note(G5, 110.0, 260.0, 1.0)], + SoundEvent::VoiceLeft => vec![note(G5, 0.0, 170.0, 0.9), note(C5, 110.0, 260.0, 1.0)], + SoundEvent::PeerJoined => vec![note(E5, 0.0, 110.0, 0.55), note(A5, 80.0, 190.0, 0.6)], + SoundEvent::PeerLeft => vec![note(A5, 0.0, 110.0, 0.55), note(E5, 80.0, 190.0, 0.6)], + SoundEvent::Message => vec![note(B5, 0.0, 230.0, 0.7)], + SoundEvent::Mention => vec![ + note(E6, 0.0, 120.0, 0.9), + note(B5, 100.0, 120.0, 0.8), + note(E6, 200.0, 280.0, 1.0), + ], + SoundEvent::MicMuted => vec![note(A5, 0.0, 70.0, 0.6), note(E5, 60.0, 110.0, 0.6)], + SoundEvent::MicUnmuted => vec![note(E5, 0.0, 70.0, 0.6), note(A5, 60.0, 110.0, 0.6)], + SoundEvent::Deafened => vec![ + note(G5, 0.0, 80.0, 0.6), + note(E5, 70.0, 80.0, 0.6), + note(C5, 140.0, 140.0, 0.6), + ], + SoundEvent::Undeafened => vec![ + note(C5, 0.0, 80.0, 0.6), + note(E5, 70.0, 80.0, 0.6), + note(G5, 140.0, 140.0, 0.6), + ], + SoundEvent::Connected => vec![ + note(C5, 0.0, 120.0, 0.7), + note(E5, 90.0, 120.0, 0.7), + note(C6, 180.0, 300.0, 0.8), + ], + SoundEvent::ConnectionLost => vec![note(A4, 0.0, 160.0, 0.8), note(E4, 130.0, 320.0, 0.8)], + SoundEvent::Error => vec![note(E4, 0.0, 120.0, 0.9), note(D4, 150.0, 220.0, 0.9)], + } +} + +fn sample_count(ms: f32) -> usize { + (ms * OPUS_RATE as f32 / 1000.0).round() as usize +} + +/// Renders a motif to mono 48 kHz samples with a peak of [`PEAK`]. +pub fn render_motif(notes: &[Note]) -> Vec { + let total_ms = notes + .iter() + .map(|n| n.start_ms + n.duration_ms) + .fold(0.0f32, f32::max); + // A short silent tail keeps the last release inside the buffer. + let mut out = vec![0.0f32; sample_count(total_ms) + sample_count(RELEASE_MS)]; + let rate = OPUS_RATE as f32; + for n in notes { + let start = sample_count(n.start_ms); + let length = sample_count(n.duration_ms); + let attack = sample_count(ATTACK_MS).max(1); + let release = sample_count(RELEASE_MS).max(1).min(length); + let tau = n.duration_ms / 1000.0 * 0.4; + for i in 0..length { + let t = i as f32 / rate; + let phase = TAU * n.hz * t; + let tone = phase.sin() + 0.25 * (2.0 * phase).sin() + 0.08 * (3.0 * phase).sin(); + let mut envelope = (-t / tau).exp(); + if i < attack { + envelope *= i as f32 / attack as f32; + } + if i + release > length { + envelope *= (length - i) as f32 / release as f32; + } + if let Some(slot) = out.get_mut(start + i) { + *slot += tone * envelope * n.amplitude; + } + } + } + let peak = out.iter().fold(0.0f32, |p, s| p.max(s.abs())); + if peak > 0.0 { + let scale = PEAK / peak; + for s in &mut out { + *s *= scale; + } + } + out +} + +/// Cached rendering of an event's sound. +pub fn render(event: SoundEvent) -> &'static [f32] { + static CACHE: OnceLock>> = OnceLock::new(); + const ALL: [SoundEvent; 13] = [ + SoundEvent::VoiceJoined, + SoundEvent::VoiceLeft, + SoundEvent::PeerJoined, + SoundEvent::PeerLeft, + SoundEvent::Message, + SoundEvent::Mention, + SoundEvent::MicMuted, + SoundEvent::MicUnmuted, + SoundEvent::Deafened, + SoundEvent::Undeafened, + SoundEvent::Connected, + SoundEvent::ConnectionLost, + SoundEvent::Error, + ]; + CACHE + .get_or_init(|| { + ALL.iter() + .map(|&event| (event, render_motif(&motif(event)))) + .collect() + }) + .get(&event) + .map(Vec::as_slice) + .unwrap_or(&[]) +} + +#[cfg(test)] +mod tests { + use super::*; + + const ALL: [SoundEvent; 13] = [ + SoundEvent::VoiceJoined, + SoundEvent::VoiceLeft, + SoundEvent::PeerJoined, + SoundEvent::PeerLeft, + SoundEvent::Message, + SoundEvent::Mention, + SoundEvent::MicMuted, + SoundEvent::MicUnmuted, + SoundEvent::Deafened, + SoundEvent::Undeafened, + SoundEvent::Connected, + SoundEvent::ConnectionLost, + SoundEvent::Error, + ]; + + #[test] + fn every_event_has_a_short_bounded_nonsilent_sound() { + for event in ALL { + let samples = render(event); + assert!(!samples.is_empty(), "{event:?}"); + // Under 0.8 s and within the peak ceiling. + assert!(samples.len() < OPUS_RATE as usize * 8 / 10, "{event:?}"); + let peak = samples.iter().fold(0.0f32, |p, s| p.max(s.abs())); + assert!(peak > 0.3 && peak <= PEAK + 1e-4, "{event:?} peak {peak}"); + assert!(samples.iter().all(|s| s.is_finite())); + } + } + + #[test] + fn sounds_start_and_end_at_zero_so_they_cannot_click() { + for event in ALL { + let samples = render(event); + assert!(samples[0].abs() < 1e-3, "{event:?} start"); + assert!(samples[samples.len() - 1].abs() < 1e-3, "{event:?} end"); + } + } + + #[test] + fn join_motifs_rise_and_leave_motifs_fall() { + let rises = |event| { + let m = motif(event); + m[m.len() - 1].hz > m[0].hz + }; + assert!(rises(SoundEvent::VoiceJoined)); + assert!(!rises(SoundEvent::VoiceLeft)); + assert!(rises(SoundEvent::PeerJoined)); + assert!(!rises(SoundEvent::PeerLeft)); + assert!(rises(SoundEvent::MicUnmuted)); + assert!(!rises(SoundEvent::MicMuted)); + assert!(rises(SoundEvent::Undeafened)); + assert!(!rises(SoundEvent::Deafened)); + } + + #[test] + fn rendered_tone_has_the_requested_pitch() { + let samples = render_motif(&[note(A5, 0.0, 300.0, 1.0)]); + // Count rising zero crossings in the stable part of the note. + let window = &samples[sample_count(40.0)..sample_count(240.0)]; + let crossings = window + .windows(2) + .filter(|w| w[0] <= 0.0 && w[1] > 0.0) + .count(); + let seconds = window.len() as f32 / OPUS_RATE as f32; + let measured = crossings as f32 / seconds; + assert!((measured - A5).abs() < 25.0, "measured {measured} Hz"); + } + + #[test] + fn empty_motif_renders_silence_without_panicking() { + assert!(render_motif(&[]).iter().all(|s| *s == 0.0)); + } +} diff --git a/src/main.rs b/src/main.rs index 6f91cf8..1a30750 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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>) { }); } + { + 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>) { 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>) { 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(); diff --git a/src/ui/bridge.rs b/src/ui/bridge.rs index d0dc29c..a10c972 100644 --- a/src/ui/bridge.rs +++ b/src/ui/bridge.rs @@ -418,6 +418,11 @@ pub fn sync_settings(window: &MainWindow, state: &UiState, own_pubkey: &str) { window.set_voice_bitrate(state.voice_bitrate); window.set_vad_mode(state.vad_mode as i32); window.set_volume(state.output_volume); + window.set_sounds_enabled(state.sounds.enabled); + window.set_sounds_volume(state.sounds.volume); + window.set_sounds_voice_room(state.sounds.voice_room); + window.set_sounds_messages(state.sounds.messages); + window.set_sounds_mentions(state.sounds.mentions); window.set_settings_open(state.settings_open); window.set_input_device_index(state.mic_device as i32); window.set_output_device_index(state.output_device as i32); diff --git a/src/ui/mod.rs b/src/ui/mod.rs index f02cbf0..819e4cc 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -6,6 +6,7 @@ pub mod i18n; pub mod media; pub mod preferences; pub mod slint; +pub mod sounds; pub mod state; pub mod update; diff --git a/src/ui/preferences.rs b/src/ui/preferences.rs index 372aecf..34e316a 100644 --- a/src/ui/preferences.rs +++ b/src/ui/preferences.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use super::state::{DEFAULT_VOICE_MODE, UiState}; use vnox_client::audio::devices::{self, filter}; +use vnox_client::audio::sounds::SoundSettings; #[derive(Default, Serialize, Deserialize)] #[serde(default)] @@ -22,6 +23,8 @@ struct AudioPreferences { /// stored `mode: 0` for everybody, so an unmarked push-to-talk is not a real choice. mode_chosen: bool, volume: Option, + /// Notification sound switches and volume. + sounds: SoundSettings, } fn path() -> PathBuf { @@ -67,6 +70,10 @@ pub fn load(state: &mut UiState) { state.voice_bitrate = prefs.bitrate.unwrap_or(64.0).clamp(8.0, 128.0); (state.vad_mode, state.vad_mode_chosen) = resolve_mode(&prefs); state.output_volume = prefs.volume.unwrap_or(90.0).clamp(0.0, 100.0); + state.sounds = SoundSettings { + volume: prefs.sounds.volume.clamp(0.0, 100.0), + ..prefs.sounds + }; } pub fn save(state: &UiState) -> anyhow::Result<()> { @@ -83,6 +90,7 @@ pub fn save(state: &UiState) -> anyhow::Result<()> { mode: state.vad_mode, mode_chosen: state.vad_mode_chosen, volume: Some(state.output_volume), + sounds: state.sounds, }; std::fs::write(path, serde_json::to_vec_pretty(&preferences)?)?; Ok(()) diff --git a/src/ui/slint/main.slint b/src/ui/slint/main.slint index 2878e2f..82c3b10 100644 --- a/src/ui/slint/main.slint +++ b/src/ui/slint/main.slint @@ -85,6 +85,13 @@ export component MainWindow inherits Window { in-out property voice-bitrate: 64.0; in-out property vad-mode: 1; in-out property volume: 100.0; + in-out property sounds-enabled: true; + in-out property sounds-volume: 60; + in-out property sounds-voice-room: true; + in-out property sounds-messages: true; + in-out property sounds-mentions: true; + callback sound-settings-changed(bool, float, bool, bool, bool); + callback preview-sound(); in-out property language-choice: "system"; callback language-selected(string); in-out property theme-mode: "dark"; @@ -331,6 +338,13 @@ export component MainWindow inherits Window { voice-bitrate <=> root.voice-bitrate; vad-mode <=> root.vad-mode; volume <=> root.volume; + sounds-enabled <=> root.sounds-enabled; + sounds-volume <=> root.sounds-volume; + sounds-voice-room <=> root.sounds-voice-room; + sounds-messages <=> root.sounds-messages; + sounds-mentions <=> root.sounds-mentions; + sounds-changed => { root.sound-settings-changed(root.sounds-enabled, root.sounds-volume, root.sounds-voice-room, root.sounds-messages, root.sounds-mentions); } + preview-sound => { root.preview-sound(); } active-tab <=> root.active-tab; passphrase-modal-open <=> root.passphrase-modal-open; diff --git a/src/ui/slint/settings.slint b/src/ui/slint/settings.slint index 4701a5e..0ef205d 100644 --- a/src/ui/slint/settings.slint +++ b/src/ui/slint/settings.slint @@ -1,5 +1,6 @@ import { Theme, ActionButton, Symbol } from "theme.slint"; import { AudioSettings } from "settings/audio.slint"; +import { SoundSettings } from "settings/sounds.slint"; import { AppearanceSettings } from "settings/appearance.slint"; import { IdentitySettings } from "settings/identity.slint"; @@ -46,6 +47,13 @@ export component SettingsWindow inherits Rectangle { in-out property voice-bitrate; in-out property vad-mode; in-out property volume; + in-out property sounds-enabled: true; + in-out property sounds-volume: 60; + in-out property sounds-voice-room: true; + in-out property sounds-messages: true; + in-out property sounds-mentions: true; + callback sounds-changed(); + callback preview-sound(); in-out property active-tab: "audio"; in-out property passphrase-modal-open; in-out property passphrase-input; @@ -132,6 +140,15 @@ export component SettingsWindow inherits Rectangle { volume <=> root.volume; audio-changed => { root.audio-changed(); } } + if root.active-tab == "audio" || (root.active-tab != "appearance" && root.active-tab != "identity") : SoundSettings { + sounds-enabled <=> root.sounds-enabled; + sounds-volume <=> root.sounds-volume; + sounds-voice-room <=> root.sounds-voice-room; + sounds-messages <=> root.sounds-messages; + sounds-mentions <=> root.sounds-mentions; + sounds-changed => { root.sounds-changed(); } + preview-sound => { root.preview-sound(); } + } if root.active-tab == "appearance" : AppearanceSettings { language-choice <=> root.language-choice; language-selected(choice) => { root.language-selected(choice); } diff --git a/src/ui/slint/settings/sounds.slint b/src/ui/slint/settings/sounds.slint new file mode 100644 index 0000000..ae74a3e --- /dev/null +++ b/src/ui/slint/settings/sounds.slint @@ -0,0 +1,86 @@ +import { Theme, ActionButton } from "../theme.slint"; +import { AudioSlider } from "../controls.slint"; + +component SoundToggle inherits Rectangle { + in property label; + in property detail; + in-out property checked; + in property enabled: true; + callback toggled(); + height: 46px; + accessible-role: checkbox; + accessible-label: root.label; + accessible-checked: root.checked; + HorizontalLayout { + spacing: 12px; + VerticalLayout { + alignment: center; spacing: 2px; horizontal-stretch: 1; + Text { text: root.label; color: root.enabled ? Theme.text-primary : Theme.text-disabled; font-size: Math.max(Theme.font-size - 2px, 11px); } + Text { text: root.detail; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); overflow: elide; } + } + ActionButton { + text: root.checked ? "✓" : "○"; width: 34px; height: 30px; quiet: true; + clicked => { if root.enabled { root.checked = !root.checked; root.toggled(); } } + } + } +} + +export component SoundSettings inherits Rectangle { + in-out property sounds-enabled: true; + in-out property sounds-volume: 60; + in-out property sounds-voice-room: true; + in-out property sounds-messages: true; + in-out property sounds-mentions: true; + callback sounds-changed(); + callback preview-sound(); + VerticalLayout { + spacing: 0; + alignment: start; + Rectangle { height: 1px; background: Theme.border; } + Rectangle { height: 26px; } + Text { text: @tr("Sounds"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; } + Text { text: @tr("Short tones for voice rooms, messages and connection changes. They stay silent while you are deafened."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } + Rectangle { height: 14px; } + SoundToggle { + label: @tr("Play sounds"); + detail: @tr("Master switch, also covers connection and error tones"); + checked <=> root.sounds-enabled; + toggled => { root.sounds-changed(); } + } + SoundToggle { + label: @tr("Voice room"); + detail: @tr("Joining, leaving, microphone and sound on or off"); + enabled: root.sounds-enabled; + checked <=> root.sounds-voice-room; + toggled => { root.sounds-changed(); } + } + SoundToggle { + label: @tr("Messages"); + detail: @tr("New messages in chats you are not looking at"); + enabled: root.sounds-enabled; + checked <=> root.sounds-messages; + toggled => { root.sounds-changed(); } + } + SoundToggle { + label: @tr("Mentions"); + detail: @tr("Someone mentions you or everyone"); + enabled: root.sounds-enabled; + checked <=> root.sounds-mentions; + toggled => { root.sounds-changed(); } + } + Rectangle { height: 10px; } + HorizontalLayout { + spacing: 20px; + Text { text: @tr("Sound volume"); color: Theme.text-primary; font-size: Theme.font-size - 1px; font-weight: 600; horizontal-stretch: 1; } + Text { text: Math.round(root.sounds-volume) + "%"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 2px, 11px); horizontal-alignment: right; } + } + Rectangle { height: 10px; } + AudioSlider { minimum: 0; maximum: 100; value <=> root.sounds-volume; changed(value) => { root.sounds-changed(); } } + Rectangle { height: 12px; } + HorizontalLayout { + ActionButton { text: @tr("Play a test sound"); quiet: true; clicked => { root.preview-sound(); } } + Rectangle { horizontal-stretch: 1; } + } + Rectangle { height: 26px; } + } +} diff --git a/src/ui/sounds.rs b/src/ui/sounds.rs new file mode 100644 index 0000000..758e2fa --- /dev/null +++ b/src/ui/sounds.rs @@ -0,0 +1,217 @@ +//! Maps application events to notification sounds and plays them. +use std::sync::OnceLock; + +use vnox_client::audio::sounds::{self, SoundEvent, SoundPlayer}; +use vnox_client::net::NetEvent; + +use crate::AppState; +use crate::ui::state::{ConnState, UiState, VoiceUiState}; + +fn player() -> &'static SoundPlayer { + static PLAYER: OnceLock = OnceLock::new(); + PLAYER.get_or_init(SoundPlayer::default) +} + +/// Plays `event` if the sound settings and the deafen state allow it. +pub fn play(state: &AppState, event: SoundEvent) { + if let Some(event) = sounds::select(event, &state.ui.sounds, state.ui.deafen) { + player().play( + event, + state.ui.sounds.gain(), + state.audio.as_ref(), + &state.ui.output_device_id, + ); + } +} + +/// Plays the test sound from the settings page, ignoring the category switches but not the +/// master switch or volume. +pub fn preview(state: &AppState) { + let mut settings = state.ui.sounds; + settings.voice_room = true; + if let Some(event) = sounds::select(SoundEvent::PeerJoined, &settings, false) { + player().play( + event, + settings.gain(), + state.audio.as_ref(), + &state.ui.output_device_id, + ); + } +} + +/// True when the person is looking at the text channel `channel_id`. +fn viewing_channel(ui: &UiState, channel_id: &str) -> bool { + !ui.showing_voice + && !ui.browsing_dms + && ui.active_dm_id.is_none() + && ui.active_channel.as_deref() == Some(channel_id) +} + +/// The sound a network event should make, before settings are applied. +pub fn sound_for_event( + ui: &UiState, + own_id: &str, + own_nickname: &str, + event: &NetEvent, +) -> Option { + match event { + NetEvent::Connected { .. } => Some(SoundEvent::Connected), + // Only a connection that was established can be lost; failed attempts stay quiet. + NetEvent::Disconnected { .. } if matches!(ui.conn, ConnState::Connected { .. }) => { + Some(SoundEvent::ConnectionLost) + } + NetEvent::Error { .. } => Some(SoundEvent::Error), + NetEvent::UserJoin { + channel_id, + user_id, + .. + } if user_id != own_id && in_current_voice_room(ui, channel_id) => { + Some(SoundEvent::PeerJoined) + } + NetEvent::UserLeave { + channel_id, + user_id, + } if user_id != own_id && in_current_voice_room(ui, channel_id) => { + Some(SoundEvent::PeerLeft) + } + NetEvent::ChatMessage { + channel_id, + sender_id, + content, + .. + } => sounds::message_event( + sender_id == own_id, + sounds::is_mention(content, own_nickname), + viewing_channel(ui, channel_id), + ), + NetEvent::DmMessage { + dm_id, sender_id, .. + } => sounds::message_event( + sender_id == own_id, + false, + !ui.showing_voice && ui.active_dm_id.as_deref() == Some(dm_id.as_str()), + ), + _ => None, + } +} + +fn in_current_voice_room(ui: &UiState, channel_id: &str) -> bool { + matches!(&ui.voice, VoiceUiState::Active { channel } if channel == channel_id) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn connected_ui() -> UiState { + UiState { + conn: ConnState::Connected { + session_id: "s".into(), + node_name: "n".into(), + }, + active_channel: Some("general".into()), + ..UiState::default() + } + } + + fn chat(channel: &str, sender: &str, content: &str) -> NetEvent { + NetEvent::ChatMessage { + message_id: "m".into(), + channel_id: channel.into(), + sender_id: sender.into(), + nickname: sender.into(), + content: content.into(), + timestamp: 0, + reply_to: None, + } + } + + #[test] + fn messages_sound_only_outside_the_viewed_channel() { + let ui = connected_ui(); + assert_eq!( + sound_for_event(&ui, "me", "me", &chat("general", "bob", "hi")), + None + ); + assert_eq!( + sound_for_event(&ui, "me", "me", &chat("random", "bob", "hi")), + Some(SoundEvent::Message) + ); + assert_eq!( + sound_for_event(&ui, "me", "me", &chat("random", "me", "hi")), + None + ); + } + + #[test] + fn viewing_the_voice_page_does_not_count_as_viewing_the_channel() { + let ui = UiState { + showing_voice: true, + ..connected_ui() + }; + assert_eq!( + sound_for_event(&ui, "me", "me", &chat("general", "bob", "hi")), + Some(SoundEvent::Message) + ); + } + + #[test] + fn mentions_use_the_mention_sound_even_in_the_viewed_channel() { + let ui = connected_ui(); + assert_eq!( + sound_for_event(&ui, "me", "Alice", &chat("general", "bob", "hey @alice")), + Some(SoundEvent::Mention) + ); + } + + #[test] + fn peers_are_announced_only_in_the_voice_room_you_are_in() { + let ui = UiState { + voice: VoiceUiState::Active { + channel: "lounge".into(), + }, + ..connected_ui() + }; + let join = |channel: &str, user: &str| NetEvent::UserJoin { + channel_id: channel.into(), + user_id: user.into(), + nickname: user.into(), + }; + assert_eq!( + sound_for_event(&ui, "me", "me", &join("lounge", "bob")), + Some(SoundEvent::PeerJoined) + ); + assert_eq!( + sound_for_event(&ui, "me", "me", &join("lounge", "me")), + None + ); + assert_eq!( + sound_for_event(&ui, "me", "me", &join("general", "bob")), + None + ); + let leave = NetEvent::UserLeave { + channel_id: "lounge".into(), + user_id: "bob".into(), + }; + assert_eq!( + sound_for_event(&ui, "me", "me", &leave), + Some(SoundEvent::PeerLeft) + ); + } + + #[test] + fn only_an_established_connection_can_be_lost() { + let lost = NetEvent::Disconnected { + reason: "x".into(), + will_retry: true, + }; + assert_eq!( + sound_for_event(&connected_ui(), "me", "me", &lost), + Some(SoundEvent::ConnectionLost) + ); + assert_eq!( + sound_for_event(&UiState::default(), "me", "me", &lost), + None + ); + } +} diff --git a/src/ui/state/default.rs b/src/ui/state/default.rs index 9cdf67f..f2f6f0a 100644 --- a/src/ui/state/default.rs +++ b/src/ui/state/default.rs @@ -43,6 +43,7 @@ impl Default for UiState { output_device: 0, output_device_id: String::new(), output_volume: 90.0, + sounds: Default::default(), device_lists: Default::default(), vad_mode_chosen: false, diff --git a/src/ui/state/types.rs b/src/ui/state/types.rs index 7817458..1c666c9 100644 --- a/src/ui/state/types.rs +++ b/src/ui/state/types.rs @@ -90,6 +90,7 @@ pub struct UiState { /// Persisted output device id; empty is the system default. pub output_device_id: String, pub output_volume: f32, + pub sounds: vnox_client::audio::sounds::SoundSettings, /// Devices behind the picker positions, as of the last enumeration. pub device_lists: vnox_client::audio::DeviceLists, /// True once the person picked a voice input mode themselves. diff --git a/src/ui/update.rs b/src/ui/update.rs index 4ae73b4..2c64c44 100644 --- a/src/ui/update.rs +++ b/src/ui/update.rs @@ -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 diff --git a/translations/en/LC_MESSAGES/vnox-client.po b/translations/en/LC_MESSAGES/vnox-client.po index 08cef80..8e70ef5 100644 --- a/translations/en/LC_MESSAGES/vnox-client.po +++ b/translations/en/LC_MESSAGES/vnox-client.po @@ -271,6 +271,9 @@ msgstr "Join" msgid "Joining voice…" msgstr "Joining voice…" +msgid "Joining, leaving, microphone and sound on or off" +msgstr "Joining, leaving, microphone and sound on or off" + msgid "Keep your keys in a safe place to restore your profile on another device." msgstr "Keep your keys in a safe place to restore your profile on another device." @@ -304,15 +307,24 @@ msgstr "Make Vnox yours." msgid "Make yourself heard, your way." msgstr "Make yourself heard, your way." +msgid "Master switch, also covers connection and error tones" +msgstr "Master switch, also covers connection and error tones" + msgid "Members" msgstr "Members" msgid "Members — {}" msgstr "Members — {}" +msgid "Mentions" +msgstr "Mentions" + msgid "Message" msgstr "Message" +msgid "Messages" +msgstr "Messages" + msgid "Microphone" msgstr "Microphone" @@ -331,6 +343,9 @@ msgstr "Mute microphone" msgid "New deliveries stop. Existing messages stay in the channel." msgstr "New deliveries stop. Existing messages stay in the channel." +msgid "New messages in chats you are not looking at" +msgstr "New messages in chats you are not looking at" + msgid "New passphrase · at least 8 characters" msgstr "New passphrase · at least 8 characters" @@ -403,6 +418,12 @@ msgstr "Photo" msgid "Photo crop area. Drag the image to adjust the crop." msgstr "Photo crop area. Drag the image to adjust the crop." +msgid "Play a test sound" +msgstr "Play a test sound" + +msgid "Play sounds" +msgstr "Play sounds" + msgid "Playback volume for voice rooms." msgstr "Playback volume for voice rooms." @@ -523,6 +544,18 @@ msgstr "Settings for this device" msgid "Share audio" msgstr "Share audio" +msgid "Short tones for voice rooms, messages and connection changes. They stay silent while you are deafened." +msgstr "Short tones for voice rooms, messages and connection changes. They stay silent while you are deafened." + +msgid "Someone mentions you or everyone" +msgstr "Someone mentions you or everyone" + +msgid "Sound volume" +msgstr "Sound volume" + +msgid "Sounds" +msgstr "Sounds" + msgid "Speaking" msgstr "Speaking" @@ -631,6 +664,9 @@ msgstr "Voice input" msgid "Voice quality" msgstr "Voice quality" +msgid "Voice room" +msgstr "Voice room" + msgid "Voice rooms" msgstr "Voice rooms" diff --git a/translations/ru.json b/translations/ru.json index 27afbee..0e05c7c 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -203,6 +203,7 @@ "Could not remove photo: {error}": "Не удалось удалить фото: {error}", "Language": "Язык", "System default": "Как в системе", + "Default audio device": "По умолчанию (системное)", "Choose your language. Changes apply immediately.": "Выбери язык. Изменения применяются сразу.", "{n} participant": [ "{n} участник", @@ -231,7 +232,6 @@ "Idle": "Нет на месте", "Do not disturb": "Не беспокоить", "Default": "По умолчанию", - "System default": "По умолчанию (системное)", "Reply to {}": "Ответ {}", "Members — {}": "Участники — {}", "Zoom {}%": "Масштаб {}%", @@ -366,5 +366,17 @@ "Forget this server": "Забыть этот сервер", "Trust and connect": "Доверять и подключиться", "Could not save the trusted fingerprint": "Не удалось сохранить доверенный отпечаток", - "Server forgotten. Connect again to review its fingerprint.": "Сервер забыт. Подключись снова, чтобы проверить его отпечаток." + "Server forgotten. Connect again to review its fingerprint.": "Сервер забыт. Подключись снова, чтобы проверить его отпечаток.", + "Sounds": "Звуки", + "Short tones for voice rooms, messages and connection changes. They stay silent while you are deafened.": "Короткие сигналы для голосовых комнат, сообщений и смены состояния связи. Пока звук выключен, они молчат.", + "Play sounds": "Воспроизводить звуки", + "Master switch, also covers connection and error tones": "Общий переключатель, включая сигналы связи и ошибок", + "Voice room": "Голосовая комната", + "Joining, leaving, microphone and sound on or off": "Вход, выход, микрофон и включение или выключение звука", + "Messages": "Сообщения", + "New messages in chats you are not looking at": "Новые сообщения в чатах, которые вы сейчас не смотрите", + "Mentions": "Упоминания", + "Someone mentions you or everyone": "Вас или всех упомянули", + "Sound volume": "Громкость звуков", + "Play a test sound": "Проверить звук" } diff --git a/translations/ru/LC_MESSAGES/vnox-client.po b/translations/ru/LC_MESSAGES/vnox-client.po index 77efa4e..352f52c 100644 --- a/translations/ru/LC_MESSAGES/vnox-client.po +++ b/translations/ru/LC_MESSAGES/vnox-client.po @@ -272,6 +272,9 @@ msgstr "Войти" msgid "Joining voice…" msgstr "Подключение к голосовой комнате…" +msgid "Joining, leaving, microphone and sound on or off" +msgstr "Вход, выход, микрофон и включение или выключение звука" + msgid "Keep your keys in a safe place to restore your profile on another device." msgstr "Сохрани ключи в безопасном месте, чтобы восстановить профиль на другом устройстве." @@ -305,15 +308,24 @@ msgstr "Сделай Vnox своим." msgid "Make yourself heard, your way." msgstr "Голос должен звучать так, как тебе удобно." +msgid "Master switch, also covers connection and error tones" +msgstr "Общий переключатель, включая сигналы связи и ошибок" + msgid "Members" msgstr "Участники" msgid "Members — {}" msgstr "Участники — {}" +msgid "Mentions" +msgstr "Упоминания" + msgid "Message" msgstr "Написать" +msgid "Messages" +msgstr "Сообщения" + msgid "Microphone" msgstr "Микрофон" @@ -332,6 +344,9 @@ msgstr "Выключить микрофон" msgid "New deliveries stop. Existing messages stay in the channel." msgstr "Новые доставки прекратятся. Отправленные сообщения останутся в канале." +msgid "New messages in chats you are not looking at" +msgstr "Новые сообщения в чатах, которые вы сейчас не смотрите" + msgid "New passphrase · at least 8 characters" msgstr "Новый пароль · минимум 8 символов" @@ -404,6 +419,12 @@ msgstr "Фото" msgid "Photo crop area. Drag the image to adjust the crop." msgstr "Область фото. Перетаскивай изображение, чтобы изменить кадрирование." +msgid "Play a test sound" +msgstr "Проверить звук" + +msgid "Play sounds" +msgstr "Воспроизводить звуки" + msgid "Playback volume for voice rooms." msgstr "Общий уровень воспроизведения голосовых комнат." @@ -524,6 +545,18 @@ msgstr "Настройки этого устройства" msgid "Share audio" msgstr "Звук демонстрации" +msgid "Short tones for voice rooms, messages and connection changes. They stay silent while you are deafened." +msgstr "Короткие сигналы для голосовых комнат, сообщений и смены состояния связи. Пока звук выключен, они молчат." + +msgid "Someone mentions you or everyone" +msgstr "Вас или всех упомянули" + +msgid "Sound volume" +msgstr "Громкость звуков" + +msgid "Sounds" +msgstr "Звуки" + msgid "Speaking" msgstr "Говорит" @@ -543,7 +576,7 @@ msgid "Stop watching" msgstr "Закрыть просмотр" msgid "System default" -msgstr "По умолчанию (системное)" +msgstr "Как в системе" msgid "System output" msgstr "Системный звук" @@ -632,6 +665,9 @@ msgstr "Передача голоса" msgid "Voice quality" msgstr "Качество голоса" +msgid "Voice room" +msgstr "Голосовая комната" + msgid "Voice rooms" msgstr "Голосовые комнаты"