Struct bwavfile::AudioFrameReader
source · pub struct AudioFrameReader<R: Read + Seek> { /* private fields */ }
Expand description
Read audio frames
The inner reader is interpreted as a raw audio data
bitstream having a format specified by format
.
Implementations§
source§impl<R: Read + Seek> AudioFrameReader<R>
impl<R: Read + Seek> AudioFrameReader<R>
sourcepub fn new(
inner: R,
format: WaveFmt,
start: u64,
length: u64
) -> Result<Self, Error>
pub fn new( inner: R, format: WaveFmt, start: u64, length: u64 ) -> Result<Self, Error>
Create a new AudioFrameReader
Panics
This method does a few sanity checks on the provided format
parameter to confirm the block_alignment
law is fulfilled
and the format tag is readable by this implementation (only
format 0x01 is supported at this time.)
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Unwrap the inner reader.
sourcepub fn locate(&mut self, to: u64) -> Result<u64, Error>
pub fn locate(&mut self, to: u64) -> Result<u64, Error>
Locate the read position to a different frame
Seeks within the audio stream.
Returns the new location of the read position.
locate() behaves similarly to Read methods in that seeking after the end of the audio data is not an error.
sourcepub fn read_frames<S>(&mut self, buffer: &mut [S]) -> Result<u64, Error>where
S: Sample,
pub fn read_frames<S>(&mut self, buffer: &mut [S]) -> Result<u64, Error>where S: Sample,
Reads frames from the file into the provided buffer
The function will attempt to fill the buffer, but will stop without error when the end of the file is reached.
The reader will convert from the file’s sample type into the buffer’s sample type. Note that no dithering will be applied during sample type conversion, if dithering is required then it will need to be applied manually.
The return value is the number of frames read into the buffer.