[][src]Enum soundio::Format

pub enum Format {
    Invalid,
    S8,
    U8,
    S16LE,
    S16BE,
    U16LE,
    U16BE,
    S24LE,
    S24BE,
    U24LE,
    U24BE,
    S32LE,
    S32BE,
    U32LE,
    U32BE,
    Float32LE,
    Float32BE,
    Float64LE,
    Float64BE,
}

Format defines the format of the samples. In 90% of cases you'll want S16LE, or maybe Float64LE.

Variants

Invalid

Invalid format

S8

Signed 8 bit

U8

Unsigned 8 bit

S16LE

Signed 16 bit Little Endian

S16BE

Signed 16 bit Big Endian

U16LE

Unsigned 16 bit Little Endian

U16BE

Unsigned 16 bit Big Endian

S24LE

Signed 24 bit Little Endian using low three bytes in 32-bit word

S24BE

Signed 24 bit Big Endian using low three bytes in 32-bit word

U24LE

Unsigned 24 bit Little Endian using low three bytes in 32-bit word

U24BE

Unsigned 24 bit Big Endian using low three bytes in 32-bit word

S32LE

Signed 32 bit Little Endian

S32BE

Signed 32 bit Big Endian

U32LE

Unsigned 32 bit Little Endian

U32BE

Unsigned 32 bit Big Endian

Float32LE

Float 32 bit Little Endian, Range -1.0 to 1.0

Float32BE

Float 32 bit Big Endian, Range -1.0 to 1.0

Float64LE

Float 64 bit Little Endian, Range -1.0 to 1.0

Float64BE

Float 64 bit Big Endian, Range -1.0 to 1.0

Methods

impl Format[src]

pub fn bytes_per_sample(self) -> usize[src]

Returns the number of byte used per sample. Note that this is the size of the storage used for the sample, not the number of bits used. For example S24LE returns 4.

The returned values are specifically:

  • S8: 1
  • U8: 1
  • S16LE: 2
  • S16BE: 2
  • U16LE: 2
  • U16BE: 2
  • S24LE: 4
  • S24BE: 4
  • U24LE: 4
  • U24BE: 4
  • S32LE: 4
  • S32BE: 4
  • U32LE: 4
  • U32BE: 4
  • Float32LE: 4
  • Float32BE: 4
  • Float64LE: 8
  • Float64BE: 8
  • Invalid: -1

Examples

let a = soundio::Format::S8;
assert_eq!(a.bytes_per_sample(), 1);
let b = soundio::Format::Float64LE;
assert_eq!(b.bytes_per_sample(), 8);

pub fn bytes_per_frame(self, channel_count: usize) -> usize[src]

Returns the number of bytes per frame. A frame is one sample for all channels so this is simply the number of bytes for a sample bytes_per_sample() multiplied by the number of channels.

Examples

let a = soundio::Format::S8;
assert_eq!(a.bytes_per_frame(2), 2);
let b = soundio::Format::Float64LE;
assert_eq!(b.bytes_per_frame(4), 32);

pub fn bytes_per_second(self, channel_count: usize, sample_rate: usize) -> usize[src]

Returns the number of bytes per second, which is the number of bytes per frame multiplied by the number of frames per second (the sample rate).

Examples

let a = soundio::Format::S8;
assert_eq!(a.bytes_per_second(2, 8000), 16000);
let b = soundio::Format::Float64LE;
assert_eq!(b.bytes_per_second(4, 4000), 128000);

Trait Implementations

impl Clone for Format[src]

impl Copy for Format[src]

impl Debug for Format[src]

impl Display for Format[src]

impl Eq for Format[src]

impl From<Format> for SoundIoFormat[src]

impl From<SoundIoFormat> for Format[src]

impl PartialEq<Format> for Format[src]

impl StructuralEq for Format[src]

impl StructuralPartialEq for Format[src]

Auto Trait Implementations

impl RefUnwindSafe for Format

impl Send for Format

impl Sync for Format

impl Unpin for Format

impl UnwindSafe for Format

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.