mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
display correct launch time
This commit is contained in:
parent
b4015a727a
commit
491ed81e83
3 changed files with 7 additions and 9 deletions
|
|
@ -164,13 +164,13 @@ pub trait UsecPosition<U: TimeUnit> {
|
|||
pub trait LaunchSync<U: TimeUnit> {
|
||||
fn sync (&self) -> U;
|
||||
fn set_sync (&self, sync: U);
|
||||
#[inline] fn next_launch_sample (&self) -> U where U: TimeInteger, Self: PulsePosition<U> {
|
||||
#[inline] fn next_launch_pulse (&self) -> U where U: TimeInteger, Self: PulsePosition<U> {
|
||||
let sync = self.sync();
|
||||
let pulse = self.pulse();
|
||||
if pulse % sync == U::from(0) {
|
||||
pulse
|
||||
} else {
|
||||
(pulse / sync) * sync + U::from(1)
|
||||
(pulse / sync + U::from(1)) * sync
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,17 +170,15 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
let name = format!("▎{}", &name[0..max_w]);
|
||||
let player = &track.player;
|
||||
let clock = &player.clock;
|
||||
let time1 = player.phrase.as_ref()
|
||||
let elapsed = player.phrase.as_ref()
|
||||
.map(|_|player.frames_since_start())
|
||||
.flatten()
|
||||
.map(|t|format!("▎{t:>}"))
|
||||
.unwrap_or(String::from("▎"));
|
||||
let time2 = player.next_phrase.as_ref()
|
||||
.map(|(t, _)|format!("▎{:>}", clock.format_beats(
|
||||
clock.samples_to_pulse(t.load(Ordering::Relaxed) as f64) as usize
|
||||
)))
|
||||
let until_next = player.next_phrase.as_ref()
|
||||
.map(|(t, _)|format!("▎{:>}", clock.format_beats(t.load(Ordering::Relaxed))))
|
||||
.unwrap_or(String::from("▎"));
|
||||
col!(name, time1, time2)
|
||||
col!(name, elapsed, until_next)
|
||||
.min_xy(w as u16, title_h)
|
||||
.bg(track.color)
|
||||
.push_x(offset - 1)
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
pub fn toggle_record (&mut self) { self.recording = !self.recording; }
|
||||
pub fn toggle_overdub (&mut self) { self.overdub = !self.overdub; }
|
||||
pub fn enqueue_next (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
|
||||
let start = self.clock.next_launch_sample();
|
||||
let start = self.clock.next_launch_pulse();
|
||||
self.next_phrase = Some((start.into(), phrase.map(|p|p.clone())));
|
||||
self.reset = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue