Struct sampara::signal::Phase[][src]

pub struct Phase<D, const N: usize> where
    D: Delta<N>, 
{ /* fields omitted */ }

A Signal that wraps a Delta and accumulates it in an automated way, wrapping it to the interval [0.0, 1.0) as needed.

use sampara::{signal, Signal};

fn main() {
    let mut phase = signal::phase_hz(44100.0, 440.0);

    assert_eq!(phase.next(), Some(0.009977324263038548));
    assert_eq!(phase.next(), Some(0.019954648526077097));
    assert_eq!(phase.next(), Some(0.029931972789115645));

    // [`Phase`] keeps track of the accumutated steps, and resets back to
    // 0.0 if it exceeds 1.0.
    let mut phase = signal::phase_hz(1.1, 0.5);
    assert_eq!(phase.next(), Some(0.45454545454545453));
    assert_eq!(phase.next(), Some(0.9090909090909091));
    assert_eq!(phase.next(), Some(0.36363636363636354));
}

Trait Implementations

impl<D, const N: usize> Signal<N> for Phase<D, N> where
    D: Delta<N>, 
[src]

type Frame = D::Delta

The Frame type returned by this Signal.

Auto Trait Implementations

impl<D, const N: usize> RefUnwindSafe for Phase<D, N> where
    D: RefUnwindSafe,
    <D as Delta<N>>::Delta: RefUnwindSafe

impl<D, const N: usize> Send for Phase<D, N> where
    D: Send,
    <D as Delta<N>>::Delta: Send

impl<D, const N: usize> Sync for Phase<D, N> where
    D: Sync,
    <D as Delta<N>>::Delta: Sync

impl<D, const N: usize> Unpin for Phase<D, N> where
    D: Unpin,
    <D as Delta<N>>::Delta: Unpin

impl<D, const N: usize> UnwindSafe for Phase<D, N> where
    D: UnwindSafe,
    <D as Delta<N>>::Delta: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.