Struct symphonia_core::audio::AudioBuffer
source · pub struct AudioBuffer<S: Sample> { /* private fields */ }
Expand description
AudioBuffer
is a container for multi-channel planar audio sample data. An AudioBuffer
is
characterized by the duration (capacity), and audio specification (channels and sample rate).
The capacity of an AudioBuffer
is the maximum number of samples the buffer may store per
channel. Manipulation of samples is accomplished through the Signal trait or direct buffer
manipulation.
Implementations§
source§impl<S: Sample> AudioBuffer<S>
impl<S: Sample> AudioBuffer<S>
sourcepub fn new(duration: Duration, spec: SignalSpec) -> Self
pub fn new(duration: Duration, spec: SignalSpec) -> Self
Instantiate a new AudioBuffer
using the specified signal specification and of the given
duration.
sourcepub fn unused() -> Self
pub fn unused() -> Self
Instantiates an unused AudioBuffer
. An unused AudioBuffer
will not allocate any memory,
has a sample rate of 0, and no audio channels.
sourcepub fn spec(&self) -> &SignalSpec
pub fn spec(&self) -> &SignalSpec
Gets the signal specification for the buffer.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Gets the total capacity of the buffer. The capacity is the maximum number of audio frames a buffer can store.
sourcepub fn planes(&self) -> AudioPlanes<'_, S>
pub fn planes(&self) -> AudioPlanes<'_, S>
Gets immutable references to all audio planes (channels) within the audio buffer.
Note: This is not a cheap operation for audio buffers with > 8 channels. It is advisable
that this call is only used when operating on large batches of frames. Generally speaking,
it is almost always better to use chan()
to selectively choose the plane to read instead.
sourcepub fn planes_mut(&mut self) -> AudioPlanesMut<'_, S>
pub fn planes_mut(&mut self) -> AudioPlanesMut<'_, S>
Gets mutable references to all audio planes (channels) within the buffer.
Note: This is not a cheap operation for audio buffers with > 8 channels. It is advisable
that this call is only used when modifying large batches of frames. Generally speaking,
it is almost always better to use render()
, fill()
, chan_mut()
, and chan_pair_mut()
to modify the buffer instead.
sourcepub fn convert<T: Sample>(&self, dest: &mut AudioBuffer<T>)where
S: IntoSample<T>,
pub fn convert<T: Sample>(&self, dest: &mut AudioBuffer<T>)where
S: IntoSample<T>,
Converts the contents of an AudioBuffer into an equivalent destination AudioBuffer of a different type. If the types are the same then this is a copy operation.
sourcepub fn make_equivalent<E: Sample>(&self) -> AudioBuffer<E>
pub fn make_equivalent<E: Sample>(&self) -> AudioBuffer<E>
Makes an equivalent AudioBuffer of a different type.
Trait Implementations§
source§impl AsAudioBufferRef for AudioBuffer<f32>
impl AsAudioBufferRef for AudioBuffer<f32>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<f64>
impl AsAudioBufferRef for AudioBuffer<f64>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<i16>
impl AsAudioBufferRef for AudioBuffer<i16>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<i24>
impl AsAudioBufferRef for AudioBuffer<i24>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<i32>
impl AsAudioBufferRef for AudioBuffer<i32>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<i8>
impl AsAudioBufferRef for AudioBuffer<i8>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<u16>
impl AsAudioBufferRef for AudioBuffer<u16>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<u24>
impl AsAudioBufferRef for AudioBuffer<u24>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<u32>
impl AsAudioBufferRef for AudioBuffer<u32>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl AsAudioBufferRef for AudioBuffer<u8>
impl AsAudioBufferRef for AudioBuffer<u8>
source§fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
fn as_audio_buffer_ref(&self) -> AudioBufferRef<'_>
AudioBufferRef
reference.source§impl<S: Clone + Sample> Clone for AudioBuffer<S>
impl<S: Clone + Sample> Clone for AudioBuffer<S>
source§fn clone(&self) -> AudioBuffer<S>
fn clone(&self) -> AudioBuffer<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Sample> Signal<S> for AudioBuffer<S>
impl<S: Sample> Signal<S> for AudioBuffer<S>
source§fn clear(&mut self)
fn clear(&mut self)
source§fn frames(&self) -> usize
fn frames(&self) -> usize
source§fn chan(&self, channel: usize) -> &[S]
fn chan(&self, channel: usize) -> &[S]
source§fn chan_mut(&mut self, channel: usize) -> &mut [S]
fn chan_mut(&mut self, channel: usize) -> &mut [S]
source§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])
source§fn render_silence(&mut self, n_frames: Option<usize>)
fn render_silence(&mut self, n_frames: Option<usize>)
source§fn render_reserved(&mut self, n_frames: Option<usize>)
fn render_reserved(&mut self, n_frames: Option<usize>)
source§fn 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<()>
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.