Enum DataFormat

Source
pub enum DataFormat {
    Unspecified,
    Pcm,
    Adpcm(AdpcmSubFormat),
    PcmALaw,
    PcmMuLaw,
    Mp3(Mp3EncoderOptions),
    Opus(OpusEncoderOptions),
    Flac(FlacEncoderParams),
    OggVorbis(OggVorbisEncoderParams),
}
Expand description
  • Specify the audio codecs of the WAV file.

Variants§

§

Unspecified

  • This is used for creating a new DataFormat to specify an unknown format.
§

Pcm

  • PCM format, supports u8, i16, i24, i32, f32, f64 for WAV, supports channel number >= 2, no compresion, lossless.
§

Adpcm(AdpcmSubFormat)

  • ADPCM format, every sample stores as nibbles (One 4-bit nibble for a 16-bit sample), max channels is 2, lossy. Good for voice chatting, and very small memory usage.
§

PcmALaw

  • PCM-aLaw, every sample stores as a byte (One byte for a 16-bit sample), max channels is 2, lossy. Encoding/decoding is by table lookup. These tables are not that small.
  • Kind of useless. I prefer just to use the plain u8 PCM format to replace it. My supreme audio card can handle my u8 PCM and the playback is just as perfect as i16 does.
§

PcmMuLaw

  • PCM-MuLaw. Not much different than the PCM-aLaw. Uses a different algorithm to encode.
§

Mp3(Mp3EncoderOptions)

  • MP3. Just a pure MP3 file encapsulated in the data chunk. It needs some extra extension data in the fmt chunk.
  • With the help of the WAV fmt chunk, you can get the spec of the audio file without decoding it first.
  • The WAV file which encapsulates the MP3 file as its content, the size of the WAV file looks like an MP3 file size.
§

Opus(OpusEncoderOptions)

  • Naked opus stream, without the Ogg container. The encoded data is stored as blocks in the data chunk, the block size is stored in the fmt chunk.
  • Just take a look at the blocks, there are lots of zero bytes at the end, indicating that the Opus format is excellent at compressing the audio data.
  • But WAV can’t get rid of these zero bytes, resulting in the compression ratio just like encoding each sample into a byte.
  • Opus was originally designed for low-lag digital audio transmission with good quality. Encapsulating this thing into a WAV file is very weird.
§

Flac(FlacEncoderParams)

  • FLAC. Just a pure FLAC file encapsulated in the data chunk.
  • With the help of the WAV fmt chunk, you can get the spec of the audio file without decoding it first.
  • The WAV file which encapsulates the FLAC file as its content, the size of the WAV file looks like an FLAC file size.
§

OggVorbis(OggVorbisEncoderParams)

  • OggVorbis. Just a pure OggVorbis file encapsulated in the data chunk.
  • The WAV file which encapsulates the OggVorbis file as its content, the size of the WAV file looks like an OggVorbis file size.

Trait Implementations§

Source§

impl Clone for DataFormat

Source§

fn clone(&self) -> DataFormat

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DataFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DataFormat

Source§

fn eq(&self, other: &DataFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DataFormat

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.