Struct hound::WavReader [] [src]

pub struct WavReader<R> { /* fields omitted */ }

A reader that reads the WAVE format from the underlying reader.

A WavReader is a streaming reader. It reads data from the underlying reader on demand, and it reads no more than strictly necessary. No internal buffering is performed on the underlying reader, but this can easily be added by wrapping the reader in an io::BufReader. The open constructor takes care of this for you.

Methods

impl<R> WavReader<R> where
    R: Read
[src]

[src]

Attempts to create a reader that reads the WAVE format.

The header is read immediately. Reading the data will be done on demand.

[src]

Returns information about the WAVE file.

Important traits for WavSamples<'wr, R, S>
[src]

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 where the first iterator stopped.

The type S must have at least spec().bits_per_sample bits, otherwise every 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.

The type of S (int or float) must match spec().sample_format, otherwise every iteration will return an error.

Important traits for WavIntoSamples<R, S>
[src]

Same as samples, but takes ownership of the WavReader.

See samples() for more info.

[src]

Returns the duration of the file in samples.

The duration is independent of the number of channels. It is expressed in units of samples. The duration in seconds can be obtained by dividing this number by the sample rate. The duration is independent of how many samples have been read already.

[src]

Returns the number of values that the sample iterator will yield.

The length of the file is its duration (in samples) times the number of channels. The length is independent of how many samples have been read already. To get the number of samples left, use len() on the samples() iterator.

[src]

Destroys the WavReader and returns the underlying reader.

[src]

Seek to the given time within the file.

The given time is measured in number of samples (independent of the number of channels) since the beginning of the audio data. To seek to a particular time in seconds, multiply the number of seconds with WavSpec::sample_rate. The given time should not exceed the duration of the file (returned by duration()). The behavior when seeking beyond duration() depends on the reader's Seek implementation.

This method requires that the inner reader R implements Seek.

impl WavReader<BufReader<File>>
[src]

[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 WavReader from it.

Trait Implementations

Auto Trait Implementations

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

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