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

View file

@ -419,7 +419,12 @@ impl PhrasePlayer {
pub fn samples_since_start (&self) -> Option<usize> { pub fn samples_since_start (&self) -> Option<usize> {
self.phrase.as_ref() self.phrase.as_ref()
.map(|(started,_)|started.sample().get()) .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> { impl<E: Engine> PhraseLength<E> {

View file

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

View file

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