[−][src]Enum soundio::Format
Format defines the format of the samples. In 90% of cases you'll want S16LE
, or maybe Float64LE
.
Variants
Invalid format
Signed 8 bit
Unsigned 8 bit
Signed 16 bit Little Endian
Signed 16 bit Big Endian
Unsigned 16 bit Little Endian
Unsigned 16 bit Big Endian
Signed 24 bit Little Endian using low three bytes in 32-bit word
Signed 24 bit Big Endian using low three bytes in 32-bit word
Unsigned 24 bit Little Endian using low three bytes in 32-bit word
Unsigned 24 bit Big Endian using low three bytes in 32-bit word
Signed 32 bit Little Endian
Signed 32 bit Big Endian
Unsigned 32 bit Little Endian
Unsigned 32 bit Big Endian
Float 32 bit Little Endian, Range -1.0 to 1.0
Float 32 bit Big Endian, Range -1.0 to 1.0
Float 64 bit Little Endian, Range -1.0 to 1.0
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]
fn from(format: Format) -> SoundIoFormat
[src]
impl From<SoundIoFormat> for Format
[src]
fn from(format: SoundIoFormat) -> 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,