dasp_signal

Function gen

Source
pub fn gen<G, F>(gen: G) -> Gen<G, F>
where G: Fn() -> F, F: Frame,
Expand description

A signal that generates frames using the given function.

The resulting signal is assumed to be infinite and is_exhausted will always return false. To create an exhaustive signal first create an Iterator and then use from_iter.

ยงExample

use dasp_signal::{self as signal, Signal};

fn main() {
    let mut frames = signal::gen(|| [0.5]);
    assert_eq!(frames.next(), [0.5]);
    assert_eq!(frames.next(), [0.5]);
    assert_eq!(frames.next(), [0.5]);
}