mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-07 22:17:07 +02:00
struct Track; load Sampler in Launcher
This commit is contained in:
parent
1038e24ceb
commit
685c49cfd9
6 changed files with 150 additions and 122 deletions
|
|
@ -36,7 +36,7 @@ impl Sampler {
|
|||
];
|
||||
let samples = Arc::new(Mutex::new(samples));
|
||||
let input = client.register_port("trigger", ::jack::MidiIn::default())?;
|
||||
Ok(DynamicDevice::new(render, handle, Self::process, Self {
|
||||
DynamicDevice::new(render, handle, Self::process, Self {
|
||||
name: name.into(),
|
||||
input,
|
||||
selected_sample: 0,
|
||||
|
|
@ -45,7 +45,7 @@ impl Sampler {
|
|||
midi_ins: vec![],
|
||||
audio_ins: vec![],
|
||||
audio_outs: vec![],
|
||||
}))
|
||||
}).activate(client)
|
||||
}
|
||||
|
||||
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
|
|
@ -80,7 +80,7 @@ impl Sampler {
|
|||
Control::Continue
|
||||
}
|
||||
|
||||
fn load_sample (&mut self, path: &str) {}
|
||||
fn load_sample (&mut self, _path: &str) {}
|
||||
}
|
||||
|
||||
impl PortList for Sampler {
|
||||
|
|
@ -128,29 +128,32 @@ impl Sample {
|
|||
|
||||
}
|
||||
|
||||
pub fn render (state: &Sampler, buf: &mut Buffer, Rect { x, y, .. }: Rect)
|
||||
pub fn render (state: &Sampler, buf: &mut Buffer, Rect { x, y, width, .. }: Rect)
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let width = 40;
|
||||
let style = Style::default().gray();
|
||||
draw_box(buf, Rect { x, y: y, width: 40, height: 12 });
|
||||
buf.set_string(x + 1, y + 1, &format!(" {} │", state.name), style.white().bold());
|
||||
buf.set_string(x + 0, y + 2, &format!("├--------------------------------------┤"), style.dim());
|
||||
buf.set_string(x + 2, y + 3, &format!("C4 Sample#000"), style.bold());
|
||||
buf.set_string(x + 2, y + 4, &format!(" {:.03}s",
|
||||
100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 5, &format!("C#4 Sample#001"), style.bold());
|
||||
buf.set_string(x + 2, y + 6, &format!(" {:.03}-{:.03}s",
|
||||
50000.0/44100.0, 100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 7, &format!("D4 Sample#002"), style.bold());
|
||||
buf.set_string(x + 2, y + 8, &format!(" {:.03}-{:.03}/{:.03}s",
|
||||
0.0, 50000.0/44100.0, 100000.0/44100.0), style);
|
||||
buf.set_string(x + 2, y + 9, &format!("D#4 Sample#003"), style.bold());
|
||||
buf.set_string(x + 2, y + 10, &format!(" {:.03}-[{:.03}-{:.03}]/{:.03}s ",
|
||||
10000.0/44100.0, 25000.0/44100.0, 50000.0/44100.0, 100000.0/44100.0), style);
|
||||
//buf.set_string(x + 1, y + 7 + 6, &format!(" Inputs... │ Outputs... "), style.dim());
|
||||
//render_table(state, stdout, offset)?;
|
||||
//render_meters(state, stdout, offset)?;
|
||||
Ok(Rect { x, y, width: 40, height: 11 })
|
||||
let separator = format!("├{}┤", "-".repeat((width - 2).into()));
|
||||
separator.blit(buf, x, y + 2, Some(style.dim()));
|
||||
format!(" {} │", state.name).blit(buf, x+1, y+1, Some(style.white().bold()));
|
||||
for (i, (note, name, cut)) in [
|
||||
("C4", "Sample#000", format!("{:.03}s",
|
||||
100000.0/44100.0)),
|
||||
("C#4", "Sample#001", format!("{:.03}-{:.03}s",
|
||||
50000.0/44100.0, 100000.0/44100.0)),
|
||||
("D4", "Sample#002", format!("{:.03}-{:.03}/{:.03}s",
|
||||
0.0, 50000.0/44100.0, 100000.0/44100.0)),
|
||||
("D#4", "Sample#003", format!("{:.03}-[{:.03}-{:.03}]/{:.03}s ",
|
||||
10000.0/44100.0, 25000.0/44100.0, 50000.0/44100.0, 100000.0/44100.0)),
|
||||
].iter().enumerate() {
|
||||
let i = i as u16;
|
||||
format!("{note:3} {name}")
|
||||
.blit(buf, x+2, y+3+i*2, Some(style.bold()));
|
||||
format!(" {cut}")
|
||||
.blit(buf, x+2, y+4+i*2, Some(style));
|
||||
}
|
||||
Ok(Rect { x, y, width, height: 11 })
|
||||
}
|
||||
|
||||
//fn render_table (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue