pub struct An<X: AudioNode>(pub X);
Expand description
AudioNode wrapper that implements operators and traits.
Tuple Fields§
§0: X
Implementations§
Source§impl<X: AudioNode> An<X>
impl<X: AudioNode> An<X>
pub fn reset(&mut self)
pub fn set_sample_rate(&mut self, sample_rate: f64)
pub fn tick(&mut self, input: &Frame<f32, X::Inputs>) -> Frame<f32, X::Outputs>
pub fn process( &mut self, size: usize, input: &BufferRef<'_>, output: &mut BufferMut<'_>, )
pub fn route(&mut self, input: &SignalFrame, frequency: f64) -> SignalFrame
pub fn inputs(&self) -> usize
pub fn outputs(&self) -> usize
pub fn set_hash(&mut self, hash: u64)
pub fn ping(&mut self, probe: bool, hash: AttoHash) -> AttoHash
pub fn get_mono(&mut self) -> f32
pub fn get_stereo(&mut self) -> (f32, f32)
pub fn filter_mono(&mut self, x: f32) -> f32
pub fn filter_stereo(&mut self, x: f32, y: f32) -> (f32, f32)
Trait Implementations§
Source§impl<X: AudioNode + Sync + Send> AudioUnit for An<X>
impl<X: AudioNode + Sync + Send> AudioUnit for An<X>
Source§fn reset(&mut self)
fn reset(&mut self)
Reset the input state of the unit to an initial state where it has not processed any data.
In other words, reset time to zero.
Source§fn set_sample_rate(&mut self, sample_rate: f64)
fn set_sample_rate(&mut self, sample_rate: f64)
Set the sample rate of the unit.
The default sample rate is 44100 Hz.
The unit is allowed to reset itself here in response to sample rate changes.
If the sample rate stays unchanged, then the goal is to maintain current state.
Source§fn tick(&mut self, input: &[f32], output: &mut [f32])
fn tick(&mut self, input: &[f32], output: &mut [f32])
Process one sample.
The length of
input
and output
must be equal to inputs
and outputs
, respectively.Source§fn process(
&mut self,
size: usize,
input: &BufferRef<'_>,
output: &mut BufferMut<'_>,
)
fn process( &mut self, size: usize, input: &BufferRef<'_>, output: &mut BufferMut<'_>, )
Process up to 64 (MAX_BUFFER_SIZE) samples.
If
size
is zero then this is a no-op, which is permitted.Source§fn set(&mut self, setting: Setting)
fn set(&mut self, setting: Setting)
Set a parameter. What formats are recognized depends on the component.
Source§fn inputs(&self) -> usize
fn inputs(&self) -> usize
Number of inputs to this unit.
Equals size of the input argument in
tick
and process
.
This should be fixed after construction.Source§fn outputs(&self) -> usize
fn outputs(&self) -> usize
Number of outputs from this unit.
Equals size of the output argument in
tick
and process
.
This should be fixed after construction.Source§fn route(&mut self, input: &SignalFrame, frequency: f64) -> SignalFrame
fn route(&mut self, input: &SignalFrame, frequency: f64) -> SignalFrame
Route constants, latencies and frequency responses at
frequency
Hz
from inputs to outputs. Return output signal.Source§fn set_hash(&mut self, hash: u64)
fn set_hash(&mut self, hash: u64)
Set unit pseudorandom phase hash. Override this to use the hash.
This is called from
ping
(only). It should not be called by users.Source§fn ping(&mut self, probe: bool, hash: AttoHash) -> AttoHash
fn ping(&mut self, probe: bool, hash: AttoHash) -> AttoHash
Ping contained
AudioUnit
s and AudioNode
s to obtain
a deterministic pseudorandom hash. The local hash includes children, too.
Leaf nodes should not need to override this.
If probe
is true, then this is a probe for computing the network hash
and set_hash
should not be called yet.
To set a custom hash for a graph, call this method with ping
set to false and hash
initialized with the custom hash.Source§fn footprint(&self) -> usize
fn footprint(&self) -> usize
Memory footprint of this unit in bytes, without counting buffers and other allocations.
Source§fn get_mono(&mut self) -> f32
fn get_mono(&mut self) -> f32
Retrieve the next mono sample from a generator.
The node must have no inputs and 1 or 2 outputs.
If there are two outputs, average them. Read more
Source§fn get_stereo(&mut self) -> (f32, f32)
fn get_stereo(&mut self) -> (f32, f32)
Retrieve the next stereo sample (left, right) from a generator.
The node must have no inputs and 1 or 2 outputs.
If there is just one output, duplicate it. Read more
Source§fn filter_mono(&mut self, x: f32) -> f32
fn filter_mono(&mut self, x: f32) -> f32
Filter the next mono sample
x
.
The node must have exactly 1 input and 1 output. Read moreSource§fn filter_stereo(&mut self, x: f32, y: f32) -> (f32, f32)
fn filter_stereo(&mut self, x: f32, y: f32) -> (f32, f32)
Filter the next stereo sample
(x, y)
.
The node must have exactly 2 inputs and 2 outputs. Read moreSource§fn response(&mut self, output: usize, frequency: f64) -> Option<Complex64>
fn response(&mut self, output: usize, frequency: f64) -> Option<Complex64>
Evaluate frequency response of
output
at frequency
Hz.
Any linear response can be composed.
Return None
if there is no response or it could not be calculated. Read moreSource§fn response_db(&mut self, output: usize, frequency: f64) -> Option<f64>
fn response_db(&mut self, output: usize, frequency: f64) -> Option<f64>
Evaluate frequency response of
output
in dB at frequency
Hz.
Any linear response can be composed.
Return None
if there is no response or it could not be calculated. Read moreSource§impl<X> Not for An<X>where
X: AudioNode,
The thru operator makes output arity match input arity
and passes through missing outputs.
impl<X> Not for An<X>where
X: AudioNode,
The thru operator makes output arity match input arity and passes through missing outputs.
Auto Trait Implementations§
impl<X> Freeze for An<X>where
X: Freeze,
impl<X> RefUnwindSafe for An<X>where
X: RefUnwindSafe,
impl<X> Send for An<X>
impl<X> Sync for An<X>
impl<X> Unpin for An<X>where
X: Unpin,
impl<X> UnwindSafe for An<X>where
X: UnwindSafe,
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