invoke timebase callback, persists state but doesn't seem to do anything

This commit is contained in:
🪞👃🪞 2024-12-29 00:52:20 +01:00
parent ae69e87dc9
commit 003329aa1b
10 changed files with 350 additions and 329 deletions

View file

@ -45,8 +45,20 @@ impl GrooveboxCli {
jack.connect_audio_to(&app.sampler.audio_outs[1], &self.r_to)?;
if self.sync {
jack.read().unwrap().client().register_timebase_callback(false, |bbt, state, nframes, new_pos|{
println!("\r{state:?} {nframes} {new_pos}");
// TODO
if new_pos {
let ppq = bbt.ticks_per_beat;
let pulse = bbt.bar as f64 * 4. * ppq + bbt.beat as f64 * ppq + bbt.tick as f64;
app.clock().playhead.update_from_pulse(pulse)
} else {
let pulse = app.clock().playhead.pulse.get();
let ppq = app.clock().timebase.ppq.get();
let bpm = app.clock().timebase.bpm.get();
bbt.bar = (pulse / ppq) as usize / 4;
bbt.beat = (pulse / ppq) as usize % 4;
bbt.tick = (pulse % ppq) as usize;
bbt.ticks_per_beat = ppq;
bbt.bpm = bpm;
}
})?
}
Ok(app)