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);
|
audio!(|self: SamplerTui, _client, _scope|Control::Continue);
|
||||||
render!(|self: SamplerTui|render(|to|{
|
render!(|self: SamplerTui|{
|
||||||
let [x, y, w, h] = to.area();
|
Tui::fill_xy(lay!([
|
||||||
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();
|
Tui::fill_xy(render(|to|{ // border
|
||||||
let voice = self.state.voices.read().unwrap().len();
|
let [x, y, w, h] = to.area();
|
||||||
let title = format!(" {} ({voice})", self.state.name);
|
let green = Some(Style::default().fg(Color::Green));
|
||||||
to.blit(&title, x+1, y, Some(style.white().bold().not_dim()));
|
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(())
|
||||||
|
})),
|
||||||
|
|
||||||
let mut width = title.len() + 2;
|
col!([
|
||||||
let mut y1 = 1;
|
"",
|
||||||
let mut j = 0;
|
row!([
|
||||||
for (note, sample) in self.state.mapped.iter()
|
" ", Tui::bold(true, "Sampler."), " Voices: ",
|
||||||
.map(|(note, sample)|(Some(note), sample))
|
&format!("{}", self.state.voices.read().unwrap().len()),
|
||||||
.chain(self.state.unmapped.iter().map(|sample|(None, sample)))
|
]),
|
||||||
{
|
" ",
|
||||||
if y1 >= h {
|
Tui::either(self.state.unmapped.len() > 0,
|
||||||
break
|
col!((index, sample) in self.state.unmapped.iter().enumerate() =>
|
||||||
}
|
{ &format!("| Unmapped #{index}") }), " · No unmapped samples."),
|
||||||
let active = j == self.cursor.0;
|
" ",
|
||||||
width = width.max(
|
Tui::either(self.state.mapped.len() > 0,
|
||||||
draw_sample(to, x, y + y1, note, &*sample.read().unwrap(), active)?
|
col!((index, sample) in self.state.unmapped.iter().enumerate() =>
|
||||||
);
|
{ &format!("| Mapped #{index}") }), " · No mapped samples."),
|
||||||
y1 = y1 + 1;
|
])
|
||||||
j = j + 1;
|
|
||||||
}
|
//render(|to|{
|
||||||
let h = ((2 + y1) as u16).min(h);
|
//let [x, y, w, h] = to.area();
|
||||||
//Ok(Some([x, y, (width as u16).min(to.area().w()), h]))
|
//let style = Style::default().gray();
|
||||||
Ok(())
|
//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 {
|
impl SamplerTui {
|
||||||
/// Immutable reference to sample at cursor.
|
/// Immutable reference to sample at cursor.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue