mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: now following transport position
This commit is contained in:
parent
e5ec4ded31
commit
cfbb9722af
2 changed files with 19 additions and 12 deletions
|
|
@ -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[1], &self.r_to)?;
|
||||
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 {
|
||||
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)
|
||||
app.clock().playhead.update_from_sample(position.frame() as f64)
|
||||
} else {
|
||||
let pulse = app.clock().playhead.pulse.get();
|
||||
let ppq = app.clock().timebase.ppq.get();
|
||||
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();
|
||||
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;
|
||||
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
|
||||
})?
|
||||
}
|
||||
Ok(app)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9a94493e6efffd2137a5c7f54baa85e42d12a13f
|
||||
Subproject commit de9a6b4e46c403b08703b272b5b2ee353aa6cb53
|
||||
Loading…
Add table
Add a link
Reference in a new issue