1#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
5pub enum ProcessMode {
6 #[default]
8 Realtime,
9 Buffered,
12 Offline,
14}
15
16impl ProcessMode {
17 #[must_use]
18 pub fn is_offline(self) -> bool {
19 matches!(self, Self::Offline)
20 }
21}
22
23#[derive(Clone, Copy, Debug)]
25pub struct AudioConfig {
26 pub sample_rate: f64,
27 pub max_block_size: usize,
28 pub process_mode: ProcessMode,
29 pub main_input_channels: u32,
31 pub main_output_channels: u32,
33 pub sidechain_input_channels: u32,
35 pub aux_output_channels: u32,
37}
38
39impl AudioConfig {
40 #[must_use]
42 pub fn new(sample_rate: f64, max_block_size: usize) -> Self {
43 Self {
44 sample_rate,
45 max_block_size,
46 process_mode: ProcessMode::Realtime,
47 main_input_channels: 2,
48 main_output_channels: 2,
49 sidechain_input_channels: 0,
50 aux_output_channels: 0,
51 }
52 }
53
54 #[must_use]
55 pub fn with_process_mode(mut self, mode: ProcessMode) -> Self {
56 self.process_mode = mode;
57 self
58 }
59
60 #[must_use]
61 pub fn with_channels(mut self, main_in: u32, main_out: u32) -> Self {
62 self.main_input_channels = main_in;
63 self.main_output_channels = main_out;
64 self
65 }
66
67 #[must_use]
68 pub fn with_sidechain_channels(mut self, sidechain_in: u32) -> Self {
69 self.sidechain_input_channels = sidechain_in;
70 self
71 }
72
73 #[must_use]
74 pub fn with_aux_channels(mut self, aux_out: u32) -> Self {
75 self.aux_output_channels = aux_out;
76 self
77 }
78}