sim_lib_audio_graph_core/
block.rs1use sim_kernel::{Error, Result};
2
3use crate::{BlockArena, BlockEvent, EventSink, Transport};
4
5pub struct ProcessBlock<'a> {
8 pub frames: u32,
10 pub in_audio: &'a [&'a [f32]],
12 pub out_audio: &'a mut [&'a mut [f32]],
14 pub in_events: &'a [BlockEvent<'a>],
16 pub out_events: &'a mut dyn EventSink,
18 pub transport: Transport,
20 pub scratch: &'a mut BlockArena,
22}
23
24impl ProcessBlock<'_> {
25 pub fn validate_audio_lanes(&self) -> Result<()> {
28 let frames = self.frames as usize;
29 if let Some(len) = self
30 .in_audio
31 .iter()
32 .find_map(|lane| (lane.len() < frames).then_some(lane.len()))
33 {
34 return Err(Error::Eval(format!(
35 "input audio lane has {len} frames, expected at least {frames}"
36 )));
37 }
38 if let Some(len) = self
39 .out_audio
40 .iter()
41 .find_map(|lane| (lane.len() < frames).then_some(lane.len()))
42 {
43 return Err(Error::Eval(format!(
44 "output audio lane has {len} frames, expected at least {frames}"
45 )));
46 }
47 Ok(())
48 }
49}