Trait sampara::signal::Signal [−][src]
Types that yield a sequence of Frame
s, representing an audio signal.
This trait is inspired by the Iterator
trait and has similar methods
and adaptors, but with a DSP-related focus.
Associated Types
Loading content...Required methods
Loading content...Provided methods
fn sig_next(&mut self) -> Self::Frame
[src]
Similar to [next
], but will always yield a Frame
. Yields
Frame::EQUILIBRIUM
if there are no more actual Frame
s to yield.
fn by_ref(&mut self) -> &mut Self where
Self: Sized,
[src]
Self: Sized,
Borrows this Signal
rather than consuming it.
This is useful for applying adaptors while still retaining ownership of
the original Signal
.
use sampara::{signal, Signal}; fn main() { let mut signal = signal::from_frames(vec![0, 1, 2, 3]); assert_eq!(signal.next(), Some(0)); assert_eq!(signal.by_ref().add_amp(10).next(), Some(11)); assert_eq!(signal.by_ref().mul_amp(2.5_f32).next(), Some(5)); assert_eq!(signal.next(), Some(3)); }
fn map<F, M, const NF: usize>(self, func: M) -> Map<Self, F, M, N, NF> where
Self: Sized,
F: Frame<NF>,
M: FnMut(Self::Frame) -> F,
[src]
Self: Sized,
F: Frame<NF>,
M: FnMut(Self::Frame) -> F,
fn zip_map<O, F, M, const NO: usize, const NF: usize>(
self,
other: O,
func: M
) -> ZipMap<Self, O, F, M, N, NO, NF> where
Self: Sized,
O: Signal<NO>,
F: Frame<NF>,
M: FnMut(Self::Frame, O::Frame) -> F,
[src]
self,
other: O,
func: M
) -> ZipMap<Self, O, F, M, N, NO, NF> where
Self: Sized,
O: Signal<NO>,
F: Frame<NF>,
M: FnMut(Self::Frame, O::Frame) -> F,
fn add_signal<B>(self, other: B) -> AddSignal<Self, B, N> where
Self: Sized,
B: Signal<N>,
Self::Frame: Frame<N, Signed = <B::Frame as Frame<N>>::Signed>,
[src]
Self: Sized,
B: Signal<N>,
Self::Frame: Frame<N, Signed = <B::Frame as Frame<N>>::Signed>,
Creates a new Signal
that yields the sum of pairs of Frame
s
yielded by Self
and another Signal
in lockstep.
fn mul_signal<B>(self, other: B) -> MulSignal<Self, B, N> where
Self: Sized,
B: Signal<N>,
Self::Frame: Frame<N, Float = <B::Frame as Frame<N>>::Float>,
[src]
Self: Sized,
B: Signal<N>,
Self::Frame: Frame<N, Float = <B::Frame as Frame<N>>::Float>,
Creates a new Signal
that yields the product of pairs of Frame
s
yielded by Self
and another Signal
in lockstep.
fn add_frame<F>(self, frame: F) -> AddFrame<Self, F, N> where
Self: Sized,
Self::Frame: Frame<N, Signed = F>,
F: Frame<N>,
[src]
Self: Sized,
Self::Frame: Frame<N, Signed = F>,
F: Frame<N>,
fn mul_frame<F>(self, frame: F) -> MulFrame<Self, F, N> where
Self: Sized,
Self::Frame: Frame<N, Float = F>,
F: Frame<N>,
[src]
Self: Sized,
Self::Frame: Frame<N, Float = F>,
F: Frame<N>,
fn add_amp<X>(self, amp: X) -> AddAmp<Self, X, N> where
Self: Sized,
Self::Frame: Frame<N>,
<Self::Frame as Frame<N>>::Sample: Sample<Signed = X>,
X: Sample,
[src]
Self: Sized,
Self::Frame: Frame<N>,
<Self::Frame as Frame<N>>::Sample: Sample<Signed = X>,
X: Sample,
Creates a new Signal
that yields each Frame
of a Signal
with each channel summed with a constant Sample
.
fn mul_amp<X>(self, amp: X) -> MulAmp<Self, X, N> where
Self: Sized,
Self::Frame: Frame<N>,
<Self::Frame as Frame<N>>::Sample: Sample<Float = X>,
X: Sample,
[src]
Self: Sized,
Self::Frame: Frame<N>,
<Self::Frame as Frame<N>>::Sample: Sample<Float = X>,
X: Sample,
Creates a new Signal
that yields each Frame
of a Signal
with each channel multiplied with a constant Sample
.
fn delay(self, n_frames: usize) -> Delay<Self, N> where
Self: Sized,
[src]
Self: Sized,
Delays Self
by a given number of frames. The delay is performed by
yielding Frame::EQUILIBRIUM
that number of times before continuing
to yield frames from Self
.
fn inspect<F>(self, func: F) -> Inspect<Self, F, N> where
Self: Sized,
F: FnMut(&Self::Frame),
[src]
Self: Sized,
F: FnMut(&Self::Frame),
Calls an inspection function on each Frame
yielded by this
Signal
, and then passes the Frame
through.
use sampara::{signal, Signal}; fn main() { let mut max: Option<i32> = None; let mut signal = signal::from_frames(vec![2i32, 3, 1]) .inspect(|&f| { if let Some(m) = max { max.replace(m.max(f)); } else { max = Some(f); } }); assert_eq!(signal.next(), Some(2)); assert_eq!(signal.next(), Some(3)); assert_eq!(signal.next(), Some(1)); assert_eq!(signal.next(), None); assert_eq!(max, Some(3)); }
fn take(self, n: usize) -> Take<Self, N> where
Self: Sized,
[src]
Self: Sized,
Returns a new Signal
that yields only the first N Frame
s of
Self
.
use sampara::{signal, Signal}; fn main() { let mut signal = signal::from_frames(0u8..=99) .take(3); assert_eq!(signal.next(), Some(0)); assert_eq!(signal.next(), Some(1)); assert_eq!(signal.next(), Some(2)); assert_eq!(signal.next(), None); }
fn into_iter(self) -> IntoIter<Self, N>ⓘ where
Self: Sized,
[src]
Self: Sized,
Implementations on Foreign Types
impl<S, const N: usize> Signal<N> for &mut S where
S: Signal<N>,
[src]
Loading content...S: Signal<N>,
Implementors
impl<A, B, const N: usize> Signal<N> for AddSignal<A, B, N> where
A: Signal<N>,
B: Signal<N>,
A::Frame: Frame<N, Signed = <B::Frame as Frame<N>>::Signed>,
[src]
A: Signal<N>,
B: Signal<N>,
A::Frame: Frame<N, Signed = <B::Frame as Frame<N>>::Signed>,
impl<A, B, const N: usize> Signal<N> for MulSignal<A, B, N> where
A: Signal<N>,
B: Signal<N>,
A::Frame: Frame<N, Float = <B::Frame as Frame<N>>::Float>,
[src]
A: Signal<N>,
B: Signal<N>,
A::Frame: Frame<N, Float = <B::Frame as Frame<N>>::Float>,
impl<D, const N: usize> Signal<N> for Phase<D, N> where
D: Delta<N>,
[src]
D: Delta<N>,
impl<D, const N: usize> Signal<N> for Saw<D, N> where
D: Delta<N>,
[src]
D: Delta<N>,
impl<D, const N: usize> Signal<N> for Sine<D, N> where
D: Delta<N>,
[src]
D: Delta<N>,
impl<D, const N: usize> Signal<N> for Square<D, N> where
D: Delta<N>,
[src]
D: Delta<N>,
impl<F, G, const N: usize> Signal<N> for FromFn<F, G, N> where
F: Frame<N>,
G: FnMut() -> Option<F>,
[src]
F: Frame<N>,
G: FnMut() -> Option<F>,
impl<F, I, const N: usize> Signal<N> for FromSamples<F, I, N> where
F: Frame<N, Sample = I::Item>,
I: Iterator,
I::Item: Sample,
[src]
F: Frame<N, Sample = I::Item>,
I: Iterator,
I::Item: Sample,
impl<F, const N: usize> Signal<N> for Constant<F, N> where
F: Frame<N>,
[src]
F: Frame<N>,
impl<F, const N: usize> Signal<N> for Empty<F, N> where
F: Frame<N>,
[src]
F: Frame<N>,
impl<F, const N: usize> Signal<N> for Equilibrium<F, N> where
F: Frame<N>,
[src]
F: Frame<N>,
impl<I, const N: usize> Signal<N> for FromFrames<I, N> where
I: Iterator,
I::Item: Frame<N>,
[src]
I: Iterator,
I::Item: Frame<N>,
impl<S, F, M, const N: usize, const NF: usize> Signal<NF> for Map<S, F, M, N, NF> where
S: Signal<N>,
F: Frame<NF>,
M: FnMut(S::Frame) -> F,
[src]
S: Signal<N>,
F: Frame<NF>,
M: FnMut(S::Frame) -> F,
impl<S, F, const N: usize> Signal<N> for AddFrame<S, F, N> where
S: Signal<N>,
S::Frame: Frame<N, Signed = F>,
F: Frame<N>,
[src]
S: Signal<N>,
S::Frame: Frame<N, Signed = F>,
F: Frame<N>,
impl<S, F, const N: usize> Signal<N> for Inspect<S, F, N> where
S: Signal<N>,
F: FnMut(&S::Frame),
[src]
S: Signal<N>,
F: FnMut(&S::Frame),
impl<S, F, const N: usize> Signal<N> for MulFrame<S, F, N> where
S: Signal<N>,
S::Frame: Frame<N, Float = F>,
F: Frame<N>,
[src]
S: Signal<N>,
S::Frame: Frame<N, Float = F>,
F: Frame<N>,
impl<S, O, M, F, const N: usize, const NO: usize, const NF: usize> Signal<NF> for ZipMap<S, O, F, M, N, NO, NF> where
S: Signal<N>,
O: Signal<NO>,
M: FnMut(S::Frame, O::Frame) -> F,
F: Frame<NF>,
[src]
S: Signal<N>,
O: Signal<NO>,
M: FnMut(S::Frame, O::Frame) -> F,
F: Frame<NF>,
impl<S, X, const N: usize> Signal<N> for AddAmp<S, X, N> where
S: Signal<N>,
S::Frame: Frame<N>,
<S::Frame as Frame<N>>::Sample: Sample<Signed = X>,
X: Sample,
[src]
S: Signal<N>,
S::Frame: Frame<N>,
<S::Frame as Frame<N>>::Sample: Sample<Signed = X>,
X: Sample,
impl<S, X, const N: usize> Signal<N> for MulAmp<S, X, N> where
S: Signal<N>,
S::Frame: Frame<N>,
<S::Frame as Frame<N>>::Sample: Sample<Float = X>,
X: Sample,
[src]
S: Signal<N>,
S::Frame: Frame<N>,
<S::Frame as Frame<N>>::Sample: Sample<Float = X>,
X: Sample,
impl<S, const N: usize> Signal<N> for Delay<S, N> where
S: Signal<N>,
[src]
S: Signal<N>,
impl<S, const N: usize> Signal<N> for Take<S, N> where
S: Signal<N>,
[src]
S: Signal<N>,