pub trait Sample: Copy + Clone + Add<Output = Self> + Sub<Output = Self> + Default + PartialOrd + PartialEq + Sized {
    const FORMAT: SampleFormat;
    const EFF_BITS: u32;
    const MID: Self;

    // Required method
    fn clamped(self) -> Self;
}
Expand description

Sample provides a common interface for manipulating sample’s regardless of the underlying data type. Additionally, Sample provides information regarding the format of underlying data types representing the sample when in memory, but also when exported.

Required Associated Constants§

source

const FORMAT: SampleFormat

A unique enum value representing the sample format. This constant may be used to dynamically choose how to process the sample at runtime.

source

const EFF_BITS: u32

The effective number of bits of the valid (clamped) sample range. Quantifies the dynamic range of the sample format in bits.

source

const MID: Self

The mid-point value between the maximum and minimum sample value. If a sample is set to this value it is silent.

Required Methods§

source

fn clamped(self) -> Self

If the sample format does not use the full range of the underlying data type, returns the sample clamped to the valid range. Otherwise, returns the sample unchanged.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Sample for f32

source§

const FORMAT: SampleFormat = SampleFormat::F32

source§

const EFF_BITS: u32 = 24u32

source§

const MID: f32 = 0f32

source§

fn clamped(self) -> Self

source§

impl Sample for f64

source§

const FORMAT: SampleFormat = SampleFormat::F64

source§

const EFF_BITS: u32 = 53u32

source§

const MID: f64 = 0f64

source§

fn clamped(self) -> Self

source§

impl Sample for i8

source§

const FORMAT: SampleFormat = SampleFormat::S8

source§

const EFF_BITS: u32 = 8u32

source§

const MID: i8 = 0i8

source§

fn clamped(self) -> Self

source§

impl Sample for i16

source§

const FORMAT: SampleFormat = SampleFormat::S16

source§

const EFF_BITS: u32 = 16u32

source§

const MID: i16 = 0i16

source§

fn clamped(self) -> Self

source§

impl Sample for i32

source§

const FORMAT: SampleFormat = SampleFormat::S32

source§

const EFF_BITS: u32 = 32u32

source§

const MID: i32 = 0i32

source§

fn clamped(self) -> Self

source§

impl Sample for u8

source§

const FORMAT: SampleFormat = SampleFormat::U8

source§

const EFF_BITS: u32 = 8u32

source§

const MID: u8 = 128u8

source§

fn clamped(self) -> Self

source§

impl Sample for u16

source§

const FORMAT: SampleFormat = SampleFormat::U16

source§

const EFF_BITS: u32 = 16u32

source§

const MID: u16 = 32_768u16

source§

fn clamped(self) -> Self

source§

impl Sample for u32

source§

const FORMAT: SampleFormat = SampleFormat::U32

source§

const EFF_BITS: u32 = 32u32

source§

const MID: u32 = 2_147_483_648u32

source§

fn clamped(self) -> Self

Implementors§

source§

impl Sample for i24

source§

const FORMAT: SampleFormat = SampleFormat::S24

source§

const EFF_BITS: u32 = 24u32

source§

const MID: i24 = _

source§

impl Sample for u24

source§

const FORMAT: SampleFormat = SampleFormat::U24

source§

const EFF_BITS: u32 = 24u32

source§

const MID: u24 = _