Skip to main content

aura_core/
config.rs

1//! Activation-time processing configuration.
2
3/// How the host is driving audio through the plugin this activation.
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
5pub enum ProcessMode {
6    /// Fixed-rate realtime playback. Honor the no-alloc / no-lock rule.
7    #[default]
8    Realtime,
9    /// Ahead-of-time / prefetch style (e.g. VST3 kPrefetch). Treat like realtime
10    /// unless you have a specific reason to relax discipline.
11    Buffered,
12    /// Freewheeling offline render — no wall-clock deadline.
13    Offline,
14}
15
16impl ProcessMode {
17    #[must_use]
18    pub fn is_offline(self) -> bool {
19        matches!(self, Self::Offline)
20    }
21}
22
23/// Config handed to `reset` when the host (re)prepares the plugin.
24#[derive(Clone, Copy, Debug)]
25pub struct AudioConfig {
26    pub sample_rate: f64,
27    pub max_block_size: usize,
28    pub process_mode: ProcessMode,
29    /// Main input channel count for the selected bus layout (`0` = no input).
30    pub main_input_channels: u32,
31    /// Main output channel count for the selected bus layout.
32    pub main_output_channels: u32,
33    /// Optional sidechain input channel count for the selected bus layout (`0` = none).
34    pub sidechain_input_channels: u32,
35    /// Optional aux output channel count for the selected bus layout (`0` = none).
36    pub aux_output_channels: u32,
37}
38
39impl AudioConfig {
40    /// Stereo main I/O defaults (matches [`BusLayout::stereo`](crate::BusLayout::stereo)).
41    #[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}