pub struct WavReader<R> { /* private fields */ }
Expand description

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.

Implementations

Attempts to create a reader that reads the WAVE format.

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

Returns information about the WAVE file.

Returns an iterator over all samples.

The channel data 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.

Same as samples, but takes ownership of the WavReader.

See samples() for more info.

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.

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.

Destroys the WavReader and returns the underlying reader.

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.

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.