mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
implement sync_lead and sync_follow flags for groovebox
This commit is contained in:
parent
b96fa34702
commit
b78b55faa2
2 changed files with 20 additions and 12 deletions
|
|
@ -5,31 +5,34 @@ pub fn main () -> Usually<()> { GrooveboxCli::parse().run() }
|
||||||
pub struct GrooveboxCli {
|
pub struct GrooveboxCli {
|
||||||
/// Name of JACK client
|
/// Name of JACK client
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
/// Whether to include a transport toolbar (default: true)
|
/// Whether to include a transport toolbar (default: true)
|
||||||
#[arg(short, long, default_value_t = true)]
|
#[arg(short, long, default_value_t = true)]
|
||||||
transport: bool,
|
transport: bool,
|
||||||
/// Whether to attempt to become transport master
|
/// Whether to attempt to become transport master
|
||||||
#[arg(short, long, default_value_t = true)]
|
#[arg(short='S', long, default_value_t = false)]
|
||||||
sync: bool,
|
sync_lead: bool,
|
||||||
|
/// Whether to attempt to become transport master
|
||||||
|
#[arg(short='s', long, default_value_t = true)]
|
||||||
|
sync_follow: bool,
|
||||||
/// MIDI outs to connect to MIDI input
|
/// MIDI outs to connect to MIDI input
|
||||||
#[arg(short='i', long)]
|
#[arg(short='i', long)]
|
||||||
midi_from: Vec<String>,
|
midi_from: Vec<String>,
|
||||||
/// MIDI ins to connect from MIDI output
|
/// MIDI ins to connect from MIDI output
|
||||||
#[arg(short='o', long)]
|
#[arg(short='o', long)]
|
||||||
midi_to: Vec<String>,
|
midi_to: Vec<String>,
|
||||||
/// Audio outs to connect to left input
|
/// Audio outs to connect to left input
|
||||||
#[arg(short='l', long)]
|
#[arg(short='l', long)]
|
||||||
l_from: Vec<String>,
|
l_from: Vec<String>,
|
||||||
/// Audio outs to connect to right input
|
/// Audio outs to connect to right input
|
||||||
#[arg(short='r', long)]
|
#[arg(short='r', long)]
|
||||||
r_from: Vec<String>,
|
r_from: Vec<String>,
|
||||||
/// Audio ins to connect from left output
|
/// Audio ins to connect from left output
|
||||||
#[arg(short='L', long)]
|
#[arg(short='L', long)]
|
||||||
l_to: Vec<String>,
|
l_to: Vec<String>,
|
||||||
/// Audio ins to connect from right output
|
/// Audio ins to connect from right output
|
||||||
#[arg(short='R', long)]
|
#[arg(short='R', long)]
|
||||||
r_to: Vec<String>,
|
r_to: Vec<String>,
|
||||||
}
|
}
|
||||||
impl GrooveboxCli {
|
impl GrooveboxCli {
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
|
|
@ -43,12 +46,17 @@ impl GrooveboxCli {
|
||||||
jack.connect_audio_from(&app.sampler.audio_ins[1], &self.r_from)?;
|
jack.connect_audio_from(&app.sampler.audio_ins[1], &self.r_from)?;
|
||||||
jack.connect_audio_to(&app.sampler.audio_outs[0], &self.l_to)?;
|
jack.connect_audio_to(&app.sampler.audio_outs[0], &self.l_to)?;
|
||||||
jack.connect_audio_to(&app.sampler.audio_outs[1], &self.r_to)?;
|
jack.connect_audio_to(&app.sampler.audio_outs[1], &self.r_to)?;
|
||||||
if self.sync {
|
if self.sync_lead {
|
||||||
jack.read().unwrap().client().register_timebase_callback(false, |mut state|{
|
jack.read().unwrap().client().register_timebase_callback(false, |mut state|{
|
||||||
app.clock().playhead.update_from_sample(state.position.frame() as f64);
|
app.clock().playhead.update_from_sample(state.position.frame() as f64);
|
||||||
state.position.bbt = Some(app.clock().bbt());
|
state.position.bbt = Some(app.clock().bbt());
|
||||||
state.position
|
state.position
|
||||||
})?
|
})?
|
||||||
|
} else if self.sync_follow {
|
||||||
|
jack.read().unwrap().client().register_timebase_callback(false, |state|{
|
||||||
|
app.clock().playhead.update_from_sample(state.position.frame() as f64);
|
||||||
|
state.position
|
||||||
|
})?
|
||||||
}
|
}
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})?)?;
|
})?)?;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 76f4bef07e3f9115e8efba0bc053a9bad7e25a19
|
Subproject commit d09788959fe1cc937b27e8bfb2b695f84b406885
|
||||||
Loading…
Add table
Add a link
Reference in a new issue