launch countdown/switchover, pt.4

This commit is contained in:
🪞👃🪞 2024-11-01 22:14:08 +02:00
parent 5f112cc203
commit 6cb609f8b8
4 changed files with 25 additions and 24 deletions

View file

@ -133,10 +133,10 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
let scenes = state.scenes.as_ref();
let bg = state.color;
let clip_bg = Color::Rgb(40, 50, 30);
let border_bg = Color::Rgb(40, 50, 30);
let border_hi = Color::Rgb(100, 110, 40);
let border_lo = Color::Rgb(70, 80, 50);
let border_fg = if self.0.focused { border_hi } else { border_lo };
//let border_bg = Color::Rgb(40, 50, 30);
//let border_fg = if self.0.focused { border_hi } else { border_lo };
//let border = Lozenge(Style::default().bg(border_bg).fg(border_fg));
let track_title_h = 2u16;
let tracks_footer = 3u16;
@ -187,15 +187,17 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
// track controls
let footer = row!((track, w) in tracks.iter().zip(cols.iter().map(|col|col.0))=>{
let player = &track.player;
let elapsed = player.phrase.as_ref()
.map(|_|player.samples_since_start())
.flatten()
.map(|t|format!("{t:>}"))
.unwrap_or(String::from(""));
let elapsed = if let Some((_, Some(_))) = player.phrase.as_ref() {
let elapsed = player.pulses_since_start().unwrap();
let elapsed = clock.timebase().format_beats_1(elapsed);
format!("▎+{elapsed:>}")
} else {
String::from("")
};
let until_next = player.next_phrase.as_ref()
.map(|(t, _)|{
let target = t.pulse().get();
let current = clock.instant.pulse().get();
let target = t.pulse().get();
let current = clock.instant.pulse().get();
if target > current {
let remaining = clock.timebase().format_beats_0(target - current);
format!("▎-{remaining:>}")

View file

@ -419,7 +419,12 @@ impl PhrasePlayer {
pub fn samples_since_start (&self) -> Option<usize> {
self.phrase.as_ref()
.map(|(started,_)|started.sample().get())
.map(|started|(started - self.clock.instant.sample().get()) as usize)
.map(|started|(self.clock.instant.sample().get() - started) as usize)
}
pub fn pulses_since_start (&self) -> Option<f64> {
self.phrase.as_ref()
.map(|(started,_)|started.pulse().get())
.map(|started|self.clock.instant.pulse().get() - started)
}
}
impl<E: Engine> PhraseLength<E> {

View file

@ -14,12 +14,12 @@ impl Audio for PhrasePlayer {
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
let has_midi_outputs = self.has_midi_outputs();
let has_midi_inputs = self.has_midi_inputs();
if has_midi_outputs {
//if has_midi_outputs {
// Clear output buffer(s)
self.clear(scope, false);
// Write chunk of phrase to output
self.play(scope);
}
//}
if has_midi_inputs {
if self.recording || self.monitoring {
// Record and/or monitor input
@ -140,11 +140,10 @@ impl PhrasePlayer {
}
if self.recording {
phrase.record_event({
let pulse = self.clock.timebase().samples_to_pulse(
(sample0 + sample - start) as f64
);
let sample = (sample0 + sample - start) as f64;
let pulse = self.clock.timebase().samples_to_pulse(sample);
let quantized = (pulse / quant).round() * quant;
let looped = quantized as usize % length;
let looped = quantized as usize % length;
looped
}, message);
}

View file

@ -207,14 +207,9 @@ impl<E: Engine> PhraseEditor<E> {
}
fn fill_seq_bg (buf: &mut BigBuffer, length: usize, ppq: usize) {
for x in 0..buf.width {
if x as usize >= length {
break
}
let style = Style::default();
buf.get_mut(x, 0).map(|cell|{
cell.set_char('-');
cell.set_style(style);
});
// Only fill as far as phrase length
if x as usize >= length { break }
// Fill each row with background characters
for y in 0 .. buf.height {
buf.get_mut(x, y).map(|cell|{
cell.set_char(if ppq == 0 {