wip: phrase loop

This commit is contained in:
🪞👃🪞 2024-07-04 16:24:57 +03:00
parent 9a6e7ab3b4
commit 4b909ffdc3
2 changed files with 31 additions and 1 deletions

View file

@ -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<PhraseData>) -> 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 {