gdritter repos chenoska / 8eea66f
audio: add simple playback using rodio Jason Dagit 6 years ago
3 changed file(s) with 16 addition(s) and 1 deletion(s). Collapse all Expand all
1616 glutin = "*"
1717 # panem-nostrum-quotidianum = { path = "../panem-nostrum-quotidianum/" }
1818 imagefmt = "*"
19 rodio = "0.6.0"
Binary diff not shown
55 }
66 extern crate glutin;
77 extern crate imagefmt;
8 extern crate rodio;
89
910 pub mod board;
1011 pub mod graphics;
8283 vbo.bind_uv("uv")?;
8384 vbo.unbind();
8485
86 let endpoint = rodio::default_endpoint().unwrap();
87
88 let mut audio_queue = rodio::Sink::new(&endpoint);
89 audio_queue.set_volume(0.5);
90
8591 window.run(|event| {
8692 use glutin::{ControlFlow, Event, WindowEvent, VirtualKeyCode};
8793
98104 match k.virtual_keycode {
99105 Some(VirtualKeyCode::Q) =>
100106 return ControlFlow::Break,
101 Some(c) => println!("pressed {:#?}", c),
107 Some(c) => {
108 use std::io::BufReader; // Used for audio file reading
109
110 println!("pressed {:#?}", c);
111
112 let file = std::fs::File::open("assets/testing.wav").unwrap();
113 let testing_wav = rodio::Decoder::new(BufReader::new(file)).unwrap();
114 audio_queue.append(testing_wav);
115 }
102116 _ => (),
103117 }
104118 }