Function dsp::signal::phase [] [src]

pub fn phase<S>(step: S) -> Phase<S> where S: Step

Creates a Phase that continuously steps forward by the given step size yielder.

Example

extern crate sample;

use sample::signal;

fn main() {
    let step = signal::rate(4.0).const_hz(1.0);
    // Note that this is the same as `step.phase()`, a composable alternative.
    let mut phase = signal::phase(step);
    assert_eq!(phase.next(), Some([0.0]));
    assert_eq!(phase.next(), Some([0.25]));
    assert_eq!(phase.next(), Some([0.5]));
    assert_eq!(phase.next(), Some([0.75]));
    assert_eq!(phase.next(), Some([0.0]));
    assert_eq!(phase.next(), Some([0.25]));
}