Stretch

Struct Stretch 

Source
pub struct Stretch<S: SignalMut, I: Interpolate>
where I::Buf: BufferMut<Item = S::Sample>,
{ /* private fields */ }
Expand description

Samples a SignalMut and time-stretches it. Both pitch and speed will be modified.

Implementations§

Source§

impl<S: SignalMut, I: Interpolate> Stretch<S, I>
where I::Buf: BufferMut<Item = S::Sample>,

Source

pub fn new(sgn: S, factor: f64) -> Self

Initializes a new Stretch.

If you call this function, you’ll have to write down the interpolation mode explicitly. Consider instead calling one of Self::new_drop, Self::new_linear, Self::new_cubic or Self::new_hermite.

Source

pub const fn sgn(&self) -> &S

Returns a reference to the original signal.

Note that the signal might have been read a few samples ahead of what’s currently playing, depending on the interpolation method.

Source

pub fn sgn_mut(&mut self) -> &mut S

Returns a mutable reference to the original signal.

Note that the signal might have been read a few samples ahead of what’s currently playing, depending on the interpolation method.

Source

pub fn factor(&self) -> f64

Returns the time-stretching factor.

Source

pub const fn val(&self) -> Val

The fractional position between the current and next samples.

Source§

impl<S: SignalMut> Stretch<S, Drop<<S as Signal>::Sample>>
where S::Sample: Audio,

Source

pub fn new_drop(sgn: S, factor: f64) -> Self

Initializes a new DropStretch.

Source§

impl<S: SignalMut> Stretch<S, Linear<<S as Signal>::Sample>>
where S::Sample: Audio,

Source

pub fn new_linear(sgn: S, factor: f64) -> Self

Initializes a new LinearStretch.

Source§

impl<S: SignalMut> Stretch<S, Cubic<<S as Signal>::Sample>>
where S::Sample: Audio,

Source

pub fn new_cubic(sgn: S, factor: f64) -> Self

Initializes a new CubicStretch.

Source§

impl<S: SignalMut> Stretch<S, Hermite<<S as Signal>::Sample>>
where S::Sample: Audio,

Source

pub fn new_hermite(sgn: S, factor: f64) -> Self

Initializes a new HermiteStretch.

Trait Implementations§

Source§

impl<S: SignalMut, I: Interpolate> Signal for Stretch<S, I>
where I::Buf: BufferMut<Item = S::Sample>,

Source§

type Sample = <S as Signal>::Sample

The type of sample generated by the signal.
Source§

fn get(&self) -> S::Sample

Gets the next sample from the signal. Read more
Source§

fn _get(&self) -> Self::Sample

Currently, rust-analyzer trips up sometimes that get is called, confusing it with Array::get. This hack bypasses this.
Source§

impl<S: SignalMut, I: Interpolate> SignalMut for Stretch<S, I>
where I::Buf: BufferMut<Item = S::Sample>,

Source§

fn advance(&mut self)

Advances the state of the signal by a frame.
Source§

fn retrigger(&mut self)

Resets the signal to its initial state.
Source§

fn next(&mut self) -> Self::Sample

Gets the next sample and advances the state of the signal.

Auto Trait Implementations§

§

impl<S, I> Freeze for Stretch<S, I>
where S: Freeze, I: Freeze,

§

impl<S, I> RefUnwindSafe for Stretch<S, I>

§

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

§

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

§

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

§

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

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<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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V