mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: still trying to retain correct position
This commit is contained in:
parent
cfbb9722af
commit
29db79f806
3 changed files with 21 additions and 17 deletions
|
|
@ -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
|
||||
})?
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit de9a6b4e46c403b08703b272b5b2ee353aa6cb53
|
||||
Subproject commit cfd2a62e959f2a0f5569a129790cfdb316570a7f
|
||||
17
src/time.rs
17
src/time.rs
|
|
@ -199,6 +199,23 @@ impl ClockModel {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn bbt (&self) -> ::jack::contrib::PositionBBT {
|
||||
let pulse = self.playhead.pulse.get() as i32;
|
||||
let ppq = self.timebase.ppq.get() as i32;
|
||||
let bpm = self.timebase.bpm.get();
|
||||
let bar = (pulse / ppq) / 4;
|
||||
::jack::contrib::PositionBBT {
|
||||
bar: 1 + bar,
|
||||
beat: 1 + (pulse / ppq) % 4,
|
||||
tick: (pulse % ppq),
|
||||
bar_start_tick: (bar * 4 * ppq) as f64,
|
||||
beat_type: 4.,
|
||||
beats_per_bar: 4.,
|
||||
beats_per_minute: bpm,
|
||||
ticks_per_beat: ppq as f64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue