Struct xbadpcm::XboxADPCMEncoder
source · pub struct XboxADPCMEncoder<'a, E> { /* private fields */ }
Expand description
XboxADPCM encoder implementation.
Implementations
sourceimpl<'a, E> XboxADPCMEncoder<'a, E>where
E: Sized,
impl<'a, E> XboxADPCMEncoder<'a, E>where
E: Sized,
sourcepub fn new(
num_channels: usize,
lookahead: u8,
sink: &'a mut dyn XboxADPCMEncodeSink<Error = E>
) -> XboxADPCMEncoder<'a, E>
pub fn new(
num_channels: usize,
lookahead: u8,
sink: &'a mut dyn XboxADPCMEncodeSink<Error = E>
) -> XboxADPCMEncoder<'a, E>
Initialize an encoder with the given channel count, and lookahead for the given sink.
Higher lookahead may slightly reduce noise, but it will also exponentially increase encoding time.
Panics
Panics if num_channels
is not between 1 and 8
sourcepub fn encode<B: AsRef<[C]>, C: AsRef<[i16]>>(
&mut self,
input: B
) -> Result<(), E>
pub fn encode<B: AsRef<[C]>, C: AsRef<[i16]>>(
&mut self,
input: B
) -> Result<(), E>
Encode with the given samples using some samples.
Note that this may not always encode all samples passed and may store some in a buffer. To flush the buffer, run XboxADPCMEncoder::finish
.
Panics
Panics if the input has the wrong number of channels or the samples are wrong.
sourcepub fn finish(&mut self) -> Result<(), E>
pub fn finish(&mut self) -> Result<(), E>
Finish encoding and then resets the encoder.
This will encode all remaining samples, filling any unused samples with silence. If a simple reset is desired without any further writes, call XboxADPCMEncoder::reset
instead.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the encoder immediately without writing any more samples.
Any samples yet to be encoded will be dropped. If this is not desired, call XboxADPCMEncoder::finish
instead.