Skip to content

Commit db5909d

Browse files
committed
format
1 parent d60e5a1 commit db5909d

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

examples/distortion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rodio::source::{SineWave, Source};
22
use std::error::Error;
3-
use std::time::Duration;
43
use std::thread;
4+
use std::time::Duration;
55

66
fn main() -> Result<(), Box<dyn Error>> {
77
// Open the default output stream and get the mixer

examples/distortion_mp3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ fn main() -> Result<(), Box<dyn Error>> {
1414
sink.sleep_until_end();
1515

1616
Ok(())
17-
}
17+
}

examples/distortion_wav_alternate.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use std::error::Error;
2-
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
2+
use std::sync::{
3+
atomic::{AtomicBool, Ordering},
4+
Arc,
5+
};
36
use std::thread;
47
use std::time::Duration;
58

@@ -17,15 +20,16 @@ fn main() -> Result<(), Box<dyn Error>> {
1720
let distortion_enabled_clone = distortion_enabled.clone();
1821

1922
// Apply distortion and alternate the effect during playback
20-
let distorted = source
21-
.distortion(4.0, 0.3)
22-
.periodic_access(Duration::from_millis(250), move |src| {
23-
// src is &mut PeriodicAccess<Distortion<Decoder<...>>>
24-
let enable = distortion_enabled_clone.load(Ordering::Relaxed);
25-
// Call the setters on the distortion filter inside the source
26-
src.set_gain(if enable { 4.0 } else { 1.0 });
27-
src.set_threshold(if enable { 0.3 } else { 1.0 });
28-
});
23+
let distorted =
24+
source
25+
.distortion(4.0, 0.3)
26+
.periodic_access(Duration::from_millis(250), move |src| {
27+
// src is &mut PeriodicAccess<Distortion<Decoder<...>>>
28+
let enable = distortion_enabled_clone.load(Ordering::Relaxed);
29+
// Call the setters on the distortion filter inside the source
30+
src.set_gain(if enable { 4.0 } else { 1.0 });
31+
src.set_threshold(if enable { 0.3 } else { 1.0 });
32+
});
2933

3034
sink.append(distorted);
3135

@@ -42,4 +46,4 @@ fn main() -> Result<(), Box<dyn Error>> {
4246
sink.sleep_until_end();
4347

4448
Ok(())
45-
}
49+
}

src/source/distortion.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616
1717
use std::time::Duration;
1818

19+
use super::SeekError;
1920
use crate::common::{ChannelCount, SampleRate};
2021
use crate::Source;
21-
use super::SeekError;
2222

2323
/// Internal function that builds a `Distortion` object.
2424
pub fn distortion<I>(input: I, gain: f32, threshold: f32) -> Distortion<I>
2525
where
2626
I: Source,
2727
{
28-
Distortion { input, gain, threshold }
28+
Distortion {
29+
input,
30+
gain,
31+
threshold,
32+
}
2933
}
3034

3135
/// Filter that applies a distortion effect to the source.

src/source/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub use self::channel_volume::ChannelVolume;
1616
pub use self::chirp::{chirp, Chirp};
1717
pub use self::crossfade::Crossfade;
1818
pub use self::delay::Delay;
19+
pub use self::distortion::Distortion;
1920
pub use self::done::Done;
2021
pub use self::empty::Empty;
2122
pub use self::empty_callback::EmptyCallback;
@@ -42,7 +43,6 @@ pub use self::take::TakeDuration;
4243
pub use self::triangle::TriangleWave;
4344
pub use self::uniform::UniformSourceIterator;
4445
pub use self::zero::Zero;
45-
pub use self::distortion::Distortion;
4646

4747
mod agc;
4848
mod amplify;
@@ -52,6 +52,7 @@ mod channel_volume;
5252
mod chirp;
5353
mod crossfade;
5454
mod delay;
55+
mod distortion;
5556
mod done;
5657
mod empty;
5758
mod empty_callback;
@@ -78,7 +79,6 @@ mod take;
7879
mod triangle;
7980
mod uniform;
8081
mod zero;
81-
mod distortion;
8282

8383
#[cfg(feature = "noise")]
8484
mod noise;

0 commit comments

Comments
 (0)