wip: now following transport position

This commit is contained in:
🪞👃🪞 2024-12-29 13:54:56 +01:00
parent e5ec4ded31
commit cfbb9722af
2 changed files with 19 additions and 12 deletions

View file

@ -44,21 +44,28 @@ impl GrooveboxCli {
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 {
jack.read().unwrap().client().register_timebase_callback(false, |bbt, state, nframes, new_pos|{ jack.read().unwrap().client().register_timebase_callback(false, |state|{
let ::jack::contrib::TimebaseInfo { state, new_pos, nframes, mut position } = state;
if new_pos { if new_pos {
let ppq = bbt.ticks_per_beat; app.clock().playhead.update_from_sample(position.frame() as f64)
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 { } else {
let pulse = app.clock().playhead.pulse.get(); println!("\n\r{state:?} {new_pos} {nframes} {position:?}");
let ppq = app.clock().timebase.ppq.get(); 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(); let bpm = app.clock().timebase.bpm.get();
bbt.bar = (pulse / ppq) as usize / 4; position.bbt = Some(::jack::contrib::PositionBBT {
bbt.beat = (pulse / ppq) as usize % 4; bar: 1 + (pulse / ppq) / 4,
bbt.tick = (pulse % ppq) as usize; beat: 1 + (pulse / ppq) % 4,
bbt.ticks_per_beat = ppq; tick: (pulse % ppq),
bbt.bpm = bpm; 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
})? })?
} }
Ok(app) Ok(app)

@ -1 +1 @@
Subproject commit 9a94493e6efffd2137a5c7f54baa85e42d12a13f Subproject commit de9a6b4e46c403b08703b272b5b2ee353aa6cb53