[−][src]Struct usfx::Mixer
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,