Struct claxon::FlacReader [] [src]

pub struct FlacReader<R: Read> {
    // some fields omitted
}

A FLAC decoder that can decode the stream from the underlying reader.

TODO: Is stream a good name? Should it be called reader/decoder? TODO: Add an example.

Methods

impl<R: Read> FlacReader<R>
[src]

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.

Returns the streaminfo metadata.

This contains information like the sample rate and number of channels.

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().

Returns an iterator over all samples.

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.)

The type S must have at least streaminfo().bits_per_sample bits, otherwise iteration will return an error. All bit depths up to 32 bits per sample can be decoded into an i32, but if you know beforehand that you will be reading a file with 16 bits per sample, you can save memory by decoding into an i16.

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. For more control over when decoding happens, use blocks().

impl FlacReader<BufReader<File>>
[src]

Attempts to create a reader that reads from the specified file.

This is a convenience constructor that opens a File, wraps it in a BufReader and then constructs a FlacReader from it.