mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
use Arc<str> where applicable; use konst split_at
This commit is contained in:
parent
411fc0c4bc
commit
305481adee
35 changed files with 286 additions and 273 deletions
|
|
@ -78,32 +78,32 @@ impl Timebase {
|
|||
events.map(|(time, event)|(self.quantize(step, time).0, event)).collect()
|
||||
}
|
||||
/// Format a number of pulses into Beat.Bar.Pulse starting from 0
|
||||
#[inline] pub fn format_beats_0 (&self, pulse: f64) -> String {
|
||||
#[inline] pub fn format_beats_0 (&self, pulse: f64) -> Arc<str> {
|
||||
let pulse = pulse as usize;
|
||||
let ppq = self.ppq.get() as usize;
|
||||
let (beats, pulses) = if ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) };
|
||||
format!("{}.{}.{pulses:02}", beats / 4, beats % 4)
|
||||
format!("{}.{}.{pulses:02}", beats / 4, beats % 4).into()
|
||||
}
|
||||
/// Format a number of pulses into Beat.Bar starting from 0
|
||||
#[inline] pub fn format_beats_0_short (&self, pulse: f64) -> String {
|
||||
#[inline] pub fn format_beats_0_short (&self, pulse: f64) -> Arc<str> {
|
||||
let pulse = pulse as usize;
|
||||
let ppq = self.ppq.get() as usize;
|
||||
let beats = if ppq > 0 { pulse / ppq } else { 0 };
|
||||
format!("{}.{}", beats / 4, beats % 4)
|
||||
format!("{}.{}", beats / 4, beats % 4).into()
|
||||
}
|
||||
/// Format a number of pulses into Beat.Bar.Pulse starting from 1
|
||||
#[inline] pub fn format_beats_1 (&self, pulse: f64) -> String {
|
||||
#[inline] pub fn format_beats_1 (&self, pulse: f64) -> Arc<str> {
|
||||
let pulse = pulse as usize;
|
||||
let ppq = self.ppq.get() as usize;
|
||||
let (beats, pulses) = if ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) };
|
||||
format!("{}.{}.{pulses:02}", beats / 4 + 1, beats % 4 + 1)
|
||||
format!("{}.{}.{pulses:02}", beats / 4 + 1, beats % 4 + 1).into()
|
||||
}
|
||||
/// Format a number of pulses into Beat.Bar.Pulse starting from 1
|
||||
#[inline] pub fn format_beats_1_short (&self, pulse: f64) -> String {
|
||||
#[inline] pub fn format_beats_1_short (&self, pulse: f64) -> Arc<str> {
|
||||
let pulse = pulse as usize;
|
||||
let ppq = self.ppq.get() as usize;
|
||||
let beats = if ppq > 0 { pulse / ppq } else { 0 };
|
||||
format!("{}.{}", beats / 4 + 1, beats % 4 + 1)
|
||||
format!("{}.{}", beats / 4 + 1, beats % 4 + 1).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue