wip: f64 timebase (sloooo)

This commit is contained in:
🪞👃🪞 2024-07-01 17:48:16 +03:00
parent c4d8692b71
commit 4055662bbd
12 changed files with 206 additions and 142 deletions

View file

@ -13,12 +13,12 @@ pub fn draw (
if let Some(phrase) = s.phrase() {
lanes(buf, x, y,
phrase,
s.timebase.ppq() as u32,
s.time_zoom as u32,
s.time_start as u32,
s.time_start as u32 + area.width as u32,
s.note_start as u32,
s.note_start as u32 + area.height as u32,
s.timebase.ppq() as usize,
s.time_zoom,
s.time_start,
s.time_start + area.width as usize,
s.note_start,
s.note_start + area.height as usize,
);
}
cursor(
@ -76,17 +76,17 @@ pub fn lanes (
x: u16,
y: u16,
phrase: &Phrase,
ppq: u32,
time_zoom: u32,
time0: u32,
time1: u32,
note0: u32,
note1: u32,
ppq: usize,
time_zoom: usize,
time0: usize,
time1: usize,
note0: usize,
note1: usize,
) {
let bg = Style::default();
let (bw, wh) = (bg.dim(), bg.white());
for step in time0..time1 {
let x = x as u32 + 5 + step;
let x = x as usize + 5 + step;
let (a, b) = ((step + 0) * ppq / time_zoom, (step + 1) * ppq / time_zoom,);
if step % 4 == 0 {
"|".blit(buf, x as u16, y - 1, Some(Style::default().dim()));
@ -95,7 +95,7 @@ pub fn lanes (
format!("{}", step / time_zoom / 4 + 1)
.blit(buf, x as u16, y - 1, Some(Style::default().bold().not_dim()));
}
let h = ((note1-note0)/2).saturating_sub(y as u32);
let h = ((note1-note0)/2).saturating_sub(y as usize);
for k in 0..h {
let (character, style) = match (
contains_note_on(phrase, u7::from_int_lossy((note0 + k * 2 + 0) as u8), a, b),
@ -106,7 +106,7 @@ pub fn lanes (
(false, true) => ("", wh),
(false, false) => ("·", bw),
};
let y = y as u32 + k;
let y = y as usize + k;
character.blit(buf, x as u16, y as u16, Some(style));
}
}