Function dsp::signal::sine [] [src]

pub fn sine<S>(phase: Phase<S>) -> Sine<S>

Produces a Signal that yields a sine wave oscillating at the given hz.

Example

extern crate sample;

use sample::signal;

fn main() {
    // Generates a sine wave signal at 1hz to be sampled 4 times per second.
    let mut signal = signal::rate(4.0).const_hz(1.0).sine();
    assert_eq!(signal.next(), Some([0.0]));
    assert_eq!(signal.next(), Some([1.0]));
    signal.next();
    assert_eq!(signal.next(), Some([-1.0]));
}