mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: long awaited fixes to main sequencer
This commit is contained in:
parent
2837ffff4a
commit
78e5469b32
17 changed files with 391 additions and 563 deletions
|
|
@ -131,10 +131,10 @@ impl Launcher {
|
|||
} }
|
||||
}
|
||||
fn sequencer <'a> (&'a self) -> Option<MutexGuard<Sequencer>> {
|
||||
self.track().map(|t|t.1.sequencer.state())
|
||||
Some(self.track()?.1.sequencer.state())
|
||||
}
|
||||
fn chain <'a> (&'a self) -> Option<MutexGuard<Chain>> {
|
||||
self.track().map(|t|t.1.chain.state())
|
||||
Some(self.track()?.1.chain.state())
|
||||
}
|
||||
fn phrase_id (&self) -> Option<usize> {
|
||||
let (track_id, _) = self.track()?;
|
||||
|
|
@ -190,10 +190,10 @@ pub fn render (state: &Launcher, buf: &mut Buffer, mut area: Rect) -> Usually<Re
|
|||
crate::device::transport::draw_rec(buf, x + 12, y, state.recording);
|
||||
crate::device::transport::draw_mon(buf, x + 19, y, state.monitoring);
|
||||
crate::device::transport::draw_dub(buf, x + 26, y, state.overdub);
|
||||
draw_bpm(buf, x + 33, y, state.timebase.tempo());
|
||||
draw_timer(buf, x + width - 1, y, &state.timebase, state.position);
|
||||
crate::device::transport::draw_bpm(buf, x + 33, y, state.timebase.bpm());
|
||||
crate::device::transport::draw_timer(buf, x + width - 1, y, &state.timebase, state.position);
|
||||
let mut y = y + 1;
|
||||
y = y + LauncherGridView::new(
|
||||
y = y + LauncherGrid::new(
|
||||
state, buf, Rect { x, y, width, height: height / 3 }, state.view.is_tracks()
|
||||
).draw()?.height;
|
||||
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: height / 3 })?.height;
|
||||
|
|
@ -206,28 +206,6 @@ pub fn render (state: &Launcher, buf: &mut Buffer, mut area: Rect) -> Usually<Re
|
|||
}
|
||||
Ok(area)
|
||||
}
|
||||
fn draw_bpm (buf: &mut Buffer, x: u16, y: u16, tempo: usize) {
|
||||
let style = Style::default().not_dim();
|
||||
"BPM"
|
||||
.blit(buf, x, y, Some(style));
|
||||
format!("{:03}.{:03}", tempo / 1000, tempo % 1000)
|
||||
.blit(buf, x + 4, y, Some(style.bold()));
|
||||
"SYNC"
|
||||
.blit(buf, x + 13, y, Some(style));
|
||||
"4/4"
|
||||
.blit(buf, x + 18, y, Some(style.bold()));
|
||||
"QUANT"
|
||||
.blit(buf, x + 23, y, Some(style));
|
||||
"1/16"
|
||||
.blit(buf, x + 29, y, Some(style.bold()));
|
||||
}
|
||||
fn draw_timer (buf: &mut Buffer, x: u16, y: u16, timebase: &Arc<Timebase>, frame: usize) {
|
||||
let tick = (frame as f64 / timebase.frames_per_tick()) as usize;
|
||||
let (beats, ticks) = (tick / timebase.ppq(), tick % timebase.ppq());
|
||||
let (bars, beats) = (beats / 4, beats % 4);
|
||||
let timer = format!("{}.{}.{ticks:02}", bars + 1, beats + 1);
|
||||
timer.blit(buf, x - timer.len() as u16, y, Some(Style::default().not_dim()));
|
||||
}
|
||||
fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let style = Some(Style::default().green().dim());
|
||||
|
|
@ -239,50 +217,46 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
|
|||
},
|
||||
_ => {},
|
||||
};
|
||||
if let Some((_, track)) = state.track() {
|
||||
let frame = state.position;
|
||||
let timebase = &state.timebase;
|
||||
let tick = (frame as f64 / timebase.frames_per_tick()) as usize;
|
||||
let sequencer = track.sequencer.state();
|
||||
let zoom = sequencer.resolution;
|
||||
|
||||
let steps = if let Some(_phrase) = sequencer.phrase() { 0 } else { 0 } / 4; // TODO
|
||||
|
||||
crate::device::sequencer::horizontal::timer(buf, x+5, y,
|
||||
steps, sequencer.steps * zoom, sequencer.time_axis.0, sequencer.time_axis.1
|
||||
);
|
||||
crate::device::sequencer::horizontal::keys(buf, Rect { x, y: y + 1, width, height },
|
||||
sequencer.note_axis.1
|
||||
)?;
|
||||
if let Some(id) = state.phrase_id() {
|
||||
if let Some(phrase) = sequencer.phrases.get(id) {
|
||||
crate::device::sequencer::horizontal::lanes(buf, x, y + 1,
|
||||
&phrase,
|
||||
sequencer.timebase.ppq() as u32,
|
||||
sequencer.resolution as u32,
|
||||
sequencer.time_axis.0 as u32,
|
||||
sequencer.time_axis.1 as u32,
|
||||
sequencer.note_axis.0 as u32,
|
||||
sequencer.note_axis.1 as u32,
|
||||
);
|
||||
}
|
||||
let track = state.track();
|
||||
if track.is_none() {
|
||||
return Ok(area);
|
||||
}
|
||||
let track = track.unwrap().1;
|
||||
let sequencer = track.sequencer.state();
|
||||
crate::device::sequencer::horizontal::timer(
|
||||
buf, x+5, y,
|
||||
sequencer.time_axis.0,
|
||||
sequencer.time_axis.0 + area.width,
|
||||
0
|
||||
);
|
||||
crate::device::sequencer::horizontal::keys(
|
||||
buf, Rect { x, y: y + 1, width, height },
|
||||
sequencer.note_axis.1
|
||||
)?;
|
||||
if let Some(id) = state.phrase_id() {
|
||||
if let Some(phrase) = sequencer.phrases.get(id) {
|
||||
crate::device::sequencer::horizontal::lanes(
|
||||
buf, x, y + 1,
|
||||
&phrase,
|
||||
sequencer.timebase.ppq() as u32,
|
||||
sequencer.time_zoom as u32,
|
||||
sequencer.time_axis.0 as u32,
|
||||
sequencer.time_axis.0 as u32 + area.width as u32,
|
||||
sequencer.note_axis.0 as u32,
|
||||
sequencer.note_axis.1 as u32,
|
||||
);
|
||||
}
|
||||
let cursor_style = match view {
|
||||
LauncherView::Sequencer => Style::default().green().not_dim(),
|
||||
_ => Style::default().green().dim(),
|
||||
};
|
||||
crate::device::sequencer::horizontal::cursor(buf, x, y + 1, cursor_style,
|
||||
sequencer.time_cursor,
|
||||
sequencer.note_cursor
|
||||
);
|
||||
}
|
||||
let cursor_style = match view {
|
||||
LauncherView::Sequencer => Style::default().green().not_dim(),
|
||||
_ => Style::default().green().dim(),
|
||||
};
|
||||
crate::device::sequencer::horizontal::cursor(buf, x, y + 1, cursor_style,
|
||||
sequencer.time_cursor,
|
||||
sequencer.note_cursor
|
||||
);
|
||||
Ok(area)
|
||||
}
|
||||
fn draw_highlight (buf: &mut Buffer, highlight: &Option<Rect>, style: Style) {
|
||||
if let Some(area) = highlight {
|
||||
draw_box_styled(buf, *area, Some(style));
|
||||
}
|
||||
}
|
||||
fn draw_section_chains (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let style = Some(Style::default().green().dim());
|
||||
match state.view {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue