[][src]Trait soundio::Sample

pub trait Sample {
    fn from_u8(v: u8) -> Self;
fn from_u16(v: u16) -> Self;
fn from_u24(v: u24) -> Self;
fn from_u32(v: u32) -> Self;
fn from_i8(v: i8) -> Self;
fn from_i16(v: i16) -> Self;
fn from_i24(v: i24) -> Self;
fn from_i32(v: i32) -> Self;
fn from_f32(v: f32) -> Self;
fn from_f64(v: f64) -> Self;
fn to_u8(v: Self) -> u8;
fn to_u16(v: Self) -> u16;
fn to_u24(v: Self) -> u24;
fn to_u32(v: Self) -> u32;
fn to_i8(v: Self) -> i8;
fn to_i16(v: Self) -> i16;
fn to_i24(v: Self) -> i24;
fn to_i32(v: Self) -> i32;
fn to_f32(v: Self) -> f32;
fn to_f64(v: Self) -> f64;
unsafe fn from_raw_le(ptr: *const u8) -> Self;
unsafe fn from_raw_be(ptr: *const u8) -> Self;
unsafe fn to_raw_le(v: Self, ptr: *mut u8);
unsafe fn to_raw_be(v: Self, ptr: *mut u8); }

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.

fn to_u8(v: Self) -> u8

fn to_u16(v: Self) -> u16

fn to_u24(v: Self) -> u24

fn to_u32(v: Self) -> u32

fn to_i8(v: Self) -> i8

fn to_i16(v: Self) -> i16

fn to_i24(v: Self) -> i24

fn to_i32(v: Self) -> i32

fn to_f32(v: Self) -> f32

fn to_f64(v: Self) -> f64

unsafe fn from_raw_le(ptr: *const u8) -> Self

unsafe fn from_raw_be(ptr: *const u8) -> Self

unsafe fn to_raw_le(v: Self, ptr: *mut u8)

unsafe fn to_raw_be(v: Self, ptr: *mut u8)

Loading content...

Implementations on Foreign Types

impl Sample for u8[src]

impl Sample for u16[src]

impl Sample for u32[src]

impl Sample for i8[src]

impl Sample for i16[src]

impl Sample for i32[src]

impl Sample for f32[src]

impl Sample for f64[src]

Loading content...

Implementors

impl Sample for i24[src]

impl Sample for u24[src]

Loading content...