|
@@ -12,28 +12,32 @@ mod support_ogl;
|
|
|
use env_logger;
|
|
|
use log::*;
|
|
|
|
|
|
+fn collect_sounds (root: &str) -> Vec<Sound> {
|
|
|
+ WalkDir::new(root)
|
|
|
+ .into_iter()
|
|
|
+ .filter_map(|e| e.ok())
|
|
|
+ .filter(|e| e.path().is_file())
|
|
|
+ .map(|f| Sound::new(&f.path().to_string_lossy().to_string()))
|
|
|
+ .filter_map(|e| e.ok())
|
|
|
+ .collect()
|
|
|
+}
|
|
|
fn main() {
|
|
|
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 mut sounds = collect_sounds("media");
|
|
|
+ let mut active_sound: usize = 0;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
let dev = rodio::default_output_device().unwrap();
|
|
|
|
|
|
let mut bar = Bar::default();
|
|
|
bar.bpm = 160;
|
|
|
- bar.repeat = 2;
|
|
|
|
|
|
- let system = support_ogl::init(file!());
|
|
|
+ let mut timeline = Timeline::default();
|
|
|
+
|
|
|
+ let mut system = support_ogl::init(file!());
|
|
|
+ let s = system.imgui.style_mut();
|
|
|
+ s.window_rounding = 1.5;
|
|
|
// let system = support_glium::init(file!());
|
|
|
|
|
|
system.main_loop(move |_, ui| {
|
|
@@ -44,17 +48,18 @@ fn main() {
|
|
|
// .always_auto_resize(true)
|
|
|
.size([300.0, 300.0], Condition::FirstUseEver)
|
|
|
.build(ui, || {
|
|
|
- // let mut s = ui.clone_style();
|
|
|
- // ui.show_style_editor(&mut s);
|
|
|
|
|
|
- ui.show_default_style_editor();
|
|
|
+ // ui.show_default_style_editor();
|
|
|
|
|
|
- ui.tree_node(im_str!("Tree")).build(|| {
|
|
|
- for s in &sounds {
|
|
|
+ ui.tree_node(im_str!("snds"))
|
|
|
+ .opened(true, Condition::Appearing)
|
|
|
+ .build(|| {
|
|
|
+ for s in &mut 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!("add to bar")) {
|
|
|
+ bar.sounds[active_sound] = Some(s.clone());
|
|
|
+ }
|
|
|
ui.same_line(0.0);
|
|
|
if ui.small_button(im_str!("play")) {
|
|
|
s.play(&dev);
|
|
@@ -64,15 +69,55 @@ fn main() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- Window::new(im_str!("Hello world"))
|
|
|
+ Window::new(im_str!("bar"))
|
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
|
.build(ui, || {
|
|
|
ui.text(im_str!("bars"));
|
|
|
+ ui.same_line(0.0);
|
|
|
+ ui.text(im_str!("snd {}", active_sound));
|
|
|
+
|
|
|
+ for i in 0..bar.length() {
|
|
|
+ ui.same_line(0.0);
|
|
|
+
|
|
|
+ let token = match active_sound == i {
|
|
|
+ true => ui.push_style_color(StyleColor::Button, [1.0, 0.0, 0.0, 1.0]),
|
|
|
+ false => ui.push_style_color(StyleColor::CheckMark, [0.0, 0.0, 0.0, 1.0])
|
|
|
+ };
|
|
|
+
|
|
|
+ if ui.small_button(&im_str!("{}", i)) {
|
|
|
+ active_sound = i as usize;
|
|
|
+ }
|
|
|
+
|
|
|
+ token.pop(ui);
|
|
|
+
|
|
|
+ }
|
|
|
+ if ui.small_button(&im_str!("extend")) {
|
|
|
+ bar.extend(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ui.small_button(&im_str!("dbg")) {
|
|
|
+ dbg!(&bar);
|
|
|
+ }
|
|
|
+ if ui.small_button(&im_str!("ply")) {
|
|
|
+ bar.play(&dev);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Window::new(im_str!("sound"))
|
|
|
+ .size([300.0, 100.0], Condition::FirstUseEver)
|
|
|
+ .build(ui, || {
|
|
|
+ let snd = &bar.sounds[active_sound];
|
|
|
+ if let Some(s) = snd{
|
|
|
+ ui.text(im_str!("name {}", s.name));
|
|
|
+ ui.text(im_str!("roll {}", s.roll));
|
|
|
+ ui.text(im_str!("volume {}", s.volume));
|
|
|
+ ui.text(im_str!("rate {}", s.rate));
|
|
|
+ }
|
|
|
|
|
|
- // for i in 0..bar.length {
|
|
|
- // ui.same_line(0.0);
|
|
|
- // ui.small_button(&im_str!("{}", i));
|
|
|
- // }
|
|
|
+
|
|
|
});
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
}
|