Struct claxon::frame::Block [−][src]
pub struct Block { /* fields omitted */ }
A block of raw audio samples.
Methods
impl Block
[src]
impl Block
pub fn empty() -> Block
[src]
pub fn empty() -> Block
Returns a block with 0 channels and 0 samples.
pub fn time(&self) -> u64
[src]
pub fn time(&self) -> u64
Returns the inter-channel sample number of the first sample in the block.
The time is independent of the number of channels. To get the start time of the block in seconds, divide this number by the sample rate in the streaminfo.
pub fn len(&self) -> u32
[src]
pub fn len(&self) -> u32
Returns the total number of samples in this block.
Samples in different channels are counted as distinct samples.
pub fn duration(&self) -> u32
[src]
pub fn duration(&self) -> u32
Returns the number of inter-channel samples in the block.
The duration is independent of the number of channels. The returned value is also referred to as the block size. To get the duration of the block in seconds, divide this number by the sample rate in the streaminfo.
pub fn channels(&self) -> u32
[src]
pub fn channels(&self) -> u32
Returns the number of channels in the block.
pub fn channel(&self, ch: u32) -> &[i32]
[src]
pub fn channel(&self, ch: u32) -> &[i32]
pub fn sample(&self, ch: u32, sample: u32) -> i32
[src]
pub fn sample(&self, ch: u32, sample: u32) -> i32
Returns a sample in this block.
The value returned is for the zero-based ch
-th channel of the
inter-channel sample with index sample
in this block (so this is not
the global sample number).
Panics
Panics if ch >= channels()
or if sample >= len()
for the last
channel.
pub fn into_buffer(self) -> Vec<i32>
[src]
pub fn into_buffer(self) -> Vec<i32>
Returns the underlying buffer that stores the samples in this block.
This allows the buffer to be reused to decode the next frame. The
capacity of the buffer may be bigger than len()
times channels()
.
ⓘImportant traits for StereoSamples<'a>pub fn stereo_samples<'a>(&'a self) -> StereoSamples<'a>
[src]
pub fn stereo_samples<'a>(&'a self) -> StereoSamples<'a>
Returns an iterator that produces left and right channel samples.
This iterator can be more efficient than requesting a sample directly, because it avoids a bounds check.
Panics
Panics if the number of channels in the block is not 2.