mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
systematizing jack handlers
This commit is contained in:
parent
d627d257ad
commit
4ae62c5bc2
10 changed files with 342 additions and 208 deletions
|
|
@ -47,50 +47,74 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
area.width = area.width.min(80);
|
||||
area.height = 5;
|
||||
//draw_box(buf, area);
|
||||
draw_leaf(buf, area, 1, 0, "REC");
|
||||
draw_leaf(buf, area, 1, 5, "DUB");
|
||||
draw_leaf(buf, area, 1, 10, "STOP");
|
||||
draw_leaf(buf, area, 1, 16, "PLAY/PAUSE");
|
||||
draw_leaf(buf, area, 1, 28, "START");
|
||||
draw_leaf(buf, area, 1, 35, "Project: Witty Gerbil - Sha Na Na ");
|
||||
draw_leaf(buf, area, 3, 0, &format!("BPM {:03}.{:03}",
|
||||
state.bpm as u64,
|
||||
((state.bpm % 1.0) * 1000.0) as u64
|
||||
));
|
||||
let position = state.transport.as_ref().map(|t|t.query());
|
||||
if let Some(Ok(position)) = position {
|
||||
let rate = position.pos.frame_rate().unwrap();
|
||||
let frame = position.pos.frame();
|
||||
let second = (frame as f64) / (rate as f64);
|
||||
let minute = second / 60f64;
|
||||
let bpm = 120f64;
|
||||
let div = 4;
|
||||
let beats = minute * bpm;
|
||||
let bars = beats as u32 / div as u32;
|
||||
let beat = beats as u32 % div as u32 + 1;
|
||||
let beat_sub = beats % 1.0;
|
||||
//buf.set_string(
|
||||
//area.x - 18, area.y + area.height,
|
||||
//format!("BBT {bars:04}:{beat:02}.{:02}", (beat_sub * 16.0) as u32),
|
||||
//Style::default()
|
||||
//);
|
||||
draw_leaf(buf, area, 3, 13, &format!("BBT {bars:04}:{beat:02}.{:02}",
|
||||
(beat_sub * 16.0) as u32
|
||||
));
|
||||
let time = frame as f64 / rate as f64;
|
||||
let seconds = time % 60.0;
|
||||
let msec = seconds % 1.0;
|
||||
let minutes = (time / 60.0) % 60.0;
|
||||
let hours = time / 3600.0;
|
||||
draw_leaf(buf, area, 3, 29, &format!("Time {:02}:{:02}:{:02}.{:03}",
|
||||
hours as u64,
|
||||
minutes as u64,
|
||||
seconds as u64,
|
||||
(msec * 1000.0) as u64
|
||||
));
|
||||
draw_leaf(buf, area, 3, 48, &format!("Rate {:>6}Hz", rate));
|
||||
draw_leaf(buf, area, 3, 63, &format!("Frame {:>10}", frame));
|
||||
let label = Style::default().white().not_dim();
|
||||
let border = Style::default().gray().dim();
|
||||
let mut x = 2;
|
||||
for button in [
|
||||
"PLAY",
|
||||
"STOP",
|
||||
"REC",
|
||||
"DUB",
|
||||
"0.0.00",
|
||||
"0:00.000",
|
||||
&format!("BPM {:03}.{:03}",
|
||||
state.bpm as u64,
|
||||
((state.bpm % 1.0) * 1000.0) as u64
|
||||
)
|
||||
].iter() {
|
||||
buf.set_string(area.x + x, area.y + 2, button, label);
|
||||
x = x + button.len() as u16 + 1;
|
||||
buf.set_string(area.x + x, area.y + 1, "│", border);
|
||||
buf.set_string(area.x + x, area.y + 2, "│", border);
|
||||
buf.set_string(area.x + x, area.y + 3, "│", border);
|
||||
x = x + 2;
|
||||
}
|
||||
//buf.set_string(area.x, area.y + 5, "Witty Gerbil - Sha Na Na", label.bold());
|
||||
//&format!(" │ 00:00.00 / 00:00.00"), style);
|
||||
//draw_leaf(buf, area, 1, 0, "REC");
|
||||
//draw_leaf(buf, area, 1, 5, "DUB");
|
||||
//draw_leaf(buf, area, 1, 10, "STOP");
|
||||
//draw_leaf(buf, area, 1, 16, "PLAY/PAUSE");
|
||||
//draw_leaf(buf, area, 1, 28, "START");
|
||||
//draw_leaf(buf, area, 1, 35, "Project: Witty Gerbil - Sha Na Na ");
|
||||
//draw_leaf(buf, area, 3, 0, &format!("BPM {:03}.{:03}",
|
||||
//state.bpm as u64,
|
||||
//((state.bpm % 1.0) * 1000.0) as u64
|
||||
//));
|
||||
//let position = state.transport.as_ref().map(|t|t.query());
|
||||
//if let Some(Ok(position)) = position {
|
||||
//let rate = position.pos.frame_rate().unwrap();
|
||||
//let frame = position.pos.frame();
|
||||
//let second = (frame as f64) / (rate as f64);
|
||||
//let minute = second / 60f64;
|
||||
//let bpm = 120f64;
|
||||
//let div = 4;
|
||||
//let beats = minute * bpm;
|
||||
//let bars = beats as u32 / div as u32;
|
||||
//let beat = beats as u32 % div as u32 + 1;
|
||||
//let beat_sub = beats % 1.0;
|
||||
////buf.set_string(
|
||||
////area.x - 18, area.y + area.height,
|
||||
////format!("BBT {bars:04}:{beat:02}.{:02}", (beat_sub * 16.0) as u32),
|
||||
////Style::default()
|
||||
////);
|
||||
//draw_leaf(buf, area, 3, 13, &format!("BBT {bars:04}:{beat:02}.{:02}",
|
||||
//(beat_sub * 16.0) as u32
|
||||
//));
|
||||
//let time = frame as f64 / rate as f64;
|
||||
//let seconds = time % 60.0;
|
||||
//let msec = seconds % 1.0;
|
||||
//let minutes = (time / 60.0) % 60.0;
|
||||
//let hours = time / 3600.0;
|
||||
//draw_leaf(buf, area, 3, 29, &format!("Time {:02}:{:02}:{:02}.{:03}",
|
||||
//hours as u64,
|
||||
//minutes as u64,
|
||||
//seconds as u64,
|
||||
//(msec * 1000.0) as u64
|
||||
//));
|
||||
//draw_leaf(buf, area, 3, 48, &format!("Rate {:>6}Hz", rate));
|
||||
//draw_leaf(buf, area, 3, 63, &format!("Frame {:>10}", frame));
|
||||
//}
|
||||
//let bbt = position.pos.bbt().map(|mut bbt|*bbt
|
||||
//.with_bpm(state.bpm)
|
||||
//.with_timesig(state.timesig.0, state.timesig.1));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue