pub struct NodeInputs<'a> {
pub raw: &'a [Option<&'a [f32; 64]>; 8],
}Expand description
Ergonomic wrapper around the raw input buffer array.
Fields§
§raw: &'a [Option<&'a [f32; 64]>; 8]Implementations§
Source§impl<'a> NodeInputs<'a>
impl<'a> NodeInputs<'a>
Sourcepub fn get(&self, slot: usize) -> &[f32; 64]
pub fn get(&self, slot: usize) -> &[f32; 64]
Examples found in repository?
examples/simple_gain.rs (line 30)
22 fn process(
23 &mut self,
24 inputs: &NodeInputs,
25 output: &mut NodeOutput,
26 params: &mut ParamBlock,
27 _sample_rate: f32,
28 ) {
29 // Get input buffer (or silence if not connected)
30 let input = inputs.get(0);
31
32 // Get current gain value (smoothed automatically)
33 let gain = params.get(0).current;
34
35 // Process each sample
36 for (i, out) in output.iter_mut().enumerate() {
37 *out = input[i] * gain;
38 params.tick_all(); // Advance parameter smoothing
39 }
40 }More examples
examples/tremolo.rs (line 26)
19 fn process(
20 &mut self,
21 inputs: &NodeInputs,
22 output: &mut NodeOutput,
23 params: &mut ParamBlock,
24 sample_rate: f32,
25 ) {
26 let input = inputs.get(0);
27 for (i, out) in output.iter_mut().enumerate() {
28 let rate = params.get(0).current;
29 let depth = params.get(1).current;
30 // LFO: 1.0 at phase=0, dips to (1-depth) at phase=0.5
31 let lfo = 1.0 - depth * 0.5 * (1.0 - (self.phase * std::f32::consts::TAU).cos());
32 *out = input[i] * lfo;
33 self.phase = (self.phase + rate / sample_rate).fract();
34 params.tick_all();
35 }
36 }examples/bitcrusher.rs (line 26)
19 fn process(
20 &mut self,
21 inputs: &NodeInputs,
22 output: &mut NodeOutput,
23 params: &mut ParamBlock,
24 _sample_rate: f32,
25 ) {
26 let input = inputs.get(0);
27 for (i, out) in output.iter_mut().enumerate() {
28 let bits = params.get(0).current.clamp(1.0, 16.0);
29 let crush = params.get(1).current.clamp(1.0, 32.0);
30
31 // Sample-rate reduction
32 self.counter += 1.0;
33 if self.counter >= crush {
34 self.counter = 0.0;
35 // Bit quantization
36 let levels = (2.0f32).powf(bits);
37 self.held_sample = (input[i] * levels).round() / levels;
38 }
39 *out = self.held_sample;
40 params.tick_all();
41 }
42 }Auto Trait Implementations§
impl<'a> Freeze for NodeInputs<'a>
impl<'a> RefUnwindSafe for NodeInputs<'a>
impl<'a> Send for NodeInputs<'a>
impl<'a> Sync for NodeInputs<'a>
impl<'a> Unpin for NodeInputs<'a>
impl<'a> UnsafeUnpin for NodeInputs<'a>
impl<'a> UnwindSafe for NodeInputs<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more