pub trait Signal<S: Sample> {
Show 13 methods // Required methods fn frames(&self) -> usize; fn clear(&mut self); fn chan(&self, channel: usize) -> &[S]; fn chan_mut(&mut self, channel: usize) -> &mut [S]; fn chan_pair_mut( &mut self, first: usize, second: usize ) -> (&mut [S], &mut [S]); fn render_silence(&mut self, n_frames: Option<usize>); fn render_reserved(&mut self, n_frames: Option<usize>); fn render<'a, F>( &'a mut self, n_frames: Option<usize>, render: F ) -> Result<()> where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<()>; fn transform<F>(&mut self, f: F) where F: Fn(S) -> S; fn truncate(&mut self, n_frames: usize); fn shift(&mut self, shift: usize); // Provided methods fn fill<'a, F>(&'a mut self, fill: F) -> Result<()> where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<()> { ... } fn trim(&mut self, start: usize, end: usize) { ... }
}
Expand description

The Signal trait provides methods for rendering and transforming contiguous buffers of audio data.

Required Methods§

source

fn frames(&self) -> usize

Gets the number of actual frames written to the buffer. Conversely, this also is the number of written samples in any one channel.

source

fn clear(&mut self)

Clears all written frames from the buffer. This is a cheap operation and does not zero the underlying audio data.

source

fn chan(&self, channel: usize) -> &[S]

Gets an immutable reference to all the written samples in the specified channel.

source

fn chan_mut(&mut self, channel: usize) -> &mut [S]

Gets a mutable reference to all the written samples in the specified channel.

source

fn chan_pair_mut(&mut self, first: usize, second: usize) -> (&mut [S], &mut [S])

Gets two mutable references to two different channels.

source

fn render_silence(&mut self, n_frames: Option<usize>)

Renders a number of silent frames.

If n_frames is None, the remaining number of frames will be used.

source

fn render_reserved(&mut self, n_frames: Option<usize>)

Renders a reserved number of frames. This is a cheap operation and simply advances the frame counter. The underlying audio data is not modified and should be overwritten through other means.

If n_frames is None, the remaining number of frames will be used. If n_frames is too large, this function will assert.

source

fn render<'a, F>(&'a mut self, n_frames: Option<usize>, render: F) -> Result<()>
where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<()>,

Renders a number of frames using the provided render function. The number of frames to render is specified by n_frames. If n_frames is None, the remaining number of frames in the buffer will be rendered. If the render function returns an error, the render operation is terminated prematurely.

source

fn transform<F>(&mut self, f: F)
where F: Fn(S) -> S,

Transforms every written sample in the signal using the transformation function provided. This function does not guarantee an order in which the samples are transformed.

source

fn truncate(&mut self, n_frames: usize)

Truncates the buffer to the number of frames specified. If the number of frames in the buffer is less-than the number of frames specified, then this function does nothing.

source

fn shift(&mut self, shift: usize)

Shifts the contents of the buffer back by the number of frames specified. The leading frames are dropped from the buffer.

Provided Methods§

source

fn fill<'a, F>(&'a mut self, fill: F) -> Result<()>
where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<()>,

Clears, and then renders the entire buffer using the fill function. This is a convenience wrapper around render and exhibits the same behaviour as render in regards to the fill function.

source

fn trim(&mut self, start: usize, end: usize)

Trims samples from the start and end of the buffer.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<S: Sample> Signal<S> for AudioBuffer<S>