mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
sequencer time indicator
This commit is contained in:
parent
4ebecc2427
commit
e13569df93
5 changed files with 68 additions and 40 deletions
|
|
@ -17,6 +17,13 @@ impl<'a> LauncherGridView<'a> {
|
||||||
self.separator_h(2, false);
|
self.separator_h(2, false);
|
||||||
self.separator_h((self.state.cursor.1 * 2) as u16, true);
|
self.separator_h((self.state.cursor.1 * 2) as u16, true);
|
||||||
self.separator_h(((self.state.cursor.1 + 1) * 2) as u16, true);
|
self.separator_h(((self.state.cursor.1 + 1) * 2) as u16, true);
|
||||||
|
draw_box_styled(self.buf, self.area, Some(
|
||||||
|
if self.focused {
|
||||||
|
Style::default().green().dim()
|
||||||
|
} else {
|
||||||
|
Style::default().dim()
|
||||||
|
}
|
||||||
|
));
|
||||||
let columns = self.column_names();
|
let columns = self.column_names();
|
||||||
|
|
||||||
let (mut x, y) = (self.area.x, self.area.y);
|
let (mut x, y) = (self.area.x, self.area.y);
|
||||||
|
|
@ -47,7 +54,6 @@ impl<'a> LauncherGridView<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
"+Add track…".blit(self.buf, x + 2, y + 1, Some(Style::default().dim()));
|
"+Add track…".blit(self.buf, x + 2, y + 1, Some(Style::default().dim()));
|
||||||
draw_box_styled(self.buf, self.area, Some(self.highlight(self.focused)));
|
|
||||||
Ok(self.area)
|
Ok(self.area)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +141,14 @@ impl<'a> LauncherGridView<'a> {
|
||||||
}
|
}
|
||||||
y2 = y2 + 1;
|
y2 = y2 + 1;
|
||||||
}
|
}
|
||||||
|
let hi = (track + 1 == self.state.cursor.0) &&
|
||||||
|
(self.state.scenes.len() + 1 == self.state.cursor.1);
|
||||||
" + Add clip".blit(self.buf, x, y + y2, Some(Style::default().dim()));
|
" + Add clip".blit(self.buf, x, y + y2, Some(Style::default().dim()));
|
||||||
|
if hi {
|
||||||
|
draw_box_styled(
|
||||||
|
self.buf, Rect { x: x - 2, y: y + y2 - 1, width: 16, height: 3 }, Some(Style::default().green())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn highlight (&self, highlight: bool) -> Style {
|
fn highlight (&self, highlight: bool) -> Style {
|
||||||
|
|
|
||||||
|
|
@ -183,10 +183,10 @@ pub fn render (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect>
|
||||||
//separator.blit(buf, x, y + 22, Some(Style::default().dim()));
|
//separator.blit(buf, x, y + 22, Some(Style::default().dim()));
|
||||||
//separator.blit(buf, x, y + 41, Some(Style::default().dim()));
|
//separator.blit(buf, x, y + 41, Some(Style::default().dim()));
|
||||||
let mut y = y + 1;
|
let mut y = y + 1;
|
||||||
y = y + LauncherGridView
|
y = y + LauncherGridView::new(
|
||||||
::new(state, buf, Rect { x, y, width, height: 22 }, state.view.is_tracks())
|
state, buf, Rect { x, y, width, height: 22 }, state.view.is_tracks()
|
||||||
.draw()?.height + 1;
|
).draw()?.height;
|
||||||
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: 28 })?.height + 1;
|
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: 28 })?.height;
|
||||||
y = y + draw_section_chains(state, buf, Rect { x, y, width, height: 21 })?.height;
|
y = y + draw_section_chains(state, buf, Rect { x, y, width, height: 21 })?.height;
|
||||||
if state.show_help {
|
if state.show_help {
|
||||||
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
||||||
|
|
@ -221,16 +221,32 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
|
||||||
let Rect { x, y, width, height } = area;
|
let Rect { x, y, width, height } = area;
|
||||||
let style = Some(Style::default().green().dim());
|
let style = Some(Style::default().green().dim());
|
||||||
let view = &state.view;
|
let view = &state.view;
|
||||||
match state.view {
|
match view {
|
||||||
LauncherView::Sequencer => {
|
LauncherView::Sequencer => {
|
||||||
draw_box_styled(buf, area, style);
|
draw_box_styled(buf, area, style);
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
if let Some(track) = state.tracks.get(state.col().saturating_sub(1)) {
|
if let Some(track) = state.tracks.get(state.col().saturating_sub(1)) {
|
||||||
|
let frame = state.position;
|
||||||
|
let timebase = &state.timebase;
|
||||||
|
let tick = (frame as f64 / timebase.frames_per_tick()) as usize;
|
||||||
let state = track.sequencer.state();
|
let state = track.sequencer.state();
|
||||||
|
let zoom = state.resolution;
|
||||||
|
|
||||||
|
let step = state.phrase().map(|_|tick / zoom);
|
||||||
|
crate::device::sequencer::horizontal::timer(buf, x+5, y,
|
||||||
|
step.unwrap_or(0) / 4,
|
||||||
|
state.steps * zoom,
|
||||||
|
state.time_axis.0,
|
||||||
|
state.time_axis.1
|
||||||
|
);
|
||||||
|
|
||||||
let keys_area = Rect { x, y: y + 1, width, height };
|
let keys_area = Rect { x, y: y + 1, width, height };
|
||||||
crate::device::sequencer::horizontal::keys(buf, keys_area, state.note_axis.1)?;
|
crate::device::sequencer::horizontal::keys(buf, keys_area,
|
||||||
|
state.note_axis.1
|
||||||
|
)?;
|
||||||
|
|
||||||
if let Some(phrase) = state.phrase() {
|
if let Some(phrase) = state.phrase() {
|
||||||
crate::device::sequencer::horizontal::lanes(buf, x, y + 1,
|
crate::device::sequencer::horizontal::lanes(buf, x, y + 1,
|
||||||
&phrase,
|
&phrase,
|
||||||
|
|
@ -242,13 +258,15 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
|
||||||
state.note_axis.1 as u32,
|
state.note_axis.1 as u32,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let cursor_style = match view {
|
let cursor_style = match view {
|
||||||
LauncherView::Sequencer => Style::default().green().not_dim(),
|
LauncherView::Sequencer => Style::default().green().not_dim(),
|
||||||
_ => Style::default().green().dim(),
|
_ => Style::default().green().dim(),
|
||||||
};
|
};
|
||||||
crate::device::sequencer::horizontal::cursor(buf, x, y + 1, cursor_style,
|
crate::device::sequencer::horizontal::cursor(buf, x, y + 1, cursor_style,
|
||||||
state.time_cursor,
|
state.time_cursor,
|
||||||
state.note_cursor);
|
state.note_cursor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ pub fn draw (
|
||||||
area.x = area.x + 13;
|
area.x = area.x + 13;
|
||||||
let Rect { x, y, width, .. } = area;
|
let Rect { x, y, width, .. } = area;
|
||||||
keys(buf, area, s.note_axis.1)?;
|
keys(buf, area, s.note_axis.1)?;
|
||||||
timer(s, buf, x, y, beat);
|
timer(buf, x + 6, y - 1, beat, s.steps, s.time_axis.0, s.time_axis.1);
|
||||||
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
let height = 32.max(s.note_axis.1 - s.note_axis.0) / 2;
|
||||||
if let Some(phrase) = s.phrase() {
|
if let Some(phrase) = s.phrase() {
|
||||||
lanes(buf, x, y,
|
lanes(buf, x, y,
|
||||||
|
|
@ -25,7 +25,8 @@ pub fn draw (
|
||||||
}
|
}
|
||||||
cursor(buf, x, y, Style::default().green().not_dim(),
|
cursor(buf, x, y, Style::default().green().not_dim(),
|
||||||
s.time_cursor,
|
s.time_cursor,
|
||||||
s.note_cursor);
|
s.note_cursor
|
||||||
|
);
|
||||||
footer(s, buf, x, y, width, height);
|
footer(s, buf, x, y, width, height);
|
||||||
Ok(Rect {
|
Ok(Rect {
|
||||||
x: x - 13,
|
x: x - 13,
|
||||||
|
|
@ -35,10 +36,9 @@ pub fn draw (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn timer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, beat: usize) {
|
pub fn timer (buf: &mut Buffer, x: u16, y: u16, beat: usize, steps: usize, time0: u16, time1: u16) {
|
||||||
let (time0, time1) = s.time_axis;
|
|
||||||
for step in time0..time1 {
|
for step in time0..time1 {
|
||||||
buf.set_string(x + 6 + step, y - 1, &"-", if beat % s.steps == step as usize {
|
buf.set_string(x + step, y, &"-", if beat % steps == step as usize {
|
||||||
Style::default().yellow().bold().not_dim()
|
Style::default().yellow().bold().not_dim()
|
||||||
} else {
|
} else {
|
||||||
Style::default()
|
Style::default()
|
||||||
|
|
@ -77,16 +77,16 @@ pub fn lanes (
|
||||||
note1: u32,
|
note1: u32,
|
||||||
) {
|
) {
|
||||||
let bg = Style::default();
|
let bg = Style::default();
|
||||||
let bw = bg.dim();
|
let (bw, wh) = (bg.dim(), bg.white());
|
||||||
let wh = bg.white();
|
|
||||||
//let (time0, time1) = s.time_axis;
|
|
||||||
//let (note0, note1) = s.note_axis;
|
|
||||||
//let resolution = s.resolution;
|
|
||||||
for step in time0..time1 {
|
for step in time0..time1 {
|
||||||
let x = x as u32 + 5 + step;
|
let x = x as u32 + 5 + step;
|
||||||
let (a, b) = ((step + 0) * ppq / time_zoom, (step + 1) * ppq / time_zoom,);
|
let (a, b) = ((step + 0) * ppq / time_zoom, (step + 1) * ppq / time_zoom,);
|
||||||
if step % time_zoom == 0 {
|
if step % 4 == 0 {
|
||||||
format!("{}", step + 1).blit(buf, x as u16, y - 1, None);
|
"|".blit(buf, x as u16, y - 1, Some(Style::default().dim()));
|
||||||
|
}
|
||||||
|
if step % (time_zoom * 4) == 0 {
|
||||||
|
format!("{}", step / time_zoom / 4 + 1)
|
||||||
|
.blit(buf, x as u16, y - 1, Some(Style::default().bold().not_dim()));
|
||||||
}
|
}
|
||||||
let h = (note1-note0)/2;
|
let h = (note1-note0)/2;
|
||||||
for k in 0..h {
|
for k in 0..h {
|
||||||
|
|
|
||||||
|
|
@ -26,24 +26,22 @@ impl Phrase {
|
||||||
pub struct Sequencer {
|
pub struct Sequencer {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// JACK transport handle.
|
/// JACK transport handle.
|
||||||
transport: ::jack::Transport,
|
pub transport: ::jack::Transport,
|
||||||
/// JACK MIDI input port that will be created.
|
/// JACK MIDI input port that will be created.
|
||||||
pub midi_in: Port<MidiIn>,
|
pub midi_in: Port<MidiIn>,
|
||||||
/// JACK MIDI output port that will be created.
|
/// JACK MIDI output port that will be created.
|
||||||
pub midi_out: Port<MidiOut>,
|
pub midi_out: Port<MidiOut>,
|
||||||
|
|
||||||
/// Holds info about tempo
|
/// Holds info about tempo
|
||||||
pub timebase: Arc<Timebase>,
|
pub timebase: Arc<Timebase>,
|
||||||
/// Steps in sequence, e.g. 64 16ths = 4 beat loop.
|
/// Steps in sequence, e.g. 64 16ths = 4 beat loop.
|
||||||
/// FIXME: play start / end / loop in ppm
|
/// FIXME: play start / end / loop in ppm
|
||||||
steps: usize,
|
pub steps: usize,
|
||||||
/// Phrase selector
|
/// Phrase selector
|
||||||
sequence: usize,
|
pub sequence: usize,
|
||||||
/// Map: tick -> MIDI events at tick
|
/// Map: tick -> MIDI events at tick
|
||||||
pub sequences: Vec<Phrase>,
|
pub sequences: Vec<Phrase>,
|
||||||
/// Red keys on piano roll.
|
/// Red keys on piano roll.
|
||||||
notes_on: Vec<bool>,
|
pub notes_on: Vec<bool>,
|
||||||
|
|
||||||
/// Play sequence to output.
|
/// Play sequence to output.
|
||||||
pub playing: TransportState,
|
pub playing: TransportState,
|
||||||
/// Play input through output.
|
/// Play input through output.
|
||||||
|
|
@ -52,9 +50,8 @@ pub struct Sequencer {
|
||||||
pub recording: bool,
|
pub recording: bool,
|
||||||
/// Don't delete when recording.
|
/// Don't delete when recording.
|
||||||
pub overdub: bool,
|
pub overdub: bool,
|
||||||
|
|
||||||
/// Display mode
|
/// Display mode
|
||||||
mode: SequencerView,
|
pub mode: SequencerView,
|
||||||
/// Range of notes to display
|
/// Range of notes to display
|
||||||
pub note_axis: (u16, u16),
|
pub note_axis: (u16, u16),
|
||||||
/// Position of cursor within note range
|
/// Position of cursor within note range
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ fn main () -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
Track::new("Kick", &timebase, Some(vec![
|
Track::new("Kick", &timebase, Some(vec![
|
||||||
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
||||||
|
Sampler::new("Sampler")?.boxed(),
|
||||||
]), Some(vec![
|
]), Some(vec![
|
||||||
Phrase::new("HelloKick", ppq * 4, Some(BTreeMap::from([
|
Phrase::new("HelloKick", ppq * 4, Some(BTreeMap::from([
|
||||||
( ppq * 0, vec![MidiMessage::NoteOn { key: 36.into(), vel: 100.into() }] ),
|
( ppq * 0, vec![MidiMessage::NoteOn { key: 36.into(), vel: 100.into() }] ),
|
||||||
|
|
@ -58,7 +59,6 @@ fn main () -> Result<(), Box<dyn Error>> {
|
||||||
])))
|
])))
|
||||||
]))?,
|
]))?,
|
||||||
|
|
||||||
//Sampler::new("Sampler")?.boxed(),
|
|
||||||
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
||||||
//Plugin::lv2("Bass/Helm", "file:///home/user/.lv2/Helm.lv2", &[1, 0, 0, 2])?.boxed(),
|
//Plugin::lv2("Bass/Helm", "file:///home/user/.lv2/Helm.lv2", &[1, 0, 0, 2])?.boxed(),
|
||||||
//Plugin::lv2("Pads/Odin2", "file:///home/user/.lv2/Odin2.lv2", &[1, 0, 0, 2])?.boxed(),
|
//Plugin::lv2("Pads/Odin2", "file:///home/user/.lv2/Odin2.lv2", &[1, 0, 0, 2])?.boxed(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue