Trait hound::Sample [] [src]

pub trait Sample: Sized {
    fn write<W: Write>(self, writer: &mut W, bits: u16) -> Result<()>;
    fn read<R: Read>(reader: &mut R, bytes: u16, bits: u16) -> Result<Self>;
}

A type that can be used to represent audio samples.

Via this trait, decoding can be generic over i8, i16 and i32. All bit depths up to 32 bits per sample can be decoded into i32, but it takes up more memory. If you know beforehand that you will be reading a file with 16 bits per sample, then decoding into an i16 will be sufficient.

Required Methods

fn write<W: Write>(self, writer: &mut W, bits: u16) -> Result<()>

Writes the audio sample to the WAVE data chunk.

fn read<R: Read>(reader: &mut R, bytes: u16, bits: u16) -> Result<Self>

Reads the audio sample from the WAVE data chunk.

Implementors