mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 21:26:43 +01:00
wip: highlight keys
This commit is contained in:
parent
dff42ca5a7
commit
1e3d96e64e
5 changed files with 124 additions and 35 deletions
|
|
@ -16,15 +16,17 @@ pub struct Track {
|
|||
/// Output from current sequence.
|
||||
pub midi_out: Port<MidiOut>,
|
||||
midi_out_buf: Vec<Vec<Vec<u8>>>,
|
||||
/// Red keys on piano roll.
|
||||
pub notes_on: Vec<bool>,
|
||||
/// Device chain
|
||||
pub devices: Vec<JackDevice>,
|
||||
/// Device selector
|
||||
pub device: usize,
|
||||
/// Send all notes off
|
||||
/// FIXME: Some(nframes)?
|
||||
pub reset: bool
|
||||
pub reset: bool,
|
||||
/// Highlight keys on piano roll.
|
||||
pub notes_in: [bool;128],
|
||||
/// Highlight keys on piano roll.
|
||||
pub notes_out: [bool;128],
|
||||
}
|
||||
ports!(Track {
|
||||
audio: {
|
||||
|
|
@ -46,7 +48,8 @@ impl Track {
|
|||
name: name.to_string(),
|
||||
midi_out: jack.register_port(name, MidiOut)?,
|
||||
midi_out_buf: vec![vec![];16384],
|
||||
notes_on: vec![false;128],
|
||||
notes_in: [false;128],
|
||||
notes_out: [false;128],
|
||||
monitoring: false,
|
||||
recording: false,
|
||||
overdub: true,
|
||||
|
|
@ -147,14 +150,13 @@ impl Track {
|
|||
) {
|
||||
phrase.process_out(
|
||||
&mut self.midi_out_buf,
|
||||
&mut self.notes_on,
|
||||
&mut self.notes_out,
|
||||
timebase,
|
||||
(frame0.saturating_sub(start_frame), frames, period)
|
||||
);
|
||||
// Monitor and record input
|
||||
if self.recording || self.monitoring {
|
||||
// For highlighting keys and note repeat
|
||||
let notes_on = &mut self.notes_on;
|
||||
for (frame, event, bytes) in parse_midi_input(input) {
|
||||
match event {
|
||||
LiveEvent::Midi { message, .. } => {
|
||||
|
|
@ -175,10 +177,10 @@ impl Track {
|
|||
}
|
||||
match message {
|
||||
MidiMessage::NoteOn { key, .. } => {
|
||||
notes_on[key.as_int() as usize] = true;
|
||||
self.notes_in[key.as_int() as usize] = true;
|
||||
}
|
||||
MidiMessage::NoteOff { key, .. } => {
|
||||
notes_on[key.as_int() as usize] = false;
|
||||
self.notes_in[key.as_int() as usize] = false;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -218,10 +220,10 @@ impl Track {
|
|||
fn process_monitor_message (&mut self, message: &MidiMessage) {
|
||||
match message {
|
||||
MidiMessage::NoteOn { key, .. } => {
|
||||
self.notes_on[key.as_int() as usize] = true;
|
||||
self.notes_in[key.as_int() as usize] = true;
|
||||
}
|
||||
MidiMessage::NoteOff { key, .. } => {
|
||||
self.notes_on[key.as_int() as usize] = false;
|
||||
self.notes_in[key.as_int() as usize] = false;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue