wip: remudolarize 4

This commit is contained in:
🪞👃🪞 2025-01-08 19:56:31 +01:00
parent 0d9a4d4830
commit e8430c373f
46 changed files with 175 additions and 63 deletions

115
Cargo.lock generated
View file

@ -23,6 +23,55 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "approx" name = "approx"
version = "0.5.1" version = "0.5.1"
@ -132,6 +181,46 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]] [[package]]
name = "clojure-reader" name = "clojure-reader"
version = "0.3.0" version = "0.3.0"
@ -141,6 +230,12 @@ dependencies = [
"ordered-float", "ordered-float",
] ]
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]] [[package]]
name = "compact_str" name = "compact_str"
version = "0.8.1" version = "0.8.1"
@ -414,6 +509,12 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.13.0" version = "0.13.0"
@ -1320,6 +1421,14 @@ dependencies = [
"wavers", "wavers",
] ]
[[package]]
name = "tek_cli"
version = "0.2.0"
dependencies = [
"clap",
"tek",
]
[[package]] [[package]]
name = "tek_edn" name = "tek_edn"
version = "0.1.0" version = "0.1.0"
@ -1487,6 +1596,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.11.0" version = "1.11.0"

View file

@ -1,30 +1,8 @@
[package] [package]
name = "tek" name = "tek_cli"
edition = "2021" edition = "2021"
version = "0.2.0" version = "0.2.0"
[dependencies] [dependencies]
tek_tui = { path = "./tui" } tek = { path = "./tek" }
tek_jack = { path = "./jack" } clap = { version = "4.5.4", features = [ "derive" ] }
tek_time = { path = "./time" }
tek_midi = { path = "./midi" }
backtrace = "0.3.72"
livi = "0.7.4"
palette = { version = "0.7.6", features = [ "random" ] }
rand = "0.8.5"
symphonia = { version = "0.5.4", features = [ "all" ] }
toml = "0.8.12"
wavers = "1.4.3"
#once_cell = "1.19.0"
#no_deadlocks = "1.3.2"
#suil-rs = { path = "../suil" }
#vst = "0.4.0"
#vst3 = "0.1.0"
#winit = { version = "0.30.4", features = [ "x11" ] }
[features]
default = []
[profile.release]
lto = true

View file

@ -1,8 +0,0 @@
[package]
name = "tek_cli"
edition = "2021"
version = "0.2.0"
[dependencies]
tek = { path = ".." }
clap = { version = "4.5.4", features = [ "derive" ] }

View file

@ -1,3 +1,4 @@
use std::sync::{Arc, RwLock};
use tek::*; use tek::*;
#[allow(unused_imports)] use clap::{self, Parser, Subcommand, ValueEnum}; #[allow(unused_imports)] use clap::{self, Parser, Subcommand, ValueEnum};
@ -92,24 +93,23 @@ pub enum TekMode {
/// Application entrypoint. /// Application entrypoint.
pub fn main () -> Usually<()> { pub fn main () -> Usually<()> {
use TekMode::*;
let cli = TekCli::parse(); let cli = TekCli::parse();
let name = cli.name.as_ref().map_or("tek", |x|x.as_str()); let name = cli.name.as_ref().map_or("tek", |x|x.as_str());
let jack = JackConnection::new(name)?; let jack = JackConnection::new(name)?;
let engine = Tui::new()?; let engine = Tui::new()?;
Ok(match cli.mode { Ok(match cli.mode {
Clock => engine.run(&jack.activate_with(|jack|Ok(crate::TransportTui { TekMode::Clock => engine.run(&jack.activate_with(|jack|Ok(TransportTui {
clock: crate::Clock::from(jack), clock: Clock::from(jack),
jack: jack.clone() jack: jack.clone()
}))?)?, }))?)?,
Sequencer { TekMode::Sequencer {
midi_from, midi_from,
midi_to, .. midi_to, ..
} => engine.run(&jack.activate_with(|jack|Ok({ } => engine.run(&jack.activate_with(|jack|Ok({
let clock = crate::Clock::from(jack); let clock = Clock::from(jack);
let phrase = Arc::new(RwLock::new(crate::MidiClip::new( let phrase = Arc::new(RwLock::new(MidiClip::new(
"Clip", true, 4 * clock.timebase.ppq.get() as usize, "Clip", true, 4 * clock.timebase.ppq.get() as usize,
None, Some(ItemColor::random().into()) None, Some(ItemColor::random().into())
))); )));
@ -117,11 +117,11 @@ pub fn main () -> Usually<()> {
connect_from(&jack, &midi_in, &midi_from)?; connect_from(&jack, &midi_in, &midi_from)?;
let midi_out = jack.read().unwrap().register_port("o", MidiOut::default())?; let midi_out = jack.read().unwrap().register_port("o", MidiOut::default())?;
connect_to(&jack, &midi_out, &midi_to)?; connect_to(&jack, &midi_out, &midi_to)?;
crate::Sequencer { Sequencer {
_jack: jack.clone(), _jack: jack.clone(),
pool: PoolModel::from(&phrase), pool: PoolModel::from(&phrase),
editor: crate::MidiEditor::from(&phrase), editor: MidiEditor::from(&phrase),
player: crate::MidiPlayer::new(&clock, &phrase, &[midi_in], &[midi_out])?, player: MidiPlayer::new(&clock, &phrase, &[midi_in], &[midi_out])?,
compact: true, compact: true,
transport: true, transport: true,
selectors: true, selectors: true,
@ -134,10 +134,10 @@ pub fn main () -> Usually<()> {
} }
}))?)?, }))?)?,
Sampler { TekMode::Sampler {
midi_from, l_from, r_from, l_to, r_to, .. midi_from, l_from, r_from, l_to, r_to, ..
} => engine.run(&jack.activate_with(|jack|Ok( } => engine.run(&jack.activate_with(|jack|Ok(
tek::SamplerTui { SamplerTui {
cursor: (0, 0), cursor: (0, 0),
editing: None, editing: None,
mode: None, mode: None,
@ -145,7 +145,7 @@ pub fn main () -> Usually<()> {
note_lo: 36.into(), note_lo: 36.into(),
note_pt: 36.into(), note_pt: 36.into(),
color: ItemPalette::from(Color::Rgb(64, 128, 32)), color: ItemPalette::from(Color::Rgb(64, 128, 32)),
state: tek::Sampler::new(jack, &"sampler", state: Sampler::new(jack, &"sampler",
&midi_from, &midi_from,
&[&l_from, &r_from], &[&l_from, &r_from],
&[&l_to, &r_to], &[&l_to, &r_to],
@ -153,19 +153,19 @@ pub fn main () -> Usually<()> {
} }
))?)?, ))?)?,
Groovebox { TekMode::Groovebox {
midi_from, midi_to, l_from, r_from, l_to, r_to, .. midi_from, midi_to, l_from, r_from, l_to, r_to, ..
} => engine.run(&jack.activate_with(|jack|Ok({ } => engine.run(&jack.activate_with(|jack|Ok({
let phrase = Arc::new(RwLock::new(MidiClip::new( let phrase = Arc::new(RwLock::new(MidiClip::new(
"Clip", true, 4 * player.clock.timebase.ppq.get() as usize, "Clip", true, 4 * player.clock.timebase.ppq.get() as usize,
None, Some(ItemColor::random().into()) None, Some(ItemColor::random().into())
))); )));
let mut player = crate::midi::MidiPlayer::new(jack, &"sequencer", Some(&phrase), let mut player = MidiPlayer::new(jack, &"sequencer", Some(&phrase),
&midi_from, &midi_from,
&midi_to &midi_to
)?; )?;
player.play_phrase = Some((Moment::zero(&player.clock.timebase), Some(phrase.clone()))); player.play_phrase = Some((Moment::zero(&player.clock.timebase), Some(phrase.clone())));
let sampler = crate::sampler::Sampler::new(jack, &"sampler", let sampler = Sampler::new(jack, &"sampler",
midi_from, midi_from,
&[l_from, r_from], &[l_from, r_from],
&[l_to, r_to ], &[l_to, r_to ],
@ -174,7 +174,7 @@ pub fn main () -> Usually<()> {
&player.midi_outs[0], &player.midi_outs[0],
&sampler.midi_in &sampler.midi_in
)?; )?;
let app = tek::Groovebox { let app = Groovebox {
player, player,
sampler, sampler,
_jack: jack.clone(), _jack: jack.clone(),
@ -189,13 +189,6 @@ pub fn main () -> Usually<()> {
note_buf: vec![], note_buf: vec![],
perf: PerfModel::default(), perf: PerfModel::default(),
}; };
let app = tek::Groovebox::new(
jack,
&midi_from, &midi_to,
&[&l_from, &r_from],
&[&l_to, &r_to],
)?;
if let Some(bpm) = cli.bpm { if let Some(bpm) = cli.bpm {
app.clock().timebase.bpm.set(bpm); app.clock().timebase.bpm.set(bpm);
} }
@ -214,10 +207,10 @@ pub fn main () -> Usually<()> {
app app
}))?)?, }))?)?,
Arranger { TekMode::Arranger {
scenes, tracks, track_width, midi_from, midi_to, .. scenes, tracks, track_width, midi_from, midi_to, ..
} => engine.run(&jack.activate_with(|jack|Ok({ } => engine.run(&jack.activate_with(|jack|Ok({
let mut app = crate::Arranger::new(jack); let mut app = Arranger::new(jack);
app.tracks_add(tracks, track_width, midi_from.as_slice(), midi_to.as_slice())?; app.tracks_add(tracks, track_width, midi_from.as_slice(), midi_to.as_slice())?;
app.scenes_add(scenes)?; app.scenes_add(scenes)?;
app app

30
tek/Cargo.toml Normal file
View file

@ -0,0 +1,30 @@
[package]
name = "tek"
edition = "2021"
version = "0.2.0"
[dependencies]
tek_tui = { path = "../tui" }
tek_jack = { path = "../jack" }
tek_time = { path = "../time" }
tek_midi = { path = "../midi" }
backtrace = "0.3.72"
livi = "0.7.4"
palette = { version = "0.7.6", features = [ "random" ] }
rand = "0.8.5"
symphonia = { version = "0.5.4", features = [ "all" ] }
toml = "0.8.12"
wavers = "1.4.3"
#once_cell = "1.19.0"
#no_deadlocks = "1.3.2"
#suil-rs = { path = "../suil" }
#vst = "0.4.0"
#vst3 = "0.1.0"
#winit = { version = "0.30.4", features = [ "x11" ] }
[features]
default = []
[profile.release]
lto = true

View file

@ -5,6 +5,11 @@
#![feature(impl_trait_in_assoc_type)] #![feature(impl_trait_in_assoc_type)]
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
/// Standard result type.
pub type Usually<T> = std::result::Result<T, Box<dyn Error>>;
/// Standard optional result type.
pub type Perhaps<T> = std::result::Result<Option<T>, Box<dyn Error>>;
pub mod arranger; pub use self::arranger::*; pub mod arranger; pub use self::arranger::*;
pub mod groovebox; pub use self::groovebox::*; pub mod groovebox; pub use self::groovebox::*;
pub mod meter; pub use self::meter::*; pub mod meter; pub use self::meter::*;
@ -14,11 +19,10 @@ pub mod pool; pub use self::pool::*;
pub mod sampler; pub use self::sampler::*; pub mod sampler; pub use self::sampler::*;
pub mod sequencer; pub use self::sequencer::*; pub mod sequencer; pub use self::sequencer::*;
pub use ::tek_time; pub(crate) use ::tek_time::*; pub use ::tek_time; pub use ::tek_time::*;
pub use ::tek_jack; pub(crate) use ::tek_jack::{*, jack::{*, contrib::*}}; pub use ::tek_jack; pub use ::tek_jack::{*, jack::{*, contrib::*}};
pub use ::tek_midi; pub(crate) use ::tek_midi::{*, midly::{*, num::*, live::*}}; pub use ::tek_midi; pub use ::tek_midi::{*, midly::{*, num::*, live::*}};
pub use ::tek_tui::{self, tek_edn, tek_input, tek_output}; pub use ::tek_tui::{
pub(crate) use ::tek_tui::{
*, *,
tek_edn::*, tek_edn::*,
tek_input::*, tek_input::*,