mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56: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 {
|
||||
/// Name of JACK client
|
||||
#[arg(short, long)]
|
||||
name: Option<String>,
|
||||
name: Option<String>,
|
||||
/// Whether to include a transport toolbar (default: true)
|
||||
#[arg(short, long, default_value_t = true)]
|
||||
transport: bool,
|
||||
transport: bool,
|
||||
/// Whether to attempt to become transport master
|
||||
#[arg(short, long, default_value_t = true)]
|
||||
sync: bool,
|
||||
#[arg(short='S', long, default_value_t = false)]
|
||||
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
|
||||
#[arg(short='i', long)]
|
||||
midi_from: Vec<String>,
|
||||
midi_from: Vec<String>,
|
||||
/// MIDI ins to connect from MIDI output
|
||||
#[arg(short='o', long)]
|
||||
midi_to: Vec<String>,
|
||||
midi_to: Vec<String>,
|
||||
/// Audio outs to connect to left input
|
||||
#[arg(short='l', long)]
|
||||
l_from: Vec<String>,
|
||||
l_from: Vec<String>,
|
||||
/// Audio outs to connect to right input
|
||||
#[arg(short='r', long)]
|
||||
r_from: Vec<String>,
|
||||
r_from: Vec<String>,
|
||||
/// Audio ins to connect from left output
|
||||
#[arg(short='L', long)]
|
||||
l_to: Vec<String>,
|
||||
l_to: Vec<String>,
|
||||
/// Audio ins to connect from right output
|
||||
#[arg(short='R', long)]
|
||||
r_to: Vec<String>,
|
||||
r_to: Vec<String>,
|
||||
}
|
||||
impl GrooveboxCli {
|
||||
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_to(&app.sampler.audio_outs[0], &self.l_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|{
|
||||
app.clock().playhead.update_from_sample(state.position.frame() as f64);
|
||||
state.position.bbt = Some(app.clock().bbt());
|
||||
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)
|
||||
})?)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue