pub struct AudioRenderQuantum { /* private fields */ }
Expand description

Render thread audio buffer, consisting of multiple channel buffers

Internal fixed length audio asset of RENDER_QUANTUM_SIZE sample frames for block rendering, basically a matrix of channels * AudioRenderQuantumChannel cf. https://webaudio.github.io/web-audio-api/#render-quantum

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

Usage

Audio buffers are managed with a dedicated allocator per render thread, hence there are no public constructors available. If you must create a new instance, copy an existing one and mutate it from there.

use web_audio_api::render::AudioRenderQuantum;

fn apply_gain(buffer: &mut AudioRenderQuantum, gain: f32) {
    buffer.channels_mut()
        .iter_mut()
        .for_each(|ch| ch.iter_mut().for_each(|s| *s *= gain))
}

Implementations

Number of channels in this AudioRenderQuantum

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.

Get the samples from this specific channel.

Panics

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

Get the samples (mutable) from this specific channel.

Panics

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

Channel data as slice

Channel data as slice (mutable)

Convert this buffer to silence

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.