|
@@ -1,64 +1,84 @@
|
|
|
use std::io::BufReader;
|
|
|
use std::path::PathBuf;
|
|
|
-
|
|
|
use std::thread;
|
|
|
use std::time::Duration;
|
|
|
extern crate rodio;
|
|
|
mod base;
|
|
|
use base::*;
|
|
|
-use rodio::Source;
|
|
|
-
|
|
|
+// use rodio::Source;
|
|
|
+use walkdir::WalkDir;
|
|
|
use imgui::*;
|
|
|
mod support;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+use log::*;
|
|
|
+use env_logger;
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
- let dev = rodio::default_output_device().unwrap();
|
|
|
|
|
|
+ env_logger::init();
|
|
|
+ let mut sounds = vec![];
|
|
|
+
|
|
|
+ for entry in WalkDir::new("media")
|
|
|
+ .into_iter()
|
|
|
+ .filter_map(|e| e.ok())
|
|
|
+ .filter(|e| e.path().is_file())
|
|
|
+ {
|
|
|
+ match Sound::new(&entry.path().to_string_lossy().to_string()) {
|
|
|
+ Ok(s) => sounds.push(s),
|
|
|
+ Err(e) => error!("{:?} while opening {:?}", e, entry)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- let hat = Sound::new("media/c64sid-ch1.wav").unwrap();
|
|
|
- let snare = Sound::new("media/c64sid-snare12.wav").unwrap();
|
|
|
- let kick = Sound::new("media/c64sid-kick5.wav").unwrap();
|
|
|
+ let dev = rodio::default_output_device().unwrap();
|
|
|
|
|
|
let mut bar = Bar::default();
|
|
|
bar.bpm = 160;
|
|
|
-
|
|
|
bar.repeat = 2;
|
|
|
|
|
|
- // bar.sounds = vec!(
|
|
|
- // kick.clone(),
|
|
|
- // hat.clone(),
|
|
|
- // snare.clone(),
|
|
|
- // hat.clone(),
|
|
|
- // kick.clone(),
|
|
|
- // hat.clone(),
|
|
|
- // snare.clone(),
|
|
|
- // hat.clone(),
|
|
|
- // );
|
|
|
-
|
|
|
- // bar.play(&dev);
|
|
|
- // thread::sleep(Duration::from_millis(200));
|
|
|
|
|
|
let system = support::init(file!());
|
|
|
|
|
|
|
|
|
system.main_loop(|_, ui| {
|
|
|
- Window::new(im_str!("yo"))
|
|
|
+ Window::new(im_str!("sources"))
|
|
|
+ // .resizable(false)
|
|
|
+ .position([400.0, 140.0], Condition::Appearing)
|
|
|
+ .collapsible(false)
|
|
|
+ // .always_auto_resize(true)
|
|
|
+ .size([300.0, 300.0], Condition::FirstUseEver)
|
|
|
+ .build(ui, || {
|
|
|
+
|
|
|
+ ui.tree_node(im_str!("Tree")).build(|| {
|
|
|
+ for s in &sounds {
|
|
|
+ ui.tree_node(&im_str!("{}", s.name)).build(|| {
|
|
|
+ ui.text(im_str!("blah blah"));
|
|
|
+ ui.same_line(0.0);
|
|
|
+ if ui.small_button(im_str!("add")) {
|
|
|
+
|
|
|
+ }
|
|
|
+ ui.same_line(0.0);
|
|
|
+ if ui.small_button(im_str!("play")) {
|
|
|
+ s.play(&dev);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ Window::new(im_str!("Hello world"))
|
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
|
.build(ui, || {
|
|
|
- ui.text(im_str!("Hello world!"));
|
|
|
- ui.text(im_str!("こんにちは世界!"));
|
|
|
- ui.text(im_str!("This...is...imgui-rs!"));
|
|
|
- ui.separator();
|
|
|
- let mouse_pos = ui.io().mouse_pos;
|
|
|
- ui.text(format!(
|
|
|
- "Mouse Position: ({:.1},{:.1})",
|
|
|
- mouse_pos[0], mouse_pos[1]
|
|
|
- ));
|
|
|
+ ui.text(im_str!("bars"));
|
|
|
+
|
|
|
+ for i in 0..bar.length {
|
|
|
+ ui.same_line(0.0);
|
|
|
+ ui.small_button(&im_str!("{}", i));
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
|
|
|
|