launch countdown, pt.1

This commit is contained in:
🪞👃🪞 2024-11-01 16:23:47 +02:00
parent 9a1616904c
commit b8047ab1ef
3 changed files with 12 additions and 14 deletions

View file

@ -77,7 +77,7 @@ impl Timebase {
TicksIterator { fpt: self.samples_per_pulse(), sample: start, start, end }
}
}
impl Default for Timebase { fn default () -> Self { Self::new(48000f64, 150f64, 96f64) } }
impl Default for Timebase { fn default () -> Self { Self::new(48000f64, 150f64, DEFAULT_PPQ) } }
impl Instant {
pub fn zero (timebase: &Arc<Timebase>) -> Self {
Self { usec: 0.into(), sample: 0.into(), pulse: 0.into(), timebase: timebase.clone() }
@ -126,12 +126,7 @@ impl Instant {
}
}
/// Iterator that emits subsequent ticks within a range.
pub struct TicksIterator {
fpt: f64,
sample: usize,
start: usize,
end: usize,
}
pub struct TicksIterator { fpt: f64, sample: usize, start: usize, end: usize, }
impl Iterator for TicksIterator {
type Item = (usize, usize);
fn next (&mut self) -> Option<Self::Item> {
@ -305,10 +300,7 @@ pub const NOTE_DURATIONS: [(usize, &str);26] = [
];
/// Returns the next shorter length
pub fn prev_note_length (pulses: usize) -> usize {
for i in 1..=16 {
let length = NOTE_DURATIONS[16-i].0;
if length < pulses { return length }
}
for i in 1..=16 { let length = NOTE_DURATIONS[16-i].0; if length < pulses { return length } }
pulses
}
/// Returns the next longer length