mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
add tiny piano
This commit is contained in:
parent
13af81c5ad
commit
414b5e1580
12 changed files with 68 additions and 57 deletions
|
|
@ -9,3 +9,12 @@
|
|||
(@shift-O output add)
|
||||
(@shift-S scene add)
|
||||
(@shift-T track add)
|
||||
|
||||
(@up select :scene-prev)
|
||||
(@w select :scene-prev)
|
||||
(@down select :scene-next)
|
||||
(@s select :scene-next)
|
||||
(@left select :track-prev)
|
||||
(@a select :track-prev)
|
||||
(@right select :track-next)
|
||||
(@d select :track-next)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ atom_command!(TekCommand: |app: Tek| {
|
|||
("track" [,..a] TrackCommand::try_from_expr(app, a).map(Self::Track))
|
||||
("input" [,..a] InputCommand::try_from_expr(app, a).map(Self::Input))
|
||||
("output" [,..a] OutputCommand::try_from_expr(app, a).map(Self::Output))
|
||||
("select" [t: Selection] Some(t.map(Self::Select).expect("no selection")))
|
||||
("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) {
|
||||
(0, 0) => Self::Select(Selection::Mix),
|
||||
(t, 0) => Self::Select(Selection::Track(t)),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
(@up select :track :scene-prev)
|
||||
(@w select :track :scene-prev)
|
||||
(@down select :track :scene-next)
|
||||
(@s select :track :scene-next)
|
||||
(@left select :track-prev :scene)
|
||||
(@a select :track-prev :scene)
|
||||
(@right select :track-next :scene)
|
||||
(@d select :track-next :scene)
|
||||
|
||||
(@q clip launch :track :scene)
|
||||
(@c clip color :track :scene)
|
||||
(@g clip get)
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
(@down select 0 1)
|
||||
(@s select 0 1)
|
||||
|
||||
(@right select 1 0)
|
||||
(@d select 1 0)
|
||||
|
|
@ -1,10 +1,3 @@
|
|||
(@up select :track :scene-prev)
|
||||
(@w select :track :scene-prev)
|
||||
(@down select :track :scene-next)
|
||||
(@s select :track :scene-next)
|
||||
(@right select :track-next :scene)
|
||||
(@d select :track-next :scene)
|
||||
|
||||
(@q scene launch :scene)
|
||||
(@c scene color :scene)
|
||||
(@comma scene prev)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
(@left select :track-prev :scene)
|
||||
(@a select :track-prev :scene)
|
||||
(@right select :track-next :scene)
|
||||
(@d select :track-next :scene)
|
||||
(@down select :track :scene-next)
|
||||
(@s select :track :scene-next)
|
||||
(@up select :track :scene-last)
|
||||
(@w select :track :scene-last)
|
||||
|
||||
(@q track launch :track)
|
||||
(@c track color :track)
|
||||
(@comma track prev)
|
||||
|
|
|
|||
|
|
@ -27,5 +27,11 @@ pub use ::tek_tui::{
|
|||
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers, KeyCode::{self, *},
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::Relaxed}};
|
||||
// ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
||||
//██Let me play the world's tiniest piano for you. ██
|
||||
//█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
|
||||
//█▙▙█▙▙▙█▙▙█▙▙▙█▙▙█▙▙▙█▙▙█▙▙▙█▙▙█▙▙▙█▙▙█▙▙▙█▙▙█▙▙▙██
|
||||
//█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
|
||||
//███████████████████████████████████████████████████
|
||||
//█ ▀ ▀ ▀ █
|
||||
|
|
|
|||
|
|
@ -56,20 +56,51 @@ has_editor!(|self: Tek|{
|
|||
editor_h = 15;
|
||||
is_editing = self.editing.load(Relaxed); });
|
||||
provide!(Color: |self: Tek| {});
|
||||
provide!(Selection: |self: Tek| {});
|
||||
provide!(Arc<RwLock<MidiClip>>: |self: Tek| {});
|
||||
provide!(Option<Arc<RwLock<MidiClip>>>: |self: Tek| {});
|
||||
provide!(Option<Arc<RwLock<MidiClip>>>: |self: Tek| {
|
||||
":clip" => match self.selected {
|
||||
Selection::Clip(t, s) => self.scenes[s].clips[t].clone(),
|
||||
_ => None
|
||||
}
|
||||
});
|
||||
provide_bool!(bool: |self: Tek| {});
|
||||
provide_num!(isize: |self: Tek| {});
|
||||
provide_num!(usize: |self: Tek| {
|
||||
":scene" => self.selected.scene().unwrap_or(0),
|
||||
":scene-last" => self.scenes.len(),
|
||||
":scene-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()),
|
||||
":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1),
|
||||
":track" => self.selected.track().unwrap_or(0),
|
||||
":track-last" => self.tracks.len(),
|
||||
":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()),
|
||||
":track-prev" => self.selected.track().unwrap_or(0).saturating_sub(1) });
|
||||
":track-last" => self.tracks.len() });
|
||||
provide!(Option<usize>: |self: Tek| {
|
||||
":scene" => self.selected.scene(),
|
||||
":track" => self.selected.track() });
|
||||
provide!(Selection: |self: Tek| {
|
||||
":scene-next" => match self.selected {
|
||||
Selection::Mix => Selection::Scene(0),
|
||||
Selection::Track(t) => Selection::Clip(t, 0),
|
||||
Selection::Scene(s) => Selection::Scene(s + 1),
|
||||
Selection::Clip(t, s) => Selection::Clip(t, s + 1),
|
||||
},
|
||||
":scene-prev" => match self.selected {
|
||||
Selection::Mix => Selection::Mix,
|
||||
Selection::Track(t) => Selection::Track(t),
|
||||
Selection::Scene(0) => Selection::Mix,
|
||||
Selection::Scene(s) => Selection::Scene(s - 1),
|
||||
Selection::Clip(t, 0) => Selection::Track(t),
|
||||
Selection::Clip(t, s) => Selection::Clip(t, s - 1),
|
||||
},
|
||||
":track-next" => match self.selected {
|
||||
Selection::Mix => Selection::Track(0),
|
||||
Selection::Track(t) => Selection::Track(t + 1),
|
||||
Selection::Scene(s) => Selection::Clip(0, s),
|
||||
Selection::Clip(t, s) => Selection::Clip(t + 1, s),
|
||||
},
|
||||
":track-prev" => match self.selected {
|
||||
Selection::Mix => Selection::Mix,
|
||||
Selection::Scene(s) => Selection::Scene(s),
|
||||
Selection::Track(0) => Selection::Mix,
|
||||
Selection::Track(t) => Selection::Track(t - 1),
|
||||
Selection::Clip(0, s) => Selection::Scene(s),
|
||||
Selection::Clip(t, s) => Selection::Clip(t - 1, s),
|
||||
},
|
||||
});
|
||||
impl Tek {
|
||||
pub fn scenes_add (&mut self, n: usize) -> Usually<()> {
|
||||
let scene_color_1 = ItemColor::random();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl Selection {
|
|||
use Selection::*;
|
||||
match self { Clip(_, s) => Some(*s), Scene(s) => Some(*s), _ => None }
|
||||
}
|
||||
fn description (&self, tracks: &[Track], scenes: &[Scene]) -> Arc<str> {
|
||||
pub fn describe (&self, tracks: &[Track], scenes: &[Scene]) -> Arc<str> {
|
||||
format!("Selected: {}", match self {
|
||||
Self::Mix => "Everything".to_string(),
|
||||
Self::Track(t) => tracks.get(*t).map(|track|format!("T{t}: {}", &track.name))
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ impl Tek {
|
|||
Bsp::a(
|
||||
Fill::xy(Align::w(self.view_play_pause())),
|
||||
Fill::xy(Align::e(row!(
|
||||
FieldH(theme, "Sel", self.selected.describe(&self.tracks, &self.scenes)),
|
||||
FieldH(theme, "SR", fmtd.sr.view.clone()),
|
||||
FieldH(theme, "Buf", fmtd.buf.view.clone()),
|
||||
FieldH(theme, "Lat", fmtd.lat.view.clone()),
|
||||
|
|
@ -261,15 +262,8 @@ impl Tek {
|
|||
fn per_track <'a, T: Content<TuiOut> + 'a> (
|
||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
let width = self.size.w();
|
||||
let filter = move|(t, track, x1, x2)|if x2 >= width {None} else {Some((t, track, x1, x2))};
|
||||
let tracks = move||self.tracks_sizes(self.is_editing(), self.editor_w()).map_while(filter);
|
||||
Align::x(Tui::bg(Yellow, Map::new(tracks, move|(index, track, x1, x2), _|{
|
||||
let width = (x2 - x1) as u16;
|
||||
map_east(x1 as u16, width, Fixed::x(width, Tui::fg_bg(
|
||||
track.color.lightest.rgb,
|
||||
track.color.base.rgb,
|
||||
Fill::y(Align::y(Fixed::y(1, f(index, track))))))) }))) }
|
||||
self.per_track_top(move|index, track|Fill::y(Align::y(f(index, track))))
|
||||
}
|
||||
fn per_track_top <'a, T: Content<TuiOut> + 'a> (
|
||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
|
|
@ -281,7 +275,7 @@ impl Tek {
|
|||
map_east(x1 as u16, width, Fixed::x(width, Tui::fg_bg(
|
||||
track.color.lightest.rgb,
|
||||
track.color.base.rgb,
|
||||
Fixed::y(1, f(index, track))))) }))) }
|
||||
f(index, track)))) }))) }
|
||||
fn io_ports <'a, T: PortsSizes<'a>> (
|
||||
&'a self, fg: Color, bg: Color, iter: impl Fn()->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ impl Tek {
|
|||
)
|
||||
}
|
||||
fn view_clips_into (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
let heading = Align::e("Into:");
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, " --- "));
|
||||
self.row_top(self.w(), 1, heading, content)
|
||||
self.row_top(self.w(), 2,
|
||||
Bsp::s(Align::e("Input:"), Align::e("Into:")),
|
||||
self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s("▙▙█▙▙▙█", " ----- ")))))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ impl Tek {
|
|||
}
|
||||
fn view_clips_from (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
let heading = Align::e("From:");
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, " --- "));
|
||||
self.row_top(self.w(), 1, heading, content)
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s("▙▙█▙▙▙█", " ----- "))));
|
||||
self.row_top(self.w(), 2, heading, content)
|
||||
}
|
||||
fn view_clips_next (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
let heading = Align::e("Next:");
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, " --- "));
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, " ----- "));
|
||||
self.row_top(self.w(), 1, heading, content)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue