mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
clock.instant -> clock.current
This commit is contained in:
parent
e7dce0f84b
commit
a31d6389be
5 changed files with 10 additions and 10 deletions
|
|
@ -203,7 +203,7 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
||||||
let until_next = player.next_phrase.as_ref()
|
let until_next = player.next_phrase.as_ref()
|
||||||
.map(|(t, _)|{
|
.map(|(t, _)|{
|
||||||
let target = t.pulse().get();
|
let target = t.pulse().get();
|
||||||
let current = clock.instant.pulse().get();
|
let current = clock.current.pulse().get();
|
||||||
if target > current {
|
if target > current {
|
||||||
let remaining = target - current;
|
let remaining = target - current;
|
||||||
format!("▎-{:>}", clock.timebase().format_beats_0_short(remaining))
|
format!("▎-{:>}", clock.timebase().format_beats_0_short(remaining))
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ impl PhrasePlayer {
|
||||||
}
|
}
|
||||||
pub fn pulses_since_start (&self) -> Option<f64> {
|
pub fn pulses_since_start (&self) -> Option<f64> {
|
||||||
if let Some((started, Some(_))) = self.phrase.as_ref() {
|
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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::*;
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct TransportTime {
|
pub struct TransportTime {
|
||||||
/// Current moment in time
|
/// Current moment in time
|
||||||
pub instant: Instant,
|
pub current: Instant,
|
||||||
/// Note quantization factor
|
/// Note quantization factor
|
||||||
pub quant: TimeUnit,
|
pub quant: TimeUnit,
|
||||||
/// Launch quantization factor
|
/// Launch quantization factor
|
||||||
|
|
@ -11,10 +11,10 @@ pub struct TransportTime {
|
||||||
pub playing: RwLock<Option<TransportState>>,
|
pub playing: RwLock<Option<TransportState>>,
|
||||||
}
|
}
|
||||||
impl TransportTime {
|
impl TransportTime {
|
||||||
pub fn timebase (&self) -> &Arc<Timebase> { &self.instant.timebase }
|
pub fn timebase (&self) -> &Arc<Timebase> { &self.current.timebase }
|
||||||
}
|
}
|
||||||
impl PulsePosition for TransportTime {
|
impl PulsePosition for TransportTime {
|
||||||
#[inline] fn pulse (&self) -> &TimeUnit { self.instant.pulse() }
|
#[inline] fn pulse (&self) -> &TimeUnit { self.current.pulse() }
|
||||||
}
|
}
|
||||||
impl Quantize for TransportTime {
|
impl Quantize for TransportTime {
|
||||||
#[inline] fn quant (&self) -> &TimeUnit { &self.quant }
|
#[inline] fn quant (&self) -> &TimeUnit { &self.quant }
|
||||||
|
|
@ -64,7 +64,7 @@ impl<E: Engine> TransportToolbar<E> {
|
||||||
playing: Some(TransportState::Stopped).into(),
|
playing: Some(TransportState::Stopped).into(),
|
||||||
quant: 24.into(),
|
quant: 24.into(),
|
||||||
sync: (timebase.ppq().get() * 4.).into(),
|
sync: (timebase.ppq().get() * 4.).into(),
|
||||||
instant: Instant::default(),
|
current: Instant::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ impl<E: Engine> Audio for TransportToolbar<E> {
|
||||||
let CycleTimes { current_frames, current_usecs, next_usecs: _, period_usecs: _ } = times;
|
let CycleTimes { current_frames, current_usecs, next_usecs: _, period_usecs: _ } = times;
|
||||||
let _chunk_size = scope.n_frames() as usize;
|
let _chunk_size = scope.n_frames() as usize;
|
||||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
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) {
|
if *self.clock.playing.read().unwrap() != Some(transport.state) {
|
||||||
self.started = match transport.state {
|
self.started = match transport.state {
|
||||||
TransportState::Rolling => Some((current_frames as usize, current_usecs as usize)),
|
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) {
|
if *self.clock.playing.read().unwrap() == Some(TransportState::Stopped) {
|
||||||
self.started = None;
|
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,
|
Some((_, usecs)) => current_usecs as f64 - usecs as f64,
|
||||||
None => 0.
|
None => 0.
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ impl Content for TransportToolbar<Tui> {
|
||||||
).align_w().fill_x(),
|
).align_w().fill_x(),
|
||||||
|
|
||||||
self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{
|
self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{
|
||||||
let time1 = self.clock.instant.format_beat();
|
let time1 = self.clock.current.format_beat();
|
||||||
let time2 = self.clock.instant.format_current_usec();
|
let time2 = self.clock.current.format_current_usec();
|
||||||
row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
|
row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
|
||||||
}).align_e().fill_x(),
|
}).align_e().fill_x(),
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue