Пример #1
0
    def test_trigger_on_custom_chord(self):
        mock = unittest.mock.Mock()
        chord = Chord.from_midi_list([20, 40, 60])
        self.assertFalse(self.MEL.handlers)  # Empty check
        self.MEL.add_handler(mock, chord)

        press_chord(self.loopback, chord)
        mock.assert_called()
Пример #2
0
 def _callback(self, msg):
     if msg.type == "note_on" and msg.velocity > 0:  # Key down
         self.recent_notes.append(msg.note)
         self.down_notes.add(msg.note)
         self.recent_chords.append(Chord.from_midi_list(self.down_notes))
         logger.debug(f"Note {msg.note} on")
         self._check_handlers()
     elif msg.type == "note_off" or (msg.type == "note_on" and msg.velocity == 0):  # Key up
         self.down_notes.remove(msg.note)
         logger.debug(f"Note {msg.note} off")