From 4b909ffdc3d3d242cdc9e395cb030f6548e7fc99 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Thu, 4 Jul 2024 16:24:57 +0300 Subject: [PATCH] wip: phrase loop --- src/control.rs | 24 ++++++++++++++++++++++++ src/model/phrase.rs | 8 +++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/control.rs b/src/control.rs index 1a7818d5..966d8688 100644 --- a/src/control.rs +++ b/src/control.rs @@ -18,6 +18,30 @@ handle!(App |self, e| { }); const KEYMAP: &'static [KeyBinding] = keymap!(App { + [Char('x'), NONE, "extend", "double the current clip", |app: &mut App| { + // TODO: This duplicates the current clip's contents and doubles the length. + Ok(true) + }], + [Char('l'), NONE, "toggle_loop", "toggle looping", |app: &mut App| { + // TODO: This toggles the loop flag for the clip under the cursor. + Ok(true) + }], + [Char('['), NONE, "loop_start_dec", "move loop start back", |app: &mut App| { + // TODO: This moves the loop start to the previous quant. + Ok(true) + }], + [Char(']'), NONE, "loop_start_inc", "move loop start forward", |app: &mut App| { + // TODO: This moves the loop start to the next quant. + Ok(true) + }], + [Char('{'), NONE, "loop_end_dec", "move loop end back", |app: &mut App| { + // TODOO: This moves the loop end to the previous quant. + Ok(true) + }], + [Char('}'), NONE, "loop_end_inc", "move loop end forward", |app: &mut App| { + // TODO: This moves the loop end to the next quant. + Ok(true) + }], [Char(' '), NONE, "toggle_play", "play or pause", |app: &mut App| { app.toggle_play()?; Ok(true) diff --git a/src/model/phrase.rs b/src/model/phrase.rs index be954ac7..e1afccc3 100644 --- a/src/model/phrase.rs +++ b/src/model/phrase.rs @@ -4,6 +4,7 @@ pub struct Phrase { pub name: String, pub length: usize, pub notes: PhraseData, + pub looped: Option<(usize, usize)> } impl Default for Phrase { @@ -14,7 +15,12 @@ impl Default for Phrase { impl Phrase { pub fn new (name: &str, length: usize, notes: Option) -> Self { - Self { name: name.to_string(), length, notes: notes.unwrap_or(BTreeMap::new()) } + Self { + name: name.to_string(), + length, + notes: notes.unwrap_or(BTreeMap::new()), + looped: Some((0, length)) + } } /// Check if a range `start..end` contains MIDI Note On `k` pub fn contains_note_on (&self, k: u7, start: usize, end: usize) -> bool {