Struct web_audio_api::buffer::AudioBuffer [−][src]
pub struct AudioBuffer { /* fields omitted */ }
Expand description
Memory-resident audio asset, basically a matrix of channels * samples
An AudioBuffer has copy-on-write semantics, so it is cheap to clone.
Implementations
Allocate a silent audiobuffer with given channel and samples count.
Create a multi-channel audiobuffer.
Number of channels in this AudioBuffer
Number of samples per channel in this AudioBuffer
Sample rate of this AudioBuffer in Hertz
Channel data as slice
Channel data as slice (mutable)
Get the samples from this specific channel.
Panics if the index is greater than the available number of channels
Get the samples (mutable) from this specific channel.
Panics if the index is greater than the available number of channels
Modify every channel in the same way
Extends an AudioBuffer with the contents of another.
This function will panic if the sample_rate and channel_count are not equal
Extends an AudioBuffer with an FixedAudioBuffer
This assumes the sample_rate matches. No up/down-mixing is performed
Split an AudioBuffer in chunks with length sample_len
.
The last chunk may be shorter than sample_len
Split an AudioBuffer in two at the given index.
Resample to the desired sample rate.
This changes the sample_length of the buffer.
use web_audio_api::SampleRate;
use web_audio_api::buffer::{ChannelData, AudioBuffer};
let channel = ChannelData::from(vec![1., 2., 3., 4., 5.]);
let mut buffer = AudioBuffer::from_channels(vec![channel], SampleRate(48_000));
// upmix from 48k to 96k Hertz sample rate
buffer.resample(SampleRate(96_000));
assert_eq!(
buffer.channel_data(0),
&ChannelData::from(vec![1., 1., 2., 2., 3., 3., 4., 4., 5., 5.,])
);
assert_eq!(buffer.sample_rate().0, 96_000);
Trait Implementations
Creates a value from an iterator. Read more
Auto Trait Implementations
impl RefUnwindSafe for AudioBuffer
impl Send for AudioBuffer
impl Sync for AudioBuffer
impl Unpin for AudioBuffer
impl UnwindSafe for AudioBuffer
Blanket Implementations
Mutably borrows from an owned value. Read more