Struct web_audio_api::alloc::AudioBuffer[][src]

pub struct AudioBuffer { /* fields omitted */ }
Expand description

Fixed length audio asset, basically a matrix of channels * [f32; BUFFER_SIZE]

An AudioBuffer has copy-on-write semantics, so it is cheap to clone.

Implementations

impl AudioBuffer[src]

pub fn new(channel: ChannelData) -> Self[src]

pub fn number_of_channels(&self) -> usize[src]

Number of channels in this AudioBuffer

pub fn set_number_of_channels(&mut self, n: usize)[src]

Set number of channels in this AudioBuffer

Note: if the new number is higher than the previous, the new channels will be filled with garbage.

pub fn channel_data(&self, index: usize) -> &ChannelData[src]

Get the samples from this specific channel.

Panics if the index is greater than the available number of channels

pub fn channel_data_mut(&mut self, index: usize) -> &mut ChannelData[src]

Get the samples (mutable) from this specific channel.

Panics if the index is greater than the available number of channels

pub fn channels(&self) -> &[ChannelData][src]

Channel data as slice

pub fn channels_mut(&mut self) -> &mut [ChannelData][src]

Channel data as slice (mutable)

pub fn mix(&mut self, channels: usize, interpretation: ChannelInterpretation)[src]

Up/Down-mix to the desired number of channels

pub fn make_silent(&mut self)[src]

Convert this buffer to silence

pub fn force_mono(&mut self)[src]

Convert to a single channel buffer, dropping excess channels

pub fn modify_channels<F: Fn(&mut ChannelData)>(&mut self, fun: F)[src]

Modify every channel in the same way

pub fn add(&mut self, other: &Self, interpretation: ChannelInterpretation)[src]

Sum two AudioBuffers

If the channel counts differ, the buffer with lower count will be upmixed.

Trait Implementations

impl Clone for AudioBuffer[src]

fn clone(&self) -> AudioBuffer[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.