mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
fix next_launch_pulse
This commit is contained in:
parent
a305ba3cc1
commit
9a1616904c
1 changed files with 5 additions and 14 deletions
|
|
@ -80,12 +80,7 @@ impl Timebase {
|
||||||
impl Default for Timebase { fn default () -> Self { Self::new(48000f64, 150f64, 96f64) } }
|
impl Default for Timebase { fn default () -> Self { Self::new(48000f64, 150f64, 96f64) } }
|
||||||
impl Instant {
|
impl Instant {
|
||||||
pub fn zero (timebase: &Arc<Timebase>) -> Self {
|
pub fn zero (timebase: &Arc<Timebase>) -> Self {
|
||||||
Self {
|
Self { usec: 0.into(), sample: 0.into(), pulse: 0.into(), timebase: timebase.clone() }
|
||||||
usec: 0.into(),
|
|
||||||
sample: 0.into(),
|
|
||||||
pulse: 0.into(),
|
|
||||||
timebase: timebase.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn from_usec (timebase: &Arc<Timebase>, usec: f64) -> Self {
|
pub fn from_usec (timebase: &Arc<Timebase>, usec: f64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -271,14 +266,10 @@ impl UsecPosition for Instant { #[inline] fn usec (&self) -> &TimeUnit { &self.u
|
||||||
/// Something that defines launch quantization
|
/// Something that defines launch quantization
|
||||||
pub trait LaunchSync {
|
pub trait LaunchSync {
|
||||||
fn sync (&self) -> &TimeUnit;
|
fn sync (&self) -> &TimeUnit;
|
||||||
#[inline] fn next_launch_pulse (&self) -> f64 where Self: PulsePosition {
|
#[inline] fn next_launch_pulse (&self) -> usize where Self: PulsePosition {
|
||||||
let sync: f64 = self.sync().get();
|
let sync = self.sync().get() as usize;
|
||||||
let pulse = self.pulse().get();
|
let pulse = self.pulse().get() as usize;
|
||||||
if pulse % sync == 0. {
|
if pulse % sync == 0 { pulse } else { (pulse / sync + 1) * sync }
|
||||||
pulse
|
|
||||||
} else {
|
|
||||||
(pulse / sync + 1.) * sync
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Something that defines note quantization
|
/// Something that defines note quantization
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue