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 theWaveDataSource
isReader
, theWaveReader
will create an auto-delete temporary file for thedata
chunk.
Sourcepub fn get_fact_data(&self) -> u64
pub fn get_fact_data(&self) -> u64
- The
fact
data is the number of the total samples in thedata
chunk.
Sourcepub fn get_fmt__chunk(&self) -> &FmtChunk
pub fn get_fmt__chunk(&self) -> &FmtChunk
- The
fmt
chunk is to specify the detailed audio file format.
Sourcepub fn get_slnt_chunk(&self) -> &Option<SlntChunk>
pub fn get_slnt_chunk(&self) -> &Option<SlntChunk>
- The
slnt
chunk indicates how long to stay silent.
Sourcepub fn get_bext_chunk(&self) -> &Option<BextChunk>
pub fn get_bext_chunk(&self) -> &Option<BextChunk>
- The
bext
chunk has somedescription
,version
,time_ref
pieces of information, etc.
Sourcepub fn get_smpl_chunk(&self) -> &Option<SmplChunk>
pub fn get_smpl_chunk(&self) -> &Option<SmplChunk>
- The
smpl
chunk has some pieces of information about MIDI notes, pitch, etc.
Sourcepub fn get_inst_chunk(&self) -> &Option<InstChunk>
pub fn get_inst_chunk(&self) -> &Option<InstChunk>
- The
inst
chunk has somebase_note
,gain
,velocity
, etc.
Sourcepub fn get_plst_chunk(&self) -> &Option<PlstChunk>
pub fn get_plst_chunk(&self) -> &Option<PlstChunk>
- The
plst
chunk is the playlist, it has a list that each element havecue_point
,num_samples
,repeats
.
Sourcepub fn get_trkn_chunk(&self) -> &Option<TrknChunk>
pub fn get_trkn_chunk(&self) -> &Option<TrknChunk>
- The
trkn
chunk, by the name.
Sourcepub fn get_cue__chunk(&self) -> &Option<CueChunk>
pub fn get_cue__chunk(&self) -> &Option<CueChunk>
- The
cue
chunk is with theplst
chunk, it has a list that each element havecue_point_id
,position
,chunk_start
, etc.
Sourcepub fn get_axml_chunk(&self) -> &Option<String>
pub fn get_axml_chunk(&self) -> &Option<String>
- The
axml
chunk. 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) -> &Option<String>
pub fn get_ixml_chunk(&self) -> &Option<String>
- The
ixml
chunk. 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) -> &BTreeSet<ListChunk>
pub fn get_list_chunk(&self) -> &BTreeSet<ListChunk>
- The
list
chunk, it has 2 subtypes, one isINFO
, and another isadtl
. - The
INFO
subtype is the metadata that containsartist
,album
,title
, etc. It lacksalbumartist
info. - The
adtl
subtype is with thecue
chunk, it’s a list including thelabel
,note
,text
,file
for the playlist.
Sourcepub fn get_acid_chunk(&self) -> &Option<AcidChunk>
pub fn get_acid_chunk(&self) -> &Option<AcidChunk>
- The
acid
chunk, contains some pieces of information about the rhythm, e.g.num_beats
,tempo
, etc.
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 INFO
chunk.
Sourcepub fn get_junk_chunks(&self) -> &BTreeSet<JunkChunk>
pub fn get_junk_chunks(&self) -> &BTreeSet<JunkChunk>
- The
JUNK
chunk, 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 adtl
chunks, then BAM you can call this function for full playlist info. - Returns
Err
if 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
IntoIterator
is only for two-channel stereof32
samples.
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