[−][src]Struct dasp_signal::Buffered
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]
S: Signal,
D: Slice<Element = S::Frame> + SliceMut,
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]
S: Signal,
D: Slice<Element = S::Frame> + SliceMut,
type Frame = S::Frame
The Frame
type returned by the Signal
.
fn next(&mut self) -> Self::Frame
[src]
fn is_exhausted(&self) -> bool
[src]
fn map<M, F>(self, map: M) -> Map<Self, M, F> where
Self: Sized,
M: FnMut(Self::Frame) -> F,
F: Frame,
[src]
Self: Sized,
M: FnMut(Self::Frame) -> F,
F: Frame,
fn zip_map<O, M, F>(self, other: O, map: M) -> ZipMap<Self, O, M, F> where
Self: Sized,
M: FnMut(Self::Frame, O::Frame) -> F,
O: Signal,
F: Frame,
[src]
Self: Sized,
M: FnMut(Self::Frame, O::Frame) -> F,
O: Signal,
F: Frame,
fn add_amp<S>(self, other: S) -> AddAmp<Self, S> where
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
fn mul_amp<S>(self, other: S) -> MulAmp<Self, S> where
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
fn offset_amp(
self,
offset: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> OffsetAmp<Self> where
Self: Sized,
[src]
self,
offset: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> OffsetAmp<Self> where
Self: Sized,
fn scale_amp(
self,
amp: <<Self::Frame as Frame>::Sample as Sample>::Float
) -> ScaleAmp<Self> where
Self: Sized,
[src]
self,
amp: <<Self::Frame as Frame>::Sample as Sample>::Float
) -> ScaleAmp<Self> where
Self: Sized,
fn offset_amp_per_channel<F>(self, amp_frame: F) -> OffsetAmpPerChannel<Self, F> where
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
fn scale_amp_per_channel<F>(self, amp_frame: F) -> ScaleAmpPerChannel<Self, F> where
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
fn mul_hz<M, I>(self, interpolator: I, mul_per_frame: M) -> MulHz<Self, M, I> where
Self: Sized,
M: Signal<Frame = f64>,
I: Interpolator,
[src]
Self: Sized,
M: Signal<Frame = f64>,
I: Interpolator,
fn from_hz_to_hz<I>(
self,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
[src]
self,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
fn scale_hz<I>(self, interpolator: I, multi: f64) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
[src]
Self: Sized,
I: Interpolator,
fn delay(self, n_frames: usize) -> Delay<Self> where
Self: Sized,
[src]
Self: Sized,
fn into_interleaved_samples(self) -> IntoInterleavedSamples<Self> where
Self: Sized,
[src]
Self: Sized,
fn clip_amp(
self,
thresh: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> ClipAmp<Self> where
Self: Sized,
[src]
self,
thresh: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> ClipAmp<Self> where
Self: Sized,
fn inspect<F>(self, inspect: F) -> Inspect<Self, F> where
Self: Sized,
F: FnMut(&Self::Frame),
[src]
Self: Sized,
F: FnMut(&Self::Frame),
fn fork<S>(self, ring_buffer: Bounded<S>) -> Fork<Self, S> where
Self: Sized,
S: SliceMut<Element = Self::Frame>,
[src]
Self: Sized,
S: SliceMut<Element = Self::Frame>,
fn take(self, n: usize) -> Take<Self> where
Self: Sized,
[src]
Self: Sized,
fn until_exhausted(self) -> UntilExhausted<Self> where
Self: Sized,
[src]
Self: Sized,
fn buffered<S>(self, ring_buffer: Bounded<S>) -> Buffered<Self, S> where
Self: Sized,
S: Slice<Element = Self::Frame> + SliceMut,
[src]
Self: Sized,
S: Slice<Element = Self::Frame> + SliceMut,
fn by_ref(&mut self) -> &mut Self where
Self: Sized,
[src]
Self: Sized,
Auto Trait Implementations
impl<S, D> RefUnwindSafe for Buffered<S, D> where
D: RefUnwindSafe,
S: RefUnwindSafe,
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, D> Send for Buffered<S, D> where
D: Send,
S: Send,
D: Send,
S: Send,
impl<S, D> Sync for Buffered<S, D> where
D: Sync,
S: Sync,
D: Sync,
S: Sync,
impl<S, D> Unpin for Buffered<S, D> where
D: Unpin,
S: Unpin,
D: Unpin,
S: Unpin,
impl<S, D> UnwindSafe for Buffered<S, D> where
D: UnwindSafe,
S: UnwindSafe,
D: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
[src]
T: FromSample<S> + ToSample<S>,
impl<T> From<T> for T
[src]
impl<S> FromSample<S> for S
[src]
fn from_sample_(s: S) -> S
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SignalBus for T where
T: Signal,
[src]
T: Signal,
impl<T> SignalEnvelope for T where
T: Signal,
[src]
T: Signal,
fn detect_envelope<D>(
self,
detector: Detector<Self::Frame, D>
) -> DetectEnvelope<Self, D> where
Self: Sized,
D: Detect<Self::Frame>,
[src]
self,
detector: Detector<Self::Frame, D>
) -> DetectEnvelope<Self, D> where
Self: Sized,
D: Detect<Self::Frame>,
impl<T> SignalRms for T where
T: Signal,
[src]
T: Signal,
fn rms<S>(self, ring_buffer: Fixed<S>) -> Rms<Self, S> where
Self: Sized,
S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut,
[src]
Self: Sized,
S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
[src]
U: FromSample<T>,
fn to_sample_(self) -> U
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,