Function sampara::signal::phase_steps[][src]

pub fn phase_steps<S, const N: usize>(
    delta_signal: S
) -> Phase<Variable<S, N>, N> where
    S: Signal<N>,
    S::Frame: Frame<N, Sample = f64>, 

Creates a Phase with Frames of deltas over time, as yielded by a Signal.

Unlike phase_step, this Phase will terminate and stop yielding step values once the contained Signal is fully consumed.

use sampara::{signal, Signal};

fn main() {
    let delta_signal = signal::from_frames(vec![
        [0.03125, 0.0625],
        [0.375, 0.500],
        [0.625, 0.750],
    ]);

    let mut phase = signal::phase_steps(delta_signal);

    // Note that this [`Phase`] terminates once the contained [`Signal`]
    // is consumed.
    assert_eq!(phase.next(), Some([0.03125, 0.0625]));
    assert_eq!(phase.next(), Some([0.40625, 0.5625]));
    assert_eq!(phase.next(), Some([0.03125, 0.3125]));
    assert_eq!(phase.next(), None);
}