diff --git a/src/midi.rs b/src/midi.rs index dd2528d..d45c5f8 100644 --- a/src/midi.rs +++ b/src/midi.rs @@ -60,24 +60,22 @@ pub fn connect_loop_with_callback( // Handle MIDI messages here let (command, note, _value) = (message[0], message[1], message[2]); //println!("Received MIDI message: {:?}", message); - match (command, note) { - (144, 3..=4) => { - for (id, f) in calls.iter() { - if note == *id { - f(); - } - let mut list = vec![]; - if note == 3 { - list.push([command, 3, 2]); - list.push([command, 4, 3]); - } else { - list.push([command, 3, 1]); - list.push([command, 4, 4]); - } - for n in list.iter() { - conn_clone.lock().unwrap().send(n).unwrap(); - conn_clone.lock().unwrap().send(n).unwrap(); - } + if let (144, 3..=4) = (command, note) { + for (id, f) in calls.iter() { + if note == *id { + f(); + } + let mut list = vec![]; + if note == 3 { + list.push([command, 3, 2]); + list.push([command, 4, 3]); + } else { + list.push([command, 3, 1]); + list.push([command, 4, 4]); + } + for n in list.iter() { + conn_clone.lock().unwrap().send(n).unwrap(); + conn_clone.lock().unwrap().send(n).unwrap(); } } } diff --git a/src/viewboard.rs b/src/viewboard.rs index baf6a27..4836bb6 100644 --- a/src/viewboard.rs +++ b/src/viewboard.rs @@ -29,7 +29,6 @@ struct RecvCommander<'a> { impl RecvCommander<'_> { fn new(output_interface: &mut Arc>) -> RecvCommander { // Assert all vectors are of the same size - assert_eq!(70, 70); RecvCommander { midi_address: output_interface, list_notes: (0..89).collect(), @@ -73,5 +72,7 @@ fn main() { send_note_on(&mut output_interface.lock().unwrap(), 2, 1); // sleep(Duration::from_millis(1000)); board.update(); - loop {} + loop { + sleep(Duration::from_millis(500)); + } }