pub struct WaveReader { /* private fields */ }Expand description
§The WaveReader is dedicated to reading a WAV file and provides you with samples as you want.
Usage:
- Open a WAV file
- Get the iterator
- The iterator excretes the PCM samples with the format you specified.
Implementations§
Source§impl WaveReader
impl WaveReader
Sourcepub fn open(file_source: &str) -> Result<Self, AudioReadError>
pub fn open(file_source: &str) -> Result<Self, AudioReadError>
- Open the WAV file from a file path. No temporary files will be created.
Sourcepub fn new(file_source: WaveDataSource) -> Result<Self, AudioReadError>
pub fn new(file_source: WaveDataSource) -> Result<Self, AudioReadError>
- Open the WAV file from a
WaveDataSource, if theWaveDataSourceisReader, theWaveReaderwill create an auto-delete temporary file for thedatachunk.
Sourcepub fn get_fact_data(&self) -> u64
pub fn get_fact_data(&self) -> u64
- The
factdata is the number of the total samples in thedatachunk.
Sourcepub fn get_fmt__chunk(&self) -> &FmtChunk
pub fn get_fmt__chunk(&self) -> &FmtChunk
- The
fmtchunk is to specify the detailed audio file format.
Sourcepub fn get_slnt_chunk(&self) -> &Vec<SlntChunk>
pub fn get_slnt_chunk(&self) -> &Vec<SlntChunk>
- The
slntchunk indicates how long to stay silent.
Sourcepub fn get_bext_chunk(&self) -> &Vec<BextChunk>
pub fn get_bext_chunk(&self) -> &Vec<BextChunk>
- The
bextchunk has somedescription,version,time_refpieces of information, etc.
Sourcepub fn get_smpl_chunk(&self) -> &Vec<SmplChunk>
pub fn get_smpl_chunk(&self) -> &Vec<SmplChunk>
- The
smplchunk has some pieces of information about MIDI notes, pitch, etc.
Sourcepub fn get_inst_chunk(&self) -> &Vec<InstChunk>
pub fn get_inst_chunk(&self) -> &Vec<InstChunk>
- The
instchunk has somebase_note,gain,velocity, etc.
Sourcepub fn get_plst_chunk(&self) -> &Option<PlstChunk>
pub fn get_plst_chunk(&self) -> &Option<PlstChunk>
- The
plstchunk is the playlist, it has a list that each element havecue_point,num_samples,repeats.
Sourcepub fn get_cue__chunk(&self) -> &Option<CueChunk>
pub fn get_cue__chunk(&self) -> &Option<CueChunk>
- The
cuechunk is with theplstchunk, it has a list that each element havecue_point_id,position,chunk_start, etc.
Sourcepub fn get_axml_chunk(&self) -> &Vec<String>
pub fn get_axml_chunk(&self) -> &Vec<String>
- The
axmlchunk. I personally don’t know what it is, by the name it looks like some kind ofaudio XML. It’s a pure string chunk.
Sourcepub fn get_ixml_chunk(&self) -> &Vec<String>
pub fn get_ixml_chunk(&self) -> &Vec<String>
- The
ixmlchunk. I personally don’t know what it is, by the name it looks like some kind ofinfo XML. It’s a pure string chunk.
Sourcepub fn get_list_chunk(&self) -> &Vec<ListChunk>
pub fn get_list_chunk(&self) -> &Vec<ListChunk>
- The
listchunk, it has 2 subtypes, one isINFO, and another isadtl. - The
INFOsubtype is the metadata that containsartist,album,title, etc. It lacksalbumartistinfo. - The
adtlsubtype is with thecuechunk, it’s a list including thelabel,note,text,filefor the playlist.
Sourcepub fn get_acid_chunk(&self) -> &Vec<AcidChunk>
pub fn get_acid_chunk(&self) -> &Vec<AcidChunk>
- The
acidchunk, contains some pieces of information about the rhythm, e.g.num_beats,tempo, etc.
Sourcepub fn get_trkn_chunk(&self) -> &Vec<String>
pub fn get_trkn_chunk(&self) -> &Vec<String>
- The
trknchunk, by the name, looks liketrack note. It’s a pure string chunk.
Sourcepub fn get_id3__chunk(&self) -> &Option<Tag>
pub fn get_id3__chunk(&self) -> &Option<Tag>
- Another metadata chunk for the audio file. This covers more metadata than the
LIST INFOchunk.
Sourcepub fn get_junk_chunks(&self) -> &Vec<JunkChunk>
pub fn get_junk_chunks(&self) -> &Vec<JunkChunk>
- The
JUNKchunk, sometimes it’s used for placeholder, sometimes it contains some random data for some random music software to show off.
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 adtlchunks, then BAM you can call this function for full playlist info. - Returns
Errif some of these chunks are absent.
Sourcepub fn frame_iter<S>(&mut self) -> Result<FrameIter<'_, S>, AudioReadError>where
S: SampleType,
pub fn frame_iter<S>(&mut self) -> Result<FrameIter<'_, S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame, excretes multi-channel audio frames.
- Every audio frame is an array that includes one sample for every channel.
- This iterator supports multi-channel audio files e.g. 5.1 stereo or 7.1 stereo audio files.
- Since each audio frame is a
Vec, it’s expensive in memory and slow. - Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple frames.
Sourcepub fn mono_iter<S>(&mut self) -> Result<MonoIter<'_, S>, AudioReadError>where
S: SampleType,
pub fn mono_iter<S>(&mut self) -> Result<MonoIter<'_, S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame, excretes mono-channel samples.
- This iterator is dedicated to mono audio, it combines every channel into one channel and excretes every single sample as an audio frame.
- Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple samples.
Sourcepub fn stereo_iter<S>(&mut self) -> Result<StereoIter<'_, S>, AudioReadError>where
S: SampleType,
pub fn stereo_iter<S>(&mut self) -> Result<StereoIter<'_, S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame, excretes two-channel stereo frames.
- This iterator is dedicated to two-channel stereo audio, if the source audio is mono, it duplicates the sample to excrete stereo frames for you. If the source audio is multi-channel audio, this iterator can’t be created.
- Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple samples.
Sourcepub fn frame_intoiter<S>(self) -> Result<FrameIntoIter<S>, AudioReadError>where
S: SampleType,
pub fn frame_intoiter<S>(self) -> Result<FrameIntoIter<S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame and consumes the WaveReader, excretes multi-channel audio frames.
- Every audio frame is an array that includes one sample for every channel.
- This iterator supports multi-channel audio files e.g. 5.1 stereo or 7.1 stereo audio files.
- Since each audio frame is a
Vec, it’s expensive in memory and slow. - Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple frames.
Sourcepub fn mono_intoiter<S>(self) -> Result<MonoIntoIter<S>, AudioReadError>where
S: SampleType,
pub fn mono_intoiter<S>(self) -> Result<MonoIntoIter<S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame and consumes the WaveReader, excretes mono-channel samples.
- This iterator is dedicated to mono audio, it combines every channel into one channel and excretes every single sample as an audio frame.
- Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple samples.
Sourcepub fn stereo_intoiter<S>(self) -> Result<StereoIntoIter<S>, AudioReadError>where
S: SampleType,
pub fn stereo_intoiter<S>(self) -> Result<StereoIntoIter<S>, AudioReadError>where
S: SampleType,
§Create an iterator for iterating through each audio frame and consumes the WaveReader, excretes two-channel stereo frames.
- This iterator is dedicated to two-channel stereo audio, if the source audio is mono, it duplicates the sample to excrete stereo frames for you. If the source audio is multi-channel audio, this iterator can’t be created.
- Besides it’s an iterator, the struct itself provides
decode_frames()for batch decode multiple samples.
Trait Implementations§
Source§impl Debug for WaveReader
impl Debug for WaveReader
Source§impl IntoIterator for WaveReader
- The
IntoIterator is only for two-channel stereo f32 samples.
impl IntoIterator for WaveReader
- The
IntoIteratoris only for two-channel stereof32samples.
Auto Trait Implementations§
impl Freeze for WaveReader
impl !RefUnwindSafe for WaveReader
impl !Send for WaveReader
impl !Sync for WaveReader
impl Unpin for WaveReader
impl !UnwindSafe for WaveReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more