mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
Compare commits
No commits in common. "0c97f68754187b9a0bb33e5316cc114ac7c54bd3" and "74b497cf3a37c9bb60d11fedda8a24844daa1378" have entirely different histories.
0c97f68754
...
74b497cf3a
15 changed files with 204 additions and 201 deletions
|
|
@ -1,5 +1,5 @@
|
|||
[workspace.package]
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
version = "0.2.1"
|
||||
|
||||
[workspace]
|
||||
|
|
|
|||
2
Justfile
2
Justfile
|
|
@ -1,5 +1,3 @@
|
|||
export RUSTFLAGS := "--cfg procmacro2_semver_exempt -Zmacro-backtrace"
|
||||
|
||||
debug := "reset && cargo run --"
|
||||
release := "reset && cargo run --release --"
|
||||
name := "-n tek"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(type_changing_struct_update)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(closure_lifetime_binder)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(generic_arg_infer)]
|
||||
pub use ::tek_engine:: *;
|
||||
pub use ::tek_device::{self, *};
|
||||
pub use ::tengri::{Usually, Perhaps, Has, MaybeHas};
|
||||
|
|
@ -35,6 +38,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::Relaxed};
|
|||
use std::error::Error;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write;
|
||||
use ::tengri::tui::ratatui::prelude::Position;
|
||||
use xdg::BaseDirectories;
|
||||
mod app_jack; pub use self::app_jack::*;
|
||||
#[cfg(test)] mod app_test;
|
||||
|
|
@ -210,14 +214,19 @@ impl App {
|
|||
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
||||
}
|
||||
}
|
||||
|
||||
fn render_dsl <'t, S> (state: &'t S, src: &str) -> Box<dyn Render<TuiOut>>
|
||||
where S: DslSymNs<'t, Box<dyn Render<TuiOut>>> + DslExpNs<'t, Box<dyn Render<TuiOut>>>
|
||||
{
|
||||
let sym_err: Option<Box<dyn Error>> = match state.from_sym(src) {
|
||||
Ok(Some(value)) => return value, Ok(None) => None, Err(e) => Some(e),
|
||||
Ok(Some(value)) => return value,
|
||||
Ok(None) => None,
|
||||
Err(e) => Some(e),
|
||||
};
|
||||
let exp_err = match state.from_exp(src) {
|
||||
Ok(Some(value)) => return value, Ok(None) => None, Err(e) => Some(e),
|
||||
Ok(Some(value)) => return value,
|
||||
Ok(None) => None,
|
||||
Err(e) => Some(e),
|
||||
};
|
||||
let (err_fg_1, err_bg_1) = (Color::Rgb(240, 160, 100), Color::Rgb(48, 0, 0));
|
||||
let (err_fg_2, err_bg_2) = (Color::Rgb(250, 200, 120), Color::Rgb(32, 0, 0));
|
||||
|
|
@ -228,20 +237,18 @@ fn render_dsl <'t, S> (state: &'t S, src: &str) -> Box<dyn Render<TuiOut>>
|
|||
Fill::x(Margin::x(1, Tui::fg_bg(err_fg_2, err_bg_2, format!("{exp_err:?}")))),
|
||||
}))
|
||||
}
|
||||
dsl_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
||||
("bold", value: bool, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::bold(value, x)),
|
||||
|
||||
dsl_exp_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
||||
("bold", value: bool, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::bold(value, x)),
|
||||
("fg", color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg(color, x)),
|
||||
("bg", color: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::bg(color, x)),
|
||||
("fg/bg", fg: Color, bg: Color, x: Box<dyn Render<TuiOut>>) => Box::new(Tui::fg_bg(fg, bg, x)),
|
||||
|
||||
("bsp/n", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::n(a, b)),
|
||||
("bsp/s", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::s(a, b)),
|
||||
("bsp/e", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::e(a, b)),
|
||||
("bsp/w", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::w(a, b)),
|
||||
("bsp/a", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::a(a, b)),
|
||||
("bsp/b", a: Box<dyn Render<TuiOut>>, b: Box<dyn Render<TuiOut>>) => Box::new(Bsp::b(a, b)),
|
||||
|
||||
("align/n", x: Box<dyn Render<TuiOut>>) => Box::new(Align::n(x)),
|
||||
("align/s", x: Box<dyn Render<TuiOut>>) => Box::new(Align::s(x)),
|
||||
("align/e", x: Box<dyn Render<TuiOut>>) => Box::new(Align::e(x)),
|
||||
|
|
@ -249,49 +256,36 @@ dsl_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
|||
("align/x", x: Box<dyn Render<TuiOut>>) => Box::new(Align::x(x)),
|
||||
("align/y", x: Box<dyn Render<TuiOut>>) => Box::new(Align::y(x)),
|
||||
("align/c", x: Box<dyn Render<TuiOut>>) => Box::new(Align::c(x)),
|
||||
|
||||
("fill/x", x: Box<dyn Render<TuiOut>>) => Box::new(Fill::x(x)),
|
||||
("fill/y", x: Box<dyn Render<TuiOut>>) => Box::new(Fill::y(x)),
|
||||
("fill/xy", x: Box<dyn Render<TuiOut>>) => Box::new(Fill::xy(x)),
|
||||
});
|
||||
|
||||
("fixed/x", x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::x(x, c)),
|
||||
("fixed/y", y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::y(y, c)),
|
||||
("fixed/xy", x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Fixed::xy(x, y, c)),
|
||||
dsl_exp_ns!(|app: App| -> Color {
|
||||
("g", n: u8) =>
|
||||
Color::Rgb(n, n, n),
|
||||
("rgb", r: u8, g: u8, b: u8) =>
|
||||
Color::Rgb(r, g, b),
|
||||
});
|
||||
|
||||
("min/x", x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::x(x, c)),
|
||||
("min/y", y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::y(y, c)),
|
||||
("min/xy", x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Min::xy(x, y, c)),
|
||||
dsl_sym_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
||||
|
||||
("max/x", x: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::x(x, c)),
|
||||
("max/y", y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::y(y, c)),
|
||||
("max/xy", x: u16, y: u16, c: Box<dyn Render<TuiOut>>) => Box::new(Max::xy(x, y, c)),
|
||||
|
||||
":view/menu" =>
|
||||
app.view(stringify!((bg (rgb 0 0 0)
|
||||
":view/menu" => app.view(stringify!((bg (rgb 0 0 0)
|
||||
(bsp/s :view/ports/outs (bsp/s (bg (rgb 33 33 33) (bold :true "tek 0.3.0-rc.0")))
|
||||
(bsp/n :view/ports/ins (bsp/n (bg (rgb 33 33 33) (bsp/e (fg (rgb 255 192 48) "[Enter]") " new session"))
|
||||
(align/n (fill/xy :view/modes)))))))),
|
||||
":view/ports/outs" =>
|
||||
app.view(stringify!((fill/x (fixed/y 3
|
||||
|
||||
":view/ports/outs" => app.view(stringify!((fill/x (fixed/y 3
|
||||
(bsp/a (fill/x (align/w "L AUDIO OUT")
|
||||
(bsp/a "MIDI OUT" (fill/x (align/e "AUDIO OUT R"))))))))),
|
||||
":view/ports/ins" =>
|
||||
app.view(stringify!(fill/x (fixed/y 3
|
||||
|
||||
":view/ports/ins" => app.view(stringify!(fill/x (fixed/y 3
|
||||
(bsp/a (fill/x (align/w "L AUDIO IN ")
|
||||
(bsp/a "MIDI IN " (fill/x (align/e "AUDIO IN R")))))))),
|
||||
":view/browse" =>
|
||||
app.view(stringify!(bsp/s
|
||||
|
||||
":view/browse" => app.view(stringify!(bsp/s
|
||||
(padding/xy 3 1 :view/browse-title) (enclose (fg (g 96)) :view/browser))),
|
||||
":view/browse/title" =>
|
||||
Box::new(Fill::x(Align::w(FieldV(Default::default(),
|
||||
match app.dialog.browser_target().unwrap() {
|
||||
BrowserTarget::SaveProject => "Save project:",
|
||||
BrowserTarget::LoadProject => "Load project:",
|
||||
BrowserTarget::ImportSample(_) => "Import sample:",
|
||||
BrowserTarget::ExportSample(_) => "Export sample:",
|
||||
BrowserTarget::ImportClip(_) => "Import clip:",
|
||||
BrowserTarget::ExportClip(_) => "Export clip:",
|
||||
}, Shrink::x(3, Fixed::y(1, Tui::fg(Tui::g(96), RepeatH("🭻")))))))),
|
||||
|
||||
":view/modes" => Box::new({
|
||||
let modes = app.config.modes.clone();
|
||||
Stack::south(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
|
|
@ -305,6 +299,19 @@ dsl_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
|||
//(fill/x (align/w #info))))))));
|
||||
}
|
||||
}) }),
|
||||
|
||||
":view/browse/title" => {
|
||||
let title = match app.dialog.browser_target().unwrap() {
|
||||
BrowserTarget::SaveProject => "Save project:",
|
||||
BrowserTarget::LoadProject => "Load project:",
|
||||
BrowserTarget::ImportSample(_) => "Import sample:",
|
||||
BrowserTarget::ExportSample(_) => "Export sample:",
|
||||
BrowserTarget::ImportClip(_) => "Import clip:",
|
||||
BrowserTarget::ExportClip(_) => "Export clip:",
|
||||
};
|
||||
Box::new(Fill::x(Align::w(FieldV(Default::default(), title, Shrink::x(3, Fixed::y(1, Tui::fg(Tui::g(96), RepeatH("🭻"))))))))
|
||||
},
|
||||
|
||||
":view/device" => {
|
||||
let selected = app.dialog.device_kind().unwrap();
|
||||
Box::new(Bsp::s(Tui::bold(true, "Add device"), Map::south(1,
|
||||
|
|
@ -314,13 +321,9 @@ dsl_ns!(|app: App| -> Box<dyn Render<TuiOut>> {
|
|||
let lb = if i == selected { "[ " } else { " " };
|
||||
let rb = if i == selected { " ]" } else { " " };
|
||||
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) },
|
||||
|
||||
//(":view/options", view_options),
|
||||
});
|
||||
dsl_ns!(|app: App| -> Color {
|
||||
("g", n: u8) => Color::Rgb(n, n, n),
|
||||
("rgb", r: u8, g: u8, b: u8) => Color::Rgb(r, g, b),
|
||||
});
|
||||
|
||||
fn wrap_dialog (dialog: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b(
|
||||
Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))).enclose(dialog))))
|
||||
|
|
@ -576,39 +579,39 @@ handle!(TuiIn:|self: App, input|{
|
|||
//None
|
||||
//})
|
||||
});
|
||||
dsl_ns!(|app: App| -> u8
|
||||
{ ":_u8_stub" => 1 });
|
||||
dsl_ns!(|app: App| -> isize
|
||||
{ ":_isize_stub" => -1 });
|
||||
dsl_ns!(|app: App| -> ItemTheme
|
||||
{ ":_theme_stub" => Default::default() });
|
||||
dsl_ns!(|app: App| -> u16{
|
||||
dsl_sym_ns!(|app: App| -> isize {
|
||||
":_isize_stub" => -1
|
||||
});
|
||||
dsl_sym_ns!(|app: App| -> ItemTheme {
|
||||
":_theme_stub" => Default::default()
|
||||
});
|
||||
dsl_sym_ns!(|app: App| -> u16{
|
||||
":w/sidebar" => app.project.w_sidebar(app.editor().is_some()),
|
||||
":h/sample-detail" => 6.max(app.height() as u16 * 3 / 9),
|
||||
});
|
||||
dsl_ns!(|app: App| -> usize {
|
||||
dsl_sym_ns!(|app: App| -> usize {
|
||||
":scene-count" => app.scenes().len(),
|
||||
":track-count" => app.tracks().len(),
|
||||
":device-kind" => app.dialog.device_kind().unwrap_or(0),
|
||||
":device-kind/next" => app.dialog.device_kind_next().unwrap_or(0),
|
||||
":device-kind/prev" => app.dialog.device_kind_prev().unwrap_or(0),
|
||||
});
|
||||
dsl_ns!(|app: App| -> bool {
|
||||
dsl_sym_ns!(|app: App| -> bool {
|
||||
":focused/editor" => app.project.editor.is_some(),
|
||||
":focused/dialog" => !matches!(app.dialog, Dialog::None),
|
||||
":focused/message" => matches!(app.dialog, Dialog::Message(..)),
|
||||
":focused/add_device" => matches!(app.dialog, Dialog::Device(..)),
|
||||
":focused/browser" => app.dialog.browser().is_some(),
|
||||
":focused/clip" => !app.editor_focused() && matches!(app.selection(), Selection::TrackClip{..}),
|
||||
":focused/track" => !app.editor_focused() && matches!(app.selection(), Selection::Track(..)),
|
||||
":focused/scene" => !app.editor_focused() && matches!(app.selection(), Selection::Scene(..)),
|
||||
":focused/mix" => !app.editor_focused() && matches!(app.selection(), Selection::Mix),
|
||||
":focused/clip" => !app.focused_editor() && matches!(app.selection(), Selection::TrackClip{..}),
|
||||
":focused/track" => !app.focused_editor() && matches!(app.selection(), Selection::Track(..)),
|
||||
":focused/scene" => !app.focused_editor() && matches!(app.selection(), Selection::Scene(..)),
|
||||
":focused/mix" => !app.focused_editor() && matches!(app.selection(), Selection::Mix),
|
||||
":focused/pool/import" => matches!(app.pool.mode, Some(PoolMode::Import(..))),
|
||||
":focused/pool/export" => matches!(app.pool.mode, Some(PoolMode::Export(..))),
|
||||
":focused/pool/rename" => matches!(app.pool.mode, Some(PoolMode::Rename(..))),
|
||||
":focused/pool/length" => matches!(app.pool.mode, Some(PoolMode::Length(..))),
|
||||
});
|
||||
dsl_ns!(|app: App| -> Dialog {
|
||||
dsl_sym_ns!(|app: App| -> Dialog {
|
||||
":dialog/none" => Dialog::None,
|
||||
":dialog/options" => Dialog::Options,
|
||||
":dialog/device" => Dialog::Device(0),
|
||||
|
|
@ -623,7 +626,7 @@ dsl_ns!(|app: App| -> Dialog {
|
|||
":dialog/import/sample" => Dialog::Browser(BrowserTarget::ImportSample(Default::default()), Browser::new(None).unwrap().into()),
|
||||
":dialog/export/sample" => Dialog::Browser(BrowserTarget::ExportSample(Default::default()), Browser::new(None).unwrap().into()),
|
||||
});
|
||||
dsl_ns!(|app: App| -> Selection {
|
||||
dsl_sym_ns!(|app: App| -> Selection {
|
||||
":select/scene" => app.selection().select_scene(app.tracks().len()),
|
||||
":select/scene/next" => app.selection().select_scene_next(app.scenes().len()),
|
||||
":select/scene/prev" => app.selection().select_scene_prev(),
|
||||
|
|
@ -631,14 +634,14 @@ dsl_ns!(|app: App| -> Selection {
|
|||
":select/track/next" => app.selection().select_track_next(app.tracks().len()),
|
||||
":select/track/prev" => app.selection().select_track_prev(),
|
||||
});
|
||||
dsl_ns!(|app: App| -> Option<u7> {
|
||||
dsl_sym_ns!(|app: App| -> Option<u7> {
|
||||
":editor/pitch" => Some((app.editor().as_ref().map(|e|e.get_note_pos()).unwrap() as u8).into())
|
||||
});
|
||||
dsl_ns!(|app: App| -> Option<usize> {
|
||||
dsl_sym_ns!(|app: App| -> Option<usize> {
|
||||
":selected/scene" => app.selection().scene(),
|
||||
":selected/track" => app.selection().track(),
|
||||
});
|
||||
dsl_ns!(|app: App| -> Option<Arc<RwLock<MidiClip>>> {
|
||||
dsl_sym_ns!(|app: App| -> Option<Arc<RwLock<MidiClip>>> {
|
||||
":selected/clip" => if let Selection::TrackClip { track, scene } = app.selection() {
|
||||
app.scenes()[*scene].clips[*track].clone()
|
||||
} else {
|
||||
|
|
@ -646,8 +649,9 @@ dsl_ns!(|app: App| -> Option<Arc<RwLock<MidiClip>>> {
|
|||
}
|
||||
});
|
||||
#[derive(Debug)]
|
||||
pub enum AppCommand { /* TODO */ }
|
||||
dsl_ns!(|app: App| -> AppCommand {
|
||||
pub enum AppCommand {
|
||||
}
|
||||
dsl_exp_ns!(|app: App| -> AppCommand {
|
||||
("stop-all") => todo!(),//app.project.stop_all(),
|
||||
("enqueue", clip: Option<Arc<RwLock<MidiClip>>>) => todo!(),
|
||||
("history", delta: isize) => todo!(),
|
||||
|
|
@ -660,14 +664,14 @@ dsl_ns!(|app: App| -> AppCommand {
|
|||
("pool" / command: PoolCommand) => todo!(),
|
||||
("pool" / editor: MidiEditCommand) => todo!(),
|
||||
});
|
||||
dsl_ns!(|app: App| -> DialogCommand {});
|
||||
dsl_ns!(|app: App| -> ArrangementCommand {});
|
||||
dsl_ns!(|app: App| -> ClockCommand {});
|
||||
dsl_ns!(|app: App| -> SamplerCommand {});
|
||||
dsl_ns!(|app: App| -> PoolCommand {});
|
||||
dsl_ns!(|app: App| -> MidiEditCommand {});
|
||||
dsl_exp_ns!(|app: App| -> DialogCommand {});
|
||||
dsl_exp_ns!(|app: App| -> ArrangementCommand {});
|
||||
dsl_exp_ns!(|app: App| -> ClockCommand {});
|
||||
dsl_exp_ns!(|app: App| -> SamplerCommand {});
|
||||
dsl_exp_ns!(|app: App| -> PoolCommand {});
|
||||
dsl_exp_ns!(|app: App| -> MidiEditCommand {});
|
||||
impl App {
|
||||
pub fn editor_focused (&self) -> bool {
|
||||
pub fn focused_editor (&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
@ -694,6 +698,97 @@ impl Dialog {
|
|||
todo!()
|
||||
}
|
||||
}
|
||||
//dsl_bind!(AppCommand: App {
|
||||
//enqueue = |app, clip: Option<Arc<RwLock<MidiClip>>>| { todo!() };
|
||||
//history = |app, delta: isize| { todo!() };
|
||||
//zoom = |app, zoom: usize| { todo!() };
|
||||
//stop_all = |app| { app.tracks_stop_all(); Ok(None) };
|
||||
////dialog = |app, command: DialogCommand|
|
||||
////Ok(command.delegate(&mut app.dialog, |c|Self::Dialog{command: c})?);
|
||||
//project = |app, command: ArrangementCommand|
|
||||
//Ok(command.delegate(&mut app.project, |c|Self::Project{command: c})?);
|
||||
//clock = |app, command: ClockCommand|
|
||||
//Ok(command.execute(app.clock_mut())?.map(|c|Self::Clock{command: c}));
|
||||
//sampler = |app, command: SamplerCommand|
|
||||
//Ok(app.project.sampler_mut().map(|s|command.delegate(s, |command|Self::Sampler{command}))
|
||||
//.transpose()?.flatten());
|
||||
//pool = |app, command: PoolCommand| {
|
||||
//let undo = command.clone().delegate(&mut app.pool, |command|AppCommand::Pool{command})?;
|
||||
//// update linked editor after pool action
|
||||
//match command {
|
||||
//// autoselect: automatically load selected clip in editor
|
||||
//PoolCommand::Select { .. } |
|
||||
//// autocolor: update color in all places simultaneously
|
||||
//PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } => {
|
||||
//let clip = app.pool.clip().clone();
|
||||
//app.editor_mut().map(|editor|editor.set_clip(clip.as_ref()))
|
||||
//},
|
||||
//_ => None
|
||||
//};
|
||||
//Ok(undo)
|
||||
//};
|
||||
//select = |app, selection: Selection| {
|
||||
//*app.project.selection_mut() = selection;
|
||||
////todo!
|
||||
////if let Some(ref mut editor) = app.editor_mut() {
|
||||
////editor.set_clip(match selection {
|
||||
////Selection::TrackClip { track, scene } if let Some(Some(Some(clip))) = app
|
||||
////.project
|
||||
////.scenes.get(scene)
|
||||
////.map(|s|s.clips.get(track))
|
||||
////=>
|
||||
////Some(clip),
|
||||
////_ =>
|
||||
////None
|
||||
////});
|
||||
////}
|
||||
//Ok(None)
|
||||
////("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)),
|
||||
////(0, s) => Self::Select(Selection::Scene(s)),
|
||||
////(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
|
||||
//// autoedit: load focused clip in editor.
|
||||
//};
|
||||
////fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||
////Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
||||
////}
|
||||
////fn launch (app: &mut App) -> Perhaps<Self> {
|
||||
////app.project.launch();
|
||||
////Ok(None)
|
||||
////}
|
||||
//toggle_editor = |app, value: bool|{ app.toggle_editor(Some(value)); Ok(None) };
|
||||
//editor = |app, command: MidiEditCommand| Ok(if let Some(editor) = app.editor_mut() {
|
||||
//let undo = command.clone().delegate(editor, |command|AppCommand::Editor{command})?;
|
||||
//// update linked sampler after editor action
|
||||
//app.project.sampler_mut().map(|sampler|match command {
|
||||
//// autoselect: automatically select sample in sampler
|
||||
//MidiEditCommand::SetNotePos { pos } => { sampler.set_note_pos(pos); },
|
||||
//_ => {}
|
||||
//});
|
||||
//undo
|
||||
//} else {
|
||||
//None
|
||||
//});
|
||||
//});
|
||||
//take!(ClockCommand |state: App, iter|Take::take(state.clock(), iter));
|
||||
//take!(MidiEditCommand |state: App, iter|Ok(state.editor().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(PoolCommand |state: App, iter|Take::take(&state.pool, iter));
|
||||
//take!(SamplerCommand |state: App, iter|Ok(state.project.sampler().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(ArrangementCommand |state: App, iter|Take::take(&state.project, iter));
|
||||
//take!(DialogCommand |state: App, iter|Take::take(&state.dialog, iter));
|
||||
//has_editor!(|self: App|{
|
||||
//editor = self.editor;
|
||||
//editor_w = {
|
||||
//let size = self.size.w();
|
||||
//let editor = self.editor.as_ref().expect("missing editor");
|
||||
//let time_len = editor.time_len().get();
|
||||
//let time_zoom = editor.time_zoom().get().max(1);
|
||||
//(5 + (time_len / time_zoom)).min(size.saturating_sub(20)).max(16)
|
||||
//};
|
||||
//editor_h = 15;
|
||||
//is_editing = self.editor.is_some();
|
||||
//});
|
||||
#[tengri_proc::command(Option<Dialog>)] impl DialogCommand {
|
||||
fn open (dialog: &mut Option<Dialog>, new: Dialog) -> Perhaps<Self> {
|
||||
*dialog = Some(new);
|
||||
|
|
@ -725,7 +820,7 @@ impl App {
|
|||
// autocolor: new clip colors from scene and track color
|
||||
let color = track.color.base.mix(scene.color.base, 0.5);
|
||||
clip.write().unwrap().color = ItemColor::random_near(color, 0.2).into();
|
||||
if let Some(editor) = &mut self.project.editor {
|
||||
if let Some(ref mut editor) = &mut self.project.editor {
|
||||
editor.set_clip(Some(&clip));
|
||||
}
|
||||
*slot = Some(clip.clone());
|
||||
|
|
@ -821,94 +916,3 @@ impl App {
|
|||
//}
|
||||
//}
|
||||
//
|
||||
//dsl_bind!(AppCommand: App {
|
||||
//enqueue = |app, clip: Option<Arc<RwLock<MidiClip>>>| { todo!() };
|
||||
//history = |app, delta: isize| { todo!() };
|
||||
//zoom = |app, zoom: usize| { todo!() };
|
||||
//stop_all = |app| { app.tracks_stop_all(); Ok(None) };
|
||||
////dialog = |app, command: DialogCommand|
|
||||
////Ok(command.delegate(&mut app.dialog, |c|Self::Dialog{command: c})?);
|
||||
//project = |app, command: ArrangementCommand|
|
||||
//Ok(command.delegate(&mut app.project, |c|Self::Project{command: c})?);
|
||||
//clock = |app, command: ClockCommand|
|
||||
//Ok(command.execute(app.clock_mut())?.map(|c|Self::Clock{command: c}));
|
||||
//sampler = |app, command: SamplerCommand|
|
||||
//Ok(app.project.sampler_mut().map(|s|command.delegate(s, |command|Self::Sampler{command}))
|
||||
//.transpose()?.flatten());
|
||||
//pool = |app, command: PoolCommand| {
|
||||
//let undo = command.clone().delegate(&mut app.pool, |command|AppCommand::Pool{command})?;
|
||||
//// update linked editor after pool action
|
||||
//match command {
|
||||
//// autoselect: automatically load selected clip in editor
|
||||
//PoolCommand::Select { .. } |
|
||||
//// autocolor: update color in all places simultaneously
|
||||
//PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } => {
|
||||
//let clip = app.pool.clip().clone();
|
||||
//app.editor_mut().map(|editor|editor.set_clip(clip.as_ref()))
|
||||
//},
|
||||
//_ => None
|
||||
//};
|
||||
//Ok(undo)
|
||||
//};
|
||||
//select = |app, selection: Selection| {
|
||||
//*app.project.selection_mut() = selection;
|
||||
////todo!
|
||||
////if let Some(ref mut editor) = app.editor_mut() {
|
||||
////editor.set_clip(match selection {
|
||||
////Selection::TrackClip { track, scene } if let Some(Some(Some(clip))) = app
|
||||
////.project
|
||||
////.scenes.get(scene)
|
||||
////.map(|s|s.clips.get(track))
|
||||
////=>
|
||||
////Some(clip),
|
||||
////_ =>
|
||||
////None
|
||||
////});
|
||||
////}
|
||||
//Ok(None)
|
||||
////("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)),
|
||||
////(0, s) => Self::Select(Selection::Scene(s)),
|
||||
////(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
|
||||
//// autoedit: load focused clip in editor.
|
||||
//};
|
||||
////fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||
////Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
||||
////}
|
||||
////fn launch (app: &mut App) -> Perhaps<Self> {
|
||||
////app.project.launch();
|
||||
////Ok(None)
|
||||
////}
|
||||
//toggle_editor = |app, value: bool|{ app.toggle_editor(Some(value)); Ok(None) };
|
||||
//editor = |app, command: MidiEditCommand| Ok(if let Some(editor) = app.editor_mut() {
|
||||
//let undo = command.clone().delegate(editor, |command|AppCommand::Editor{command})?;
|
||||
//// update linked sampler after editor action
|
||||
//app.project.sampler_mut().map(|sampler|match command {
|
||||
//// autoselect: automatically select sample in sampler
|
||||
//MidiEditCommand::SetNotePos { pos } => { sampler.set_note_pos(pos); },
|
||||
//_ => {}
|
||||
//});
|
||||
//undo
|
||||
//} else {
|
||||
//None
|
||||
//});
|
||||
//});
|
||||
//take!(ClockCommand |state: App, iter|Take::take(state.clock(), iter));
|
||||
//take!(MidiEditCommand |state: App, iter|Ok(state.editor().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(PoolCommand |state: App, iter|Take::take(&state.pool, iter));
|
||||
//take!(SamplerCommand |state: App, iter|Ok(state.project.sampler().map(|x|Take::take(x, iter)).transpose()?.flatten()));
|
||||
//take!(ArrangementCommand |state: App, iter|Take::take(&state.project, iter));
|
||||
//take!(DialogCommand |state: App, iter|Take::take(&state.dialog, iter));
|
||||
//has_editor!(|self: App|{
|
||||
//editor = self.editor;
|
||||
//editor_w = {
|
||||
//let size = self.size.w();
|
||||
//let editor = self.editor.as_ref().expect("missing editor");
|
||||
//let time_len = editor.time_len().get();
|
||||
//let time_zoom = editor.time_zoom().get().max(1);
|
||||
//(5 + (time_len / time_zoom)).min(size.saturating_sub(20)).max(16)
|
||||
//};
|
||||
//editor_h = 15;
|
||||
//is_editing = self.editor.is_some();
|
||||
//});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ audio!(
|
|||
let mut pitch: Option<u7> = None;
|
||||
for port in midi_in.iter() {
|
||||
for event in port.iter() {
|
||||
if let (_, Ok(LiveEvent::Midi {message: MidiMessage::NoteOn {key, ..}, ..}))
|
||||
if let (_, Ok(LiveEvent::Midi {message: MidiMessage::NoteOn {ref key, ..}, ..}))
|
||||
= event
|
||||
{
|
||||
pitch = Some(key.clone());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
pub(crate) use tek::*;
|
||||
pub(crate) use std::sync::{Arc, RwLock};
|
||||
pub(crate) use clap::{self, Parser, Subcommand};
|
||||
|
||||
/// Application entrypoint.
|
||||
|
|
@ -55,16 +56,16 @@ impl Cli {
|
|||
let empty = &[] as &[&str];
|
||||
let mut midi_ins = vec![];
|
||||
let mut midi_outs = vec![];
|
||||
let tracks = vec![];
|
||||
let scenes = vec![];
|
||||
let mut tracks = vec![];
|
||||
let mut scenes = vec![];
|
||||
let midi_froms = Connect::collect(&self.midi_from, empty, &self.midi_from_re);
|
||||
let midi_tos = Connect::collect(&self.midi_to, empty, &self.midi_to_re);
|
||||
let left_froms = Connect::collect(&self.left_from, empty, empty);
|
||||
let left_tos = Connect::collect(&self.left_to, empty, empty);
|
||||
let right_froms = Connect::collect(&self.right_from, empty, empty);
|
||||
let right_tos = Connect::collect(&self.right_to, empty, empty);
|
||||
let _audio_froms = &[left_froms.as_slice(), right_froms.as_slice()];
|
||||
let _audio_tos = &[left_tos.as_slice(), right_tos.as_slice()];
|
||||
let audio_froms = &[left_froms.as_slice(), right_froms.as_slice()];
|
||||
let audio_tos = &[left_tos.as_slice(), right_tos.as_slice()];
|
||||
Tui::new()?.run(&Jack::new_run(&name, move|jack|{
|
||||
for (index, connect) in midi_froms.iter().enumerate() {
|
||||
midi_ins.push(jack.midi_in(&format!("M/{index}"), &[connect.clone()])?);
|
||||
|
|
@ -73,7 +74,7 @@ impl Cli {
|
|||
midi_outs.push(jack.midi_out(&format!("{index}/M"), &[connect.clone()])?);
|
||||
};
|
||||
let clock = Clock::new(&jack, self.bpm)?;
|
||||
let app = App {
|
||||
let mut app = App {
|
||||
config,
|
||||
jack: jack.clone(),
|
||||
color: ItemTheme::random(),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl HasSceneScroll for Arrangement {
|
|||
fn scene_scroll (&self) -> usize { self.scene_scroll }
|
||||
}
|
||||
|
||||
pub type SceneWith<'a, T> = (usize, &'a Scene, usize, usize, T);
|
||||
pub type SceneWith<'a, T: Send + Sync> = (usize, &'a Scene, usize, usize, T);
|
||||
|
||||
impl<T: HasScenes + HasTracks> AddScene for T {}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,10 +139,10 @@ impl TrackCommand {
|
|||
std::mem::swap(&mut color, &mut track.color);
|
||||
Ok(Some(Self::SetColor { color }))
|
||||
}
|
||||
fn set_mute (_track: &mut Track, _value: Option<bool>) -> Perhaps<Self> {
|
||||
fn set_mute (track: &mut Track, value: Option<bool>) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_solo (_track: &mut Track, _value: Option<bool>) -> Perhaps<Self> {
|
||||
fn set_solo (track: &mut Track, value: Option<bool>) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_rec (track: &mut Track, value: Option<bool>) -> Perhaps<Self> {
|
||||
|
|
@ -155,10 +155,10 @@ impl TrackCommand {
|
|||
let value = value.unwrap_or(!current);
|
||||
Ok((value != current).then_some(Self::SetRec { value: Some(current) }))
|
||||
}
|
||||
fn set_size (_track: &mut Track, _size: usize) -> Perhaps<Self> {
|
||||
fn set_size (track: &mut Track, size: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn set_zoom (_track: &mut Track, _zoom: usize) -> Perhaps<Self> {
|
||||
fn set_zoom (track: &mut Track, zoom: usize) -> Perhaps<Self> {
|
||||
todo!()
|
||||
}
|
||||
fn stop (track: &mut Track) -> Perhaps<Self> {
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ pub(crate) fn button_play_pause (playing: bool) -> impl Content<TuiOut> {
|
|||
impl Default for ViewCache {
|
||||
fn default () -> Self {
|
||||
let mut beat = String::with_capacity(16);
|
||||
let _ = write!(beat, "{}", Self::BEAT_EMPTY);
|
||||
write!(beat, "{}", Self::BEAT_EMPTY);
|
||||
let mut time = String::with_capacity(16);
|
||||
let _ = write!(time, "{}", Self::TIME_EMPTY);
|
||||
write!(time, "{}", Self::TIME_EMPTY);
|
||||
let mut bpm = String::with_capacity(16);
|
||||
let _ = write!(bpm, "{}", Self::BPM_EMPTY);
|
||||
write!(bpm, "{}", Self::BPM_EMPTY);
|
||||
Self {
|
||||
beat: Memo::new(None, beat),
|
||||
time: Memo::new(None, time),
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ audio!(|self: Lv2, _client, scope|{
|
|||
audio_ins,
|
||||
audio_outs,
|
||||
lv2_features,
|
||||
lv2_instance,
|
||||
lv2_input_buffer,
|
||||
ref mut lv2_instance,
|
||||
ref mut lv2_input_buffer,
|
||||
..
|
||||
} = self;
|
||||
let urid = lv2_features.midi_urid();
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ impl PoolClipCommand {
|
|||
Ok(Self::Add { index, clip }.execute(pool)?)
|
||||
}
|
||||
|
||||
fn export (_pool: &mut Pool, _index: usize, _path: PathBuf) -> Perhaps<Self> {
|
||||
fn export (pool: &mut Pool, index: usize, path: PathBuf) -> Perhaps<Self> {
|
||||
todo!("export clip to midi file");
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ impl PoolClipCommand {
|
|||
|
||||
#[tengri_proc::command(Pool)]
|
||||
impl RenameCommand {
|
||||
fn begin (_pool: &mut Pool) -> Perhaps<Self> {
|
||||
fn begin (pool: &mut Pool) -> Perhaps<Self> {
|
||||
unreachable!();
|
||||
}
|
||||
fn cancel (pool: &mut Pool) -> Perhaps<Self> {
|
||||
|
|
@ -165,7 +165,7 @@ impl RenameCommand {
|
|||
return Ok(None)
|
||||
}
|
||||
fn confirm (pool: &mut Pool) -> Perhaps<Self> {
|
||||
if let Some(PoolMode::Rename(_clip, ref mut old_name)) = pool.mode_mut().clone() {
|
||||
if let Some(PoolMode::Rename(clip, ref mut old_name)) = pool.mode_mut().clone() {
|
||||
let old_name = old_name.clone();
|
||||
*pool.mode_mut() = None;
|
||||
return Ok(Some(Self::Set { value: old_name }))
|
||||
|
|
@ -173,7 +173,7 @@ impl RenameCommand {
|
|||
return Ok(None)
|
||||
}
|
||||
fn set (pool: &mut Pool, value: Arc<str>) -> Perhaps<Self> {
|
||||
if let Some(PoolMode::Rename(clip, ref mut _old_name)) = pool.mode_mut().clone() {
|
||||
if let Some(PoolMode::Rename(clip, ref mut old_name)) = pool.mode_mut().clone() {
|
||||
pool.clips()[clip].write().unwrap().name = value;
|
||||
}
|
||||
return Ok(None)
|
||||
|
|
@ -182,7 +182,7 @@ impl RenameCommand {
|
|||
|
||||
#[tengri_proc::command(Pool)]
|
||||
impl CropCommand {
|
||||
fn begin (_pool: &mut Pool) -> Perhaps<Self> {
|
||||
fn begin (pool: &mut Pool) -> Perhaps<Self> {
|
||||
unreachable!()
|
||||
}
|
||||
fn cancel (pool: &mut Pool) -> Perhaps<Self> {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl Sampler {
|
|||
impl SamplerCommand {
|
||||
fn record_toggle (sampler: &mut Sampler, slot: usize) -> Perhaps<Self> {
|
||||
let recording = sampler.recording.as_ref().map(|x|x.0);
|
||||
Self::record_finish(sampler)?;
|
||||
Self::record_finish(sampler);
|
||||
// autoslice: continue recording at next slot
|
||||
if recording != Some(slot) {
|
||||
Self::record_begin(sampler, slot)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ impl Sampler {
|
|||
|
||||
/// Write playing voices to output buffer
|
||||
fn populate_output_buffer (&mut self, frames: usize) {
|
||||
let Sampler { buffer, voices, output_gain, mixing_mode, .. } = self;
|
||||
let Sampler { ref mut buffer, voices, output_gain, mixing_mode, .. } = self;
|
||||
let channel_count = buffer.len();
|
||||
match mixing_mode {
|
||||
MixingMode::Summing => voices.write().unwrap().retain_mut(|voice|{
|
||||
|
|
@ -95,7 +95,7 @@ impl Sampler {
|
|||
|
||||
/// Write output buffer to output ports.
|
||||
fn write_output_buffer (&mut self, scope: &ProcessScope) {
|
||||
let Sampler { audio_outs, buffer, .. } = self;
|
||||
let Sampler { ref mut audio_outs, buffer, .. } = self;
|
||||
for (i, port) in audio_outs.iter_mut().enumerate() {
|
||||
let buffer = &buffer[i];
|
||||
for (i, value) in port.port_mut().as_mut_slice(scope).iter_mut().enumerate() {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ impl Sequencer {
|
|||
return true
|
||||
}
|
||||
// If there's a currently playing clip, output notes from it to buffer:
|
||||
if let Some(clip) = clip {
|
||||
if let Some(ref clip) = clip {
|
||||
// Source clip from which the MIDI events will be taken.
|
||||
let clip = clip.read().unwrap();
|
||||
// Clip with zero length is not processed
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ impl<'j> Jack<'j> {
|
|||
pub fn with_client <T> (&self, op: impl FnOnce(&Client)->T) -> T {
|
||||
match &*self.0.read().unwrap() {
|
||||
Inert => panic!("jack client not activated"),
|
||||
Inactive(client) => op(client),
|
||||
Inactive(ref client) => op(client),
|
||||
Activating => panic!("jack client has not finished activation"),
|
||||
Active(client) => op(client.as_client()),
|
||||
Active(ref client) => op(client.as_client()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 4c312ac8d75f9c6d1579e3882f7aba68a16a0f69
|
||||
Subproject commit d7884f6289ac6c7a88f806f4453fb7c246c87f0b
|
||||
Loading…
Add table
Add a link
Reference in a new issue