aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-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();
}