[][src]Struct dasp::signal::interpolate::Converter

pub struct Converter<S, I> where
    I: Interpolator,
    S: Signal
{ /* fields omitted */ }

A signal type that converts the rate at which frames are yielded from some source signal to some target rate.

Other names for sample::interpolate::Converter might include:

  • Sample rate converter.
  • {Up/Down}sampler.
  • Sample interpolater.
  • Sample decimator.

Implementations

impl<S, I> Converter<S, I> where
    I: Interpolator,
    S: Signal
[src]

pub fn from_hz_to_hz(
    source: S,
    interpolator: I,
    source_hz: f64,
    target_hz: f64
) -> Converter<S, I>
[src]

Construct a new Converter from the source frames and the source and target sample rates (in Hz).

pub fn scale_playback_hz(
    source: S,
    interpolator: I,
    scale: f64
) -> Converter<S, I>
[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.

pub fn scale_sample_hz(
    source: S,
    interpolator: I,
    scale: f64
) -> Converter<S, I>
[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).

pub 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.

pub 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.

pub 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.

pub fn source(&self) -> &S[src]

Borrow the source_frames Interpolator from the Converter.

pub fn source_mut(&mut self) -> &mut S[src]

Mutably borrow the source_frames Iterator from the Converter.

pub fn into_source(self) -> S[src]

Drop self and return the internal source_frames Iterator.

Trait Implementations

impl<S, I> Clone for Converter<S, I> where
    I: Clone + Interpolator,
    S: Clone + Signal
[src]

impl<S, I> Signal for Converter<S, I> where
    I: Interpolator<Frame = <S as Signal>::Frame>,
    S: Signal
[src]

type Frame = <S as Signal>::Frame

The Frame type returned by the Signal.

Auto Trait Implementations

impl<S, I> RefUnwindSafe for Converter<S, I> where
    I: RefUnwindSafe,
    S: RefUnwindSafe

impl<S, I> Send for Converter<S, I> where
    I: Send,
    S: Send

impl<S, I> Sync for Converter<S, I> where
    I: Sync,
    S: Sync

impl<S, I> Unpin for Converter<S, I> where
    I: Unpin,
    S: Unpin

impl<S, I> UnwindSafe for Converter<S, I> where
    I: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

impl<T> From<T> for T[src]

impl<S> FromSample<S> for S[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SignalBus for T where
    T: Signal
[src]

impl<T> SignalEnvelope for T where
    T: Signal
[src]

impl<T> SignalRms for T where
    T: Signal
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> ToSample<U> for T where
    U: FromSample<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.