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 theWaveWriter
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 theWaveWriter
, it will encode. - Call
finalize()
or just let theWaveWriter
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>
impl<'a> WaveWriter<'a>
Sourcepub fn create<P: AsRef<Path>>(
filename: P,
spec: Spec,
data_format: DataFormat,
file_size_option: FileSizeOption,
) -> Result<WaveWriter<'a>, AudioWriteError>
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.
Sourcepub fn from(
writer: Box<dyn Writer + 'a>,
spec: Spec,
data_format: DataFormat,
file_size_option: FileSizeOption,
) -> Result<WaveWriter<'a>, AudioWriteError>
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.
Sourcepub fn write_interleaved_samples<S>(
&mut self,
samples: &[S],
) -> Result<(), AudioWriteError>where
S: SampleType,
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.
Sourcepub fn write_mono<S>(&mut self, mono: S) -> Result<(), AudioWriteError>where
S: SampleType,
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.
Sourcepub fn write_mono_channel<S>(
&mut self,
monos: &[S],
) -> Result<(), AudioWriteError>where
S: SampleType,
pub fn write_mono_channel<S>(
&mut self,
monos: &[S],
) -> Result<(), AudioWriteError>where
S: SampleType,
Batch-saves mono samples.
Sourcepub fn write_monos<S>(
&mut self,
monos: &[Vec<S>],
) -> Result<(), AudioWriteError>where
S: SampleType,
pub fn write_monos<S>(
&mut self,
monos: &[Vec<S>],
) -> Result<(), AudioWriteError>where
S: SampleType,
Batch-saves multiple mono channels.
Sourcepub fn write_stereo<S>(&mut self, stereo: (S, S)) -> Result<(), AudioWriteError>where
S: SampleType,
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.
Sourcepub fn write_stereos<S>(
&mut self,
stereos: &[(S, S)],
) -> Result<(), AudioWriteError>where
S: SampleType,
pub fn write_stereos<S>(
&mut self,
stereos: &[(S, S)],
) -> Result<(), AudioWriteError>where
S: SampleType,
Batch-saves stereo samples.
Sourcepub fn write_dual_mono<S>(
&mut self,
mono1: S,
mono2: S,
) -> Result<(), AudioWriteError>where
S: SampleType,
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.
Sourcepub fn write_dual_monos<S>(
&mut self,
mono1: &[S],
mono2: &[S],
) -> Result<(), AudioWriteError>where
S: SampleType,
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).
Sourcepub fn write_frame<S>(&mut self, frame: &[S]) -> Result<(), AudioWriteError>where
S: SampleType,
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.
Sourcepub fn write_frames<S>(
&mut self,
frames: &[Vec<S>],
) -> Result<(), AudioWriteError>where
S: SampleType,
pub fn write_frames<S>(
&mut self,
frames: &[Vec<S>],
) -> Result<(), AudioWriteError>where
S: SampleType,
Batch-saves audio frames. Supports multi-channel layouts.
Sourcepub fn get_data_format(&self) -> DataFormat
pub fn get_data_format(&self) -> DataFormat
- See
WaveReader
Sourcepub fn get_num_frames_written(&self) -> u64
pub fn get_num_frames_written(&self) -> u64
- Get how many audio frames were written
Sourcepub fn set_slnt_chunk(&mut self, chunk: &SlntChunk)
pub fn set_slnt_chunk(&mut self, chunk: &SlntChunk)
- See
WaveReader
Sourcepub fn set_bext_chunk(&mut self, chunk: &BextChunk)
pub fn set_bext_chunk(&mut self, chunk: &BextChunk)
- See
WaveReader
Sourcepub fn set_smpl_chunk(&mut self, chunk: &SmplChunk)
pub fn set_smpl_chunk(&mut self, chunk: &SmplChunk)
- See
WaveReader
Sourcepub fn set_inst_chunk(&mut self, chunk: &InstChunk)
pub fn set_inst_chunk(&mut self, chunk: &InstChunk)
- See
WaveReader
Sourcepub fn set_plst_chunk(&mut self, chunk: &PlstChunk)
pub fn set_plst_chunk(&mut self, chunk: &PlstChunk)
- See
WaveReader
Sourcepub fn set_trkn_chunk(&mut self, chunk: &TrknChunk)
pub fn set_trkn_chunk(&mut self, chunk: &TrknChunk)
- See
WaveReader
Sourcepub fn set_cue__chunk(&mut self, chunk: &CueChunk)
pub fn set_cue__chunk(&mut self, chunk: &CueChunk)
- See
WaveReader
Sourcepub fn set_axml_chunk(&mut self, chunk: &String)
pub fn set_axml_chunk(&mut self, chunk: &String)
- See
WaveReader
Sourcepub fn set_ixml_chunk(&mut self, chunk: &String)
pub fn set_ixml_chunk(&mut self, chunk: &String)
- See
WaveReader
Sourcepub fn set_list_chunk(&mut self, chunk: ListChunk)
pub fn set_list_chunk(&mut self, chunk: ListChunk)
- See
WaveReader
Sourcepub fn set_acid_chunk(&mut self, chunk: &AcidChunk)
pub fn set_acid_chunk(&mut self, chunk: &AcidChunk)
- See
WaveReader
Sourcepub fn add_junk_chunk(&mut self, chunk: JunkChunk)
pub fn add_junk_chunk(&mut self, chunk: JunkChunk)
- See
WaveReader
Sourcepub fn inherit_metadata_from_reader(
&mut self,
reader: &WaveReader,
include_junk_chunks: bool,
)
pub fn inherit_metadata_from_reader( &mut self, reader: &WaveReader, include_junk_chunks: bool, )
Transfers audio metadata (e.g., track info) from the reader.
Sourcepub fn create_full_info_cue_data(
&self,
) -> Result<BTreeMap<u32, FullInfoCuePoint>, AudioError>
pub fn create_full_info_cue_data( &self, ) -> Result<BTreeMap<u32, FullInfoCuePoint>, AudioError>
- If your audio file has
plst
,cue
, andLIST adtl
chunks, then BAM you can call this function for full playlist info. - Returns
Err
if some of these chunks are absent.