symphonia_core::audio

Trait Signal

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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