pub struct WavFile {
pub num_channels: u16,
pub sample_rate: u32,
pub bits_per_sample: u16,
pub audio_format: u16,
pub data_offset: usize,
pub data_size: usize,
pub block_align: u16,
}Expand description
Parsed WAV file with metadata and data location
Fields§
§num_channels: u16Number of audio channels
sample_rate: u32Sample rate in Hz
bits_per_sample: u16Bits per sample
audio_format: u16Audio format code (1 = PCM)
data_offset: usizeByte offset to the start of PCM data in the source buffer
data_size: usizeSize of the PCM data section in bytes
block_align: u16Block alignment
Implementations§
Source§impl WavFile
impl WavFile
Sourcepub fn parse(data: &[u8]) -> Result<WavFile, KernelError>
pub fn parse(data: &[u8]) -> Result<WavFile, KernelError>
Parse a WAV file from a byte buffer
Validates the RIFF/WAVE header, locates the “fmt “ and “data” chunks, and extracts metadata.
Sourcepub fn sample_data<'a>(&self, source: &'a [u8]) -> &'a [u8]
pub fn sample_data<'a>(&self, source: &'a [u8]) -> &'a [u8]
Get a reference to the PCM data within the source buffer
Sourcepub fn to_audio_config(&self) -> AudioConfig
pub fn to_audio_config(&self) -> AudioConfig
Convert this WAV file’s format info to an AudioConfig
Sourcepub fn duration_ms(&self) -> u64
pub fn duration_ms(&self) -> u64
Calculate the duration of the audio in milliseconds
Sourcepub fn total_samples(&self) -> usize
pub fn total_samples(&self) -> usize
Calculate the total number of samples (all channels)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WavFile
impl RefUnwindSafe for WavFile
impl Send for WavFile
impl Sync for WavFile
impl Unpin for WavFile
impl UnwindSafe for WavFile
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)