mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
refactor: contains_note_on
This commit is contained in:
parent
edadfde1a4
commit
f5da2e6dad
4 changed files with 42 additions and 46 deletions
|
|
@ -16,7 +16,23 @@ 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()) }
|
||||
}
|
||||
/** Write a chunk of MIDI events to an output port. */
|
||||
/// Check if a range `start..end` contains MIDI Note On `k`
|
||||
pub fn contains_note_on (&self, k: u7, start: usize, end: usize) -> bool {
|
||||
for (_, (_, events)) in self.notes.range(start..end).enumerate() {
|
||||
for event in events.iter() {
|
||||
match event {
|
||||
MidiMessage::NoteOn {key,..} => {
|
||||
if *key == k {
|
||||
return true
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
/// Write a chunk of MIDI events to an output port.
|
||||
pub fn process_out (
|
||||
&self,
|
||||
output: &mut MIDIChunk,
|
||||
|
|
@ -55,7 +71,7 @@ impl Phrase {
|
|||
}
|
||||
}
|
||||
}
|
||||
/** Read a chunk of MIDI events from an input port. */
|
||||
/// Read a chunk of MIDI events from an input port.
|
||||
pub fn process_in (
|
||||
&mut self,
|
||||
input: ::jack::MidiIter,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue