wip: port: make device

This commit is contained in:
🪞👃🪞 2025-05-21 00:07:35 +03:00
parent 447638ee71
commit cb7e4f7a95
31 changed files with 602 additions and 865 deletions

View file

@ -9,10 +9,6 @@ pub use ::midly::{
live::*,
};
mod midi_in; pub use self::midi_in::*;
mod midi_out; pub use self::midi_out::*;
mod midi_hold; pub use self::midi_hold::*;
/// Return boxed iterator of MIDI events
pub fn parse_midi_input <'a> (input: ::jack::MidiIter<'a>) -> Box<dyn Iterator<Item=(usize, LiveEvent<'a>, &'a [u8])> + 'a> {
Box::new(input.map(|::jack::RawMidi { time, bytes }|(
@ -30,3 +26,12 @@ pub fn all_notes_off (output: &mut [Vec<Vec<u8>>]) {
evt.write(&mut buf).unwrap();
output[0].push(buf);
}
/// Update notes_in array
pub fn update_keys (keys: &mut[bool;128], message: &MidiMessage) {
match message {
MidiMessage::NoteOn { key, .. } => { keys[key.as_int() as usize] = true; }
MidiMessage::NoteOff { key, .. } => { keys[key.as_int() as usize] = false; },
_ => {}
}
}