Struct Node

Source
pub struct Node<F> { /* private fields */ }
Expand description

An audio node: a source, a sink, a filter, an effect, etc.

Implementations§

Source§

impl<F> Node<F>

Source

pub fn add_sine(&self, f: Freq, phase: f32) -> Node<Sine>

Add sine wave oscillator source ().

Examples found in repository?
examples/audio_sine/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_sine(audio::Freq::A4, 0.);
8}
More examples
Hide additional examples
examples/audio_chord/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_sine(audio::Freq::C4, 0.);
8    audio::OUT.add_sine(audio::Freq::E4, 0.);
9    audio::OUT.add_sine(audio::Freq::G4, 0.);
10}
examples/audio_modulator/main.rs (line 14)
6extern fn boot() {
7    let gain = audio::OUT.add_gain(0.);
8    gain.modulate(audio::LinearModulator {
9        start: 0.,
10        end: 1.,
11        start_at: audio::Time::ZERO,
12        end_at: audio::Time::seconds(2),
13    });
14    gain.add_sine(audio::Freq::A4, 0.);
15}
Source

pub fn add_square(&self, f: Freq, phase: f32) -> Node<Square>

Add square wave oscillator source ().

Examples found in repository?
examples/audio_square/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_square(audio::Freq::A4, 0.);
8}
Source

pub fn add_sawtooth(&self, f: Freq, phase: f32) -> Node<Sawtooth>

Add sawtooth wave oscillator source (╱│).

Examples found in repository?
examples/audio_sawtooth/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_sawtooth(audio::Freq::A4, 0.);
8}
Source

pub fn add_triangle(&self, f: Freq, phase: f32) -> Node<Triangle>

Add triangle wave oscillator source (╱╲).

Examples found in repository?
examples/audio_triangle/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_triangle(audio::Freq::A4, 0.);
8}
Source

pub fn add_noise(&self, seed: i32) -> Node<Noise>

Add white noise source (amplitude on each tick is random).

Examples found in repository?
examples/audio_noise/main.rs (line 7)
6extern fn boot() {
7    audio::OUT.add_noise(0);
8}
Source

pub fn add_empty(&self) -> Node<Empty>

Add always stopped source.

Source

pub fn add_zero(&self) -> Node<Zero>

Add silent source producing zeros.

Source

pub fn add_file(&self, path: &str) -> Node<File>

Play an audio file from ROM.

Source

pub fn add_mix(&self) -> Node<Mix>

Add node simply mixing all inputs.

Source

pub fn add_all_for_one(&self) -> Node<AllForOne>

Add mixer node that stops if any of the sources stops.

Source

pub fn add_gain(&self, lvl: f32) -> Node<Gain>

Add gain control node.

Examples found in repository?
examples/audio_modulator/main.rs (line 7)
6extern fn boot() {
7    let gain = audio::OUT.add_gain(0.);
8    gain.modulate(audio::LinearModulator {
9        start: 0.,
10        end: 1.,
11        start_at: audio::Time::ZERO,
12        end_at: audio::Time::seconds(2),
13    });
14    gain.add_sine(audio::Freq::A4, 0.);
15}
Source

pub fn add_loop(&self) -> Node<Loop>

Add a loop node that resets the input if it stops.

Source

pub fn add_concat(&self) -> Node<Concat>

Add a node that plays the inputs one after the other, in the order as they added.

Source

pub fn add_pan(&self, lvl: f32) -> Node<Pan>

Add node panning the audio to the left (0.), right (1.), or something in between.

Source

pub fn add_mute(&self) -> Node<Mute>

Add node that can be muted using modulation.

Source

pub fn add_pause(&self) -> Node<Pause>

Add node that can be paused using modulation.

Source

pub fn add_track_position(&self) -> Node<TrackPosition>

Add node tracking the elapsed playback time.

Source

pub fn add_low_pass(&self, freq: f32, q: f32) -> Node<LowPass>

Add lowpass filter node.

Source

pub fn add_high_pass(&self, freq: f32, q: f32) -> Node<HighPass>

Add highpass filter node.

Source

pub fn add_take_left(&self) -> Node<TakeLeft>

Add node converting stereo to mono by taking the left channel.

Source

pub fn add_take_right(&self) -> Node<TakeRight>

Add node converting stereo to mono by taking the right channel.

Source

pub fn add_swap(&self) -> Node<Swap>

Add node swapping left and right channels of the stereo input.

Source

pub fn add_clip(&self, low: f32, high: f32) -> Node<Clip>

Add node clamping the input amplitude. Can be used for hard distortion.

Source

pub fn reset(&self)

Reset the node state to how it was when it was just added.

Source

pub fn reset_all(&self)

Reset the node and all child nodes to the state to how it was when they were just added.

Source

pub fn clear(&self)

Remove all child nodes.

After it is called, you should make sure to discard all references to the old child nodes.

Source§

impl Node<Sine>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate oscillation frequency.

Source§

impl Node<Square>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate oscillation frequency.

Source§

impl Node<Sawtooth>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate oscillation frequency.

Source§

impl Node<Triangle>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate oscillation frequency.

Source§

impl Node<Gain>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate the gain level.

Examples found in repository?
examples/audio_modulator/main.rs (lines 8-13)
6extern fn boot() {
7    let gain = audio::OUT.add_gain(0.);
8    gain.modulate(audio::LinearModulator {
9        start: 0.,
10        end: 1.,
11        start_at: audio::Time::ZERO,
12        end_at: audio::Time::seconds(2),
13    });
14    gain.add_sine(audio::Freq::A4, 0.);
15}
Source§

impl Node<Pan>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate the pan value (from 0. to 1.: 0. is only left, 1. is only right).

Source§

impl Node<Mute>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate the muted state.

Below 0.5 is muted, above is unmuted.

Source§

impl Node<Pause>

Source

pub fn modulate<M: Modulator>(&self, m: M)

Modulate the paused state.

Below 0.5 is paused, above is playing.

Source§

impl Node<LowPass>

Source

pub fn modulate_freq<M: Modulator>(&self, m: M)

Modulate the cut-off frequency.

Source§

impl Node<HighPass>

Source

pub fn modulate_freq<M: Modulator>(&self, m: M)

Modulate the cut-off frequency.

Source§

impl Node<Clip>

Source

pub fn modulate_both<M: Modulator>(&self, m: M)

Modulate the low cut amplitude and adjust the high amplitude to keep the gap.

In other words, the difference between low and high cut points will stay the same.

Source

pub fn modulate_low<M: Modulator>(&self, m: M)

Modulate the low cut amplitude.

Source

pub fn modulate_high<M: Modulator>(&self, m: M)

Modulate the high cut amplitude.

Auto Trait Implementations§

§

impl<F> Freeze for Node<F>

§

impl<F> RefUnwindSafe for Node<F>
where F: RefUnwindSafe,

§

impl<F> Send for Node<F>
where F: Send,

§

impl<F> Sync for Node<F>
where F: Sync,

§

impl<F> Unpin for Node<F>
where F: Unpin,

§

impl<F> UnwindSafe for Node<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.