[][src]Struct usfx::Mixer

pub struct Mixer { /* fields omitted */ }

Manage samples and mix the volume output of each.

// Instantiate a new mixer with a sample rate of 44100
let mut mixer = usfx::Mixer::new(44_100);

// Create a default sample as the sinewave
let sample = usfx::Sample::default();
// Create another sample with a trianglewave
let mut other_sample = usfx::Sample::default();
other_sample.osc_type(usfx::OscillatorType::Triangle);

// Play two oscillators at the same time
mixer.play(sample);
mixer.play(other_sample);

// This buffer should be passed by the audio library.
let mut buffer = [0.0; 44_100];
// Fill the buffer with procedurally generated sound.
mixer.generate(&mut buffer);

Methods

impl Mixer[src]

pub fn new(sample_rate: usize) -> Self[src]

Create a new mixer object.

pub fn play(&mut self, sample: Sample)[src]

Play a sample.

pub fn generate(&mut self, output: &mut [f32])[src]

Generate a frame for the sample.

The output buffer can be smaller but not bigger than the sample size.

// Instantiate a new mixer
let mut mixer = usfx::Mixer::default();

// Create a default sample as the sinewave
mixer.play(usfx::Sample::default());

// This buffer should be passed by the audio library
let mut buffer = [0.0; 44_100];
// Fill the buffer with procedurally generated sound
mixer.generate(&mut buffer);

Trait Implementations

impl Debug for Mixer[src]

impl Default for Mixer[src]

fn default() -> Self[src]

The default sample rate is 44100.

Auto Trait Implementations

impl !RefUnwindSafe for Mixer

impl Send for Mixer

impl !Sync for Mixer

impl Unpin for Mixer

impl UnwindSafe for Mixer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.