mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
43 lines
1.6 KiB
Rust
43 lines
1.6 KiB
Rust
use crate::*;
|
|
|
|
pub(crate) mod midi_pool; pub(crate) use midi_pool::*;
|
|
pub(crate) mod midi_clip; pub(crate) use midi_clip::*;
|
|
pub(crate) mod midi_launch; pub(crate) use midi_launch::*;
|
|
pub(crate) mod midi_player; pub(crate) use midi_player::*;
|
|
pub(crate) mod midi_in; pub(crate) use midi_in::*;
|
|
pub(crate) mod midi_out; pub(crate) use midi_out::*;
|
|
|
|
pub(crate) mod midi_note; pub(crate) use midi_note::*;
|
|
pub(crate) mod midi_range; pub(crate) use midi_range::*;
|
|
pub(crate) mod midi_point; pub(crate) use midi_point::*;
|
|
pub(crate) mod midi_view; pub(crate) use midi_view::*;
|
|
|
|
pub(crate) mod midi_editor; pub(crate) use midi_editor::*;
|
|
pub(crate) mod midi_status; pub(crate) use midi_status::*;
|
|
|
|
/// Add "all notes off" to the start of a buffer.
|
|
pub fn all_notes_off (output: &mut [Vec<Vec<u8>>]) {
|
|
let mut buf = vec![];
|
|
let msg = MidiMessage::Controller { controller: 123.into(), value: 0.into() };
|
|
let evt = LiveEvent::Midi { channel: 0.into(), message: msg };
|
|
evt.write(&mut buf).unwrap();
|
|
output[0].push(buf);
|
|
}
|
|
|
|
/// Return boxed iterator of MIDI events
|
|
pub fn parse_midi_input (input: MidiIter) -> Box<dyn Iterator<Item=(usize, LiveEvent, &[u8])> + '_> {
|
|
Box::new(input.map(|RawMidi { time, bytes }|(
|
|
time as usize,
|
|
LiveEvent::parse(bytes).unwrap(),
|
|
bytes
|
|
)))
|
|
}
|
|
|
|
/// 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; },
|
|
_ => {}
|
|
}
|
|
}
|