Enum TransformFn

Source
pub enum TransformFn<'a> {
    Basic(fn(&[f32], f32) -> Vec<f32>),
    Complex(&'a dyn Fn(&[f32], f32) -> Vec<(f64, f64)>),
}
Expand description

Parameter type for open_window_connect_audio. Describes how the audio data shall be transformed, and thus, how it should be displayed in the lower part of the window.

The function is called every x milliseconds (refresh rate of window).

This works cross-platform (Windows, MacOS, Linux).

Variants§

§

Basic(fn(&[f32], f32) -> Vec<f32>)

Synchronized x-axis with the original data. Useful for transformations on the waveform, such as a (lowpass) filter.

Functions takes amplitude values and transforms them to a new amplitude value. It gets the sampling rate as second argument.

§

Complex(&'a dyn Fn(&[f32], f32) -> Vec<(f64, f64)>)

Use this, when the x-axis is different than for the original data. For example, if you want to display a spectrum.

Functions takes amplitude values (and their index) and transforms them to a new (x,y)-pair. Takes a closure instead of a function, so that it can capture state. It gets the sampling rate as second argument.

Auto Trait Implementations§

§

impl<'a> Freeze for TransformFn<'a>

§

impl<'a> !RefUnwindSafe for TransformFn<'a>

§

impl<'a> !Send for TransformFn<'a>

§

impl<'a> !Sync for TransformFn<'a>

§

impl<'a> Unpin for TransformFn<'a>

§

impl<'a> !UnwindSafe for TransformFn<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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