Skip to main content

aether_nodes/
gain.rs

1//! Gain node — scales input by a linear gain factor.
2//!
3//! Param layout:
4//!   0 = gain (linear, 0..4)
5
6use aether_core::{node::DspNode, param::ParamBlock, BUFFER_SIZE, MAX_INPUTS};
7
8pub struct Gain;
9
10impl DspNode for Gain {
11    fn process(
12        &mut self,
13        inputs: &[Option<&[f32; BUFFER_SIZE]>; MAX_INPUTS],
14        output: &mut [f32; BUFFER_SIZE],
15        params: &mut ParamBlock,
16        _sample_rate: f32,
17    ) {
18        let silence = [0.0f32; BUFFER_SIZE];
19        let input = inputs[0].unwrap_or(&silence);
20        for (i, out) in output.iter_mut().enumerate() {
21            *out = input[i] * params.get(0).current;
22            params.tick_all();
23        }
24    }
25
26    fn type_name(&self) -> &'static str {
27        "Gain"
28    }
29}