#[non_exhaustive]#[repr(u8)]pub enum SampleFormat {
U8 = 0,
S8 = 1,
S16 = 2,
S24 = 3,
S32 = 4,
F32 = 5,
F64 = 6,
U8P = 7,
S16P = 8,
S32P = 9,
F32P = 10,
F64P = 11,
}Expand description
Audio sample format.
Variants carry stable explicit discriminants — the integer value
of SampleFormat::S16 as u8 is part of the public ABI. Add new
variants only at the end with a fresh number; never reorder, renumber,
or remove. #[non_exhaustive] lets the enum grow without breaking
downstream match statements; pinned discriminants additionally let
the format round-trip through any byte-stable serialization
(config files, capability blobs, IPC) without losing meaning across
crate versions.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
U8 = 0
Unsigned 8-bit, interleaved.
S8 = 1
Signed 8-bit, interleaved. Native format of Amiga 8SVX and MOD samples.
S16 = 2
Signed 16-bit little-endian, interleaved.
S24 = 3
Signed 24-bit packed (3 bytes/sample) little-endian, interleaved.
S32 = 4
Signed 32-bit little-endian, interleaved.
F32 = 5
32-bit IEEE float, interleaved.
F64 = 6
64-bit IEEE float, interleaved.
U8P = 7
Planar variants — one plane per channel.
S16P = 8
S32P = 9
F32P = 10
F64P = 11
Implementations§
Source§impl SampleFormat
impl SampleFormat
pub fn is_planar(&self) -> bool
Sourcepub fn bytes_per_sample(&self) -> usize
pub fn bytes_per_sample(&self) -> usize
Bytes per sample per channel.
pub fn is_float(&self) -> bool
Sourcepub fn plane_count(&self, channels: u16) -> usize
pub fn plane_count(&self, channels: u16) -> usize
Number of Vec<u8> planes an AudioFrame
of this format carries for channels channels: planar formats
use one plane per channel, interleaved formats use one plane
total.
Trait Implementations§
Source§impl Clone for SampleFormat
impl Clone for SampleFormat
Source§fn clone(&self) -> SampleFormat
fn clone(&self) -> SampleFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more