pub struct NonRtResampler<T: Sample> { /* private fields */ }
Expand description
An easy to use resampler for use in non-realtime applications.
Implementations§
Source§impl<T: Sample> NonRtResampler<T>
impl<T: Sample> NonRtResampler<T>
Sourcepub fn new(
in_sample_rate: u32,
out_sample_rate: u32,
num_channels: usize,
quality: ResampleQuality,
) -> Self
pub fn new( in_sample_rate: u32, out_sample_rate: u32, num_channels: usize, quality: ResampleQuality, ) -> Self
Create a new non-realtime resampler.
in_sample_rate
- The sample rate of the input stream.out_sample_rate
- The sample rate of the output stream.num_channels
- The number of channels.interleaved
- If you are planning to useNonRtResampler::process_interleaved
, set this totrue
. Otherwise you can set this tofalse
to save a bit of memory.quality
- The quality of the resampling algorithm.
§Panics
Panics if:
in_sample_rate == 0
out_sample_rate == 0
num_channels == 0
,
Sourcepub fn from_custom(resampler: impl Into<ResamplerType<T>>) -> Self
pub fn from_custom(resampler: impl Into<ResamplerType<T>>) -> Self
Create a new non-realtime resampler using the given rubato resampler.
§Panics
Panics if max_out_frames == 0
.
Sourcepub fn num_channels(&self) -> NonZeroUsize
pub fn num_channels(&self) -> NonZeroUsize
Get the number of channels this resampler is configured for.
Sourcepub fn process_interleaved(
&mut self,
input: &[T],
on_processed: impl FnMut(&[T]),
is_last_packet: bool,
)
pub fn process_interleaved( &mut self, input: &[T], on_processed: impl FnMut(&[T]), is_last_packet: bool, )
Resample the given input data.
input
- The input data in interleaved format.on_processed
- Called whenever there is new resampled data. This data is in interleaved format.is_last_packet
- Whether or not this is the last (or only) packet of data that will be resampled. This ensures that any leftover samples in the internal resampler are flushed to the output.
Note, this method is NOT realtime-safe.
Sourcepub fn process<Vin: AsRef<[T]>>(
&mut self,
input: &[Vin],
on_processed: impl FnMut(&[Vec<T>], usize),
is_last_packet: bool,
)
pub fn process<Vin: AsRef<[T]>>( &mut self, input: &[Vin], on_processed: impl FnMut(&[Vec<T>], usize), is_last_packet: bool, )
Resample the given input data.
input
- The input data.on_processed
- Called whenever there is new resampled data. The first argument is the buffers containing the new data, and the second argument is the length of the new data in frames (NOTE, the second argument may be less than the length of theVec
s in the first argument).is_last_packet
- Whether or not this is the last (or only) packet of data that will be resampled. This ensures that any leftover samples in the internal resampler are flushed to the output.
Note, this method is NOT realtime-safe.
pub fn resampler_type(&self) -> &ResamplerType<T>
pub fn resampler_type_mut(&mut self) -> &mut ResamplerType<T>
Trait Implementations§
Source§impl<T: Sample> Into<ResamplerType<T>> for NonRtResampler<T>
impl<T: Sample> Into<ResamplerType<T>> for NonRtResampler<T>
Source§fn into(self) -> ResamplerType<T>
fn into(self) -> ResamplerType<T>
Converts this type into the (usually inferred) input type.
Auto Trait Implementations§
impl<T> Freeze for NonRtResampler<T>
impl<T> !RefUnwindSafe for NonRtResampler<T>
impl<T> Send for NonRtResampler<T>
impl<T> Sync for NonRtResampler<T>
impl<T> Unpin for NonRtResampler<T>where
T: Unpin,
impl<T> !UnwindSafe for NonRtResampler<T>
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