audrey::read

Enum Reader

Source
pub enum Reader<R>
where R: Read + Seek,
{ Flac(FlacReader<R>), OggVorbis(OggStreamReader<R>), Wav(WavReader<R>), CafAlac(AlacReader<R>), }
Expand description

Returned by the read function, enumerates the various supported readers.

Variants§

§

Flac(FlacReader<R>)

§

OggVorbis(OggStreamReader<R>)

§

Wav(WavReader<R>)

§

CafAlac(AlacReader<R>)

Implementations§

Source§

impl Reader<BufReader<File>>

Source

pub fn open<P>(file_path: P) -> Result<Self, ReadError>
where P: AsRef<Path>,

Attempts to open an audio Reader from the file at the specified Path.

This function is a convenience wrapper around the Reader::new function.

This function pays no attention to the file_path’s extension and instead attempts to read a supported Format via the file header.

Source§

impl<R> Reader<R>
where R: Read + Seek,

Source

pub fn new(reader: R) -> Result<Self, ReadError>

Attempts to read the format of the audio read by the given reader and returns the associated Reader variant.

The format is determined by attempting to construct each specific format reader until one is successful.

Source

pub fn format(&self) -> Format

The format from which the audio will be read.

Source

pub fn description(&self) -> Description

A basic description of the audio being read.

Source

pub fn samples<S>(&mut self) -> Samples<'_, R, S>
where S: Sample,

Produce an iterator that reads samples from the underlying reader, converts them to the sample type S if not already in that format and yields them.

When reading from multiple channels, samples are interleaved.

Source

pub fn frames<F>(&mut self) -> Frames<'_, R, F>
where F: Frame, F::Sample: Sample,

Produce an iterator that yields read frames from the underlying Reader.

This method currently expects that the frame type F has the same number of channels as stored in the underlying audio format.

TODO: Should consider changing this behaviour to check the audio file’s actual number of channels and automatically convert to F’s number of channels while reading.

Auto Trait Implementations§

§

impl<R> Freeze for Reader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Reader<R>
where R: RefUnwindSafe,

§

impl<R> Send for Reader<R>
where R: Send,

§

impl<R> Sync for Reader<R>
where R: Sync,

§

impl<R> Unpin for Reader<R>
where R: Unpin,

§

impl<R> UnwindSafe for Reader<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,