Trait symphonia_core::audio::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§
sourcefn 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.
sourcefn 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.
sourcefn chan(&self, channel: usize) -> &[S]
fn chan(&self, channel: usize) -> &[S]
Gets an immutable reference to all the written samples in the specified channel.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn render<'a, F>(&'a mut self, n_frames: Option<usize>, render: F) -> Result<()>
fn render<'a, F>(&'a mut self, n_frames: Option<usize>, render: F) -> 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.
sourcefn 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.