Struct WaveWriter

Source
pub struct WaveWriter<T>
where T: Seek + Write,
{ pub pcm_format: PcmFormat, /* private fields */ }
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§

Source§

impl<T> WaveWriter<T>
where T: Seek + Write,

Source

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.

Source

pub fn write_sample_u8(&mut self, sample: u8) -> WriteResult<()>

Writes a single sample as an unsigned 8-bit value.

Source

pub fn write_sample_i16(&mut self, sample: i16) -> WriteResult<()>

Writes a single sample as a signed 16-bit value.

Source

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.

Source

pub fn write_sample_i32(&mut self, sample: i32) -> WriteResult<()>

Writes a single sample as a signed 32-bit value.

Source

pub fn sync_header(&mut self) -> Result<()>

Updates the header at the beginning of the file with the new chunk sizes.

Trait Implementations§

Source§

impl<T> Debug for WaveWriter<T>
where T: Seek + Write + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for WaveWriter<T>
where T: Seek + Write,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for WaveWriter<T>
where T: Freeze,

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.