mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
wip: modularize once again
This commit is contained in:
parent
e08c9d1790
commit
3b6ff81dad
44 changed files with 984 additions and 913 deletions
43
midi/src/lib.rs
Normal file
43
midi/src/lib.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
pub(crate) use ::tek_tui::{*, tek_input::*, tek_output::*, crossterm::event::KeyCode};
|
||||
pub(crate) use ::tek_jack::*;
|
||||
|
||||
mod midi_pool; pub(crate) use midi_pool::*;
|
||||
mod midi_clip; pub(crate) use midi_clip::*;
|
||||
mod midi_launch; pub(crate) use midi_launch::*;
|
||||
mod midi_player; pub(crate) use midi_player::*;
|
||||
mod midi_in; pub(crate) use midi_in::*;
|
||||
mod midi_out; pub(crate) use midi_out::*;
|
||||
|
||||
mod midi_note; pub(crate) use midi_note::*;
|
||||
mod midi_range; pub(crate) use midi_range::*;
|
||||
mod midi_point; pub(crate) use midi_point::*;
|
||||
mod midi_view; pub(crate) use midi_view::*;
|
||||
mod midi_editor; pub(crate) use midi_editor::*;
|
||||
|
||||
/// 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; },
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue