wip: still trying to retain correct position

This commit is contained in:
🪞👃🪞 2024-12-29 15:11:06 +01:00
parent cfbb9722af
commit 29db79f806
3 changed files with 21 additions and 17 deletions

View file

@ -46,24 +46,11 @@ impl GrooveboxCli {
if self.sync {
jack.read().unwrap().client().register_timebase_callback(false, |state|{
let ::jack::contrib::TimebaseInfo { state, new_pos, nframes, mut position } = state;
println!("\n\r{state:?} {new_pos} {nframes} {position:?}");
position.bbt = Some(app.clock().bbt());
println!("\r{:?}", position.bbt);
if new_pos {
app.clock().playhead.update_from_sample(position.frame() as f64)
} else {
println!("\n\r{state:?} {new_pos} {nframes} {position:?}");
let pulse = app.clock().playhead.pulse.get() as i32;
let ppq = app.clock().timebase.ppq.get() as i32;
let bpm = app.clock().timebase.bpm.get();
position.bbt = Some(::jack::contrib::PositionBBT {
bar: 1 + (pulse / ppq) / 4,
beat: 1 + (pulse / ppq) % 4,
tick: (pulse % ppq),
bar_start_tick: 0.,
beat_type: 4.,
beats_per_bar: 4.,
beats_per_minute: bpm,
ticks_per_beat: ppq as f64
});
println!("\n\r{:?}", position.bbt);
}
position
})?