From 9b705f48e0291afdf29692616ecb24745b9fb6b8 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 10 Dec 2024 15:05:11 +0100 Subject: [PATCH] draw note names --- Justfile | 2 ++ crates/tek/src/cli/cli_sequencer.rs | 1 + crates/tek/src/tui/phrase_editor.rs | 37 ++++++++++++++--------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Justfile b/Justfile index 46575a65..4f16a1c0 100644 --- a/Justfile +++ b/Justfile @@ -16,6 +16,8 @@ arranger: cargo run --bin tek_arranger sequencer: cargo run --bin tek_sequencer +sequencer-release: + cargo run --release --bin tek_sequencer mixer: cargo run --bin tek_mixer track: diff --git a/crates/tek/src/cli/cli_sequencer.rs b/crates/tek/src/cli/cli_sequencer.rs index 1fe86a08..ec18266e 100644 --- a/crates/tek/src/cli/cli_sequencer.rs +++ b/crates/tek/src/cli/cli_sequencer.rs @@ -21,6 +21,7 @@ impl SequencerCli { fn run (&self) -> Usually<()> { Tui::run(JackClient::new("tek_sequencer")?.activate_with(|jack|{ let mut app = SequencerTui::try_from(jack)?; + //app.editor.view_mode.set_time_zoom(1); // TODO: create from arguments let midi_in = app.jack.read().unwrap().register_port("in", MidiIn::default())?; app.player.midi_ins.push(midi_in); diff --git a/crates/tek/src/tui/phrase_editor.rs b/crates/tek/src/tui/phrase_editor.rs index d2b3572b..8f23b02b 100644 --- a/crates/tek/src/tui/phrase_editor.rs +++ b/crates/tek/src/tui/phrase_editor.rs @@ -22,7 +22,6 @@ pub struct PhraseEditorModel { pub(crate) time_start: AtomicUsize, pub(crate) time_point: AtomicUsize, - pub(crate) time_scale: AtomicUsize, pub(crate) edit_mode: PhraseEditMode, pub(crate) view_mode: PhraseViewMode, @@ -53,10 +52,9 @@ impl std::fmt::Debug for PhraseEditorModel { self.note_lo.load(Ordering::Relaxed), self.note_point.load(Ordering::Relaxed), )) - .field("time_axis", &format!("{} {} {}", + .field("time_axis", &format!("{} {}", self.time_start.load(Ordering::Relaxed), self.time_point.load(Ordering::Relaxed), - self.time_scale.load(Ordering::Relaxed), )) .finish() } @@ -77,7 +75,6 @@ impl Default for PhraseEditorModel { note_point: 0.into(), time_start: 0.into(), time_point: 0.into(), - time_scale: 24.into(), view_mode: PhraseViewMode::PianoHorizontal { time_zoom: 24, note_zoom: PhraseViewNoteZoom::N(1) @@ -240,7 +237,7 @@ render!(|self: PhraseView<'a>|{ Ok(()) }), Tui::bg(Color::Rgb(40, 50, 30), Tui::fill_x(row!([ - Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), move|to: &mut TuiOutput|{ + Tui::push_y(1, Tui::fill_y(Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{ Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) }) }))), Tui::fill_x(lay!([ @@ -341,21 +338,23 @@ impl PhraseViewMode { Self::PianoHorizontal { .. } => { let [x0, y0, _, _] = to.area().xywh(); for (y, note) in (note_lo..=note_hi).rev().enumerate() { - to.blit(&match note % 12 { - 11 => "██", - 10 => " ", - 9 => "██", - 8 => " ", - 7 => "██", - 6 => " ", - 5 => "██", - 4 => "██", - 3 => " ", - 2 => "██", - 1 => " ", - 0 => "██", + let key = match note % 12 { + 11 => "█████", + 10 => " ", + 9 => "█████", + 8 => " ", + 7 => "█████", + 6 => " ", + 5 => "█████", + 4 => "█████", + 3 => " ", + 2 => "█████", + 1 => " ", + 0 => "█████", _ => unreachable!(), - }, x0, y0 + y as u16, style) + }; + to.blit(&key, x0, y0 + y as u16, style); + to.blit(&format!("{}", to_note_name(note)), x0, y0 + y as u16, None); } }, _ => unimplemented!()