Struct sample::signal::Buffered[][src]

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.

Methods

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

Important traits for BufferedFrames<'a, D>

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.

extern crate sample;

use sample::signal::{self, Signal};
use sample::ring_buffer;

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::<[[f32; 1]; 2]>::array();
    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]]);
}

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

The Frame type returned by the Signal.

Yield the next Frame in the Signal. Read more

Whether or not the signal is exhausted of meaningful frames. Read more

A signal that maps one set of frames to another. Read more

A signal that maps one set of frames to another. Read more

Provides an iterator that yields the sum of the frames yielded by both other and self in lock-step. Read more

Provides an iterator that yields the product of the frames yielded by both other and self in lock-step. Read more

Provides an iterator that offsets the amplitude of every channel in each frame of the signal by some sample value and yields the resulting frames. Read more

Produces an Iterator that scales the amplitude of the sample of each channel in every Frame yielded by self by the given amplitude. Read more

Produces a new Signal that offsets the amplitude of every Frame in self by the respective amplitudes in each channel of the given amp_frame. Read more

Produces a new Signal that scales the amplitude of every Frame in self by the respective amplitudes in each channel of the given amp_frame. Read more

Multiplies the rate at which frames of self are yielded by the given signal. Read more

Converts the rate at which frames of the Signal are yielded using interpolation. Read more

Multiplies the rate at which frames of the Signal are yielded by the given value. Read more

Delays the Signal by the given number of frames. Read more

Converts a Signal into a type that yields the interleaved Samples. Read more

Clips the amplitude of each channel in each Frame yielded by self to the given threshold amplitude. Read more

Create a new Signal that calls the enclosing function on each iteration. Read more

Forks Self into two signals that produce the same frames. Read more

Moves the Signal into a Bus from which its output may be divided into multiple other Signals in the form of Outputs. Read more

Important traits for Take<S>

Converts the Signal into an Iterator that will yield the given number for Frames before returning None. Read more

Important traits for UntilExhausted<S>

Converts the Signal into an Iterator yielding frames until the signal.is_exhausted() returns true. Read more

Buffers the signal using the given ring buffer. Read more

An adaptor that yields the RMS of the signal. Read more

An adaptor that detects and yields the envelope of the signal. Read more

Borrows a Signal rather than consuming it. Read more

Auto Trait Implementations

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