pub use super::audionode::*;
pub use super::audiounit::*;
pub use super::combinator::*;
pub use super::delay::*;
pub use super::dynamics::*;
pub use super::envelope::*;
pub use super::feedback::*;
pub use super::filter::*;
pub use super::fir::*;
pub use super::follow::*;
pub use super::granular::*;
pub use super::math::*;
pub use super::moog::*;
pub use super::net::*;
pub use super::noise::*;
pub use super::oscillator::*;
pub use super::oversample::*;
pub use super::pan::*;
pub use super::resample::*;
pub use super::sequencer::*;
pub use super::setting::*;
pub use super::shape::*;
pub use super::shared::*;
pub use super::signal::*;
pub use super::svf::*;
pub use super::system::*;
pub use super::wave::*;
pub use super::wavetable::*;
pub use super::*;
#[cfg(feature = "files")]
pub use super::read::*;
use std::sync::Arc;
pub type U0 = numeric_array::typenum::U0;
pub type U1 = numeric_array::typenum::U1;
pub type U2 = numeric_array::typenum::U2;
pub type U3 = numeric_array::typenum::U3;
pub type U4 = numeric_array::typenum::U4;
pub type U5 = numeric_array::typenum::U5;
pub type U6 = numeric_array::typenum::U6;
pub type U7 = numeric_array::typenum::U7;
pub type U8 = numeric_array::typenum::U8;
pub type U9 = numeric_array::typenum::U9;
pub type U10 = numeric_array::typenum::U10;
pub type U11 = numeric_array::typenum::U11;
pub type U12 = numeric_array::typenum::U12;
pub type U13 = numeric_array::typenum::U13;
pub type U14 = numeric_array::typenum::U14;
pub type U15 = numeric_array::typenum::U15;
pub type U16 = numeric_array::typenum::U16;
pub type U17 = numeric_array::typenum::U17;
pub type U18 = numeric_array::typenum::U18;
pub type U19 = numeric_array::typenum::U19;
pub type U20 = numeric_array::typenum::U20;
pub type U21 = numeric_array::typenum::U21;
pub type U22 = numeric_array::typenum::U22;
pub type U23 = numeric_array::typenum::U23;
pub type U24 = numeric_array::typenum::U24;
pub type U25 = numeric_array::typenum::U25;
pub type U26 = numeric_array::typenum::U26;
pub type U27 = numeric_array::typenum::U27;
pub type U28 = numeric_array::typenum::U28;
pub type U29 = numeric_array::typenum::U29;
pub type U30 = numeric_array::typenum::U30;
pub type U31 = numeric_array::typenum::U31;
pub type U32 = numeric_array::typenum::U32;
pub type U33 = numeric_array::typenum::U33;
pub type U34 = numeric_array::typenum::U34;
pub type U35 = numeric_array::typenum::U35;
pub type U36 = numeric_array::typenum::U36;
pub type U37 = numeric_array::typenum::U37;
pub type U38 = numeric_array::typenum::U38;
pub type U39 = numeric_array::typenum::U39;
pub type U40 = numeric_array::typenum::U40;
pub type U41 = numeric_array::typenum::U41;
pub type U42 = numeric_array::typenum::U42;
pub type U43 = numeric_array::typenum::U43;
pub type U44 = numeric_array::typenum::U44;
pub type U45 = numeric_array::typenum::U45;
pub type U46 = numeric_array::typenum::U46;
pub type U47 = numeric_array::typenum::U47;
pub type U48 = numeric_array::typenum::U48;
pub type U49 = numeric_array::typenum::U49;
pub type U50 = numeric_array::typenum::U50;
pub type U51 = numeric_array::typenum::U51;
pub type U52 = numeric_array::typenum::U52;
pub type U53 = numeric_array::typenum::U53;
pub type U54 = numeric_array::typenum::U54;
pub type U55 = numeric_array::typenum::U55;
pub type U56 = numeric_array::typenum::U56;
pub type U57 = numeric_array::typenum::U57;
pub type U58 = numeric_array::typenum::U58;
pub type U59 = numeric_array::typenum::U59;
pub type U60 = numeric_array::typenum::U60;
pub type U61 = numeric_array::typenum::U61;
pub type U62 = numeric_array::typenum::U62;
pub type U63 = numeric_array::typenum::U63;
pub type U64 = numeric_array::typenum::U64;
pub type U65 = numeric_array::typenum::U65;
pub type U66 = numeric_array::typenum::U66;
pub type U67 = numeric_array::typenum::U67;
pub type U68 = numeric_array::typenum::U68;
pub type U69 = numeric_array::typenum::U69;
pub type U70 = numeric_array::typenum::U70;
pub type U71 = numeric_array::typenum::U71;
pub type U72 = numeric_array::typenum::U72;
pub type U73 = numeric_array::typenum::U73;
pub type U74 = numeric_array::typenum::U74;
pub type U75 = numeric_array::typenum::U75;
pub type U76 = numeric_array::typenum::U76;
pub type U77 = numeric_array::typenum::U77;
pub type U78 = numeric_array::typenum::U78;
pub type U79 = numeric_array::typenum::U79;
pub type U80 = numeric_array::typenum::U80;
pub type U81 = numeric_array::typenum::U81;
pub type U82 = numeric_array::typenum::U82;
pub type U83 = numeric_array::typenum::U83;
pub type U84 = numeric_array::typenum::U84;
pub type U85 = numeric_array::typenum::U85;
pub type U86 = numeric_array::typenum::U86;
pub type U87 = numeric_array::typenum::U87;
pub type U88 = numeric_array::typenum::U88;
pub type U89 = numeric_array::typenum::U89;
pub type U90 = numeric_array::typenum::U80;
pub type U91 = numeric_array::typenum::U91;
pub type U92 = numeric_array::typenum::U92;
pub type U93 = numeric_array::typenum::U93;
pub type U94 = numeric_array::typenum::U94;
pub type U95 = numeric_array::typenum::U95;
pub type U96 = numeric_array::typenum::U96;
pub type U97 = numeric_array::typenum::U97;
pub type U98 = numeric_array::typenum::U98;
pub type U99 = numeric_array::typenum::U99;
pub type U100 = numeric_array::typenum::U100;
pub type U101 = numeric_array::typenum::U101;
pub type U102 = numeric_array::typenum::U102;
pub type U103 = numeric_array::typenum::U103;
pub type U104 = numeric_array::typenum::U104;
pub type U105 = numeric_array::typenum::U105;
pub type U106 = numeric_array::typenum::U106;
pub type U107 = numeric_array::typenum::U107;
pub type U108 = numeric_array::typenum::U108;
pub type U109 = numeric_array::typenum::U109;
pub type U110 = numeric_array::typenum::U110;
pub type U111 = numeric_array::typenum::U111;
pub type U112 = numeric_array::typenum::U112;
pub type U113 = numeric_array::typenum::U113;
pub type U114 = numeric_array::typenum::U114;
pub type U115 = numeric_array::typenum::U115;
pub type U116 = numeric_array::typenum::U116;
pub type U117 = numeric_array::typenum::U117;
pub type U118 = numeric_array::typenum::U118;
pub type U119 = numeric_array::typenum::U119;
pub type U120 = numeric_array::typenum::U120;
pub type U121 = numeric_array::typenum::U121;
pub type U122 = numeric_array::typenum::U122;
pub type U123 = numeric_array::typenum::U123;
pub type U124 = numeric_array::typenum::U124;
pub type U125 = numeric_array::typenum::U125;
pub type U126 = numeric_array::typenum::U126;
pub type U127 = numeric_array::typenum::U127;
pub type U128 = numeric_array::typenum::U128;
#[inline]
pub fn constant<T: Float, X: ConstantFrame<Sample = T>>(x: X) -> An<Constant<X::Size, T>>
where
X::Size: Size<T>,
{
An(Constant::new(x.convert()))
}
#[inline]
pub fn dc<T: Float, X: ConstantFrame<Sample = T>>(x: X) -> An<Constant<X::Size, T>>
where
X::Size: Size<T>,
{
An(Constant::new(x.convert()))
}
#[inline]
pub fn zero<T: Float>() -> An<Constant<U1, T>> {
dc(T::new(0))
}
#[inline]
pub fn multizero<N: Size<T>, T: Float>() -> An<Constant<N, T>> {
An(Constant::new(Frame::splat(T::zero())))
}
pub fn update<T: Float, X: AudioNode, F: FnMut(T, T, &mut X) + Clone>(
x: An<X>,
dt: T,
f: F,
) -> An<System<T, X, F>> {
An(System::new(x, dt, f))
}
#[inline]
pub fn pass<T: Float>() -> An<Pass<T>> {
An(Pass::new())
}
#[inline]
pub fn multipass<N: Size<T>, T: Float>() -> An<MultiPass<N, T>> {
An(MultiPass::new())
}
#[inline]
pub fn monitor<T: Real + Atomic>(shared: &Shared<T>, meter: Meter) -> An<Monitor<T>> {
An(Monitor::new(DEFAULT_SR, shared, meter))
}
#[inline]
pub fn meter<T: Real>(meter: Meter) -> An<MeterNode<T>> {
An(MeterNode::new(DEFAULT_SR, meter))
}
#[inline]
pub fn sink<T: Float>() -> An<Sink<U1, T>> {
An(Sink::new())
}
#[inline]
pub fn multisink<N: Size<T>, T: Float>() -> An<Sink<N, T>> {
An(Sink::new())
}
#[inline]
pub fn swap<T: Float>() -> An<Swap<T>> {
An(Swap::new())
}
#[inline]
pub fn sine<T: Real>() -> An<Sine<T>> {
An(Sine::new(DEFAULT_SR))
}
#[inline]
pub fn sine_hz<T: Real>(f: T) -> An<Pipe<T, Constant<U1, T>, Sine<T>>> {
constant(f) >> sine()
}
#[inline]
pub fn add<X: ConstantFrame>(
x: X,
) -> An<
Binop<
X::Sample,
FrameAdd<X::Size, X::Sample>,
MultiPass<X::Size, X::Sample>,
Constant<X::Size, X::Sample>,
>,
>
where
X::Size: Size<X::Sample> + Add<U0>,
<X::Size as Add<U0>>::Output: Size<X::Sample>,
{
An(MultiPass::<X::Size, X::Sample>::new()) + dc(x)
}
#[inline]
pub fn sub<X: ConstantFrame>(
x: X,
) -> An<
Binop<
X::Sample,
FrameSub<X::Size, X::Sample>,
MultiPass<X::Size, X::Sample>,
Constant<X::Size, X::Sample>,
>,
>
where
X::Size: Size<X::Sample> + Add<U0>,
<X::Size as Add<U0>>::Output: Size<X::Sample>,
{
An(MultiPass::<X::Size, X::Sample>::new()) - dc(x)
}
#[inline]
pub fn mul<X: ConstantFrame>(
x: X,
) -> An<
Binop<
X::Sample,
FrameMul<X::Size, X::Sample>,
MultiPass<X::Size, X::Sample>,
Constant<X::Size, X::Sample>,
>,
>
where
X::Size: Size<X::Sample> + Add<U0>,
<X::Size as Add<U0>>::Output: Size<X::Sample>,
{
An(MultiPass::<X::Size, X::Sample>::new()) * dc(x)
}
#[inline]
pub fn butterpass<T: Float, F: Real>() -> An<ButterLowpass<T, F, U2>> {
An(ButterLowpass::new(convert(DEFAULT_SR), F::new(440)))
}
#[inline]
pub fn butterpass_hz<T: Float, F: Real>(f: T) -> An<ButterLowpass<T, F, U1>> {
An(ButterLowpass::new(convert(DEFAULT_SR), convert(f)))
}
#[inline]
pub fn lowpole<T: Float, F: Real>() -> An<Lowpole<T, F, U2>> {
An(Lowpole::new(convert(DEFAULT_SR), F::new(440)))
}
#[inline]
pub fn lowpole_hz<T: Float, F: Real>(f: T) -> An<Lowpole<T, F, U1>> {
An(Lowpole::new(DEFAULT_SR, convert(f)))
}
#[inline]
pub fn allpole<T: Float, F: Float>() -> An<Allpole<T, F, U2>> {
An(Allpole::new(DEFAULT_SR, F::new(1)))
}
#[inline]
pub fn allpole_delay<T: Float, F: Float>(delay_in_samples: F) -> An<Allpole<T, F, U1>> {
An(Allpole::new(DEFAULT_SR, delay_in_samples))
}
#[inline]
pub fn highpole<T: Float, F: Real>() -> An<Highpole<T, F, U2>> {
An(Highpole::new(DEFAULT_SR, F::new(440)))
}
#[inline]
pub fn highpole_hz<T: Float, F: Real>(f: T) -> An<Highpole<T, F, U1>> {
An(Highpole::new(DEFAULT_SR, convert(f)))
}
#[inline]
pub fn resonator<T: Float, F: Real>() -> An<Resonator<T, F, U3>> {
An(Resonator::new(
convert(DEFAULT_SR),
F::new(440),
F::new(110),
))
}
#[inline]
pub fn resonator_hz<T: Float, F: Real>(center: T, bandwidth: T) -> An<Resonator<T, F, U1>> {
An(Resonator::new(
convert(DEFAULT_SR),
convert(center),
convert(bandwidth),
))
}
#[inline]
pub fn biquad<T: Float, F: Real>(a1: F, a2: F, b0: F, b1: F, b2: F) -> An<Biquad<T, F>> {
An(Biquad::with_coefs(BiquadCoefs::arbitrary(
a1, a2, b0, b1, b2,
)))
}
#[inline]
pub fn moog<T: Float, F: Real>() -> An<Moog<T, F, U3>> {
An(Moog::new(
convert(DEFAULT_SR),
F::new(1000),
F::from_f64(0.1),
))
}
#[inline]
pub fn moog_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Moog<T, F, U3>>> {
(multipass::<U2, T>() | dc(q)) >> An(Moog::new(convert(DEFAULT_SR), F::new(1000), convert(q)))
}
#[inline]
pub fn moog_hz<T: Float, F: Real>(frequency: F, q: F) -> An<Moog<T, F, U1>> {
An(Moog::new(convert(DEFAULT_SR), frequency, q))
}
#[inline]
pub fn envelope<T, F, E, R>(f: E) -> An<Envelope<T, F, E, R>>
where
T: Float,
F: Float,
E: Fn(F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(Envelope::new(F::from_f64(0.002), DEFAULT_SR, f))
}
#[inline]
pub fn lfo<T, F, E, R>(f: E) -> An<Envelope<T, F, E, R>>
where
T: Float,
F: Float,
E: Fn(F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(Envelope::new(F::from_f64(0.002), DEFAULT_SR, f))
}
#[inline]
pub fn envelope2<T, F, E, R>(
f: E,
) -> An<EnvelopeIn<T, F, impl Fn(F, &Frame<T, U1>) -> R + Sized + Clone, U1, R>>
where
T: Float,
F: Float,
E: Fn(F, F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(
F::from_f64(0.002),
DEFAULT_SR,
move |t, i: &Frame<T, U1>| f(t, convert(i[0])),
))
}
#[inline]
pub fn lfo2<T, F, E, R>(
f: E,
) -> An<EnvelopeIn<T, F, impl Fn(F, &Frame<T, U1>) -> R + Sized + Clone, U1, R>>
where
T: Float,
F: Float,
E: Fn(F, F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(
F::from_f64(0.002),
DEFAULT_SR,
move |t, i: &Frame<T, U1>| f(t, convert(i[0])),
))
}
#[inline]
pub fn envelope3<T, F, E, R>(
f: E,
) -> An<EnvelopeIn<T, F, impl Fn(F, &Frame<T, U2>) -> R + Sized + Clone, U2, R>>
where
T: Float,
F: Float,
E: Fn(F, F, F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(
F::from_f64(0.002),
DEFAULT_SR,
move |t, i: &Frame<T, U2>| f(t, convert(i[0]), convert(i[1])),
))
}
#[inline]
pub fn lfo3<T, F, E, R>(
f: E,
) -> An<EnvelopeIn<T, F, impl Fn(F, &Frame<T, U2>) -> R + Sized + Clone, U2, R>>
where
T: Float,
F: Float,
E: Fn(F, F, F) -> R + Clone,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(
F::from_f64(0.002),
DEFAULT_SR,
move |t, i: &Frame<T, U2>| f(t, convert(i[0]), convert(i[1])),
))
}
pub fn envelope_in<T, F, E, I, R>(f: E) -> An<EnvelopeIn<T, F, E, I, R>>
where
T: Float,
F: Float,
E: Fn(F, &Frame<T, I>) -> R + Clone,
I: Size<T>,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(F::from_f64(0.002), DEFAULT_SR, f))
}
pub fn lfo_in<T, F, E, I, R>(f: E) -> An<EnvelopeIn<T, F, E, I, R>>
where
T: Float,
F: Float,
E: Fn(F, &Frame<T, I>) -> R + Clone,
I: Size<T>,
R: ConstantFrame<Sample = F>,
R::Size: Size<F>,
R::Size: Size<T>,
{
An(EnvelopeIn::new(F::from_f64(0.002), DEFAULT_SR, f))
}
#[inline]
pub fn adsr_live<F>(
attack: F,
decay: F,
sustain: F,
release: F,
) -> An<EnvelopeIn<F, F, impl Fn(F, &Frame<F, U1>) -> F + Sized + Clone, U1, F>>
where
F: Float + Atomic,
{
super::adsr::adsr_live(attack, decay, sustain, release)
}
#[inline]
pub fn mls_bits<T: Float>(n: i64) -> An<Mls<T>> {
An(Mls::new(MlsState::new(n as u32)))
}
#[inline]
pub fn mls<T: Float>() -> An<Mls<T>> {
mls_bits(29)
}
#[inline]
pub fn noise<T: Float>() -> An<Noise<T>> {
An(Noise::new())
}
#[inline]
pub fn white<T: Float>() -> An<Noise<T>> {
An(Noise::new())
}
#[inline]
pub fn fir<X: ConstantFrame>(weights: X) -> An<Fir<X::Sample, X::Size>> {
An(Fir::new(weights))
}
#[inline]
pub fn tick<T: Float>() -> An<Tick<U1, T>> {
An(Tick::new(convert(DEFAULT_SR)))
}
#[inline]
pub fn multitick<N: Size<T>, T: Float>() -> An<Tick<N, T>> {
An(Tick::new(convert(DEFAULT_SR)))
}
#[inline]
pub fn delay<T: Float>(t: f64) -> An<Delay<T>> {
An(Delay::new(t, DEFAULT_SR))
}
#[inline]
pub fn tap<T: Float>(min_delay: T, max_delay: T) -> An<Tap<U1, T>> {
An(Tap::new(DEFAULT_SR, min_delay, max_delay))
}
#[inline]
pub fn multitap<N, T>(min_delay: T, max_delay: T) -> An<Tap<N, T>>
where
T: Float,
N: Size<T> + Add<U1>,
<N as Add<U1>>::Output: Size<T>,
{
An(Tap::new(DEFAULT_SR, min_delay, max_delay))
}
#[inline]
pub fn oversample<T, X>(node: An<X>) -> An<Oversampler<T, X>>
where
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
X::Inputs: Size<Frame<T, U128>>,
X::Outputs: Size<Frame<T, U128>>,
{
An(Oversampler::new(DEFAULT_SR, node.0))
}
#[inline]
pub fn resample<T, X>(node: An<X>) -> An<Resampler<T, X>>
where
T: Float,
X: AudioNode<Sample = T, Inputs = U0>,
X::Outputs: Size<T>,
X::Outputs: Size<Frame<T, U128>>,
{
An(Resampler::new(DEFAULT_SR, node.0))
}
#[inline]
pub fn feedback<N, T, X>(node: An<X>) -> An<Feedback<N, T, X, FrameId<N, T>>>
where
N: Size<T>,
T: Float,
X: AudioNode<Sample = T, Inputs = N, Outputs = N>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
{
An(Feedback::new(node.0, FrameId::new()))
}
#[inline]
pub fn feedback2<N, T, X, Y>(
node: An<X>,
loopback: An<Y>,
) -> An<Feedback2<N, T, X, Y, FrameId<N, T>>>
where
N: Size<T>,
T: Float,
X: AudioNode<Sample = T, Inputs = N, Outputs = N>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
Y: AudioNode<Sample = T, Inputs = N, Outputs = N>,
Y::Inputs: Size<T>,
Y::Outputs: Size<T>,
{
An(Feedback2::new(node.0, loopback.0, FrameId::new()))
}
#[inline]
pub fn map<T, M, I, O>(f: M) -> An<Map<T, M, I, O>>
where
T: Float,
M: Fn(&Frame<T, I>) -> O + Clone,
I: Size<T>,
O: ConstantFrame<Sample = T>,
O::Size: Size<T>,
{
An(Map::new(f, Routing::Arbitrary))
}
#[inline]
pub fn dcblock_hz<T: Float, F: Real>(c: F) -> An<DCBlock<T, F>> {
An(DCBlock::new(DEFAULT_SR, c))
}
#[inline]
pub fn dcblock<T: Float, F: Real>() -> An<DCBlock<T, F>> {
An(DCBlock::new(DEFAULT_SR, F::new(10)))
}
#[inline]
pub fn declick<T: Float, F: Real>() -> An<Declick<T, F>> {
An(Declick::new(DEFAULT_SR, F::from_f64(0.010)))
}
#[inline]
pub fn declick_s<T: Float, F: Real>(t: F) -> An<Declick<T, F>> {
An(Declick::new(DEFAULT_SR, t))
}
#[inline]
pub fn shape_fn<T: Float, S: Fn(T) -> T + Clone>(f: S) -> An<ShaperFn<T, S>> {
An(ShaperFn::new(f))
}
#[inline]
pub fn shape<T: Real>(mode: Shape<T>) -> An<Shaper<T>> {
An(Shaper::new(mode))
}
#[inline]
pub fn clip<T: Real>() -> An<Shaper<T>> {
An(Shaper::<T>::new(Shape::Clip))
}
#[inline]
pub fn clip_to<T: Real>(minimum: T, maximum: T) -> An<Shaper<T>> {
An(Shaper::<T>::new(Shape::ClipTo(minimum, maximum)))
}
#[inline]
pub fn panner<T: Real>() -> An<Panner<T, U2>> {
An(Panner::new(T::zero()))
}
#[inline]
pub fn pan<T: Real>(pan: T) -> An<Panner<T, U1>> {
An(Panner::new(pan))
}
#[inline]
pub fn follow<T: Float, F: Real, S: ScalarOrPair<Sample = F>>(t: S) -> An<AFollow<T, F, S>> {
An(AFollow::new(DEFAULT_SR, t))
}
#[inline]
pub fn limiter<T: Real, S: ScalarOrPair<Sample = T>>(time: S) -> An<Limiter<T, U1, S>> {
An(Limiter::new(DEFAULT_SR, time))
}
#[inline]
pub fn limiter_stereo<T: Real, S: ScalarOrPair<Sample = T>>(time: S) -> An<Limiter<T, U2, S>> {
An(Limiter::new(DEFAULT_SR, time))
}
#[inline]
pub fn pinkpass<T: Float, F: Float>() -> An<Pinkpass<T, F>> {
An(Pinkpass::new(DEFAULT_SR))
}
#[inline]
pub fn pink<T: Float, F: Float>() -> An<Pipe<T, Noise<T>, Pinkpass<T, F>>> {
white() >> pinkpass::<T, F>()
}
#[inline]
pub fn brown<T: Float, F: Real>(
) -> An<Pipe<T, Noise<T>, Binop<T, FrameMul<U1, T>, Lowpole<T, F, U1>, Constant<U1, T>>>> {
white() >> lowpole_hz::<T, F>(T::from_f64(10.0)) * dc(T::from_f64(13.7))
}
#[inline]
pub fn fdn<N, T, X>(x: An<X>) -> An<Feedback<N, T, X, FrameHadamard<N, T>>>
where
N: Size<T>,
T: Float,
X: AudioNode<Sample = T, Inputs = N, Outputs = N>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
{
An(Feedback::new(x.0, FrameHadamard::new()))
}
#[inline]
pub fn fdn2<N, T, X, Y>(x: An<X>, y: An<Y>) -> An<Feedback2<N, T, X, Y, FrameHadamard<N, T>>>
where
N: Size<T>,
T: Float,
X: AudioNode<Sample = T, Inputs = N, Outputs = N>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
Y: AudioNode<Sample = T, Inputs = N, Outputs = N>,
Y::Inputs: Size<T>,
Y::Outputs: Size<T>,
{
An(Feedback2::new(x.0, y.0, FrameHadamard::new()))
}
#[inline]
pub fn bus<N, T, X, F>(f: F) -> An<MultiBus<N, T, X>>
where
T: Float,
N: Size<T>,
N: Size<X>,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
F: Fn(i64) -> An<X>,
{
assert!(N::USIZE > 0);
let nodes = Frame::generate(|i| f(i as i64).0);
An(MultiBus::new(nodes))
}
#[inline]
pub fn busf<N, T, X, F>(f: F) -> An<MultiBus<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
F: Fn(f64) -> An<X>,
{
assert!(N::USIZE > 0);
let nodes = Frame::generate(|i| {
f(if N::USIZE > 1 {
i as f64 / (N::USIZE - 1) as f64
} else {
0.5
})
.0
});
An(MultiBus::new(nodes))
}
#[inline]
pub fn stack<N, T, X, F>(f: F) -> An<MultiStack<N, T, X>>
where
T: Float,
N: Size<T>,
N: Size<X>,
X: AudioNode<Sample = T>,
X::Inputs: Size<T> + Mul<N>,
X::Outputs: Size<T> + Mul<N>,
<X::Inputs as Mul<N>>::Output: Size<T>,
<X::Outputs as Mul<N>>::Output: Size<T>,
F: Fn(i64) -> An<X>,
{
assert!(N::USIZE > 0);
let nodes = Frame::generate(|i| f(i as i64).0);
An(MultiStack::new(nodes))
}
#[inline]
pub fn stackf<N, T, X, F>(f: F) -> An<MultiStack<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T> + Mul<N>,
X::Outputs: Size<T> + Mul<N>,
<X::Inputs as Mul<N>>::Output: Size<T>,
<X::Outputs as Mul<N>>::Output: Size<T>,
F: Fn(f64) -> An<X>,
{
assert!(N::USIZE > 0);
let nodes = Frame::generate(|i| {
f(if N::USIZE > 1 {
i as f64 / (N::USIZE - 1) as f64
} else {
0.5
})
.0
});
An(MultiStack::new(nodes))
}
#[inline]
pub fn branch<N, T, X, F>(f: F) -> An<MultiBranch<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T> + Mul<N>,
<X::Outputs as Mul<N>>::Output: Size<T>,
F: Fn(i64) -> An<X>,
{
let nodes = Frame::generate(|i| f(i as i64).0);
An(MultiBranch::new(nodes))
}
#[inline]
pub fn branchf<N, T, X, F>(f: F) -> An<MultiBranch<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T> + Mul<N>,
<X::Outputs as Mul<N>>::Output: Size<T>,
F: Fn(f64) -> An<X>,
{
let nodes = Frame::generate(|i| {
f(if N::USIZE > 1 {
i as f64 / (N::USIZE - 1) as f64
} else {
0.5
})
.0
});
An(MultiBranch::new(nodes))
}
#[inline]
pub fn sum<N, T, X, F>(f: F) -> An<Reduce<N, T, X, FrameAdd<X::Outputs, T>>>
where
T: Float,
N: Size<T>,
N: Size<X>,
X: AudioNode<Sample = T>,
X::Inputs: Size<T> + Mul<N>,
X::Outputs: Size<T>,
<X::Inputs as Mul<N>>::Output: Size<T>,
F: Fn(i64) -> An<X>,
{
let nodes = Frame::generate(|i| f(i as i64).0);
An(Reduce::new(nodes, FrameAdd::new()))
}
#[inline]
pub fn sumf<N, T, X, F>(f: F) -> An<Reduce<N, T, X, FrameAdd<X::Outputs, T>>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T> + Mul<N>,
X::Outputs: Size<T>,
<X::Inputs as Mul<N>>::Output: Size<T>,
F: Fn(f64) -> An<X>,
{
let nodes = Frame::generate(|i| {
f(if N::USIZE > 1 {
i as f64 / (N::USIZE - 1) as f64
} else {
0.5
})
.0
});
An(Reduce::new(nodes, FrameAdd::new()))
}
#[inline]
pub fn pipe<N, T, X, F>(f: F) -> An<Chain<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
F: Fn(i64) -> An<X>,
{
let nodes = Frame::generate(|i| f(i as i64).0);
An(Chain::new(nodes))
}
#[inline]
pub fn pipef<N, T, X, F>(f: F) -> An<Chain<N, T, X>>
where
N: Size<T>,
N: Size<X>,
T: Float,
X: AudioNode<Sample = T>,
X::Inputs: Size<T>,
X::Outputs: Size<T>,
F: Fn(f64) -> An<X>,
{
let nodes = Frame::generate(|i| {
f(if N::USIZE > 1 {
i as f64 / (N::USIZE - 1) as f64
} else {
0.5
})
.0
});
An(Chain::new(nodes))
}
#[inline]
pub fn split<N, T>() -> An<Split<N, T>>
where
N: Size<T>,
T: Float,
{
An(Split::new())
}
#[inline]
pub fn multisplit<M, N, T>() -> An<MultiSplit<M, N, T>>
where
M: Size<T> + Mul<N>,
N: Size<T>,
<M as Mul<N>>::Output: Size<T>,
T: Float,
{
An(MultiSplit::new())
}
#[inline]
pub fn join<N, T>() -> An<Join<N, T>>
where
T: Float,
N: Size<T>,
{
An(Join::new())
}
#[inline]
pub fn multijoin<M, N, T>() -> An<MultiJoin<M, N, T>>
where
N: Size<T>,
M: Size<T> + Mul<N>,
<M as Mul<N>>::Output: Size<T>,
T: Float,
{
An(MultiJoin::<M, N, T>::new())
}
pub fn reverb_stereo<T>(
room_size: f64,
time: f64,
) -> An<impl AudioNode<Sample = T, Inputs = U2, Outputs = U2>>
where
T: Float,
{
const DELAYS: [f64; 32] = [
0.073904, 0.052918, 0.066238, 0.066387, 0.037783, 0.080073, 0.050961, 0.075900, 0.043646,
0.072095, 0.056194, 0.045961, 0.058934, 0.068016, 0.047529, 0.058156, 0.072972, 0.036084,
0.062715, 0.076377, 0.044339, 0.076725, 0.077884, 0.046126, 0.067741, 0.049800, 0.051709,
0.082923, 0.070121, 0.079315, 0.055039, 0.081859,
];
let a = T::from_f64(pow(db_amp(-60.0), 0.03 / time));
let line = stack::<U32, T, _, _>(|i| {
delay::<T>(DELAYS[i as usize] * room_size / 10.0)
>> fir((a / T::new(4), a / T::new(2), a / T::new(4)))
});
let reverb = fdn::<U32, T, _>(line);
multisplit::<U2, U16, T>() >> reverb >> multijoin::<U2, U16, T>()
}
pub fn dsf_saw<T: Real>() -> An<Dsf<T, U2>> {
An(Dsf::new(DEFAULT_SR, T::new(1), T::from_f32(0.5)))
}
pub fn dsf_saw_r<T: Real>(roughness: T) -> An<Dsf<T, U1>> {
An(Dsf::new(DEFAULT_SR, T::new(1), roughness))
}
pub fn dsf_square<T: Real>() -> An<Dsf<T, U2>> {
An(Dsf::new(DEFAULT_SR, T::new(2), T::from_f32(0.5)))
}
pub fn dsf_square_r<T: Real>(roughness: T) -> An<Dsf<T, U1>> {
An(Dsf::new(DEFAULT_SR, T::new(2), roughness))
}
pub fn pluck<T: Float>(
frequency: T,
gain_per_second: T,
high_frequency_damping: T,
) -> An<Pluck<T>> {
An(Pluck::new(
DEFAULT_SR,
frequency,
gain_per_second,
high_frequency_damping,
))
}
#[inline]
pub fn saw<T: Float>() -> An<WaveSynth<'static, T, U1>> {
An(WaveSynth::new(DEFAULT_SR, &SAW_TABLE))
}
#[inline]
pub fn square<T: Float>() -> An<WaveSynth<'static, T, U1>> {
An(WaveSynth::new(DEFAULT_SR, &SQUARE_TABLE))
}
#[inline]
pub fn triangle<T: Float>() -> An<WaveSynth<'static, T, U1>> {
An(WaveSynth::new(DEFAULT_SR, &TRIANGLE_TABLE))
}
#[inline]
pub fn organ<T: Float>() -> An<WaveSynth<'static, T, U1>> {
An(WaveSynth::new(DEFAULT_SR, &ORGAN_TABLE))
}
#[inline]
pub fn soft_saw<T: Float>() -> An<WaveSynth<'static, T, U1>> {
An(WaveSynth::new(DEFAULT_SR, &SOFT_SAW_TABLE))
}
#[inline]
pub fn saw_hz<T: Float>(f: T) -> An<Pipe<T, Constant<U1, T>, WaveSynth<'static, T, U1>>> {
constant(f) >> saw()
}
#[inline]
pub fn square_hz<T: Float>(f: T) -> An<Pipe<T, Constant<U1, T>, WaveSynth<'static, T, U1>>> {
constant(f) >> square()
}
#[inline]
pub fn triangle_hz<T: Float>(f: T) -> An<Pipe<T, Constant<U1, T>, WaveSynth<'static, T, U1>>> {
constant(f) >> triangle()
}
#[inline]
pub fn organ_hz<T: Float>(f: T) -> An<Pipe<T, Constant<U1, T>, WaveSynth<'static, T, U1>>> {
constant(f) >> organ()
}
#[inline]
pub fn soft_saw_hz<T: Float>(f: T) -> An<Pipe<T, Constant<U1, T>, WaveSynth<'static, T, U1>>> {
constant(f) >> soft_saw()
}
#[inline]
pub fn lowpass<T: Float, F: Real>() -> An<Svf<T, F, LowpassMode<F>>> {
An(Svf::new(
LowpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn lowpass_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, LowpassMode<F>>> {
An(FixedSvf::new(
LowpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn lowpass_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, LowpassMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
LowpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn highpass<T: Float, F: Real>() -> An<Svf<T, F, HighpassMode<F>>> {
An(Svf::new(
HighpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn highpass_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, HighpassMode<F>>> {
An(FixedSvf::new(
HighpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn highpass_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, HighpassMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
HighpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn bandpass<T: Float, F: Real>() -> An<Svf<T, F, BandpassMode<F>>> {
An(Svf::new(
BandpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn bandpass_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, BandpassMode<F>>> {
An(FixedSvf::new(
BandpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn bandpass_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, BandpassMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
BandpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn notch<T: Float, F: Real>() -> An<Svf<T, F, NotchMode<F>>> {
An(Svf::new(
NotchMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn notch_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, NotchMode<F>>> {
An(FixedSvf::new(
NotchMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn notch_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, NotchMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
NotchMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn peak<T: Float, F: Real>() -> An<Svf<T, F, PeakMode<F>>> {
An(Svf::new(
PeakMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn peak_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, PeakMode<F>>> {
An(FixedSvf::new(
PeakMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn peak_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, PeakMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
PeakMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn allpass<T: Float, F: Real>() -> An<Svf<T, F, AllpassMode<F>>> {
An(Svf::new(
AllpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn allpass_hz<T: Float, F: Real>(f: T, q: T) -> An<FixedSvf<T, F, AllpassMode<F>>> {
An(FixedSvf::new(
AllpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn allpass_q<T: Float, F: Real>(
q: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U1, T>>, Svf<T, F, AllpassMode<F>>>> {
(multipass::<U2, T>() | dc(q))
>> An(Svf::new(
AllpassMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn bell<T: Float, F: Real>() -> An<Svf<T, F, BellMode<F>>> {
An(Svf::new(
BellMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn bell_hz<T: Float, F: Real>(f: T, q: T, gain: T) -> An<FixedSvf<T, F, BellMode<F>>> {
An(FixedSvf::new(
BellMode::default(),
&SvfParams::<F> {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: convert(gain),
},
))
}
#[inline]
pub fn bell_q<T: Float, F: Real>(
q: T,
gain: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U2, T>>, Svf<T, F, BellMode<F>>>> {
(multipass::<U2, T>() | dc((q, gain)))
>> An(Svf::new(
BellMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: convert(q),
gain: convert(gain),
},
))
}
#[inline]
pub fn lowshelf<T: Float, F: Real>() -> An<Svf<T, F, LowshelfMode<F>>> {
An(Svf::new(
LowshelfMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn lowshelf_hz<T: Float, F: Real>(f: T, q: T, gain: T) -> An<FixedSvf<T, F, LowshelfMode<F>>> {
An(FixedSvf::new(
LowshelfMode::default(),
&SvfParams::<F> {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: convert(gain),
},
))
}
#[inline]
pub fn lowshelf_q<T: Float, F: Real>(
q: T,
gain: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U2, T>>, Svf<T, F, LowshelfMode<F>>>> {
(multipass::<U2, T>() | dc((q, gain)))
>> An(Svf::new(
LowshelfMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(440.0),
q: convert(q),
gain: F::one(),
},
))
}
#[inline]
pub fn highshelf<T: Float, F: Real>() -> An<Svf<T, F, HighshelfMode<F>>> {
An(Svf::new(
HighshelfMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: F::new(440),
q: F::one(),
gain: F::one(),
},
))
}
#[inline]
pub fn highshelf_hz<T: Float, F: Real>(
f: T,
q: T,
gain: T,
) -> An<FixedSvf<T, F, HighshelfMode<F>>> {
An(FixedSvf::new(
HighshelfMode::default(),
&SvfParams::<F> {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(f),
q: convert(q),
gain: convert(gain),
},
))
}
#[inline]
pub fn highshelf_q<T: Float, F: Real>(
q: T,
gain: T,
) -> An<Pipe<T, Stack<T, MultiPass<U2, T>, Constant<U2, T>>, Svf<T, F, HighshelfMode<F>>>> {
(multipass::<U2, T>() | dc((q, gain)))
>> An(Svf::new(
HighshelfMode::default(),
&SvfParams {
sample_rate: convert(DEFAULT_SR),
cutoff: convert(440.0),
q: convert(q),
gain: F::one(),
},
))
}
#[derive(Clone)]
pub struct PulseWave<T: Float> {
pulse: An<
Pipe<
T,
Pipe<
T,
Stack<T, WaveSynth<'static, T, U2>, Pass<T>>,
Stack<
T,
Pass<T>,
Pipe<T, Binop<T, FrameAdd<U1, T>, Pass<T>, Pass<T>>, PhaseSynth<'static, T>>,
>,
>,
Binop<T, FrameSub<U1, T>, Pass<T>, Pass<T>>,
>,
>,
}
#[allow(clippy::new_without_default)]
impl<T: Float> PulseWave<T> {
pub fn new() -> Self {
Self {
pulse: (An(WaveSynth::<'static, T, U2>::new(DEFAULT_SR, &SAW_TABLE)) | pass())
>> (pass()
| (pass() + pass())
>> An(PhaseSynth::<'static, T>::new(DEFAULT_SR, &SAW_TABLE)))
>> pass() - pass(),
}
}
}
impl<T: Float> AudioNode for PulseWave<T> {
const ID: u64 = 44;
type Sample = T;
type Inputs = U2;
type Outputs = U1;
type Setting = ();
fn reset(&mut self, sample_rate: Option<f64>) {
self.pulse.reset(sample_rate);
}
#[inline]
fn tick(
&mut self,
input: &Frame<Self::Sample, Self::Inputs>,
) -> Frame<Self::Sample, Self::Outputs> {
self.pulse.tick(input)
}
fn process(
&mut self,
size: usize,
input: &[&[Self::Sample]],
output: &mut [&mut [Self::Sample]],
) {
self.pulse.process(size, input, output);
}
fn route(&mut self, input: &SignalFrame, frequency: f64) -> SignalFrame {
self.pulse.route(input, frequency)
}
fn ping(&mut self, probe: bool, hash: AttoHash) -> AttoHash {
self.pulse.ping(probe, hash).hash(Self::ID)
}
}
#[inline]
pub fn pulse<T: Float>() -> An<PulseWave<T>> {
An(PulseWave::new())
}
pub fn morph<T: Real, F: Real>() -> An<Morph<T, F>> {
An(Morph::new(DEFAULT_SR, F::new(440), F::one(), T::zero()))
}
pub fn morph_hz<T: Real, F: Real>(
f: T,
q: T,
morph: T,
) -> An<Pipe<T, Stack<T, Pass<T>, Constant<U3, T>>, Morph<T, F>>> {
(pass() | dc((f, q, morph)))
>> An(Morph::new(
DEFAULT_SR,
convert(f),
convert(q),
convert(morph),
))
}
pub fn wave64<T: Float>(
wave: &Arc<Wave64>,
channel: usize,
loop_point: Option<usize>,
) -> An<Wave64Player<T>> {
An(Wave64Player::new(
wave,
channel,
0,
wave.length(),
loop_point,
))
}
pub fn wave64_at<T: Float>(
wave: &Arc<Wave64>,
channel: usize,
start_point: usize,
end_point: usize,
loop_point: Option<usize>,
) -> An<Wave64Player<T>> {
An(Wave64Player::new(
wave,
channel,
start_point,
end_point,
loop_point,
))
}
pub fn wave32<T: Float>(
wave: &Arc<Wave32>,
channel: usize,
loop_point: Option<usize>,
) -> An<Wave32Player<T>> {
An(Wave32Player::new(
wave,
channel,
0,
wave.length(),
loop_point,
))
}
pub fn wave32_at<T: Float>(
wave: &Arc<Wave32>,
channel: usize,
start_point: usize,
end_point: usize,
loop_point: Option<usize>,
) -> An<Wave32Player<T>> {
An(Wave32Player::new(
wave,
channel,
start_point,
end_point,
loop_point,
))
}
pub fn chorus<T: Real>(
seed: i64,
separation: T,
variation: T,
mod_frequency: T,
) -> An<impl AudioNode<Sample = T, Inputs = U1, Outputs = U1>> {
(pass()
& (pass()
| lfo(move |t| {
(
lerp11(
separation,
separation + variation,
spline_noise(seed, t * mod_frequency),
),
lerp11(
separation * T::new(2),
separation * T::new(2) + variation,
spline_noise(hash(seed), t * (mod_frequency + T::from_f64(0.02))),
),
lerp11(
separation * T::new(3),
separation * T::new(3) + variation,
spline_noise(
hash(seed ^ 0xfedcba),
t * (mod_frequency + T::from_f64(0.04)),
),
),
lerp11(
separation * T::new(4),
separation * T::new(4) + variation,
spline_noise(
hash(seed ^ 0xfedcb),
t * (mod_frequency + T::from_f64(0.06)),
),
),
)
}))
>> multitap::<U4, T>(separation, separation * T::new(4) + variation))
* dc(T::from_f64(0.2))
}
pub fn flanger<T: Real, X: Fn(T) -> T + Clone>(
feedback_amount: T,
minimum_delay: T,
maximum_delay: T,
delay_f: X,
) -> An<impl AudioNode<Sample = T, Inputs = U1, Outputs = U1>> {
pass()
& feedback2(
(pass() | lfo(delay_f)) >> tap::<T>(minimum_delay, maximum_delay),
shape(Shape::Tanh(feedback_amount)),
)
}
pub fn phaser<T: Real, X: Fn(T) -> T + Clone>(
feedback_amount: T,
phase_f: X,
) -> An<impl AudioNode<Sample = T, Inputs = U1, Outputs = U1>> {
pass()
& feedback(
(pass() | lfo(move |t| lerp(T::new(1), T::new(10), phase_f(t))))
>> pipe::<U20, T, _, _>(|_i| {
(pass() | add(T::from_f64(0.05))) >> !allpole::<T, T>()
})
>> (mul(feedback_amount) | sink()),
)
}
#[inline]
pub fn shared<T: Atomic>(value: T) -> Shared<T> {
Shared::new(value)
}
#[inline]
pub fn var<T: Atomic>(shared: &Shared<T>) -> An<Var<T>> {
An(Var::new(shared))
}
#[inline]
pub fn var_fn<T, F, R>(shared: &Shared<T>, f: F) -> An<VarFn<T, F, R>>
where
T: Atomic + Float,
F: Clone + Fn(T) -> R,
R: ConstantFrame<Sample = T>,
R::Size: Size<T>,
{
An(VarFn::new(shared, f))
}
#[inline]
pub fn timer<T: Float + Atomic>(shared: &Shared<T>) -> An<Timer<T>> {
An(Timer::new(DEFAULT_SR, shared))
}