mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-10 21:56:42 +01:00
wip: modularize once again
This commit is contained in:
parent
e08c9d1790
commit
3b6ff81dad
44 changed files with 984 additions and 913 deletions
41
src/midi.rs
41
src/midi.rs
|
|
@ -1,41 +0,0 @@
|
|||
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::*;
|
||||
|
||||
/// 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