pub struct Frames<'a> { /* private fields */ }Expand description
Representation of the frames of an associated
DsfFile.
A frame consists of n blocks, one for each channel. So a stereo frame consits of two blocks, the first contains 4096 bytes of sample data for the front-left channel, the second contains 4096 bytes of data for the front-right channel.
Only one frame ever exists in memory at a time. When a new frame is required it is loaded from file on-demand. This keeps the memory footprint small e.g. 2 × 4096 = 8192 bytes for a stereo frame.
Implementations§
Source§impl<'a> Frames<'a>
impl<'a> Frames<'a>
Sourcepub fn offset(&self, frame_index: u64) -> Result<u64, Error>
pub fn offset(&self, frame_index: u64) -> Result<u64, Error>
Return the offset (position in the DSF file in bytes) of the specified frame.
Note that frame_index is zero-based so the first frame has
frame_index=0, etc.
§Errors
This method returns an error ifframe_index >= frame_count.
Sourcepub fn frame_and_block_index(
&self,
sample_index: u64,
) -> Result<(u64, usize), Error>
pub fn frame_and_block_index( &self, sample_index: u64, ) -> Result<(u64, usize), Error>
Return the frame and block index as a tuple (frame_index, block_index) for the given sample_index if they exist or a
out of range error if sample_index >= sample_count.
§Errors
Returns an error if sample_index >= sample_count.