mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
key lights up in response to recording
This commit is contained in:
parent
2118615aea
commit
674f95fcd2
2 changed files with 254 additions and 396 deletions
14
src/time.rs
14
src/time.rs
|
|
@ -8,7 +8,7 @@ pub struct Frame(pub u32);
|
|||
pub struct Usec(pub u64);
|
||||
|
||||
/// Beats per minute as `120000` = 120.000BPM
|
||||
pub struct Tempo(pub u32);
|
||||
pub struct Tempo(pub u64);
|
||||
|
||||
/// Time signature: N/Mths per bar.
|
||||
pub struct Signature(pub u32, pub u32);
|
||||
|
|
@ -36,17 +36,17 @@ impl Usec {
|
|||
}
|
||||
|
||||
impl Tempo {
|
||||
#[inline]
|
||||
pub fn usec_per_bar (&self, beats: u64) -> Usec {
|
||||
Usec(beats * self.usec_per_beat().0)
|
||||
}
|
||||
#[inline]
|
||||
pub fn usec_per_beat (&self) -> Usec {
|
||||
Usec(60_000_000_000 / self.0 as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn usec_per_quarter (&self) -> Usec {
|
||||
Usec(self.usec_per_beat().0 / 4)
|
||||
}
|
||||
#[inline]
|
||||
pub fn usec_per_tick (&self, ppq: u32) -> Usec {
|
||||
Usec(self.usec_per_quarter().0 / ppq as u64)
|
||||
pub fn usec_per_step (&self, divisor: u64) -> Usec {
|
||||
Usec(self.usec_per_beat().0 / divisor as u64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn quantize (&self, step: &NoteDuration, time: Usec) -> Usec {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue