From 6bfd18c1ac5c5a73ae67466e6eed2bb719014c22 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 5 Aug 2023 13:00:45 +0100 Subject: [PATCH] call on_midi_press() only if midi.current == MIDI_BUTTON --- examples/midi/__main__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/midi/__main__.py b/examples/midi/__main__.py index 1dd1a85..4f531d7 100644 --- a/examples/midi/__main__.py +++ b/examples/midi/__main__.py @@ -14,19 +14,20 @@ class App: self.vm.observer.add(self.on_midi) def on_midi(self): - self.get_info() - self.on_midi_press() + if self.get_info() == self.MIDI_BUTTON: + self.on_midi_press() def get_info(self): current = self.vm.midi.current print(f"Value of midi button {current} is {self.vm.midi.get(current)}") + return current def on_midi_press(self): """if strip 3 level max > -40 and midi button 48 is pressed, then set trigger for macrobutton 0""" if ( - max(self.vm.strip[3].levels.postfader) > -40 - and self.vm.midi.get(self.MIDI_BUTTON) == 127 + self.vm.midi.get(self.MIDI_BUTTON) == 127 + and max(self.vm.strip[3].levels.postfader) > -40 ): print( f"Strip 3 level max is greater than -40 and midi button {self.MIDI_BUTTON} is pressed"