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 anunknown
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 myu8
PCM and the playback is just as perfect asi16
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 thefmt
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 thefmt
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
impl Clone for DataFormat
Source§fn clone(&self) -> DataFormat
fn clone(&self) -> DataFormat
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DataFormat
impl Debug for DataFormat
Source§impl Display for DataFormat
impl Display for DataFormat
Source§impl PartialEq for DataFormat
impl PartialEq for DataFormat
impl StructuralPartialEq for DataFormat
Auto Trait Implementations§
impl Freeze for DataFormat
impl RefUnwindSafe for DataFormat
impl Send for DataFormat
impl Sync for DataFormat
impl Unpin for DataFormat
impl UnwindSafe for DataFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more