vst_audio_protocol/
processing.rs1use crate::Bus;
3pub use vst_audio_ring::{
4 Event, EventBuffer, EventData, MAX_EVENTS, MAX_SYSEX_BYTES, SampleFormat, Transport,
5};
6
7#[derive(Clone, Debug, Eq, PartialEq)]
8pub struct BusConfiguration {
9 pub layout: Bus,
10 pub active: bool,
11}
12impl From<Bus> for BusConfiguration {
13 fn from(layout: Bus) -> Self {
14 Self {
15 layout,
16 active: true,
17 }
18 }
19}
20#[derive(Clone, Debug, Eq, PartialEq)]
21pub struct ProcessingSetup {
22 pub sample_rate: u32,
23 pub quantum: u32,
24 pub sample_format: SampleFormat,
25 pub offline: bool,
26 pub inputs: Vec<BusConfiguration>,
27 pub outputs: Vec<BusConfiguration>,
28}
29impl ProcessingSetup {
30 pub fn channels(buses: &[BusConfiguration]) -> u16 {
31 buses
32 .iter()
33 .filter(|b| b.active)
34 .map(|b| u32::from(b.layout.channels))
35 .sum::<u32>()
36 .min(u32::from(u16::MAX)) as u16
37 }
38 pub fn valid(&self) -> bool {
39 (1000..=1_000_000).contains(&self.sample_rate)
40 && (1..=65536).contains(&self.quantum)
41 && [&self.inputs, &self.outputs].iter().all(|buses| {
42 buses.len() <= 32
43 && Self::channels(buses) <= 64
44 && buses.iter().all(|b| {
45 b.layout.channels <= 64
46 && (b.layout.arrangement == 0
47 || b.layout.arrangement.count_ones()
48 == u32::from(b.layout.channels))
49 })
50 })
51 }
52}
53#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
54pub struct Capabilities {
55 pub f64: bool,
56 pub input_event_buses: u16,
57 pub output_event_buses: u16,
58 pub editor: bool,
59 pub sysex: bool,
60 pub sample_accurate_parameters: bool,
61}