Struct sample::interpolate::Converter
[−]
[src]
pub struct Converter<S, I> where
S: Signal,
I: Interpolator, { /* fields omitted */ }
An iterator that converts the rate at which frames are yielded from some given frame Interpolator into a new type.
Other names for sample::interpolate::Converter
might include:
- Sample rate converter
- {Up/Down}sampler
- Sample interpolater
- Sample decimator
Methods
impl<S, I> Converter<S, I> where
S: Signal,
I: Interpolator,
[src]
S: Signal,
I: Interpolator,
fn from_hz_to_hz(
source: S,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Self
[src]
source: S,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Self
Construct a new Converter
from the source frames and the source and target sample rates
(in Hz).
fn scale_playback_hz(source: S, interpolator: I, scale: f64) -> Self
[src]
Construct a new Converter
from the source frames and the amount by which the current
playback rate (not sample rate) should be multiplied to reach the new playback
rate.
For example, if our source_frames
is a sine wave oscillating at a frequency of 2hz and
we wanted to convert it to a frequency of 3hz, the given scale
should be 1.5
.
fn scale_sample_hz(source: S, interpolator: I, scale: f64) -> Self
[src]
Construct a new Converter
from the source frames and the amount by which the current
sample rate (not playback rate) should be multiplied to reach the new sample
rate.
If our source_frames
are being sampled at a rate of 44_100hz and we want to
convert to a sample rate of 96_000hz, the given scale
should be 96_000.0 / 44_100.0
.
This is the same as calling Converter::scale_playback_hz(source_frames, 1.0 / scale)
.
fn set_hz_to_hz(&mut self, source_hz: f64, target_hz: f64)
[src]
Update the source_to_target_ratio
internally given the source and target hz.
This method might be useful for changing the sample rate during playback.
fn set_playback_hz_scale(&mut self, scale: f64)
[src]
Update the source_to_target_ratio
internally given a new playback rate multiplier.
This method is useful for dynamically changing rates.
fn set_sample_hz_scale(&mut self, scale: f64)
[src]
Update the source_to_target_ratio
internally given a new sample rate multiplier.
This method is useful for dynamically changing rates.
fn source(&self) -> &S
[src]
Borrow the source_frames
Interpolator from the Converter
.
fn source_mut(&mut self) -> &mut S
[src]
Mutably borrow the source_frames
Iterator from the Converter
.
fn into_source(self) -> S
[src]
Drop self
and return the internal source_frames
Iterator.
Trait Implementations
impl<S: Clone, I: Clone> Clone for Converter<S, I> where
S: Signal,
I: Interpolator,
[src]
S: Signal,
I: Interpolator,
fn clone(&self) -> Converter<S, I>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<S, I> Signal for Converter<S, I> where
S: Signal,
I: Interpolator<Frame = S::Frame>,
[src]
S: Signal,
I: Interpolator<Frame = S::Frame>,
type Frame = S::Frame
The Frame
type returned by the Signal
.
fn next(&mut self) -> Self::Frame
[src]
Yield the next Frame
in the Signal
. Read more
fn is_exhausted(&self) -> bool
[src]
Whether or not the signal is exhausted of meaningful frames. Read more
fn map<M, F>(self, map: M) -> Map<Self, M, F> where
Self: Sized,
M: FnMut(Self::Frame) -> F,
F: Frame,
[src]
Self: Sized,
M: FnMut(Self::Frame) -> F,
F: Frame,
A signal that maps one set of frames to another. Read more
fn zip_map<O, M, F>(self, other: O, map: M) -> ZipMap<Self, O, M, F> where
Self: Sized,
M: FnMut(Self::Frame, O::Frame) -> F,
O: Signal,
F: Frame,
[src]
Self: Sized,
M: FnMut(Self::Frame, O::Frame) -> F,
O: Signal,
F: Frame,
A signal that maps one set of frames to another. Read more
fn add_amp<S>(self, other: S) -> AddAmp<Self, S> where
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
Provides an iterator that yields the sum of the frames yielded by both other
and self
in lock-step. Read more
fn mul_amp<S>(self, other: S) -> MulAmp<Self, S> where
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
S: Signal,
S::Frame: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
Provides an iterator that yields the product of the frames yielded by both other
and self
in lock-step. Read more
fn offset_amp(
self,
offset: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> OffsetAmp<Self> where
Self: Sized,
[src]
self,
offset: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> OffsetAmp<Self> where
Self: Sized,
Provides an iterator that offsets the amplitude of every channel in each frame of the signal by some sample value and yields the resulting frames. Read more
fn scale_amp(
self,
amp: <<Self::Frame as Frame>::Sample as Sample>::Float
) -> ScaleAmp<Self> where
Self: Sized,
[src]
self,
amp: <<Self::Frame as Frame>::Sample as Sample>::Float
) -> ScaleAmp<Self> where
Self: Sized,
Produces an Iterator
that scales the amplitude of the sample of each channel in every Frame
yielded by self
by the given amplitude. Read more
fn offset_amp_per_channel<F>(self, amp_frame: F) -> OffsetAmpPerChannel<Self, F> where
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Signed, NumChannels = <Self::Frame as Frame>::NumChannels>,
Produces a new Signal
that offsets the amplitude of every Frame
in self
by the respective amplitudes in each channel of the given amp_frame
. Read more
fn scale_amp_per_channel<F>(self, amp_frame: F) -> ScaleAmpPerChannel<Self, F> where
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
[src]
Self: Sized,
F: Frame<Sample = <<Self::Frame as Frame>::Sample as Sample>::Float, NumChannels = <Self::Frame as Frame>::NumChannels>,
Produces a new Signal
that scales the amplitude of every Frame
in self
by the respective amplitudes in each channel of the given amp_frame
. Read more
fn mul_hz<M, I>(self, interpolator: I, mul_per_frame: M) -> MulHz<Self, M, I> where
Self: Sized,
M: Signal<Frame = [f64; 1]>,
I: Interpolator,
[src]
Self: Sized,
M: Signal<Frame = [f64; 1]>,
I: Interpolator,
Multiplies the rate at which frames of self
are yielded by the given signal
. Read more
fn from_hz_to_hz<I>(
self,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
[src]
self,
interpolator: I,
source_hz: f64,
target_hz: f64
) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
Converts the rate at which frames of the Signal
are yielded using interpolation. Read more
fn scale_hz<I>(self, interpolator: I, multi: f64) -> Converter<Self, I> where
Self: Sized,
I: Interpolator,
[src]
Self: Sized,
I: Interpolator,
Multiplies the rate at which frames of the Signal
are yielded by the given value. Read more
fn delay(self, n_frames: usize) -> Delay<Self> where
Self: Sized,
[src]
Self: Sized,
Delays the Signal
by the given number of frames. Read more
fn into_interleaved_samples(self) -> IntoInterleavedSamples<Self> where
Self: Sized,
[src]
Self: Sized,
Converts a Signal
into a type that yields the interleaved Sample
s. Read more
fn clip_amp(
self,
thresh: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> ClipAmp<Self> where
Self: Sized,
[src]
self,
thresh: <<Self::Frame as Frame>::Sample as Sample>::Signed
) -> ClipAmp<Self> where
Self: Sized,
Clips the amplitude of each channel in each Frame
yielded by self
to the given threshold amplitude. Read more
fn inspect<F>(self, inspect: F) -> Inspect<Self, F> where
Self: Sized,
F: FnMut(&Self::Frame),
[src]
Self: Sized,
F: FnMut(&Self::Frame),
Create a new Signal
that calls the enclosing function on each iteration. Read more
fn fork<S>(self, ring_buffer: Bounded<S>) -> Fork<Self, S> where
Self: Sized,
S: SliceMut<Element = Self::Frame>,
[src]
Self: Sized,
S: SliceMut<Element = Self::Frame>,
Forks Self
into two signals that produce the same frames. Read more
fn bus(self) -> Bus<Self> where
Self: Sized,
[src]
Self: Sized,
Moves the Signal
into a Bus
from which its output may be divided into multiple other Signal
s in the form of Output
s. Read more
fn take(self, n: usize) -> Take<Self> where
Self: Sized,
[src]
Self: Sized,
Converts the Signal
into an Iterator
that will yield the given number for Frame
s before returning None
. Read more
fn until_exhausted(self) -> UntilExhausted<Self> where
Self: Sized,
[src]
Self: Sized,
Converts the Signal
into an Iterator
yielding frames until the signal.is_exhausted()
returns true
. Read more
fn buffered<S>(self, ring_buffer: Bounded<S>) -> Buffered<Self, S> where
Self: Sized,
S: Slice<Element = Self::Frame> + SliceMut,
[src]
Self: Sized,
S: Slice<Element = Self::Frame> + SliceMut,
Buffers the signal using the given ring buffer. Read more
fn rms<S>(self, ring_buffer: Fixed<S>) -> Rms<Self, S> where
Self: Sized,
S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut,
[src]
Self: Sized,
S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut,
An adaptor that yields the RMS of the signal. Read more
fn detect_envelope<D>(
self,
detector: Detector<Self::Frame, D>
) -> DetectEnvelope<Self, D> where
Self: Sized,
D: Detect<Self::Frame>,
[src]
self,
detector: Detector<Self::Frame, D>
) -> DetectEnvelope<Self, D> where
Self: Sized,
D: Detect<Self::Frame>,
An adaptor that detects and yields the envelope of the signal. Read more
fn by_ref(&mut self) -> &mut Self where
Self: Sized,
[src]
Self: Sized,
Borrows a Signal rather than consuming it. Read more