devela::_dep::symphonia::core::audio

Trait Signal

pub trait Signal<S>
where 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<(), Error> where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<(), Error>; 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<(), Error> where F: FnMut(&mut AudioPlanesMut<'a, S>, usize) -> Result<(), Error> { ... } fn trim(&mut self, start: usize, end: usize) { ... }
}
Available on crate feature dep_symphonia only.
Expand description

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

Required Methods§

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.

fn clear(&mut self)

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

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

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

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

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

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

Gets two mutable references to two different channels.

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.

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.

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

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.

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.

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.

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§

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

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.

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§

§

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