mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
fix usecs_to_pulse
This commit is contained in:
parent
4ecd6eab3d
commit
9531d0e09d
2 changed files with 5 additions and 10 deletions
|
|
@ -103,7 +103,7 @@ pub trait PulsesPerQuaver<U: TimeUnit> {
|
||||||
#[inline] fn usecs_to_pulse (&self, usec: U) -> U
|
#[inline] fn usecs_to_pulse (&self, usec: U) -> U
|
||||||
where U: TimeFloat, Self: BeatsPerMinute<U>
|
where U: TimeFloat, Self: BeatsPerMinute<U>
|
||||||
{
|
{
|
||||||
usec / self.pulse_per_usec()
|
usec * self.pulse_per_usec()
|
||||||
}
|
}
|
||||||
/// Convert a number of pulses to a sample number (SR- and BPM-dependent)
|
/// Convert a number of pulses to a sample number (SR- and BPM-dependent)
|
||||||
#[inline] fn pulses_to_usec (&self, pulse: U) -> U
|
#[inline] fn pulses_to_usec (&self, pulse: U) -> U
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,10 @@ 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;
|
||||||
}
|
}
|
||||||
match self.started {
|
self.clock.instant.update_from_usec(match self.started {
|
||||||
Some((_, usecs)) => {
|
Some((_, usecs)) => current_usecs as usize - usecs,
|
||||||
let usec = current_usecs as usize - usecs;
|
None => 0
|
||||||
let pulse = self.clock.usecs_to_pulse(usec as f64);
|
});
|
||||||
self.clock.set_usec(usec);
|
|
||||||
self.clock.set_pulse(pulse as usize);
|
|
||||||
},
|
|
||||||
None => { self.clock.set_usec(0); }
|
|
||||||
};
|
|
||||||
Control::Continue
|
Control::Continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue