update Justfile and fix some warnings

This commit is contained in:
🪞👃🪞 2025-01-09 18:56:32 +01:00
parent 9e4406c66a
commit b995f81a26
11 changed files with 67 additions and 84 deletions

View file

@ -26,7 +26,7 @@ clock:
cargo run --bin tek -- clock cargo run --bin tek -- clock
clock-release: clock-release:
reset reset
cargo run --release --bin tek -- clock cargo run --release -- clock
arranger: arranger:
reset reset
@ -44,10 +44,10 @@ arranger-ext:
-o "4=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1" -o "4=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1"
arranger-release: arranger-release:
reset reset
cargo run --release --bin tek -- arranger cargo run --release -- arranger
arranger-release-ext: arranger-release-ext:
reset reset
cargo run --release --bin tek -- arranger -n tek \ cargo run --release -- arranger -n tek \
-i "1=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "1=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-o "1=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1" \ -o "1=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1" \
-i "2=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "2=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \
@ -59,10 +59,10 @@ arranger-release-ext:
groovebox: groovebox:
reset reset
cargo run --bin tek_groovebox -- -b 174 cargo run -- groovebox -b 174
groovebox-ext: groovebox-ext:
reset reset
cargo run --bin tek_groovebox -- -n tek \ cargo run -- groovebox -n tek \
-i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-l "Komplete Audio 6 Pro:capture_AUX1" \ -l "Komplete Audio 6 Pro:capture_AUX1" \
-r "Komplete Audio 6 Pro:capture_AUX1" \ -r "Komplete Audio 6 Pro:capture_AUX1" \
@ -70,10 +70,10 @@ groovebox-ext:
-R "Komplete Audio 6 Pro:playback_AUX1" -R "Komplete Audio 6 Pro:playback_AUX1"
groovebox-release: groovebox-release:
reset reset
cargo run --release --bin tek_groovebox cargo run --release -- groovebox
groovebox-release-ext: groovebox-release-ext:
reset reset
cargo run --release --bin tek_groovebox -- -n tek \ cargo run --release -- groovebox -n tek \
-i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-l "Komplete Audio 6 Pro:capture_AUX1" \ -l "Komplete Audio 6 Pro:capture_AUX1" \
-r "Komplete Audio 6 Pro:capture_AUX1" \ -r "Komplete Audio 6 Pro:capture_AUX1" \
@ -81,7 +81,7 @@ groovebox-release-ext:
-R "Komplete Audio 6 Pro:playback_AUX2" -R "Komplete Audio 6 Pro:playback_AUX2"
groovebox-release-ext-browser: groovebox-release-ext-browser:
reset reset
cargo run --release --bin tek_groovebox -- -n tek \ cargo run --release -- groovebox -n tek \
-b 112 \ -b 112 \
-i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-l "Firefox:output_FL" \ -l "Firefox:output_FL" \
@ -91,33 +91,27 @@ groovebox-release-ext-browser:
sequencer: sequencer:
reset reset
cargo run --bin tek_sequencer cargo run -- sequencer
sequencer-ext: sequencer-ext:
reset reset
cargo run --bin tek_sequencer -- \ cargo run -- sequencer \
-i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1" -o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1"
sequencer-release: sequencer-release:
reset reset cargo run --release -- sequencer
cargo run --release --bin tek_sequencer
sequencer-release-ext: sequencer-release-ext:
reset reset && cargo run --release -- sequencer \
cargo run --release --bin tek_sequencer -- \
-i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \
-o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1" -o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1"
mixer: mixer:
reset reset && cargo run -- mixer
cargo run --bin tek_mixer
track: track:
reset reset && cargo run -- track
cargo run --bin tek_track
sampler: sampler:
reset reset && cargo run -- sampler
cargo run --bin tek_sampler
plugin: plugin:
reset reset && cargo run -- plugin
cargo run --bin tek_plugin
edn: edn:
reset reset

View file

@ -8,9 +8,6 @@ mod edn_item; pub use self::edn_item::*;
mod edn_iter; pub use self::edn_iter::*; mod edn_iter; pub use self::edn_iter::*;
mod edn_token; pub use self::edn_token::*; mod edn_token; pub use self::edn_token::*;
#[cfg(feature = "tek_output")]
pub(crate) use ::tek_output::*;
#[cfg(test)] #[test] fn test_edn () -> Result<(), ParseError> { #[cfg(test)] #[test] fn test_edn () -> Result<(), ParseError> {
use EdnItem::*; use EdnItem::*;
assert_eq!(EdnItem::<String>::read_all("")?, assert_eq!(EdnItem::<String>::read_all("")?,

View file

@ -1,39 +1,4 @@
use crate::*; use crate::*;
pub trait Command<S>: Send + Sync + Sized {
fn execute (self, state: &mut S) -> Perhaps<Self>;
fn delegate <T> (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps<T> {
Ok(self.execute(state)?.map(wrap))
}
}
#[macro_export] macro_rules! input_to_command {
(<$($l:lifetime),+> $Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => {
impl<$($l),+> InputToCommand<$Input, $State> for $Command {
fn input_to_command ($state: &$State, $input: &$Input) -> Option<Self> {
Some($handler)
}
}
};
($Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => {
impl InputToCommand<$Input, $State> for $Command {
fn input_to_command ($state: &$State, $input: &$Input) -> Option<Self> {
Some($handler)
}
}
}
}
pub trait InputToCommand<I, S>: Command<S> + Sized {
fn input_to_command (state: &S, input: &I) -> Option<Self>;
fn execute_with_state (state: &mut S, input: &I) -> Perhaps<bool> {
Ok(if let Some(command) = Self::input_to_command(state, input) {
let _undo = command.execute(state)?;
Some(true)
} else {
None
})
}
}
#[macro_export] macro_rules! command { #[macro_export] macro_rules! command {
($(<$($l:lifetime),+>)?|$self:ident:$Command:ty,$state:ident:$State:ty|$handler:expr) => { ($(<$($l:lifetime),+>)?|$self:ident:$Command:ty,$state:ident:$State:ty|$handler:expr) => {
impl$(<$($l),+>)? Command<$State> for $Command { impl$(<$($l),+>)? Command<$State> for $Command {
@ -43,3 +8,9 @@ pub trait InputToCommand<I, S>: Command<S> + Sized {
} }
}; };
} }
pub trait Command<S>: Send + Sync + Sized {
fn execute (self, state: &mut S) -> Perhaps<Self>;
fn delegate <T> (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps<T> {
Ok(self.execute(state)?.map(wrap))
}
}

View file

@ -1,5 +1,3 @@
use crate::*;
/// Event source /// Event source
pub trait Input: Send + Sync + Sized { pub trait Input: Send + Sync + Sized {
/// Type of input event /// Type of input event

View file

@ -1,9 +1,8 @@
use crate::*;
pub struct EventMap<'a, S, I: PartialEq, C> { pub struct EventMap<'a, S, I: PartialEq, C> {
pub bindings: &'a [(I, &'a dyn Fn(&S) -> Option<C>)], pub bindings: &'a [(I, &'a dyn Fn(&S) -> Option<C>)],
pub fallback: Option<&'a dyn Fn(&S, &I) -> Option<C>> pub fallback: Option<&'a dyn Fn(&S, &I) -> Option<C>>
} }
impl<'a, S, I: PartialEq, C> EventMap<'a, S, I, C> { impl<'a, S, I: PartialEq, C> EventMap<'a, S, I, C> {
pub fn handle (&self, state: &S, input: &I) -> Option<C> { pub fn handle (&self, state: &S, input: &I) -> Option<C> {
for (binding, handler) in self.bindings.iter() { for (binding, handler) in self.bindings.iter() {

30
input/src/input.rs Normal file
View file

@ -0,0 +1,30 @@
use crate::*;
#[macro_export] macro_rules! input_to_command {
(<$($l:lifetime),+> $Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => {
impl<$($l),+> InputToCommand<$Input, $State> for $Command {
fn input_to_command ($state: &$State, $input: &$Input) -> Option<Self> {
Some($handler)
}
}
};
($Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => {
impl InputToCommand<$Input, $State> for $Command {
fn input_to_command ($state: &$State, $input: &$Input) -> Option<Self> {
Some($handler)
}
}
}
}
pub trait InputToCommand<I, S>: Command<S> + Sized {
fn input_to_command (state: &S, input: &I) -> Option<Self>;
fn execute_with_state (state: &mut S, input: &I) -> Perhaps<bool> {
Ok(if let Some(command) = Self::input_to_command(state, input) {
let _undo = command.execute(state)?;
Some(true)
} else {
None
})
}
}

View file

@ -1,9 +1,10 @@
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
//mod component; pub use self::component::*; //mod component; pub use self::component::*;
mod engine; pub use self::engine::*; mod engine; pub use self::engine::*;
mod handle; pub use self::handle::*; mod input; pub use self::input::*;
mod command; pub use self::command::*; mod handle; pub use self::handle::*;
mod command; pub use self::command::*;
mod event_map; pub use self::event_map::*; mod event_map; pub use self::event_map::*;
pub(crate) use std::marker::PhantomData; pub(crate) use std::marker::PhantomData;

View file

@ -5,9 +5,8 @@ pub use ::jack;
pub(crate) use ::jack::{ pub(crate) use ::jack::{
contrib::ClosureProcessHandler, NotificationHandler, contrib::ClosureProcessHandler, NotificationHandler,
Client, AsyncClient, ClientOptions, ClientStatus, Client, AsyncClient, ClientOptions, ClientStatus,
ProcessScope, Control, CycleTimes, Frames, ProcessScope, Control, Frames,
Port, PortId, PortSpec, Unowned, MidiIn, MidiOut, AudioIn, AudioOut, Port, PortId, PortSpec, Unowned, MidiIn, MidiOut, AudioIn, AudioOut,
Transport, TransportState, MidiIter, MidiWriter, RawMidi,
}; };
mod from_jack; pub use self::from_jack::*; mod from_jack; pub use self::from_jack::*;

View file

@ -2,11 +2,11 @@ use crate::*;
use std::marker::PhantomData; use std::marker::PhantomData;
use EdnItem::*; use EdnItem::*;
pub type EdnCallback<'a, Output, State> = pub type EdnCallback<'a, O: Output, State> =
dyn Fn(&'a State)-> RenderBox<'a, Output> + Send + Sync + 'a; dyn Fn(&'a State)-> RenderBox<'a, O> + Send + Sync + 'a;
pub type EdnRenderCallback<'a, Output, State> = pub type EdnRenderCallback<'a, O: Output, State> =
Box<EdnCallback<'a, Output, State>>; Box<EdnCallback<'a, O, State>>;
/// Provides values to the template /// Provides values to the template
pub trait EdnViewData<E: Output> { pub trait EdnViewData<E: Output> {
@ -49,11 +49,10 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
match_exp(s, &head.to_ref(), &tail) match_exp(s, &head.to_ref(), &tail)
} else { } else {
panic!("todo: add error handling to content() chain. invalid expression {e:?}"); panic!("todo: add error handling to content() chain. invalid expression {e:?}");
().boxed()
}, },
}, },
Self::Err(error) => { Self::Err(_error) => {
Box::new(())//&format!("EdnView error: {error:?}")) Box::new(())//&format!("EdnView error: {error:?}")) // FIXME: String is not Render
}, },
_ => todo!() _ => todo!()
} }

View file

@ -1,3 +1,4 @@
//#![feature(lazy_type_alias)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_assoc_type)] #![feature(impl_trait_in_assoc_type)]
@ -29,10 +30,10 @@ pub(crate) use std::marker::PhantomData;
pub(crate) use std::error::Error; pub(crate) use std::error::Error;
/// Standard result type. /// Standard result type.
pub(crate) type Usually<T> = Result<T, Box<dyn Error>>; pub type Usually<T> = Result<T, Box<dyn Error>>;
/// Standard optional result type. /// Standard optional result type.
pub(crate) type Perhaps<T> = Result<Option<T>, Box<dyn Error>>; pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
#[cfg(test)] #[test] fn test_layout () -> Usually<()> { #[cfg(test)] #[test] fn test_layout () -> Usually<()> {
use ::tek_tui::Tui; use ::tek_tui::Tui;

View file

@ -27,12 +27,6 @@ pub(crate) use std::error::Error;
pub(crate) use std::path::PathBuf; pub(crate) use std::path::PathBuf;
pub(crate) use std::ffi::OsString; pub(crate) use std::ffi::OsString;
/// Standard result type.
pub type Usually<T> = Result<T, Box<dyn Error>>;
/// Standard optional result type.
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
/// Prototypal case of implementor macro. /// Prototypal case of implementor macro.
/// Saves 4loc per data pats. /// Saves 4loc per data pats.
#[macro_export] macro_rules! from { #[macro_export] macro_rules! from {