conformal_component::audio

Trait Buffer

Source
pub trait Buffer {
    // Required methods
    fn channel_layout(&self) -> ChannelLayout;
    fn num_frames(&self) -> usize;
    fn channel(&self, channel: usize) -> &[f32];

    // Provided method
    fn num_channels(&self) -> usize { ... }
}
Expand description

Represents a (potentially multi-channel) buffer of audio samples

A Buffer doesn’t specify the exact storage format of the samples, but each channel must be a contiguous slice of samples. All channels must have the same number of samples, that is, Buffer::num_frames.

Required Methods§

Source

fn channel_layout(&self) -> ChannelLayout

The layout of the channels in the buffer.

Source

fn num_frames(&self) -> usize

The number of frames in the buffer.

Each channel will contain this many samples.

Source

fn channel(&self, channel: usize) -> &[f32]

Get a channel from the buffer.

This returns a slice that contains all samples of the channel. The every channel will have Self::num_frames elements.

§Panics

Panics if channel is greater than or equal to Self::num_channels.

Provided Methods§

Source

fn num_channels(&self) -> usize

The number of channels in the buffer.

Implementors§