rudimentary input quantizer

This commit is contained in:
🪞👃🪞 2024-07-05 15:48:28 +03:00
parent 665885f6ff
commit f6a7cbf38e
8 changed files with 108 additions and 54 deletions

View file

@ -18,6 +18,22 @@ handle!(App |self, e| {
});
const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
[Char('+'), NONE, "quant_inc", "Zoom in", |app: &mut App| {
app.quant = next_note_length(app.quant);
Ok(true)
}],
[Char('_'), NONE, "quant_dec", "Zoom out", |app: &mut App| {
app.quant = prev_note_length(app.quant);
Ok(true)
}],
[Char('='), NONE, "zoom_in", "Zoom in", |app: &mut App| {
app.time_zoom = prev_note_length(app.time_zoom);
Ok(true)
}],
[Char('-'), NONE, "zoom_out", "Zoom out", |app: &mut App| {
app.time_zoom = next_note_length(app.time_zoom);
Ok(true)
}],
[Char('x'), NONE, "extend", "double the current clip", |app: &mut App| {
if let Some(phrase) = app.phrase_mut() {
let mut notes = BTreeMap::new();
@ -29,7 +45,7 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
}
Ok(true)
}],
[Char('l'), NONE, "toggle_loop", "toggle looping", |app: &mut App| {
[Char('l'), NONE, "loop_toggle", "toggle looping", |app: &mut App| {
// TODO: This toggles the loop flag for the clip under the cursor.
Ok(true)
}],
@ -49,19 +65,19 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
// TODO: This moves the loop end to the next quant.
Ok(true)
}],
[Char(' '), NONE, "toggle_play", "play or pause", |app: &mut App| {
[Char(' '), NONE, "play_toggle", "play or pause", |app: &mut App| {
app.toggle_play()?;
Ok(true)
}],
[Char('a'), CONTROL, "add_scene", "add a new scene", |app: &mut App| {
[Char('a'), CONTROL, "scene_add", "add a new scene", |app: &mut App| {
app.add_scene(None)?;
Ok(true)
}],
[Char('t'), CONTROL, "add_track", "add a new track", |app: &mut App| {
[Char('t'), CONTROL, "track_add", "add a new track", |app: &mut App| {
app.add_track(None)?;
Ok(true)
}],
[Char('`'), NONE, "switch_mode", "switch the display mode", |app: &mut App| {
[Char('`'), NONE, "mode_switch", "switch the display mode", |app: &mut App| {
match app.section {
0 => {app.grid_mode = !app.grid_mode; Ok(true)},
1 => {app.chain_mode = !app.chain_mode; Ok(true)},
@ -69,16 +85,16 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
_ => Ok(false)
}
}],
[F(1), NONE, "toggle_help", "toggle help", |_: &mut App| {Ok(true)}],
[Char('r'), NONE, "toggle_record", "toggle recording", |app: &mut App| {
[F(1), NONE, "help_toggle", "toggle help", |_: &mut App| {Ok(true)}],
[Char('r'), NONE, "record_toggle", "toggle recording", |app: &mut App| {
app.track_mut().map(|t|t.1.toggle_record());
Ok(true)
}],
[Char('d'), NONE, "toggle_overdub", "toggle overdub", |app: &mut App| {
[Char('d'), NONE, "overdub_toggle", "toggle overdub", |app: &mut App| {
app.track_mut().map(|t|t.1.toggle_overdub());
Ok(true)
}],
[Char('m'), NONE, "toggle_monitor", "toggle input monitoring", |app: &mut App| {
[Char('m'), NONE, "monitor_toggle", "toggle input monitoring", |app: &mut App| {
app.track_mut().map(|t|t.1.toggle_monitor());
Ok(true)
}],
@ -96,6 +112,9 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
//s.sequencer_mut().map(|s|s.monitoring = !s.monitoring);
//Ok(true)
//}
[Tab, NONE, "focus_next", "focus next area", focus_next],
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
[Esc, NONE, "focus_out", "unfocus", escape],
[Up, NONE, "cursor_up", "move cursor up", |app: &mut App| {
if app.entered {
match app.section {
@ -174,17 +193,12 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
_ => Ok(false)
}
}],
[Tab, NONE, "focus_next", "focus next area", focus_next],
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
[Char('.'), NONE, "increment", "increment value", increment],
[Char(','), NONE, "decrement", "decrement value", decrement],
[Delete, CONTROL, "delete", "delete track", delete],
[Char('d'), CONTROL, "duplicate", "duplicate scene or track", duplicate],
[Enter, NONE, "activate", "activate item at cursor", enter],
[Esc, NONE, "escape", "unfocus", escape],
[Char('.'), NONE, "cursor_inc", "increment value", increment],
[Char(','), NONE, "cursor_dec", "decrement value", decrement],
[Delete, CONTROL, "cursor_delete", "delete track", delete],
[Char('d'), CONTROL, "cursor_duplicate", "duplicate scene or track", duplicate],
[Enter, NONE, "cursor_activate", "activate item at cursor", enter],
//[Char('r'), CONTROL, "rename", "rename current element", rename],
// [Char('='), NONE, "zoom_in", "Zoom in", zoom_in],
// [Char('-'), NONE, "zoom_out", "Zoom out", zoom_out],
// [Char('a'), NONE, "note_add", "Add note", note_add],
// [Char('z'), NONE, "note_del", "Delete note", note_del],
// [CapsLock, NONE, "advance", "Toggle auto advance", nop],