Function sampara::signal::phase_hzs[][src]

pub fn phase_hzs<S, const N: usize>(
    rate: f64,
    hz_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_hz, this Phase will terminate and stop yielding step values once the contained Signal is fully consumed.

use sampara::{signal, Signal};

fn main() {
    let freq_signal = signal::from_frames(vec![
        [0.125, 0.250],
        [0.375, 0.500],
        [0.625, 0.750],
    ]);

    let mut phase = signal::phase_hzs(4.0, freq_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.125, 0.1875]));
    assert_eq!(phase.next(), Some([0.28125, 0.375]));
    assert_eq!(phase.next(), None);
}