[][src]Struct claxon::FlacReader

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]

pub fn new(reader: R) -> Result<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.

pub fn streaminfo(&self) -> StreamInfo[src]

Returns the streaminfo metadata.

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

pub fn blocks<'r>(&'r mut self) -> FrameReader<&'r mut BufferedReader<R>>[src]

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

Important traits for FlacSamples<R>
pub fn samples<'r>(&'r mut self) -> FlacSamples<&'r mut BufferedReader<R>>[src]

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

pub fn into_inner(self) -> R[src]

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]

pub fn open<P: AsRef<Path>>(filename: P) -> Result<FlacReader<File>>[src]

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.

Auto Trait Implementations

impl<R> Send for FlacReader<R> where
    R: Send

impl<R> Sync for FlacReader<R> where
    R: Sync

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]