Struct claxon::FlacReader
[−]
[src]
pub struct FlacReader<R: Read> { /* fields omitted */ }
A FLAC decoder that can decode the stream from the underlying reader.
TODO: Add an example.
Methods
impl<R: Read> FlacReader<R>
[src]
fn new(reader: R) -> Result<FlacReader<R>>
Attempts to create a reader that reads the FLAC format.
The header and metadata blocks are read immediately. Audio frames will be read on demand.
fn streaminfo(&self) -> StreamInfo
Returns the streaminfo metadata.
This contains information like the sample rate and number of channels.
fn blocks<'r>(&'r mut self) -> FrameReader<&'r mut BufferedReader<R>>
Returns an iterator that decodes a single frame on every iteration. TODO: It is not an iterator.
This is a low-level primitive that gives you control over when decoding
happens. The representation of the decoded audio is somewhat specific to
the FLAC format. For a higher-level interface, see samples()
.
fn samples<'r>(&'r mut self) -> FlacSamples<&'r mut BufferedReader<R>>
Returns an iterator over all samples.
This is a user-friendly interface that trades performance for ease of
use. If performance is an issue, consider using blocks()
instead.
This is a high-level interface to the decoder. The cost of retrieving
the next sample can vary significantly, as sometimes a new block has to
be decoded. Additionally, there is a cost to every iteration returning a
Result
. When a block has been decoded, iterating the samples in that
block can never fail, but a match on every sample is required
nonetheless. For more control over when decoding happens, and less error
handling overhead, use blocks()
.
The channel data is is interleaved. The iterator is streaming. That is, if you call this method once, read a few samples, and call this method again, the second iterator will not start again from the beginning of the file. It will continue somewhere after where the first iterator stopped, and it might skip some samples. (This is because FLAC divides a stream into blocks, which have to be decoded entirely. If you drop the iterator, you lose the unread samples in that block.)
fn into_inner(self) -> R
Destroys the FLAC reader and returns the underlying reader.
Because the reader employs buffering internally, anything in the buffer will be lost.
impl FlacReader<File>
[src]
fn open<P: AsRef<Path>>(filename: P) -> Result<FlacReader<File>>
Attempts to create a reader that reads from the specified file.
This is a convenience constructor that opens a File
, and constructs a
FlacReader
from it. There is no need to wrap the file in a
BufReader
, as the FlacReader
employs buffering already.