pub struct SampleFormat { /* private fields */ }Expand description
Audio sample format: rate, bit depth, and channel count.
Implementations§
Source§impl SampleFormat
impl SampleFormat
Sourcepub const fn new(rate: u32, bits: u16, channels: u16) -> SampleFormat
pub const fn new(rate: u32, bits: u16, channels: u16) -> SampleFormat
Create a new sample format.
Sourcepub fn sample_size(&self) -> u16
pub fn sample_size(&self) -> u16
Size in bytes of a single mono sample.
Note: 24-bit samples are padded to 4 bytes (matching C++ behavior).
Sourcepub fn frame_size(&self) -> u16
pub fn frame_size(&self) -> u16
Size in bytes of one frame (all channels combined).
Sourcepub fn frames_to_ms(&self, frames: usize) -> f64
pub fn frames_to_ms(&self, frames: usize) -> f64
Convert a frame count to duration in milliseconds.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Whether any field has been set (non-zero).
Trait Implementations§
Source§impl Clone for SampleFormat
impl Clone for SampleFormat
Source§fn clone(&self) -> SampleFormat
fn clone(&self) -> SampleFormat
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SampleFormat
impl Debug for SampleFormat
Source§impl Default for SampleFormat
impl Default for SampleFormat
Source§fn default() -> SampleFormat
fn default() -> SampleFormat
Returns the “default value” for a type. Read more
Source§impl Display for SampleFormat
impl Display for SampleFormat
Source§impl FromStr for SampleFormat
impl FromStr for SampleFormat
Source§fn from_str(s: &str) -> Result<SampleFormat, <SampleFormat as FromStr>::Err>
fn from_str(s: &str) -> Result<SampleFormat, <SampleFormat as FromStr>::Err>
Parse from "rate:bits:channels" string. * means 0 (unspecified).
Source§type Err = SampleFormatError
type Err = SampleFormatError
The associated error which can be returned from parsing.
Source§impl PartialEq for SampleFormat
impl PartialEq for SampleFormat
impl Copy for SampleFormat
impl Eq for SampleFormat
impl StructuralPartialEq for SampleFormat
Auto Trait Implementations§
impl Freeze for SampleFormat
impl RefUnwindSafe for SampleFormat
impl Send for SampleFormat
impl Sync for SampleFormat
impl Unpin for SampleFormat
impl UnsafeUnpin for SampleFormat
impl UnwindSafe for SampleFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more