Struct riff_wave::WaveWriter
source · [−]Expand description
Helper struct that takes ownership of a writer and can be used to write data to a PCM wave file.
Fields
pcm_format: PcmFormat
Represents the PCM format for this wave file.
Implementations
sourceimpl<T> WaveWriter<T> where
T: Seek + Write,
impl<T> WaveWriter<T> where
T: Seek + Write,
sourcepub fn new(
num_channels: u16,
sample_rate: u32,
bits_per_sample: u16,
writer: T
) -> WriteResult<WaveWriter<T>>
pub fn new(
num_channels: u16,
sample_rate: u32,
bits_per_sample: u16,
writer: T
) -> WriteResult<WaveWriter<T>>
Returns a new wave writer for the given writer.
Panics
Panics if num_channels or sample_rate is zero, or if bits_per_sample doesn’t match 8, 16, 24, or 32.
sourcepub fn write_sample_u8(&mut self, sample: u8) -> WriteResult<()>
pub fn write_sample_u8(&mut self, sample: u8) -> WriteResult<()>
Writes a single sample as an unsigned 8-bit value.
sourcepub fn write_sample_i16(&mut self, sample: i16) -> WriteResult<()>
pub fn write_sample_i16(&mut self, sample: i16) -> WriteResult<()>
Writes a single sample as a signed 16-bit value.
sourcepub fn write_sample_i24(&mut self, sample: i32) -> WriteResult<()>
pub fn write_sample_i24(&mut self, sample: i32) -> WriteResult<()>
Writes a single sample as a signed 24-bit value. The value will be truncated to fit in a 24-bit value.
sourcepub fn write_sample_i32(&mut self, sample: i32) -> WriteResult<()>
pub fn write_sample_i32(&mut self, sample: i32) -> WriteResult<()>
Writes a single sample as a signed 32-bit value.
sourcepub fn sync_header(&mut self) -> Result<()>
pub fn sync_header(&mut self) -> Result<()>
Updates the header at the beginning of the file with the new chunk sizes.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for WaveWriter<T> where
T: RefUnwindSafe,
impl<T> Send for WaveWriter<T> where
T: Send,
impl<T> Sync for WaveWriter<T> where
T: Sync,
impl<T> Unpin for WaveWriter<T> where
T: Unpin,
impl<T> UnwindSafe for WaveWriter<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more