mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: simplifying timebase
This commit is contained in:
parent
238d307817
commit
b3e6206b08
5 changed files with 50 additions and 89 deletions
|
|
@ -47,8 +47,8 @@ impl Phrase {
|
|||
(frame0, frames, _): (usize, usize, f64),
|
||||
) {
|
||||
for (time, tick) in frames_to_ticks(
|
||||
timebase.pulse_frame(),
|
||||
timebase.pulses_frames(self.length as f64),
|
||||
timebase.pulse_per_frame(),
|
||||
timebase.frame_to_pulse(self.length as f64),
|
||||
frame0 as f64,
|
||||
(frame0 + frames) as f64,
|
||||
) {
|
||||
|
|
@ -76,10 +76,9 @@ fn frames_to_ticks (fpt: f64, repeat: f64, start: f64, end: f64) -> Box<dyn Iter
|
|||
let jitter = frame.rem_euclid(fpt); // ramps
|
||||
let next_jitter = (frame + 1.0).rem_euclid(fpt);
|
||||
if jitter > next_jitter { // at head of ramp crossing
|
||||
ticks.push((
|
||||
frame as usize % (end as usize-start as usize),
|
||||
(frame / fpt) as usize)
|
||||
);
|
||||
let time = frame as usize % (end as usize-start as usize);
|
||||
let tick = (frame / fpt) as usize;
|
||||
ticks.push((time, tick));
|
||||
};
|
||||
};
|
||||
let start_frame = start % repeat;
|
||||
|
|
@ -125,3 +124,18 @@ fn frames_to_ticks_2 (add_frame: &mut impl FnMut(f64), start_frame: f64, end_fra
|
|||
phrase
|
||||
}}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_frames_to_ticks () {
|
||||
let fpt = Timebase::default().pulse_per_frame();
|
||||
let repeat = 0.0;
|
||||
let start = 0.0;
|
||||
let end = 0.0;
|
||||
println!("{:?}", frames_to_ticks(fpt, repeat, start, end).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue