def _message_callback(self, msg):
        """Callback function to handle incoming MIDI messages."""
        if msg.type == 'polytouch':
            button = button_from_press(msg.note)
            if button:
                self.on_button(button, msg.value != 0)
            elif msg.note == 127:
                self.on_fader_touch(msg.value != 0)
        elif msg.type == 'control_change' and msg.control == 0:
            self._msb = msg.value
        elif msg.type == 'control_change' and msg.control == 32:
            self._fader = (self._msb << 7 | msg.value) >> 4
            self.on_fader(self._fader)
        elif msg.type == 'pitchwheel':
            self.on_rotary(1 if msg.pitch < 0 else -1)
        else:
            print('Unhandled:', msg)
def _message_callback ( self , msg ) : if msg . type == 'polytouch' : button = button_from_press ( msg . note ) if button : self . on_button ( button , msg . value != 0 ) elif msg . note == 127 : self . on_fader_touch ( msg . value != 0 ) elif msg . type == 'control_change' and msg . control == 0 : self . _msb = msg . value elif msg . type == 'control_change' and msg . control == 32 : self . _fader = ( self . _msb << 7 | msg . value ) >> 4 self . on_fader ( self . _fader ) elif msg . type == 'pitchwheel' : self . on_rotary ( 1 if msg . pitch < 0 else - 1 ) else : print ( 'Unhandled:' , msg )
Callback function to handle incoming MIDI messages.