1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright 2025 Security Union LLC
*
* Licensed under either of
*
* * Apache License, Version 2.0
* (http://www.apache.org/licenses/LICENSE-2.0)
* * MIT license
* (http://opensource.org/licenses/MIT)
*
* at your option.
*
* Unless you explicitly state otherwise, any contribution intentionally
* submitted for inclusion in the work by you, as defined in the Apache-2.0
* license, shall be dual licensed as above, without any additional terms or
* conditions.
*/
//! Shared audio tuning constants used by both the encoder-side (local
//! microphone VAD) and the decoder-side (remote peer VAD) paths.
//!
//! Centralising these values ensures that tuning any audio parameter means
//! changing **one** constant definition.
/// RMS level below which audio is considered silence (0.0–1.0 normalized).
/// 0.01 is quite sensitive, 0.05 filters out most background noise.
pub const DEFAULT_VAD_THRESHOLD: f32 = 0.002;
/// RMS level that maps to maximum glow intensity (1.0). Normal speech peaks ~0.05–0.15.
/// Anything above this ceiling is clamped to 1.0.
pub const RMS_LOUD_SPEECH_CEILING: f32 = 0.10;
/// Minimum change in computed audio intensity before emitting an update event.
/// Prevents excessive event emissions while maintaining smooth visual updates.
pub const AUDIO_LEVEL_DELTA_THRESHOLD: f32 = 0.02;
/// Minimum change in audio level before triggering a UI re-render.
/// Tighter than `AUDIO_LEVEL_DELTA_THRESHOLD` (used codec-side) to ensure
/// smooth visual transitions while still suppressing no-op updates.
pub const UI_AUDIO_LEVEL_DELTA: f32 = 0.01;
/// How often (in ms) the local microphone VAD analysis runs.
///
/// Re-exported from `adaptive_quality_constants` which is the single source
/// of truth for all adaptation and polling parameters.
pub use crateVAD_POLL_INTERVAL_MS;
/// FFT size for the Web Audio AnalyserNode used in local microphone VAD.
pub const VAD_FFT_SIZE: u32 = 2048;
/// Smoothing time constant for the Web Audio AnalyserNode (0.0–1.0).
pub const VAD_SMOOTHING_TIME_CONSTANT: f64 = 0.8;
/// How long (in ms) the mic icon stays green after audio drops to zero.
/// The border glow fades immediately; the mic icon holds to give a clear
/// visual indication that the participant was recently speaking.
pub const MIC_HOLD_DURATION_MS: u32 = 1_000;
/// Convert raw RMS energy to a perceptual intensity value (0.0–1.0).
/// Uses sqrt curve for perceptual loudness mapping.