clock.instant -> clock.current

This commit is contained in:
🪞👃🪞 2024-11-02 00:37:01 +02:00
parent e7dce0f84b
commit a31d6389be
5 changed files with 10 additions and 10 deletions

View file

@ -203,7 +203,7 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
let until_next = player.next_phrase.as_ref()
.map(|(t, _)|{
let target = t.pulse().get();
let current = clock.instant.pulse().get();
let current = clock.current.pulse().get();
if target > current {
let remaining = target - current;
format!("▎-{:>}", clock.timebase().format_beats_0_short(remaining))

View file

@ -418,7 +418,7 @@ impl PhrasePlayer {
}
pub fn pulses_since_start (&self) -> Option<f64> {
if let Some((started, Some(_))) = self.phrase.as_ref() {
Some(self.clock.instant.pulse().get() - started.pulse().get())
Some(self.clock.current.pulse().get() - started.pulse().get())
} else {
None
}

View file

@ -2,7 +2,7 @@ use crate::*;
#[derive(Debug, Default)]
pub struct TransportTime {
/// Current moment in time
pub instant: Instant,
pub current: Instant,
/// Note quantization factor
pub quant: TimeUnit,
/// Launch quantization factor
@ -11,10 +11,10 @@ pub struct TransportTime {
pub playing: RwLock<Option<TransportState>>,
}
impl TransportTime {
pub fn timebase (&self) -> &Arc<Timebase> { &self.instant.timebase }
pub fn timebase (&self) -> &Arc<Timebase> { &self.current.timebase }
}
impl PulsePosition for TransportTime {
#[inline] fn pulse (&self) -> &TimeUnit { self.instant.pulse() }
#[inline] fn pulse (&self) -> &TimeUnit { self.current.pulse() }
}
impl Quantize for TransportTime {
#[inline] fn quant (&self) -> &TimeUnit { &self.quant }
@ -64,7 +64,7 @@ impl<E: Engine> TransportToolbar<E> {
playing: Some(TransportState::Stopped).into(),
quant: 24.into(),
sync: (timebase.ppq().get() * 4.).into(),
instant: Instant::default(),
current: Instant::default(),
})
}
}

View file

@ -5,7 +5,7 @@ impl<E: Engine> Audio for TransportToolbar<E> {
let CycleTimes { current_frames, current_usecs, next_usecs: _, period_usecs: _ } = times;
let _chunk_size = scope.n_frames() as usize;
let transport = self.transport.as_ref().unwrap().query().unwrap();
self.clock.instant.sample.set(transport.pos.frame() as f64);
self.clock.current.sample.set(transport.pos.frame() as f64);
if *self.clock.playing.read().unwrap() != Some(transport.state) {
self.started = match transport.state {
TransportState::Rolling => Some((current_frames as usize, current_usecs as usize)),
@ -17,7 +17,7 @@ impl<E: Engine> Audio for TransportToolbar<E> {
if *self.clock.playing.read().unwrap() == Some(TransportState::Stopped) {
self.started = None;
}
self.clock.instant.update_from_usec(match self.started {
self.clock.current.update_from_usec(match self.started {
Some((_, usecs)) => current_usecs as f64 - usecs as f64,
None => 0.
});

View file

@ -27,8 +27,8 @@ impl Content for TransportToolbar<Tui> {
).align_w().fill_x(),
self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{
let time1 = self.clock.instant.format_beat();
let time2 = self.clock.instant.format_current_usec();
let time1 = self.clock.current.format_beat();
let time2 = self.clock.current.format_current_usec();
row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
}).align_e().fill_x(),