mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
rename frame to sample everywhere
This commit is contained in:
parent
063706017e
commit
d77fe325b0
7 changed files with 40 additions and 38 deletions
|
|
@ -237,12 +237,12 @@ impl<E: Engine> Arrangement<E> {
|
|||
match self.selected {
|
||||
ArrangementFocus::Scene(s) => {
|
||||
for (t, track) in self.tracks.iter_mut().enumerate() {
|
||||
let start = self.clock.next_launch_frame();
|
||||
let start = self.clock.next_launch_sample();
|
||||
track.player.enqueue_next(start, self.scenes[s].clips[t].as_ref());
|
||||
}
|
||||
},
|
||||
ArrangementFocus::Clip(t, s) => {
|
||||
let start = self.clock.next_launch_frame();
|
||||
let start = self.clock.next_launch_sample();
|
||||
self.tracks[t].player.enqueue_next(start, self.scenes[s].clips[t].as_ref());
|
||||
},
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,9 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
.map(|t|format!("▎{t:>}"))
|
||||
.unwrap_or(String::from("▎"));
|
||||
let time2 = track.player.next_phrase.as_ref()
|
||||
.map(|(t, _)|format!("▎{:>}", t.load(Ordering::Relaxed)))
|
||||
.map(|(t, _)|format!("▎{:>}",
|
||||
track.player.clock.samples_to_pulse(t.load(Ordering::Relaxed) as f64)
|
||||
))
|
||||
.unwrap_or(String::from("▎"));
|
||||
col!(name, time1, time2)
|
||||
.min_xy(w as u16, title_h)
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
pub fn frames_since_start (&self) -> Option<usize> {
|
||||
self.phrase.as_ref()
|
||||
.map(|(started,_)|started.load(Ordering::Relaxed))
|
||||
.map(|started|started - self.clock.frame())
|
||||
.map(|started|started - self.clock.sample())
|
||||
}
|
||||
}
|
||||
/// Displays and edits phrase length
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl Phrase {
|
|||
(frame0, frames, _): (usize, usize, f64),
|
||||
) {
|
||||
let mut buf = Vec::with_capacity(8);
|
||||
for (time, tick) in Ticks(timebase.pulses_per_sample()).between_frames(
|
||||
for (time, tick) in Ticks(timebase.pulses_per_sample()).between_samples(
|
||||
frame0, frame0 + frames
|
||||
) {
|
||||
let tick = tick % self.length;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ pub struct TransportTime {
|
|||
pub timebase: Timebase,
|
||||
/// Playback state
|
||||
pub playing: RwLock<Option<TransportState>>,
|
||||
/// Current time in frames
|
||||
pub frame: AtomicUsize,
|
||||
/// Current time in samples
|
||||
pub sample: AtomicUsize,
|
||||
/// Current time in pulses
|
||||
pub pulse: AtomicUsize,
|
||||
/// Current time in microseconds
|
||||
|
|
@ -27,7 +27,7 @@ pub struct TransportToolbar<E: Engine> {
|
|||
pub jack: Option<JackClient>,
|
||||
/// JACK transport handle.
|
||||
pub transport: Option<Transport>,
|
||||
/// Global frame and usec at which playback started
|
||||
/// Global sample and usec at which playback started
|
||||
pub started: Option<(usize, usize)>,
|
||||
/// Whether the toolbar is focused
|
||||
pub focused: bool,
|
||||
|
|
@ -52,8 +52,8 @@ impl PulsesPerQuaver<f64> for TransportTime {
|
|||
#[inline] fn set_ppq (&self, ppq: f64) { self.timebase.set_ppq(ppq); }
|
||||
}
|
||||
impl FramePosition<usize> for TransportTime {
|
||||
#[inline] fn frame (&self) -> usize { self.frame.load(Ordering::Relaxed) }
|
||||
#[inline] fn set_frame (&self, frame: usize) { self.frame.store(frame, Ordering::Relaxed); }
|
||||
#[inline] fn sample (&self) -> usize { self.sample.load(Ordering::Relaxed) }
|
||||
#[inline] fn set_sample (&self, sample: usize) { self.sample.store(sample, Ordering::Relaxed); }
|
||||
}
|
||||
impl UsecPosition<usize> for TransportTime {
|
||||
#[inline] fn usec (&self) -> usize { self.usecs.load(Ordering::Relaxed) }
|
||||
|
|
@ -92,7 +92,7 @@ impl<E: Engine> TransportToolbar<E> {
|
|||
playing: Some(TransportState::Stopped).into(),
|
||||
quant: 24.into(),
|
||||
sync: (timebase.ppq() as usize * 4).into(),
|
||||
frame: 0.into(),
|
||||
sample: 0.into(),
|
||||
pulse: 0.into(),
|
||||
usecs: 0.into(),
|
||||
timebase,
|
||||
|
|
@ -102,13 +102,13 @@ impl<E: Engine> TransportToolbar<E> {
|
|||
}
|
||||
pub fn bpm (&self) -> usize { self.clock.bpm() as usize }
|
||||
pub fn ppq (&self) -> usize { self.clock.ppq() as usize }
|
||||
pub fn pulse (&self) -> usize { self.clock.samples_to_pulse(self.clock.frame()as f64) as usize }
|
||||
pub fn usecs (&self) -> usize { self.clock.samples_to_usec(self.clock.frame() as f64) as usize }
|
||||
pub fn pulse (&self) -> usize { self.clock.samples_to_pulse(self.clock.sample()as f64) as usize }
|
||||
pub fn usecs (&self) -> usize { self.clock.samples_to_usec(self.clock.sample() as f64) as usize }
|
||||
pub fn quant (&self) -> usize { self.clock.quant() }
|
||||
pub fn sync (&self) -> usize { self.clock.sync() }
|
||||
pub fn toggle_play (&mut self) -> Usually<()> {
|
||||
let transport = self.transport.as_ref().unwrap();
|
||||
let playing = self.clock.playing.read().unwrap().expect("1st frame has not been processed yet");
|
||||
let playing = self.clock.playing.read().unwrap().expect("1st sample has not been processed yet");
|
||||
let playing = match playing {
|
||||
TransportState::Stopped => {
|
||||
transport.start()?;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ impl<E: Engine> 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.set_frame(transport.pos.frame() as usize);
|
||||
self.clock.set_sample(transport.pos.frame() as usize);
|
||||
let mut reset = false;
|
||||
if *self.clock.playing.read().unwrap() != Some(transport.state) {
|
||||
match transport.state {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue