draw note names

This commit is contained in:
🪞👃🪞 2024-12-10 15:05:11 +01:00
parent deb5348c69
commit 9b705f48e0
3 changed files with 21 additions and 19 deletions

View file

@ -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:

View file

@ -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);

View file

@ -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!()