|
@@ -4,18 +4,29 @@ use std::thread;
|
|
use std::time::Duration;
|
|
use std::time::Duration;
|
|
use std::fs::File;
|
|
use std::fs::File;
|
|
|
|
|
|
-#[derive(Clone)]
|
|
|
|
|
|
+#[derive(Clone, Default)]
|
|
pub struct Sound {
|
|
pub struct Sound {
|
|
pub location: PathBuf,
|
|
pub location: PathBuf,
|
|
|
|
+ data: Vec<u8>,
|
|
|
|
+ pub roll: i32,
|
|
|
|
+ pub rate: i32
|
|
}
|
|
}
|
|
|
|
|
|
impl Sound {
|
|
impl Sound {
|
|
|
|
+ pub fn new(location: &str) -> Sound {
|
|
|
|
+ Sound {
|
|
|
|
+ location: PathBuf::from(location),
|
|
|
|
+ data: vec![],
|
|
|
|
+ roll: 0,
|
|
|
|
+ rate: 8
|
|
|
|
+ }
|
|
|
|
+ }
|
|
pub fn play(&self, device: &rodio::Device) {
|
|
pub fn play(&self, device: &rodio::Device) {
|
|
if let Ok(file) = std::fs::File::open(&self.location) {
|
|
if let Ok(file) = std::fs::File::open(&self.location) {
|
|
// let dec = rodio::Decoder::new(BufReader::new(file)).unwrap();
|
|
// let dec = rodio::Decoder::new(BufReader::new(file)).unwrap();
|
|
let reader = BufReader::new(file);
|
|
let reader = BufReader::new(file);
|
|
let d = device.clone();
|
|
let d = device.clone();
|
|
- let sink = rodio::play_once(d, reader).unwrap().detach();
|
|
|
|
|
|
+ let _sink = rodio::play_once(d, reader).unwrap().detach();
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|