sending midi sysex using from user.py possible?

933 viewsCSS Questionsuser.py
0

Is it possible to send midi sysex in a custom function in user.py?

ogan Answered question
2

Yes, it is possible. To make it work you’ll need to give your User class the ability to access the send_midi function of ableton’s API. You can do this in 2 ways:

1. set up a send_midi method inside the User class

def send_midi(self, msg):
    self._send_midi(msg)

this lets you use self.send_midi inside your other methods to call upon a SysEx message.

2. set c_instance to a class variable inside __init__

class user(ControlSurface):
  def __init__(self, c_instance):
    super(user, self).__init__(c_instance)
    with self.component_guard():
      self.c_instance = c_instance # <--- add this line
      return

c_instance contains the send_midi function you need to send SysEx messages, but simply using self.send_midi inside your User class won’t call upon it (except if you use the first method described above). But this second method also lets you access send_midi except that you’ll need to use it like follows:

self.c_instance.send_midi(your_sysex_message_here)

the SysEx message needs to be inside a tuple

send_midi expects a tuple with the SysEx message inside it

Glenn V. Posted new comment

Or you could just simply use self._send_midi(msg). I have a knack for overcomplicating things. The gist was, self.send_midi won’t work inside the default User class without making some changes, but self._send_midi (with the extra _ before send) works.

You are viewing 1 out of 2 answers, click here to view all answers.