mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix display of horizontal sequencer
This commit is contained in:
parent
14b07c2b4f
commit
403d0f2dfe
2 changed files with 36 additions and 14 deletions
|
|
@ -54,28 +54,49 @@ pub fn keys (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
|||
}
|
||||
|
||||
pub fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default();
|
||||
let bw = bg.dim();
|
||||
let wh = bg.white();
|
||||
let ppq = s.timebase.ppq() as u32;
|
||||
let (time0, time1) = s.time_axis;
|
||||
let (note0, note1) = s.note_axis;
|
||||
let notes = &s.sequences[s.sequence].notes;
|
||||
for step in time0..time1 {
|
||||
let time_start = step as u32 * ppq;
|
||||
let time_end = (step + 1) as u32 * ppq;
|
||||
let (a, b) = (
|
||||
(step + 0) as u32 * ppq / s.resolution as u32,
|
||||
(step + 1) as u32 * ppq / s.resolution as u32,
|
||||
);
|
||||
if step % s.resolution as u16 == 0 {
|
||||
buf.set_string(x + 6 + step, y - 1, &format!("{}", step + 1), Style::default());
|
||||
}
|
||||
for (_, (_, events)) in notes.range(time_start..time_end).enumerate() {
|
||||
if events.len() > 0 {
|
||||
buf.set_string(x + 6 + step as u16, y, "█", bw);
|
||||
buf.set_string(x + 5 + step, y - 1, &format!("{}", step + 1), Style::default());
|
||||
}
|
||||
for k in 0..(note1 - note0)/2 {
|
||||
let (character, style) = match (
|
||||
contains_note_on(&s.sequences[s.sequence],
|
||||
::midly::num::u7::from_int_lossy((note0 + k * 2 + 0) as u8),
|
||||
a, b),
|
||||
contains_note_on(&s.sequences[s.sequence],
|
||||
::midly::num::u7::from_int_lossy((note0 + k * 2 + 1) as u8),
|
||||
a, b),
|
||||
) {
|
||||
(true, true) => ("█", wh),
|
||||
(true, false) => ("▀", wh),
|
||||
(false, true) => ("▄", wh),
|
||||
(false, false) => ("·", bw),
|
||||
};
|
||||
//let (character, style) = ("▄", bg);
|
||||
buf.set_string(x + 5 + step, y + k, character, style);
|
||||
}
|
||||
//for (_, (_, events)) in notes.range(time_start..time_end).enumerate() {
|
||||
//if events.len() > 0 {
|
||||
//buf.set_string(x + 6 + step as u16, y, "█", wh);
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
|
||||
buf.set_string(
|
||||
x + 6 + s.time_cursor,
|
||||
x + 5 + s.time_cursor,
|
||||
y + s.note_cursor / 2,
|
||||
if s.note_cursor % 2 == 0 { "▀" } else { "▄" },
|
||||
Style::default().green().not_dim()
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ pub fn draw (
|
|||
|
||||
pub fn steps (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) {
|
||||
let ppq = s.timebase.ppq() as u32;
|
||||
let bw = Style::default().dim().on_black();
|
||||
let bg = Style::default().on_black();
|
||||
let bg = Style::default();
|
||||
let bw = bg.dim();
|
||||
let wh = bg.white();
|
||||
let Rect { x, y, .. } = area;
|
||||
let (time0, time1) = s.time_axis;
|
||||
let (note0, note1) = s.note_axis;
|
||||
|
|
@ -43,9 +44,9 @@ pub fn steps (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) {
|
|||
contains_note_on(&s.sequences[s.sequence], key, a, b),
|
||||
contains_note_on(&s.sequences[s.sequence], key, b, c),
|
||||
) {
|
||||
(true, true) => ("█", bg),
|
||||
(true, false) => ("▀", bg),
|
||||
(false, true) => ("▄", bg),
|
||||
(true, true) => ("█", wh),
|
||||
(true, false) => ("▀", wh),
|
||||
(false, true) => ("▄", wh),
|
||||
(false, false) => ("·", bw),
|
||||
};
|
||||
buf.set_string(x + 5 + k - note0, y, character, style);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue