unify default configs
Some checks failed
/ build (push) Has been cancelled

the definitions are unified alright. it's just not supported yet :D

the idea being that tek offers to write out the default configs to
~/.config/tek-v0 where the user can customize them.
This commit is contained in:
🪞👃🪞 2025-07-30 19:12:45 +03:00
parent 9e147cda69
commit 3c8616deba
43 changed files with 441 additions and 465 deletions

View file

@ -13,7 +13,7 @@ pub struct Cli {
/// Pre-defined configuration modes.
///
/// TODO: Replace these with scripted configurations.
#[command(subcommand)] mode: LaunchMode,
#[command(subcommand)] mode: Option<LaunchMode>,
/// Name of JACK client
#[arg(short='n', long)] name: Option<String>,
/// Whether to attempt to become transport master
@ -45,29 +45,8 @@ pub struct Cli {
/// Application modes
#[derive(Debug, Clone, Subcommand)]
pub enum LaunchMode {
/// ⏯️ A standalone transport clock.
Clock,
/// 🎼 A MIDI sequencer.
Sequencer,
/// 🎺 A MIDI-controlled audio sampler.
Sampler,
/// 📻 Sequencer and sampler together.
Groovebox,
/// 🎧 Multi-track MIDI sequencer.
Arranger {
/// Number of scenes
#[arg(short = 'y', long, default_value_t = 16)] scenes: usize,
/// Number of tracks
#[arg(short = 'x', long, default_value_t = 12)] tracks: usize,
/// Width of tracks
#[arg(short = 'w', long, default_value_t = 15)] track_width: usize,
},
/// TODO: A MIDI-controlled audio mixer
Mixer,
/// TODO: A customizable channel strip
Track,
/// TODO: An audio plugin host
Plugin,
/// Create a new session instead of loading the previous one.
New,
}
impl Cli {
@ -86,9 +65,6 @@ impl Cli {
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 clip = Arc::new(RwLock::new(MidiClip::new(
"Clip", true, 384usize, None, Some(ItemColor::random().into())),
));
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()])?);
@ -96,34 +72,12 @@ impl Cli {
for (index, connect) in midi_tos.iter().enumerate() {
midi_outs.push(jack.midi_out(&format!("{index}/M"), &[connect.clone()])?);
};
let config = Configuration::from_path(&match self.mode {
LaunchMode::Clock => "config/config_transport.edn",
LaunchMode::Sequencer => "config/config_sequencer.edn",
LaunchMode::Groovebox => "config/config_groovebox.edn",
LaunchMode::Arranger { .. } => "config/config_arranger.edn",
LaunchMode::Sampler => "config/config_sampler.edn",
_ => todo!("{:?}", self.mode),
}, false)?;
let configs = Configurations::init();
let clock = Clock::new(&jack, self.bpm)?;
match self.mode {
LaunchMode::Sequencer => tracks.push(Track::new(
&name, None, &jack, Some(&clock), Some(&clip),
midi_froms.as_slice(), midi_tos.as_slice()
)?),
LaunchMode::Groovebox | LaunchMode::Sampler => tracks.push(Track::new_with_sampler(
&name, None, &jack, Some(&clock), Some(&clip),
midi_froms.as_slice(), midi_tos.as_slice(), audio_froms, audio_tos,
)?),
_ => {}
}
let mut app = App {
jack: jack.clone(),
config,
color: ItemTheme::random(),
pool: match self.mode {
LaunchMode::Sequencer | LaunchMode::Groovebox => (&clip).into(),
_ => Default::default()
},
jack: jack.clone(),
configs: Configurations::init()?,
color: ItemTheme::random(),
project: Arrangement {
name: Default::default(),
color: ItemTheme::random(),
@ -134,20 +88,16 @@ impl Cli {
selection: Selection::TrackClip { track: 0, scene: 0 },
midi_ins,
midi_outs,
editor: match self.mode {
LaunchMode::Sequencer | LaunchMode::Groovebox => Some((&clip).into()),
_ => None
},
..Default::default()
},
..Default::default()
};
if let LaunchMode::Arranger { scenes, tracks, track_width, .. } = self.mode {
app.project.arranger = Default::default();
app.project.selection = Selection::TrackClip { track: 1, scene: 1 };
app.project.scenes_add(scenes)?;
app.project.tracks_add(tracks, Some(track_width), &[], &[])?;
}
//if let LaunchMode::Arranger { scenes, tracks, track_width, .. } = self.mode {
//app.project.arranger = Default::default();
//app.project.selection = Selection::TrackClip { track: 1, scene: 1 };
//app.project.scenes_add(scenes)?;
//app.project.tracks_add(tracks, Some(track_width), &[], &[])?;
//}
jack.sync_lead(self.sync_lead, |mut state|{
let clock = app.clock();
clock.playhead.update_from_sample(state.position.frame() as f64);
@ -162,10 +112,12 @@ impl Cli {
/// CLI header
const HEADER: &'static str = r#"
"#;
~ ~~~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~~~~~
~ ~ ~ ~< ~ v0.3.0-rc.0 "no, i insist that i am not a dj ~
~ ~ ~ ~ 2025, summer, the nose of the cat. J ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On first run, Tek will create configuration and state dirs. ~
On subsequent runs, Tek should resume from where you left off. ~"#;
#[cfg(test)] #[test] fn test_cli () {
use clap::CommandFactory;