pub struct PcmFormat {
pub sample_rate_hz: u32,
pub channels: u8,
pub sample: SampleFormat,
}Expand description
Rate, channel count and sample encoding.
Fields§
§sample_rate_hz: u32Frames per second.
channels: u8Interleaved channels per frame (1 = mono, 2 = stereo).
sample: SampleFormatEncoding of each channel value.
Implementations§
Source§impl PcmFormat
impl PcmFormat
Sourcepub const PCM16_16K_MONO: PcmFormat
pub const PCM16_16K_MONO: PcmFormat
16 kHz mono 16-bit — the voice default.
Sourcepub const PCM16_48K_STEREO: PcmFormat
pub const PCM16_48K_STEREO: PcmFormat
48 kHz stereo 16-bit — the media default.
Sourcepub const fn new(
sample_rate_hz: u32,
channels: u8,
sample: SampleFormat,
) -> Result<PcmFormat, Error>
pub const fn new( sample_rate_hz: u32, channels: u8, sample: SampleFormat, ) -> Result<PcmFormat, Error>
Build a format, rejecting a zero rate or zero channels.
Sourcepub const fn frame_bytes(&self) -> usize
pub const fn frame_bytes(&self) -> usize
Bytes per sample frame (all channels).
Sourcepub const fn bytes_for_micros(&self, micros: u64) -> usize
pub const fn bytes_for_micros(&self, micros: u64) -> usize
Bytes needed to hold micros of audio, rounded down to a whole frame.
Sourcepub const fn micros_for_frames(&self, frames: usize) -> u64
pub const fn micros_for_frames(&self, frames: usize) -> u64
Duration in microseconds of frames sample frames.
Trait Implementations§
impl Copy for PcmFormat
impl Eq for PcmFormat
impl StructuralPartialEq for PcmFormat
Auto Trait Implementations§
impl Freeze for PcmFormat
impl RefUnwindSafe for PcmFormat
impl Send for PcmFormat
impl Sync for PcmFormat
impl Unpin for PcmFormat
impl UnsafeUnpin for PcmFormat
impl UnwindSafe for PcmFormat
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