Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
vihdzp committed Oct 10, 2023
1 parent 2680487 commit bd1254f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
5 changes: 4 additions & 1 deletion examples/basic_epiano.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ impl SignalMut for EPiano {
/// An electric piano with a slight tremolo effect applied.
fn trem_piano(freq: unt::Freq, vib_freq: unt::Freq) -> impl Stop<Sample = smp::Mono> {
// The volume follows a rescaled sine wave curve.
let env = gen::Loop::new(map::Comp::new(Sin, map::Linear::rescale_sgn(0.8, 1.0)), vib_freq);
let env = gen::Loop::new(
map::Comp::new(Sin, map::Linear::rescale_sgn(0.8, 1.0)),
vib_freq,
);

// Some subtle ADSR.
let adsr = eff::env::Adsr::new(
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_fiveosc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() {

// Each of our oscillators is a function of phase.
let osc = |phase| {
eff:: MutSgn::new(
eff::MutSgn::new(
// A triangle wave with a placeholder frequency.
gen::Loop::new(Tri, base),
// A sine wave, which controls the pitch of the triangle wave.
Expand Down
2 changes: 1 addition & 1 deletion examples/song_primavera_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn binaural() -> impl SignalMut<Sample = smp::Stereo> {
};

// Binaural beats.
eff::mix::StereoMix::new(wave(base * 0.985), vib(base))
eff::mix::Stereo::new(wave(base * 0.985), vib(base))
}

/// The melody that starts two minutes in.
Expand Down
2 changes: 1 addition & 1 deletion src/effects/envelopes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Signal envelopes, notably including the [`AdsrEnv`].
//! Signal envelopes, notably including the [`ArEnv`] and [`AdsrEnv`].

use crate::prelude::*;

Expand Down
16 changes: 8 additions & 8 deletions src/effects/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
use crate::prelude::*;

/// Combines two [`Mono`] signals into a [`Stereo`] signal. One signal plays on each channel.
pub struct StereoMix<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>>(pub X, pub Y);
pub struct Stereo<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>>(pub X, pub Y);

impl<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>> StereoMix<X, Y> {
impl<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>> Stereo<X, Y> {
/// Initializes a new [`StereoMix`].
pub const fn new(sgn1: X, sgn2: Y) -> Self {
Self(sgn1, sgn2)
}
}

impl<Z: Signal<Sample = smp::Mono> + Clone> StereoMix<Z, Z> {
impl<Z: Signal<Sample = smp::Mono> + Clone> Stereo<Z, Z> {
/// Duplicates a [`Mono`] signal.
pub fn dup(sgn: Z) -> Self {
Self(sgn.clone(), sgn)
}
}

impl<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>> Signal for StereoMix<X, Y> {
impl<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>> Signal for Stereo<X, Y> {
type Sample = smp::Stereo;

fn get(&self) -> Self::Sample {
Expand All @@ -28,7 +28,7 @@ impl<X: Signal<Sample = smp::Mono>, Y: Signal<Sample = smp::Mono>> Signal for St
}

impl<X: SignalMut<Sample = smp::Mono>, Y: SignalMut<Sample = smp::Mono>> SignalMut
for StereoMix<X, Y>
for Stereo<X, Y>
{
fn advance(&mut self) {
self.0.advance();
Expand All @@ -41,20 +41,20 @@ impl<X: SignalMut<Sample = smp::Mono>, Y: SignalMut<Sample = smp::Mono>> SignalM
}
}

impl<X: Done<Sample = smp::Mono>, Y: Done<Sample = smp::Mono>> Done for StereoMix<X, Y> {
impl<X: Done<Sample = smp::Mono>, Y: Done<Sample = smp::Mono>> Done for Stereo<X, Y> {
fn is_done(&self) -> bool {
self.0.is_done() && self.1.is_done()
}
}

impl<X: Stop<Sample = smp::Mono>, Y: Stop<Sample = smp::Mono>> Stop for StereoMix<X, Y> {
impl<X: Stop<Sample = smp::Mono>, Y: Stop<Sample = smp::Mono>> Stop for Stereo<X, Y> {
fn stop(&mut self) {
self.0.stop();
self.1.stop();
}
}

impl<X: Panic<Sample = smp::Mono>, Y: Panic<Sample = smp::Mono>> Panic for StereoMix<X, Y> {
impl<X: Panic<Sample = smp::Mono>, Y: Panic<Sample = smp::Mono>> Panic for Stereo<X, Y> {
fn panic(&mut self) {
self.0.panic();
self.1.panic();
Expand Down
4 changes: 2 additions & 2 deletions src/map/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<X, Y: Clone> Const<X, Y> {
}
}

impl<X, Y: Clone>map:: Map for Const<X, Y> {
impl<X, Y: Clone> map::Map for Const<X, Y> {
type Input = X;
type Output = Y;

Expand All @@ -111,7 +111,7 @@ pub struct Comp<F: map::Map, G: map::Map<Input = F::Output>> {
pub outer: G,
}

impl<F: map::Map, G:map:: Map<Input = F::Output>> Comp<F, G> {
impl<F: map::Map, G: map::Map<Input = F::Output>> Comp<F, G> {
/// Composes two functions.
pub const fn new(inner: F, outer: G) -> Self {
Self { inner, outer }
Expand Down
4 changes: 2 additions & 2 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
pub use crate::buffers::wav::*;

pub use crate::{
buffers as buf, control as ctr, curves::*, effects as eff, gen::poly as ply, generators as gen, map, sample as smp, signal::*,
units as unt,
buffers as buf, control as ctr, curves::*, effects as eff, gen::poly as ply, generators as gen,
map, sample as smp, signal::*, units as unt,
};

0 comments on commit bd1254f

Please sign in to comment.