[−][src]Trait soundio::Sample
The Sample trait defines functions to convert between the various sample formats. The full range
of the integer sample formats is always used, so 0u16.to_i8()
is -128. Converting between
signed and unsigned of the same size is lossless, as is increasing the bit depth.
The range for floating point samples is -1.0 to 1.0 inclusive.
Required methods
fn from_u8(v: u8) -> Self
Convert from a u8 sample (0 - 0xFF) to this sample type.
fn from_u16(v: u16) -> Self
Convert from a u16 sample (0 - 0xFFFF) to this sample type.
fn from_u24(v: u24) -> Self
Convert from a u24 sample (0 - 0xFFFFFF) to this sample type.
fn from_u32(v: u32) -> Self
Convert from a u32 sample (0 - 0xFFFFFFFF) to this sample type.
fn from_i8(v: i8) -> Self
Convert from an i8 sample (-0x80 - 0x7F) to this sample type.
fn from_i16(v: i16) -> Self
Convert from an i16 sample (-0x8000 - 0x7FFF) to this sample type.
fn from_i24(v: i24) -> Self
Convert from an i24 sample (-0x800000 - 0x7FFFFF) to this sample type.
fn from_i32(v: i32) -> Self
Convert from an i32 sample (-0x80000000 - 0x7FFFFFFF) to this sample type.
fn from_f32(v: f32) -> Self
Convert from an f32 sample (-1.0 - 1.0) to this sample type.
fn from_f64(v: f64) -> Self
Convert from an f64 sample (-1.0 - 1.0) to this sample type.