use crate::{
arena::NodeId, buffer_pool::BufferId, param::ParamBlock, state::StateBlob, BUFFER_SIZE,
MAX_INPUTS,
};
pub trait DspNode: Send {
fn process(
&mut self,
inputs: &[Option<&[f32; BUFFER_SIZE]>; MAX_INPUTS],
output: &mut [f32; BUFFER_SIZE],
params: &mut ParamBlock,
sample_rate: f32,
);
fn capture_state(&self) -> StateBlob {
StateBlob::EMPTY
}
fn restore_state(&mut self, _state: StateBlob) {}
fn type_name(&self) -> &'static str;
}
pub struct NodeRecord {
pub processor: Box<dyn DspNode>,
pub inputs: [Option<NodeId>; MAX_INPUTS],
pub output_buffer: BufferId,
pub params: ParamBlock,
}
impl NodeRecord {
pub fn new(processor: Box<dyn DspNode>, output_buffer: BufferId) -> Self {
Self {
processor,
inputs: [None; MAX_INPUTS],
output_buffer,
params: ParamBlock::new(),
}
}
}