diff --git a/bin/cli_arranger.rs b/bin/cli_arranger.rs index e275ff09..a29651e0 100644 --- a/bin/cli_arranger.rs +++ b/bin/cli_arranger.rs @@ -34,11 +34,8 @@ pub struct ArrangerCli { impl ArrangerCli { /// Run the arranger TUI from CLI arguments. fn run (&self) -> Usually<()> { - let mut client_name = String::from("tek_arranger"); - if let Some(name) = self.name.as_ref() { - client_name = name.clone(); - } - Tui::run(JackConnection::new(client_name.as_str())?.activate_with(|jack|{ + let name = self.name.as_deref().unwrap_or("tek_arranger"); + Tui::run(JackConnection::new(name)?.activate_with(|jack|{ let mut app = ArrangerTui::try_from(jack)?; let jack = jack.read().unwrap(); app.color = ItemPalette::random(); diff --git a/bin/cli_groovebox.rs b/bin/cli_groovebox.rs index facd66c9..a946e376 100644 --- a/bin/cli_groovebox.rs +++ b/bin/cli_groovebox.rs @@ -36,8 +36,9 @@ pub struct GrooveboxCli { } impl GrooveboxCli { fn run (&self) -> Usually<()> { - Tui::run(JackConnection::new("tek_groovebox")?.activate_with(|jack|{ - let app = tek::GrooveboxTui::new( + let name = self.name.as_deref().unwrap_or("tek_groovebox"); + Tui::run(JackConnection::new(name)?.activate_with(|jack|{ + let app = tek::Groovebox::new( jack, &self.midi_from.as_slice(), &self.midi_to.as_slice(), diff --git a/bin/cli_sampler.rs b/bin/cli_sampler.rs index 262e40c5..278ee8b0 100644 --- a/bin/cli_sampler.rs +++ b/bin/cli_sampler.rs @@ -23,7 +23,8 @@ pub fn main () -> Usually<()> { SamplerCli::parse().run() } } impl SamplerCli { fn run (&self) -> Usually<()> { - Tui::run(JackConnection::new("tek_sampler")?.activate_with(|jack|{ + let name = self.name.as_deref().unwrap_or("tek_sampler"); + Tui::run(JackConnection::new(name)?.activate_with(|jack|{ Ok(tek::SamplerTui { cursor: (0, 0), editing: None, diff --git a/bin/cli_transport.rs b/bin/cli_transport.rs index bb2e56b6..fead5a05 100644 --- a/bin/cli_transport.rs +++ b/bin/cli_transport.rs @@ -2,7 +2,8 @@ include!("./lib.rs"); /// Application entrypoint. pub fn main () -> Usually<()> { - Tui::run(JackConnection::new("tek_transport")?.activate_with(|jack|{ + let name = self.name.as_deref().unwrap_or("tek_transport"); + Tui::run(JackConnection::new(name)?.activate_with(|jack|{ TransportTui::try_from(jack) })?)?; Ok(()) diff --git a/src/groovebox.rs b/src/groovebox.rs index ce802986..29498f7a 100644 --- a/src/groovebox.rs +++ b/src/groovebox.rs @@ -6,7 +6,7 @@ use GrooveboxCommand::*; use PhraseCommand::*; use PhrasePoolCommand::*; -pub struct GrooveboxTui { +pub struct Groovebox { _jack: Arc>, pub player: MidiPlayer, @@ -20,7 +20,7 @@ pub struct GrooveboxTui { pub midi_buf: Vec>>, pub perf: PerfModel, } -impl GrooveboxTui { +impl Groovebox { pub fn new ( jack: &Arc>, midi_from: &[impl AsRef], @@ -64,8 +64,8 @@ impl GrooveboxTui { }) } } -has_clock!(|self: GrooveboxTui|self.player.clock()); -audio!(|self: GrooveboxTui, client, scope|{ +has_clock!(|self: Groovebox|self.player.clock()); +audio!(|self: Groovebox, client, scope|{ let t0 = self.perf.get_t0(); if Control::Quit == ClockAudio(&mut self.player).process(client, scope) { return Control::Quit @@ -111,7 +111,7 @@ audio!(|self: GrooveboxTui, client, scope|{ self.perf.update(t0, scope); Control::Continue }); -render!(|self:GrooveboxTui|{ +render!(|self:Groovebox|{ let w = self.size.w(); let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 }; let pool_w = if self.pool.visible { phrase_w } else { 0 }; @@ -165,7 +165,7 @@ render!(|self:GrooveboxTui|{ ])) }); -struct GrooveboxSamples<'a>(&'a GrooveboxTui); +struct GrooveboxSamples<'a>(&'a Groovebox); render!(|self: GrooveboxSamples<'a>|{ let note_lo = self.0.editor.note_lo().load(Relaxed); let note_pt = self.0.editor.note_point(); @@ -198,9 +198,9 @@ pub enum GrooveboxCommand { Sampler(SamplerCommand), } -handle!(|self: GrooveboxTui, input|GrooveboxCommand::execute_with_state(self, input)); +handle!(|self: Groovebox, input|GrooveboxCommand::execute_with_state(self, input)); -input_to_command!(GrooveboxCommand: |state: GrooveboxTui, input|match input.event() { +input_to_command!(GrooveboxCommand: |state: Groovebox, input|match input.event() { // TODO: k: toggle on-screen keyboard key_pat!(Ctrl-Char('k')) => { todo!("keyboard") @@ -249,7 +249,7 @@ input_to_command!(GrooveboxCommand: |state: GrooveboxTui, input|match input } }); -command!(|self:GrooveboxCommand,state:GrooveboxTui|match self { +command!(|self: GrooveboxCommand, state: Groovebox|match self { Self::Pool(cmd) => { let mut default = |cmd: PoolCommand|cmd .execute(&mut state.pool) diff --git a/src/lib.rs b/src/lib.rs index 31bf316b..f274eed6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,7 @@ pub mod plugin; pub(crate) use self::plugin::*; pub use self::plugin::*; pub mod groovebox; pub(crate) use self::groovebox::*; -pub use self::groovebox::GrooveboxTui; +pub use self::groovebox::Groovebox; pub mod pool; pub(crate) use self::pool::*; pub use self::pool::PoolModel; diff --git a/src/status/status_groovebox.rs b/src/status/status_groovebox.rs index a10b9b92..5fe29457 100644 --- a/src/status/status_groovebox.rs +++ b/src/status/status_groovebox.rs @@ -8,7 +8,7 @@ pub struct GrooveboxStatus { pub(crate) size: String, pub(crate) playing: bool, } -from!(|state:&GrooveboxTui|GrooveboxStatus = { +from!(|state: &Groovebox|GrooveboxStatus = { let samples = state.clock().chunk.load(Relaxed); let rate = state.clock().timebase.sr.get(); let buffer = samples as f64 / rate;