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) { ... }
}
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 ⓘ
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)
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] ⓘ
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] ⓘ
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]) ⓘ
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>)
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>)
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> ⓘ
fn render<'a, F>( &'a mut self, n_frames: Option<usize>, render: F, ) -> 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,
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.
Provided Methods§
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.