pub struct Data { /* private fields */ }
Expand description
A buffer of dynamically typed audio data, passed to raw stream callbacks.
Raw input stream callbacks receive &Data
, while raw output stream callbacks expect &mut Data
.
Implementations§
source§impl Data
impl Data
sourcepub fn sample_format(&self) -> SampleFormat
pub fn sample_format(&self) -> SampleFormat
The sample format of the internal audio data.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The full length of the buffer in samples.
The returned length is the same length as the slice of type T
that would be returned via
as_slice
given a sample type that matches the inner sample format.
sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
The raw slice of memory representing the underlying audio data as a slice of bytes.
It is up to the user to interpret the slice of memory based on Data::sample_format
.
sourcepub fn bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn bytes_mut(&mut self) -> &mut [u8] ⓘ
The raw slice of memory representing the underlying audio data as a slice of bytes.
It is up to the user to interpret the slice of memory based on Data::sample_format
.
sourcepub fn as_slice<T>(&self) -> Option<&[T]>where
T: SizedSample,
pub fn as_slice<T>(&self) -> Option<&[T]>where
T: SizedSample,
Access the data as a slice of sample type T
.
Returns None
if the sample type does not match the expected sample format.
sourcepub fn as_slice_mut<T>(&mut self) -> Option<&mut [T]>where
T: SizedSample,
pub fn as_slice_mut<T>(&mut self) -> Option<&mut [T]>where
T: SizedSample,
Access the data as a slice of sample type T
.
Returns None
if the sample type does not match the expected sample format.