Skip to main content

proteus_lib/playback/engine/
state.rs

1//! Shared playback state and metrics structures.
2
3/// Reverb configuration shared across threads.
4#[derive(Debug, Clone, Copy)]
5pub struct ReverbSettings {
6    pub enabled: bool,
7    pub dry_wet: f32,
8    pub reset_pending: bool,
9}
10
11impl ReverbSettings {
12    /// Create a new reverb settings snapshot.
13    pub fn new(dry_wet: f32) -> Self {
14        Self {
15            enabled: true,
16            dry_wet: dry_wet.clamp(0.0, 1.0),
17            reset_pending: false,
18        }
19    }
20}
21
22/// Buffering configuration for the playback engine.
23#[derive(Debug, Clone, Copy)]
24pub struct PlaybackBufferSettings {
25    pub start_buffer_ms: f32,
26    pub track_eos_ms: f32,
27}
28
29impl PlaybackBufferSettings {
30    /// Create new buffer settings with a given start buffer size (ms).
31    pub fn new(start_buffer_ms: f32) -> Self {
32        Self {
33            start_buffer_ms: start_buffer_ms.max(0.0),
34            track_eos_ms: 1000.0,
35        }
36    }
37}
38
39/// Aggregated performance metrics used by debug UI.
40#[derive(Debug, Clone, Copy, Default)]
41pub struct ReverbMetrics {
42    pub dsp_time_ms: f64,
43    pub audio_time_ms: f64,
44    pub rt_factor: f64,
45    pub avg_dsp_ms: f64,
46    pub avg_audio_ms: f64,
47    pub avg_rt_factor: f64,
48    pub min_rt_factor: f64,
49    pub max_rt_factor: f64,
50    pub buffer_fill: f64,
51    pub avg_buffer_fill: f64,
52    pub min_buffer_fill: f64,
53    pub max_buffer_fill: f64,
54    pub chain_time_ms: f64,
55    pub avg_chain_time_ms: f64,
56    pub min_chain_time_ms: f64,
57    pub max_chain_time_ms: f64,
58    pub out_interval_ms: f64,
59    pub avg_out_interval_ms: f64,
60    pub min_out_interval_ms: f64,
61    pub max_out_interval_ms: f64,
62    pub wake_total: u64,
63    pub wake_idle: u64,
64    pub dry_rms: f64,
65    pub wet_rms: f64,
66    pub mix_rms: f64,
67    pub dry_peak: f64,
68    pub wet_peak: f64,
69    pub mix_peak: f64,
70    pub wet_to_dry_db: f64,
71    pub reverb_in_len: usize,
72    pub reverb_out_len: usize,
73    pub reverb_reset_gen: u64,
74    pub reverb_block_samples: usize,
75    pub reverb_underflow_events: u64,
76    pub reverb_underflow_samples: u64,
77    pub reverb_pad_events: u64,
78    pub reverb_pad_samples: u64,
79    pub reverb_partial_drain_events: u64,
80    pub append_gap_ms: f64,
81    pub avg_append_gap_ms: f64,
82    pub min_append_gap_ms: f64,
83    pub max_append_gap_ms: f64,
84    pub track_key_count: usize,
85    pub finished_track_count: usize,
86    pub prot_key_count: usize,
87}