Trait audio_generator::Generator [−][src]
The trait for an audio generator.
Associated Types
Loading content...Required methods
fn sample(&mut self) -> Self::Sample
[src]
Generate the next sample from the generator. Advances the underlying generator to the next sample.
Examples
use audio_generator::{Generator, Sin}; let mut g = Sin::new(440.0, 44100.0); assert_eq!(g.sample(), 0.0); assert!(g.sample() > 0.0);
Provided methods
fn iter(self) -> Iter<Self> where
Self: Sized,
[src]
Self: Sized,
Construct an iterator from this generator.
use audio_generator::{Generator, Sin}; let mut g = Sin::new(440.0, 44100.0).amplitude(0.5); let samples = g.iter().take(10).collect::<Vec<f32>>(); assert_eq!(samples.len(), 10);
fn amplitude(self, amplitude: f32) -> Amplitude<Self> where
Self: Sized,
[src]
Self: Sized,
Modify the amplitude of the sample.
Examples
use audio_generator::{Generator, Sin}; let mut a = Sin::new(440.0, 44100.0).amplitude(0.1); let mut b = Sin::new(440.0, 44100.0).amplitude(0.1); for _ in 0..100 { assert!(a.sample().abs() <= b.sample().abs()); }