[][src]Struct dasp_signal::Buffered

pub struct Buffered<S, D> { /* fields omitted */ }

Buffers the signal using the given ring buffer.

When next is called, Buffered will first check if the ring buffer is empty. If so, it will completely fill the ring buffer with signal before yielding the next frame.

If next is called and the ring buffer still contains un-yielded values, the next frame will be popped from the front of the ring buffer and immediately returned.

Implementations

impl<S, D> Buffered<S, D> where
    S: Signal,
    D: Slice<Element = S::Frame> + SliceMut
[src]

pub fn next_frames(&mut self) -> BufferedFrames<D>[src]

Produces an iterator yielding the next batch of buffered frames.

The returned iterator returns None once the inner ring buffer becomes exhausted.

If the inner ring buffer is empty when this method is called, the ring buffer will first be filled using Buffered's inner signal before BufferedFrames is returned.

use dasp_ring_buffer as ring_buffer;
use dasp_signal::{self as signal, Signal};

fn main() {
    let frames = [0.1, 0.2, 0.3, 0.4];
    let signal = signal::from_iter(frames.iter().cloned());
    let ring_buffer = ring_buffer::Bounded::from([0f32; 2]);
    let mut buffered_signal = signal.buffered(ring_buffer);
    assert_eq!(buffered_signal.next_frames().collect::<Vec<_>>(), vec![0.1, 0.2]);
    assert_eq!(buffered_signal.next_frames().collect::<Vec<_>>(), vec![0.3, 0.4]);
    assert_eq!(buffered_signal.next_frames().collect::<Vec<_>>(), vec![0.0, 0.0]);
}

pub fn into_parts(self) -> (S, Bounded<D>)[src]

Consumes the Buffered signal and returns its inner signal S and bounded ring buffer.

Trait Implementations

impl<S: Clone, D: Clone> Clone for Buffered<S, D>[src]

impl<S, D> Signal for Buffered<S, D> where
    S: Signal,
    D: Slice<Element = S::Frame> + SliceMut
[src]

type Frame = S::Frame

The Frame type returned by the Signal.

Auto Trait Implementations

impl<S, D> RefUnwindSafe for Buffered<S, D> where
    D: RefUnwindSafe,
    S: RefUnwindSafe

impl<S, D> Send for Buffered<S, D> where
    D: Send,
    S: Send

impl<S, D> Sync for Buffered<S, D> where
    D: Sync,
    S: Sync

impl<S, D> Unpin for Buffered<S, D> where
    D: Unpin,
    S: Unpin

impl<S, D> UnwindSafe for Buffered<S, D> where
    D: UnwindSafe,
    S: 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<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

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

impl<S> FromSample<S> for S[src]

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

impl<T> SignalBus for T where
    T: Signal
[src]

impl<T> SignalEnvelope for T where
    T: Signal
[src]

impl<T> SignalRms for T where
    T: Signal
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> ToSample<U> for T where
    U: FromSample<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.