highlight recorded sample

This commit is contained in:
🪞👃🪞 2024-12-28 17:57:34 +01:00
parent 2feb21bd1f
commit ae3099847a
3 changed files with 76 additions and 19 deletions

View file

@ -61,7 +61,6 @@ render!(<Tui>|self:GrooveboxTui|{
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
let pool_w = if self.pool.visible { phrase_w } else { 0 };
let sampler_w = 11;
let note_pt = self.editor.note_point();
Fill::wh(lay!([
&self.size,
Fill::wh(Align::s(Fixed::h(2, GrooveboxStatus::from(self)))),
@ -82,18 +81,8 @@ render!(<Tui>|self:GrooveboxTui|{
Tui::split_w(false, pool_w,
Tui::pull_y(1, Fill::h(Align::e(PoolView(&self.pool)))),
Tui::split_e(false, sampler_w, Fill::wh(col!([
&format!("L/{:>+9.3}", self.sampler.input_meter[0]),
&format!("R/{:>+9.3}", self.sampler.input_meter[1]),
Fill::wh(col!(note in (self.editor.note_lo().load(Relaxed)..=self.editor.note_hi()).rev() => {
Tui::bg(
if note == note_pt { TuiTheme::g(64) } else { Color::Reset },
if let Some(sample) = &self.sampler.mapped[note] {
todo!()
} else {
Tui::fg(TuiTheme::g(160), format!("{note:3} (none)"))
}
)
})),
Meters(self.sampler.input_meter.as_ref()),
GrooveboxSamples(self),
])), Fill::h(&self.editor))
)
),
@ -102,6 +91,34 @@ render!(<Tui>|self:GrooveboxTui|{
]))
});
struct Meters<'a>(&'a[f32]);
render!(<Tui>|self: Meters<'a>|col!([
&format!("L/{:>+9.3}", self.0[0]),
&format!("R/{:>+9.3}", self.0[1]),
]));
struct GrooveboxSamples<'a>(&'a GrooveboxTui);
render!(<Tui>|self: GrooveboxSamples<'a>|{
let note_lo = self.0.editor.note_lo().load(Relaxed);
let note_pt = self.0.editor.note_point();
let note_hi = self.0.editor.note_hi();
Fill::wh(col!(note in (note_lo..=note_hi).rev() => {
let mut bg = if note == note_pt { TuiTheme::g(64) } else { Color::Reset };
let mut fg = TuiTheme::g(160);
if let Some((index, _)) = self.0.sampler.recording {
if note == index {
bg = Color::Rgb(64,16,0);
fg = Color::Rgb(224,64,32)
}
}
Tui::bg(bg, if let Some(sample) = &self.0.sampler.mapped[note] {
todo!()
} else {
Tui::fg(fg, format!("{note:3} (none) "))
})
}))
});
pub enum GrooveboxCommand {
History(isize),
Clock(ClockCommand),
@ -137,7 +154,7 @@ input_to_command!(GrooveboxCommand: <Tui>|state: GrooveboxTui, input|match input
key_pat!(Char('0')) => Enqueue(Some(state.pool.phrases()[0].clone())),
key_pat!(Shift-Char('R')) => Sampler(
SamplerCommand::Record(u7::from(state.editor.note_point() as u8))
SamplerCommand::RecordBegin(u7::from(state.editor.note_point() as u8))
),
// e: Toggle between editing currently playing or other phrase