fix next_launch_pulse

This commit is contained in:
🪞👃🪞 2024-11-01 15:49:24 +02:00
parent a305ba3cc1
commit 9a1616904c

View file

@ -80,12 +80,7 @@ impl Timebase {
impl Default for Timebase { fn default () -> Self { Self::new(48000f64, 150f64, 96f64) } }
impl Instant {
pub fn zero (timebase: &Arc<Timebase>) -> Self {
Self {
usec: 0.into(),
sample: 0.into(),
pulse: 0.into(),
timebase: timebase.clone(),
}
Self { usec: 0.into(), sample: 0.into(), pulse: 0.into(), timebase: timebase.clone() }
}
pub fn from_usec (timebase: &Arc<Timebase>, usec: f64) -> Self {
Self {
@ -271,14 +266,10 @@ impl UsecPosition for Instant { #[inline] fn usec (&self) -> &TimeUnit { &self.u
/// Something that defines launch quantization
pub trait LaunchSync {
fn sync (&self) -> &TimeUnit;
#[inline] fn next_launch_pulse (&self) -> f64 where Self: PulsePosition {
let sync: f64 = self.sync().get();
let pulse = self.pulse().get();
if pulse % sync == 0. {
pulse
} else {
(pulse / sync + 1.) * sync
}
#[inline] fn next_launch_pulse (&self) -> usize where Self: PulsePosition {
let sync = self.sync().get() as usize;
let pulse = self.pulse().get() as usize;
if pulse % sync == 0 { pulse } else { (pulse / sync + 1) * sync }
}
}
/// Something that defines note quantization