VNOX-Client/src/audio/mod.rs
loki5512344 eed3e28c63
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.
2026-10-25 10:03:21 +01:00

65 lines
1.7 KiB
Rust

pub mod config;
pub mod devices;
pub mod diagnostics;
mod pipeline;
mod processing;
pub mod sounds;
pub use devices::{DeviceEntry, DeviceLists};
pub use diagnostics::{AudioIssue, AudioStage, AudioStats};
pub use pipeline::JitterConfig;
pub use pipeline::{AudioPipeline, MediaMixer};
pub use processing::{DenoiseState, TransmitGate, VoiceActivity};
#[derive(Debug, Clone, Copy)]
pub struct AudioSync {
pub mic_enabled: bool,
pub vad_mode: usize,
pub vad_threshold: f32,
pub input_volume: f32,
pub ptt_held: bool,
pub output_volume: f32,
pub jitter_size: usize,
pub adaptive_buffer: bool,
pub voice_bitrate_kbps: f32,
pub noise_suppress: bool,
}
#[derive(Debug, Clone)]
pub struct PipelineConfig {
pub channel_key: u64,
/// Persisted microphone id; empty is the system default.
pub mic_device_id: String,
/// Persisted output device id; empty is the system default.
pub output_device_id: String,
pub voice_bitrate_kbps: f32,
pub packet_interval: usize,
}
impl PartialEq for PipelineConfig {
fn eq(&self, other: &Self) -> bool {
self.channel_key == other.channel_key
&& self.mic_device_id == other.mic_device_id
&& self.output_device_id == other.output_device_id
&& self.packet_interval == other.packet_interval
}
}
#[derive(Debug, Clone)]
pub struct IncomingVoice {
pub voice_seq: u32,
pub timestamp: u32,
pub channel_id: u64,
pub opus_data: Vec<u8>,
}
pub struct EncodedFrame {
pub channel_id: u64,
pub voice_seq: u32,
pub timestamp: u32,
pub data: Vec<u8>,
}
pub fn start(cfg: PipelineConfig) -> anyhow::Result<AudioPipeline> {
pipeline::start(cfg)
}