Struct WaveWriter

Source
pub struct WaveWriter<'a> {
Show 14 fields pub fmt__chunk: FmtChunk, pub slnt_chunk: Option<SlntChunk>, pub bext_chunk: Option<BextChunk>, pub smpl_chunk: Option<SmplChunk>, pub inst_chunk: Option<InstChunk>, pub plst_chunk: Option<PlstChunk>, pub trkn_chunk: Option<TrknChunk>, pub cue__chunk: Option<CueChunk>, pub axml_chunk: Option<String>, pub ixml_chunk: Option<String>, pub list_chunk: BTreeSet<ListChunk>, pub acid_chunk: Option<AcidChunk>, pub id3__chunk: Option<Tag>, pub junk_chunks: BTreeSet<JunkChunk>, /* private fields */
}
Expand description
  • The WaveWriter is dedicated to creating a WAV file. Usage:
  • Choose one of the internal formats by specifying DataFormat and use the WaveWriter to create the WAV file.
  • Use the methods, like write_samples(), write_mono_channel(), write_monos(), write_stereos(), etc, to write your PCM samples to the WaveWriter, it will encode.
  • Call finalize() or just let the WaveWriter get out of the scope.

Then BAM. The WAV file was created successfully with the audio sound as you provided.

Fields§

§fmt__chunk: FmtChunk§slnt_chunk: Option<SlntChunk>§bext_chunk: Option<BextChunk>§smpl_chunk: Option<SmplChunk>§inst_chunk: Option<InstChunk>§plst_chunk: Option<PlstChunk>§trkn_chunk: Option<TrknChunk>§cue__chunk: Option<CueChunk>§axml_chunk: Option<String>§ixml_chunk: Option<String>§list_chunk: BTreeSet<ListChunk>§acid_chunk: Option<AcidChunk>§id3__chunk: Option<Tag>§junk_chunks: BTreeSet<JunkChunk>

Implementations§

Source§

impl<'a> WaveWriter<'a>

Source

pub fn create<P: AsRef<Path>>( filename: P, spec: Spec, data_format: DataFormat, file_size_option: FileSizeOption, ) -> Result<WaveWriter<'a>, AudioWriteError>

  • Create WAV file through a file path.
Source

pub fn from( writer: Box<dyn Writer + 'a>, spec: Spec, data_format: DataFormat, file_size_option: FileSizeOption, ) -> Result<WaveWriter<'a>, AudioWriteError>

  • Write the WAV file to the writer.
Source

pub fn write_interleaved_samples<S>( &mut self, samples: &[S], ) -> Result<(), AudioWriteError>
where S: SampleType,

Stores audio samples. The generic parameter S represents the user-provided input format. The encoder converts samples to the internal target format before encoding them into the WAV file.

Source

pub fn write_mono<S>(&mut self, mono: S) -> Result<(), AudioWriteError>
where S: SampleType,

Saves a single mono sample. Avoid frequent calls due to inefficiency.

Source

pub fn write_mono_channel<S>( &mut self, monos: &[S], ) -> Result<(), AudioWriteError>
where S: SampleType,

Batch-saves mono samples.

Source

pub fn write_monos<S>( &mut self, monos: &[Vec<S>], ) -> Result<(), AudioWriteError>
where S: SampleType,

Batch-saves multiple mono channels.

Source

pub fn write_stereo<S>(&mut self, stereo: (S, S)) -> Result<(), AudioWriteError>
where S: SampleType,

Saves a single stereo sample (left + right). Avoid frequent calls due to inefficiency.

Source

pub fn write_stereos<S>( &mut self, stereos: &[(S, S)], ) -> Result<(), AudioWriteError>
where S: SampleType,

Batch-saves stereo samples.

Source

pub fn write_dual_mono<S>( &mut self, mono1: S, mono2: S, ) -> Result<(), AudioWriteError>
where S: SampleType,

Saves two mono samples (as one stereo frame). Avoid frequent calls due to inefficiency.

Source

pub fn write_dual_monos<S>( &mut self, mono1: &[S], mono2: &[S], ) -> Result<(), AudioWriteError>
where S: SampleType,

Batch-saves pairs of mono samples (as stereo audio).

Source

pub fn write_frame<S>(&mut self, frame: &[S]) -> Result<(), AudioWriteError>
where S: SampleType,

Saves one audio frame. Avoid frequent calls due to inefficiency. Supports multi-channel layouts.

Source

pub fn write_frames<S>( &mut self, frames: &[Vec<S>], ) -> Result<(), AudioWriteError>
where S: SampleType,

Batch-saves audio frames. Supports multi-channel layouts.

Source

pub fn spec(&self) -> Spec

  • Get the spec for the WaveWriter
Source

pub fn get_data_format(&self) -> DataFormat

  • See WaveReader
Source

pub fn get_num_frames_written(&self) -> u64

  • Get how many audio frames were written
Source

pub fn set_slnt_chunk(&mut self, chunk: &SlntChunk)

  • See WaveReader
Source

pub fn set_bext_chunk(&mut self, chunk: &BextChunk)

  • See WaveReader
Source

pub fn set_smpl_chunk(&mut self, chunk: &SmplChunk)

  • See WaveReader
Source

pub fn set_inst_chunk(&mut self, chunk: &InstChunk)

  • See WaveReader
Source

pub fn set_plst_chunk(&mut self, chunk: &PlstChunk)

  • See WaveReader
Source

pub fn set_trkn_chunk(&mut self, chunk: &TrknChunk)

  • See WaveReader
Source

pub fn set_cue__chunk(&mut self, chunk: &CueChunk)

  • See WaveReader
Source

pub fn set_axml_chunk(&mut self, chunk: &String)

  • See WaveReader
Source

pub fn set_ixml_chunk(&mut self, chunk: &String)

  • See WaveReader
Source

pub fn set_list_chunk(&mut self, chunk: ListChunk)

  • See WaveReader
Source

pub fn set_acid_chunk(&mut self, chunk: &AcidChunk)

  • See WaveReader
Source

pub fn add_junk_chunk(&mut self, chunk: JunkChunk)

  • See WaveReader
Source

pub fn inherit_metadata_from_reader( &mut self, reader: &WaveReader, include_junk_chunks: bool, )

Transfers audio metadata (e.g., track info) from the reader.

Source

pub fn create_full_info_cue_data( &self, ) -> Result<BTreeMap<u32, FullInfoCuePoint>, AudioError>

  • If your audio file has plst, cue , and LIST adtl chunks, then BAM you can call this function for full playlist info.
  • Returns Err if some of these chunks are absent.
Source

pub fn finalize(self)

  • If you don’t want your WaveWriter anymore, call this method.

Trait Implementations§

Source§

impl<'a> Debug for WaveWriter<'a>

Source§

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

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

impl Drop for WaveWriter<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for WaveWriter<'a>

§

impl<'a> !RefUnwindSafe for WaveWriter<'a>

§

impl<'a> !Send for WaveWriter<'a>

§

impl<'a> !Sync for WaveWriter<'a>

§

impl<'a> Unpin for WaveWriter<'a>

§

impl<'a> !UnwindSafe for WaveWriter<'a>

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.