Struct web_audio_api::render::AudioRenderQuantum
source · [−]pub struct AudioRenderQuantum { /* private fields */ }
Expand description
Internal fixed length audio asset of RENDER_QUANTUM_SIZE
sample frames for
block rendering, basically a matrix of channels * [f32; RENDER_QUANTUM_SIZE]
cf. https://webaudio.github.io/web-audio-api/#render-quantum
An AudioRenderQuantum
has copy-on-write semantics, so it is cheap to clone.
Implementations
sourceimpl AudioRenderQuantum
impl AudioRenderQuantum
pub fn new(channel: AudioRenderQuantumChannel) -> Self
sourcepub fn number_of_channels(&self) -> usize
pub fn number_of_channels(&self) -> usize
Number of channels in this AudioRenderQuantum
sourcepub fn set_number_of_channels(&mut self, n: usize)
pub fn set_number_of_channels(&mut self, n: usize)
Set number of channels in this AudioRenderQuantum
Note: if the new number is higher than the previous, the new channels will be filled with garbage.
Panics
This function will panic if the given number of channels is outside the [1, 32] range, 32 being defined by the MAX_CHANNELS constant.
sourcepub fn channel_data(&self, index: usize) -> &AudioRenderQuantumChannel
pub fn channel_data(&self, index: usize) -> &AudioRenderQuantumChannel
Get the samples from this specific channel.
Panics
Panics if the index is greater than the available number of channels
sourcepub fn channel_data_mut(
&mut self,
index: usize
) -> &mut AudioRenderQuantumChannel
pub fn channel_data_mut(
&mut self,
index: usize
) -> &mut AudioRenderQuantumChannel
Get the samples (mutable) from this specific channel.
Panics
Panics if the index is greater than the available number of channels
sourcepub fn channels(&self) -> &[AudioRenderQuantumChannel]
pub fn channels(&self) -> &[AudioRenderQuantumChannel]
Channel data as slice
sourcepub fn channels_mut(&mut self) -> &mut [AudioRenderQuantumChannel]
pub fn channels_mut(&mut self) -> &mut [AudioRenderQuantumChannel]
Channel data as slice (mutable)
sourcepub fn mix(
&mut self,
computed_number_of_channels: usize,
interpretation: ChannelInterpretation
)
pub fn mix(
&mut self,
computed_number_of_channels: usize,
interpretation: ChannelInterpretation
)
Up/Down-mix to the desired number of channels
Panics
This function will panic if the given number of channels is outside the [1, 32] range, 32 being defined by the MAX_CHANNELS constant.
sourcepub fn make_silent(&mut self)
pub fn make_silent(&mut self)
Convert this buffer to silence
sourcepub fn force_mono(&mut self)
pub fn force_mono(&mut self)
Convert to a single channel buffer, dropping excess channels
sourcepub fn modify_channels<F: Fn(&mut AudioRenderQuantumChannel)>(&mut self, fun: F)
pub fn modify_channels<F: Fn(&mut AudioRenderQuantumChannel)>(&mut self, fun: F)
Modify every channel in the same way
sourcepub fn add(&mut self, other: &Self, interpretation: ChannelInterpretation)
pub fn add(&mut self, other: &Self, interpretation: ChannelInterpretation)
Sum two AudioRenderQuantum
s
If the channel counts differ, the buffer with lower count will be upmixed.
pub fn set_channels_values_at(&mut self, sample_index: usize, values: &[f32])
Trait Implementations
sourceimpl Clone for AudioRenderQuantum
impl Clone for AudioRenderQuantum
sourcefn clone(&self) -> AudioRenderQuantum
fn clone(&self) -> AudioRenderQuantum
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for AudioRenderQuantum
impl !Send for AudioRenderQuantum
impl !Sync for AudioRenderQuantum
impl Unpin for AudioRenderQuantum
impl !UnwindSafe for AudioRenderQuantum
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, T> IntoSample<T> for F where
T: FromSample<F>,
impl<F, T> IntoSample<T> for F where
T: FromSample<F>,
fn into_sample(self) -> T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more