aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-29 00:22:17 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-29 00:22:17 -0600
commitb805af0fdcbda54df657ca9e53a94a04e8b9e2dd (patch)
treebd4dac0b8a18a1b6fd522b95525b4fa24c1a1c82 /src
parent394fbd1bfbcb9f5cfd50ff10239aa115f2b0696e (diff)
downloadsynthfinity-b805af0fdcbda54df657ca9e53a94a04e8b9e2dd.tar.gz
synthfinity-b805af0fdcbda54df657ca9e53a94a04e8b9e2dd.zip
audio test
Diffstat (limited to 'src')
-rw-r--r--src/main.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..8a3395a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,18 @@
+use std::time::Duration;
+
+use rodio::{source::SineWave, OutputStream, Sink, Source};
+
fn main() {
- println!("Hello, world!");
+ let (_stream, stream_handle) = OutputStream::try_default().unwrap();
+ let sink = Sink::try_new(&stream_handle).unwrap();
+
+ // Add a dummy source of the sake of the example.
+ let source = SineWave::new(440)
+ .take_duration(Duration::from_secs_f32(0.25))
+ .amplify(0.20);
+ sink.append(source);
+
+ // The sound plays in a separate thread. This call will block the current thread until the sink
+ // has finished playing all its queued sounds.
+ sink.sleep_until_end();
}