mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: fix keys rendering (notes still offset though)
This commit is contained in:
parent
2fc8e84551
commit
7ef97bcf3a
7 changed files with 60 additions and 19 deletions
|
|
@ -3,11 +3,11 @@
|
|||
(midi-in "nanoKEY Studio.*capture.*")
|
||||
(audio-out "Komplete.+:playback_FL", "Komplete.+:playback_FR")
|
||||
|
||||
(scene { :name "Intro" } _ 0 _ _)
|
||||
(scene { :name "Hook" } 0 1 0 _)
|
||||
(scene { :name "Verse" } 1 2 1 _)
|
||||
(scene { :name "Chorus" } 2 3 2 _)
|
||||
(scene { :name "Bridge" } 3 4 3 _)
|
||||
(scene { :name "Intro" } 0 0 _ _)
|
||||
(scene { :name "Hook" } 1 1 0 _)
|
||||
(scene { :name "Verse" } 2 2 1 _)
|
||||
(scene { :name "Chorus" } 3 3 2 _)
|
||||
(scene { :name "Bridge" } _ 4 3 _)
|
||||
(scene { :name "Outro" } 4 1 4 _)
|
||||
|
||||
(track { :name "Drums" :gain +0.0 }
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ pub const KEYMAP_GLOBAL: &'static [KeyBinding<App>] = keymap!(App {
|
|||
phrase.notes = notes;
|
||||
phrase.length = phrase.length * 2;
|
||||
});
|
||||
app.sequencer.show(app.arranger.phrase())?;
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('l'), NONE, "loop_toggle", "toggle looping", |_app: &mut App| {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::*;
|
||||
pub(crate) use ratatui::prelude::CrosstermBackend;
|
||||
pub(crate) use ratatui::style::{Stylize, Style, Color};
|
||||
pub(crate) use ratatui::style::{Stylize, Style, Color, Modifier};
|
||||
pub(crate) use ratatui::layout::Rect;
|
||||
pub(crate) use ratatui::buffer::{Buffer, Cell};
|
||||
use ratatui::widgets::WidgetRef;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub struct App {
|
|||
/// Display mode of chain section
|
||||
pub chain_mode: bool,
|
||||
/// Paths to user directories
|
||||
xdg: Option<Arc<XdgApp>>,
|
||||
_xdg: Option<Arc<XdgApp>>,
|
||||
/// Main audio outputs.
|
||||
pub audio_outs: Vec<Arc<Port<Unowned>>>,
|
||||
/// Number of frames requested by process callback
|
||||
|
|
@ -56,7 +56,7 @@ impl App {
|
|||
chunk_size: 0,
|
||||
midi_in: None,
|
||||
midi_ins: vec![],
|
||||
xdg: Some(xdg),
|
||||
_xdg: Some(xdg),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl Arranger {
|
|||
pub fn new () -> Self {
|
||||
Self {
|
||||
mode: false,
|
||||
selected: ArrangerFocus::Mix,
|
||||
selected: ArrangerFocus::Clip(0, 0),
|
||||
scenes: vec![],
|
||||
tracks: vec![],
|
||||
entered: true,
|
||||
|
|
|
|||
|
|
@ -66,23 +66,48 @@ fn keys_vert () -> Buffer {
|
|||
let area = Rect { x: 0, y: 0, width: 5, height: 64 };
|
||||
let mut buffer = Buffer::empty(area);
|
||||
buffer_update(&mut buffer, area, &|cell, x, y| {
|
||||
cell.set_char('▀');
|
||||
let y = 63 - y;
|
||||
match x {
|
||||
0 => {
|
||||
let (fg, bg) = key_colors(y);
|
||||
cell.set_char('▀');
|
||||
let (fg, bg) = key_colors(6 - y % 6);
|
||||
cell.set_fg(fg);
|
||||
cell.set_bg(bg);
|
||||
},
|
||||
1 => {
|
||||
cell.set_char('▀');
|
||||
cell.set_fg(Color::White);
|
||||
cell.set_bg(Color::White);
|
||||
}
|
||||
},
|
||||
2 => if y % 6 == 0 {
|
||||
cell.set_char('C');
|
||||
},
|
||||
3 => if y % 6 == 0 {
|
||||
cell.set_symbol(nth_octave(y / 6));
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
buffer
|
||||
}
|
||||
|
||||
fn nth_octave (index: u16) -> &'static str {
|
||||
match index {
|
||||
0 => "-1",
|
||||
1 => "0",
|
||||
2 => "1",
|
||||
3 => "2",
|
||||
4 => "3",
|
||||
5 => "4",
|
||||
6 => "5",
|
||||
7 => "6",
|
||||
8 => "7",
|
||||
9 => "8",
|
||||
10 => "9",
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
fn key_colors (index: u16) -> (Color, Color) {
|
||||
match index % 6 {
|
||||
0 => (Color::White, Color::Black),
|
||||
|
|
@ -104,16 +129,28 @@ fn fill_seq_bg (buf: &mut Buffer, length: usize, ppq: usize) -> Usually<()> {
|
|||
let cell = buf.get_mut(x, buf.area.y);
|
||||
cell.set_char('-');
|
||||
cell.set_style(style);
|
||||
let character = if ppq > 0 && x as usize % ppq == 0 { '|' } else { '·' };
|
||||
for y in 0 .. buf.area.height - buf.area.y {
|
||||
let cell = buf.get_mut(x, y);
|
||||
cell.set_char(character);
|
||||
cell.set_char(char_seq_bg(ppq, x));
|
||||
cell.set_fg(Color::Gray);
|
||||
cell.modifier = Modifier::DIM;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn char_seq_bg (ppq: usize, x: u16) -> char {
|
||||
if ppq == 0 {
|
||||
'·'
|
||||
} else if x % (4 * ppq as u16) == 0 {
|
||||
'│'
|
||||
} else if x % ppq as u16 == 0 {
|
||||
'╎'
|
||||
} else {
|
||||
'·'
|
||||
}
|
||||
}
|
||||
|
||||
fn fill_seq_fg (buf: &mut Buffer, phrase: &Phrase) -> Usually<()> {
|
||||
let mut notes_on = [false;128];
|
||||
for x in 0 .. buf.area.width - buf.area.x {
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@ impl Sequencer {
|
|||
x: area.x + Self::H_KEYS_OFFSET,
|
||||
y: area.y + 1,
|
||||
width: area.width - Self::H_KEYS_OFFSET,
|
||||
height: area.height - 1
|
||||
height: area.height - 2
|
||||
};
|
||||
buffer_update(buf, area, &|cell, x, y|{
|
||||
let src_x = (x + self.time_axis.start) * self.time_axis.scale;
|
||||
let src_y = y + self.note_axis.start;
|
||||
if src_x < self.buffer.area.width && src_y < self.buffer.area.height {
|
||||
let src = self.buffer.get(src_x, src_y);
|
||||
if src_x < self.buffer.area.width && src_y < self.buffer.area.height - 1 {
|
||||
let src = self.buffer.get(src_x, self.buffer.area.height - src_y);
|
||||
cell.set_symbol(src.symbol());
|
||||
cell.set_fg(src.fg);
|
||||
}
|
||||
|
|
@ -77,11 +77,14 @@ impl Sequencer {
|
|||
let area = Rect {
|
||||
x: area.x,
|
||||
y: area.y + 1,
|
||||
width: 2,
|
||||
width: 5,
|
||||
height: area.height - 2
|
||||
};
|
||||
buffer_update(buf, area, &|cell, x, y|{
|
||||
*cell = self.keys.get(x, y % 6).clone()
|
||||
let y = y + self.note_axis.start;
|
||||
if x < self.keys.area.width && y < self.keys.area.height {
|
||||
*cell = self.keys.get(x, y).clone()
|
||||
}
|
||||
});
|
||||
Ok(area)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue