|
@@ -31,10 +31,26 @@ fn collect_patterns (root: &str) -> Vec<Pattern> {
|
|
.filter_map(|e| e.ok())
|
|
.filter_map(|e| e.ok())
|
|
.filter(|e| e.path().is_file())
|
|
.filter(|e| e.path().is_file())
|
|
.map(|f| Pattern::load(f.path()))
|
|
.map(|f| Pattern::load(f.path()))
|
|
|
|
+ .map(|p| dbg!(p))
|
|
.filter_map(|e| e.ok())
|
|
.filter_map(|e| e.ok())
|
|
.collect()
|
|
.collect()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+// fn collect_patterns (root: &str) -> Vec<Pattern> {
|
|
|
|
+// let mut pat = vec![];
|
|
|
|
+
|
|
|
|
+// for f in WalkDir::new(root)
|
|
|
|
+// .into_iter()
|
|
|
|
+// .filter_map(|e| e.ok())
|
|
|
|
+// .filter(|e| e.path().is_file())
|
|
|
|
+// {
|
|
|
|
+// let x =
|
|
|
|
+// }
|
|
|
|
+// pat
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
fn main() {
|
|
fn main() {
|
|
env_logger::init();
|
|
env_logger::init();
|
|
let dev = rodio::default_output_device().unwrap();
|
|
let dev = rodio::default_output_device().unwrap();
|
|
@@ -43,28 +59,47 @@ fn main() {
|
|
let mut patterns = collect_patterns("patterns");
|
|
let mut patterns = collect_patterns("patterns");
|
|
|
|
|
|
let mut timeline = Timeline::default();
|
|
let mut timeline = Timeline::default();
|
|
-
|
|
|
|
- // return;
|
|
|
|
|
|
+
|
|
let mut pattern_col: usize = 0;
|
|
let mut pattern_col: usize = 0;
|
|
let mut pattern_row: usize = 0;
|
|
let mut pattern_row: usize = 0;
|
|
- let mut active_sound_idx = 0;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // let mut active_bar = Bar::default();
|
|
|
|
- // let mut active_bar = &mut timeline.patterns[0].bars[0];
|
|
|
|
|
|
+
|
|
let mut active_pattern = Pattern::default();
|
|
let mut active_pattern = Pattern::default();
|
|
let mut active_sound: Option<Sound> = None;
|
|
let mut active_sound: Option<Sound> = None;
|
|
|
|
|
|
-
|
|
|
|
let mut system = support_ogl::init(file!());
|
|
let mut system = support_ogl::init(file!());
|
|
- let s = system.imgui.style_mut();
|
|
|
|
- s.window_rounding = 1.5;
|
|
|
|
- // let system = support_glium::init(file!());
|
|
|
|
|
|
+ let style = system.imgui.style_mut();
|
|
|
|
+ style.window_rounding = 1.5;
|
|
|
|
+ style.anti_aliased_lines = false;
|
|
|
|
+ style.anti_aliased_fill = false;
|
|
|
|
+ // ui.push_style_color(
|
|
|
|
+ // style.colors[StyleColor::Text] = ImVec4(1.00, 1.00, 1.00, 1.00);
|
|
|
|
+ // // style.colors[ImGuiCol_WindowBg] = ImVec4(0.03f, 0.03f, 0.03f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_FrameBg] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_FrameBgHovered] = ImVec4(0.11f, 0.08f, 0.44f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_FrameBgActive] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_TitleBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_TitleBgActive] = ImVec4(0.14f, 0.05f, 0.96f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ScrollbarBg] = ImVec4(0.03f, 0.03f, 0.03f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_CheckMark] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_SliderGrab] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_SliderGrabActive] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_Button] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ButtonHovered] = ImVec4(0.18f, 0.12f, 0.78f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.13f, 0.88f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_Header] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_SeparatorHovered] = ImVec4(0.13f, 0.07f, 0.78f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_SeparatorActive] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ResizeGrip] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.19f, 0.12f, 0.85f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_ResizeGripActive] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_Tab] = ImVec4(0.07f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_TabHovered] = ImVec4(0.15f, 0.05f, 0.27f, 1.00f);
|
|
|
|
+ // // style.colors[ImGuiCol_TabActive] = ImVec4(0.21f, 0.14f, 0.91f, 1.00f);
|
|
|
|
+ // // style.colors.
|
|
|
|
|
|
system.main_loop(move |_, ui| {
|
|
system.main_loop(move |_, ui| {
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
Window::new(im_str!("sources"))
|
|
Window::new(im_str!("sources"))
|
|
// .resizable(false)
|
|
// .resizable(false)
|
|
.position([400.0, 140.0], Condition::Appearing)
|
|
.position([400.0, 140.0], Condition::Appearing)
|
|
@@ -81,9 +116,9 @@ fn main() {
|
|
for s in &mut sounds {
|
|
for s in &mut sounds {
|
|
ui.tree_node(&im_str!("{}", s.name)).build(|| {
|
|
ui.tree_node(&im_str!("{}", s.name)).build(|| {
|
|
// ui.same_line(0.0);
|
|
// ui.same_line(0.0);
|
|
- if ui.small_button(im_str!("add to pattern")) {
|
|
|
|
- active_pattern.sounds[pattern_row][pattern_col] = Some(s.clone());
|
|
|
|
- }
|
|
|
|
|
|
+ // if ui.small_button(im_str!("add to pattern")) {
|
|
|
|
+ // active_pattern.sounds[pattern_row][pattern_col] = Some(s.clone());
|
|
|
|
+ // }
|
|
if ui.small_button(im_str!("load")) {
|
|
if ui.small_button(im_str!("load")) {
|
|
active_sound = Some(s.clone());
|
|
active_sound = Some(s.clone());
|
|
}
|
|
}
|
|
@@ -125,35 +160,30 @@ fn main() {
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
.size([300.0, 100.0], Condition::FirstUseEver)
|
|
.build(ui, || {
|
|
.build(ui, || {
|
|
|
|
|
|
- if ui.small_button(&im_str!("column++")) {
|
|
|
|
- active_pattern.extend_length(1);
|
|
|
|
- }
|
|
|
|
|
|
+ if ui.small_button(&im_str!("increase length")) {active_pattern.extend_length(1);}
|
|
ui.same_line(0.0);
|
|
ui.same_line(0.0);
|
|
-
|
|
|
|
- if ui.small_button(&im_str!("row++")) {
|
|
|
|
- active_pattern.extend_row(1);
|
|
|
|
- }
|
|
|
|
|
|
+ if ui.small_button(&im_str!("add trk")) {active_pattern.extend_row(1);}
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ if ui.small_button(&im_str!("save")) {active_pattern.save();}
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ if ui.small_button(&im_str!("load")) {}
|
|
|
|
+ // if ui.small_button(&im_str!("theme")) {
|
|
|
|
+ // let col: Vec<[f32; 4]> = style.clone().colors.iter().map(|x| x.clone()).collect();
|
|
|
|
+ // let s = Theme {colors: col};
|
|
|
|
+ // dbg!(&s);
|
|
|
|
|
|
- // if ui.input_text(&im_str!("name"), &mut active_pattern_name).build() {
|
|
|
|
- // dbg!(&active_pattern_name);
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
let mut imstr_name = ImString::from(active_pattern.name.clone());
|
|
let mut imstr_name = ImString::from(active_pattern.name.clone());
|
|
- if ui.input_text(&im_str!("yo"), &mut imstr_name)
|
|
|
|
|
|
+ if ui.input_text(&im_str!("name"), &mut imstr_name)
|
|
.resize_buffer(true)
|
|
.resize_buffer(true)
|
|
|
|
+ .auto_select_all(true)
|
|
.build() {
|
|
.build() {
|
|
- // dbg!(&active_pattern_name);
|
|
|
|
active_pattern.name = imstr_name.to_string();
|
|
active_pattern.name = imstr_name.to_string();
|
|
};
|
|
};
|
|
-
|
|
|
|
- if ui.small_button(&im_str!("save")) {active_pattern.save();}
|
|
|
|
- if ui.small_button(&im_str!("load")) {}
|
|
|
|
-
|
|
|
|
- ui.same_line(0.0);
|
|
|
|
- if ui.small_button(&im_str!("play")) {
|
|
|
|
- active_pattern.play_mut(&dev);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ let button_size: f32 = 16.0;
|
|
|
|
|
|
ui.drag_int(im_str!("repeat"), &mut active_pattern.repeat)
|
|
ui.drag_int(im_str!("repeat"), &mut active_pattern.repeat)
|
|
.max(32)
|
|
.max(32)
|
|
@@ -162,44 +192,51 @@ fn main() {
|
|
|
|
|
|
ui.drag_int(im_str!("bpm"), &mut active_pattern.bpm).build();
|
|
ui.drag_int(im_str!("bpm"), &mut active_pattern.bpm).build();
|
|
|
|
|
|
- for row_idx in 0..active_pattern.sounds.len() {
|
|
|
|
- ui.text(im_str!("row {}", row_idx));
|
|
|
|
-
|
|
|
|
- for snd_idx in 0..active_pattern.sounds[row_idx].len() {
|
|
|
|
- ui.same_line(0.0);
|
|
|
|
- // ui.text(im_str!("snd {}", snd_idx));
|
|
|
|
-
|
|
|
|
- let mut active = false;
|
|
|
|
- if let Some(snd) = &active_pattern.sounds[row_idx][snd_idx] {
|
|
|
|
- if snd.active {
|
|
|
|
- active = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // let style = ui.push_style_color(StyleColor::Button, [0.0, 1.0, 0.1, 1.0]);
|
|
|
|
- // style.pop(ui);
|
|
|
|
-
|
|
|
|
|
|
+ ui.text(im_str!("loc "));
|
|
|
|
+ for x in 0..active_pattern.xsize {
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ ui.button(&im_str!("{}", x+1), [button_size, button_size]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- let mut label = match &active_pattern.sounds[row_idx][snd_idx] {
|
|
|
|
|
|
+ for y in 0..active_pattern.ysize {
|
|
|
|
+ ui.text(im_str!("row {:02}", y));
|
|
|
|
+ for x in 0..active_pattern.xsize {
|
|
|
|
+ let label = match &active_pattern.sounds.get(&(x,y)) {
|
|
Some(_s) => "X",
|
|
Some(_s) => "X",
|
|
None => " "
|
|
None => " "
|
|
};
|
|
};
|
|
-
|
|
|
|
- if active {
|
|
|
|
- label = "*";
|
|
|
|
|
|
+
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ if ui.button(&im_str!("{}##{}{}", label, y, x), [button_size, button_size]) {
|
|
|
|
+ pattern_col = x;
|
|
|
|
+ pattern_row = y;
|
|
|
|
+ match &active_sound {
|
|
|
|
+ Some(snd) => {active_pattern.sounds.insert((x,y), snd.clone());},
|
|
|
|
+ None => ()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- if ui.small_button(&im_str!("{}##{}{}", label, row_idx, snd_idx)) {
|
|
|
|
- pattern_col = snd_idx;
|
|
|
|
- pattern_row = row_idx;
|
|
|
|
- println!("r{}c{}", row_idx, snd_idx);
|
|
|
|
- active_pattern.sounds[row_idx][snd_idx] = active_sound.clone();
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ if ui.small_button(im_str!("replace src") ){
|
|
|
|
+ if let Some(acs) = &active_sound {
|
|
|
|
+ active_pattern.replace_sounds(acs, y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ ui.same_line(0.0);
|
|
|
|
+ if ui.small_button(im_str!("clr") ){
|
|
|
|
+ active_pattern.clear_sounds(y);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
ui.text(im_str!("pat {} {}", pattern_col, pattern_row));
|
|
ui.text(im_str!("pat {} {}", pattern_col, pattern_row));
|
|
-
|
|
|
|
|
|
+ if ui.small_button(&im_str!("play")) {
|
|
|
|
+ active_pattern.play(&dev);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
});
|
|
});
|
|
@@ -242,7 +279,7 @@ fn main() {
|
|
.build(ui, || {
|
|
.build(ui, || {
|
|
|
|
|
|
if ui.small_button(&im_str!("add")) {
|
|
if ui.small_button(&im_str!("add")) {
|
|
- active_pattern.play_mut(&dev);
|
|
|
|
|
|
+ active_pattern.play(&dev);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|