mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
stub sampler
This commit is contained in:
parent
471d5bc0d3
commit
93413ae303
1 changed files with 59 additions and 32 deletions
|
|
@ -51,40 +51,67 @@ pub enum SamplerFocus {
|
|||
}
|
||||
|
||||
audio!(|self: SamplerTui, _client, _scope|Control::Continue);
|
||||
render!(|self: SamplerTui|render(|to|{
|
||||
render!(|self: SamplerTui|{
|
||||
Tui::fill_xy(lay!([
|
||||
|
||||
Tui::fill_xy(render(|to|{ // border
|
||||
let [x, y, w, h] = to.area();
|
||||
let style = Some(Style::default().fg(Color::Green));
|
||||
to.blit(&"🭚", x, y, style);
|
||||
to.blit(&"🭥", x + w.saturating_sub(1), y, style);
|
||||
to.blit(&"🬿", x, y + h.saturating_sub(1), style);
|
||||
to.blit(&"🭊", x + w.saturating_sub(1), y + h.saturating_sub(1), style);
|
||||
|
||||
let style = Style::default().gray();
|
||||
let voice = self.state.voices.read().unwrap().len();
|
||||
let title = format!(" {} ({voice})", self.state.name);
|
||||
to.blit(&title, x+1, y, Some(style.white().bold().not_dim()));
|
||||
|
||||
let mut width = title.len() + 2;
|
||||
let mut y1 = 1;
|
||||
let mut j = 0;
|
||||
for (note, sample) in self.state.mapped.iter()
|
||||
.map(|(note, sample)|(Some(note), sample))
|
||||
.chain(self.state.unmapped.iter().map(|sample|(None, sample)))
|
||||
{
|
||||
if y1 >= h {
|
||||
break
|
||||
}
|
||||
let active = j == self.cursor.0;
|
||||
width = width.max(
|
||||
draw_sample(to, x, y + y1, note, &*sample.read().unwrap(), active)?
|
||||
);
|
||||
y1 = y1 + 1;
|
||||
j = j + 1;
|
||||
}
|
||||
let h = ((2 + y1) as u16).min(h);
|
||||
//Ok(Some([x, y, (width as u16).min(to.area().w()), h]))
|
||||
let green = Some(Style::default().fg(Color::Green));
|
||||
to.blit(&"🭚", x, y, green);
|
||||
to.blit(&"🭥", x + w.saturating_sub(1), y, green);
|
||||
to.blit(&"🬿", x, y + h.saturating_sub(1), green);
|
||||
to.blit(&"🭊", x + w.saturating_sub(1), y + h.saturating_sub(1), green);
|
||||
Ok(())
|
||||
}));
|
||||
})),
|
||||
|
||||
col!([
|
||||
"",
|
||||
row!([
|
||||
" ", Tui::bold(true, "Sampler."), " Voices: ",
|
||||
&format!("{}", self.state.voices.read().unwrap().len()),
|
||||
]),
|
||||
" ",
|
||||
Tui::either(self.state.unmapped.len() > 0,
|
||||
col!((index, sample) in self.state.unmapped.iter().enumerate() =>
|
||||
{ &format!("| Unmapped #{index}") }), " · No unmapped samples."),
|
||||
" ",
|
||||
Tui::either(self.state.mapped.len() > 0,
|
||||
col!((index, sample) in self.state.unmapped.iter().enumerate() =>
|
||||
{ &format!("| Mapped #{index}") }), " · No mapped samples."),
|
||||
])
|
||||
|
||||
//render(|to|{
|
||||
//let [x, y, w, h] = to.area();
|
||||
//let style = Style::default().gray();
|
||||
//let voice = self.state.voices.read().unwrap().len();
|
||||
//let title = format!(" {} ({voice} voice(s) playing now)", self.state.name);
|
||||
//to.blit(&title, x+1, y, Some(style.white().bold().not_dim()));
|
||||
|
||||
//let mut width = title.len() + 2;
|
||||
//let mut y1 = 1;
|
||||
//let mut j = 0;
|
||||
//for (note, sample) in self.state.mapped.iter()
|
||||
//.map(|(note, sample)|(Some(note), sample))
|
||||
//.chain(self.state.unmapped.iter().map(|sample|(None, sample)))
|
||||
//{
|
||||
//if y1 >= h {
|
||||
//break
|
||||
//}
|
||||
//let active = j == self.cursor.0;
|
||||
//width = width.max(
|
||||
//draw_sample(to, x, y + y1, note, &*sample.read().unwrap(), active)?
|
||||
//);
|
||||
//y1 = y1 + 1;
|
||||
//j = j + 1;
|
||||
//}
|
||||
//let h = ((2 + y1) as u16).min(h);
|
||||
////Ok(Some([x, y, (width as u16).min(to.area().w()), h]))
|
||||
//Ok(())
|
||||
//}),
|
||||
//])
|
||||
|
||||
]))
|
||||
});
|
||||
|
||||
impl SamplerTui {
|
||||
/// Immutable reference to sample at cursor.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue