mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
lozenges
This commit is contained in:
parent
3886e34519
commit
de2e2a2124
7 changed files with 119 additions and 65 deletions
|
|
@ -52,7 +52,7 @@ impl Sampler {
|
|||
samples: samples.unwrap_or(BTreeMap::new()),
|
||||
voices: vec![],
|
||||
midi_in: client.register_port("midi", ::jack::MidiIn::default())?,
|
||||
audio_ins: vec![
|
||||
audio_ins: vec![
|
||||
client.register_port("recL", ::jack::AudioIn::default())?,
|
||||
client.register_port("recR", ::jack::AudioIn::default())?,
|
||||
],
|
||||
|
|
@ -127,7 +127,7 @@ pub fn render (state: &Sampler, buf: &mut Buffer, Rect { x, y, height, .. }: Rec
|
|||
{
|
||||
let width = 40;
|
||||
let style = Style::default().gray();
|
||||
format!(" {}", state.name).blit(buf, x+1, y, Some(style.white().bold()));
|
||||
format!(" {} ", state.name).blit(buf, x+1, y, Some(style.white().bold().not_dim()));
|
||||
for (i, (note, sample)) in state.samples.iter().enumerate() {
|
||||
let style = if i == state.cursor.0 {
|
||||
Style::default().green()
|
||||
|
|
@ -198,9 +198,9 @@ pub fn handle (state: &mut Sampler, event: &AppEvent) -> Usually<bool> {
|
|||
Ok(handle_keymap(state, event, KEYMAP)?)
|
||||
}
|
||||
pub const KEYMAP: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||
[Up, NONE, "cursor_up", "move cursor up", cursor_up],
|
||||
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
||||
[Enter, NONE, "enter", "activate", enter],
|
||||
[Up, NONE, "cursor_up", "move cursor up", cursor_up],
|
||||
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
||||
[Enter, NONE, "select", "select item under cursor", select],
|
||||
});
|
||||
fn cursor_up (state: &mut Sampler) -> Usually<bool> {
|
||||
state.cursor.0 = if state.cursor.0 == 0 {
|
||||
|
|
@ -214,6 +214,9 @@ fn cursor_down (state: &mut Sampler) -> Usually<bool> {
|
|||
state.cursor.0 = (state.cursor.0 + 1) % state.samples.len();
|
||||
Ok(true)
|
||||
}
|
||||
fn enter (state: &mut Sampler) -> Usually<bool> {
|
||||
fn select (state: &mut Sampler) -> Usually<bool> {
|
||||
if let Some(sample) = state.samples.get(&u7::from_int_lossy(state.cursor.0 as u8)) {
|
||||
state.voices.push(sample.play())
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue