|
@@ -21,6 +21,8 @@ fn collect_sounds (root: &str) -> Vec<Sound> {
|
|
|
.filter_map(|e| e.ok())
|
|
|
.collect()
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
fn main() {
|
|
|
env_logger::init();
|
|
|
let dev = rodio::default_output_device().unwrap();
|
|
@@ -38,13 +40,17 @@ fn main() {
|
|
|
// dbg!(&track);
|
|
|
|
|
|
// return;
|
|
|
- let mut active_sound: usize = 0;
|
|
|
- let mut active_track: usize = 0;
|
|
|
+ let mut pattern_col: usize = 0;
|
|
|
+ let mut pattern_row: usize = 0;
|
|
|
+ // let mut active_track: usize = 0;
|
|
|
// let mut active_bar: usize = 0;
|
|
|
|
|
|
|
|
|
// let mut active_bar = Bar::default();
|
|
|
- let mut active_bar = &mut timeline.tracks[0].bars[0];
|
|
|
+ // let mut active_bar = &mut timeline.patterns[0].bars[0];
|
|
|
+ let mut active_pattern = Pattern::default();
|
|
|
+ let mut active_sound: &Option<Sound> = &None;
|
|
|
+ // let mut active_pattern = &mut timeline.patterns[0];
|
|
|
|
|
|
|
|
|
let mut system = support_ogl::init(file!());
|
|
@@ -69,8 +75,8 @@ fn main() {
|
|
|
for s in &mut sounds {
|
|
|
ui.tree_node(&im_str!("{}", s.name)).build(|| {
|
|
|
// ui.same_line(0.0);
|
|
|
- if ui.small_button(im_str!("add to bar")) {
|
|
|
- active_bar.sounds[active_sound] = Some(s.clone());
|
|
|
+ if ui.small_button(im_str!("add to pattern")) {
|
|
|
+ active_pattern.sounds[pattern_row][pattern_col] = Some(s.clone());
|
|
|
}
|
|
|
ui.same_line(0.0);
|
|
|
if ui.small_button(im_str!("play")) {
|
|
@@ -81,38 +87,66 @@ fn main() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- Window::new(im_str!("bar"))
|
|
|
+ Window::new(im_str!("pattern"))
|
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
|
.build(ui, || {
|
|
|
|
|
|
- for i in 0..active_bar.length() {
|
|
|
- ui.same_line(0.0);
|
|
|
+ // for i in 0..active_pattern.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;
|
|
|
+ // let token = match pattern_col == 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)) {
|
|
|
+ // pattern_col = i as usize;
|
|
|
+ // }
|
|
|
+ // token.pop(ui);
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ for (row_idx, row) in (&active_pattern).sounds.iter().enumerate() {
|
|
|
+ ui.text(im_str!("row {}", row_idx));
|
|
|
+ for (snd_idx, sound) in row.iter().enumerate() {
|
|
|
+ ui.same_line(0.0);
|
|
|
+ // ui.text(im_str!("snd {}", snd_idx));
|
|
|
+
|
|
|
+ let label = match sound {
|
|
|
+ Some(_s) => "X",
|
|
|
+ None => " "
|
|
|
+ };
|
|
|
+
|
|
|
+ if ui.small_button(&im_str!("{} {}x{}", label, row_idx, snd_idx)) {
|
|
|
+ pattern_col = snd_idx;
|
|
|
+ pattern_row = row_idx;
|
|
|
+ // pattern_col = i as usize;
|
|
|
+ }
|
|
|
}
|
|
|
- token.pop(ui);
|
|
|
|
|
|
}
|
|
|
- if ui.small_button(&im_str!("extend")) {
|
|
|
- active_bar.extend(1);
|
|
|
+
|
|
|
+ ui.text(im_str!("pat {} {}", pattern_col, pattern_row));
|
|
|
+
|
|
|
+
|
|
|
+ if ui.small_button(&im_str!("column++")) {
|
|
|
+ active_pattern.extend_length(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ui.small_button(&im_str!("row++")) {
|
|
|
+ active_pattern.extend_row(1);
|
|
|
}
|
|
|
|
|
|
|
|
|
if ui.small_button(&im_str!("ply")) {
|
|
|
- active_bar.play(&dev);
|
|
|
+ active_pattern.play(&dev);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Window::new(im_str!("sound"))
|
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
|
.build(ui, || {
|
|
|
- let snd = &active_bar.sounds[active_sound];
|
|
|
- if let Some(s) = snd{
|
|
|
+ // let snd = &active_bar.sounds[pattern_col];
|
|
|
+ if let Some(s) = &active_sound {
|
|
|
ui.text(im_str!("name {}", s.name));
|
|
|
ui.text(im_str!("roll {}", s.roll));
|
|
|
ui.text(im_str!("volume {}", s.volume));
|
|
@@ -125,7 +159,7 @@ fn main() {
|
|
|
.build(ui, || {
|
|
|
|
|
|
if ui.small_button(&im_str!("add")) {
|
|
|
- active_bar.play(&dev);
|
|
|
+ active_pattern.play(&dev);
|
|
|
}
|
|
|
});
|
|
|
|