_send_midi denied

159 viewsCSS


the file is a great chance to do more efficient script code. I´ve done a few nice things last week, now I´m frustrated: I call the ” self._send_midi() ” command for sysex in a function inside the file. But i get an error-log kind´a:

..\..\..\output\Live\win_64_static\Release\python-bundle\MIDI Remote Scripts\_Framework\”, line 690, in _do_send_midi

2024-06-15T12:52:47.868496: error: RemoteScriptError: AttributeError: ‘css_slmkiiidevice’ object has no attribute ‘send_midi’

Does anybody know how I can use it inside a function?



Glenn Verhaeghe Answered question July 1, 2024


I also was stumped by this problem a while back and today I finally found (some kind of) a solution.

The _send_midi method is part of the ControlSurface module. Looking inside the module’s code I found that it then sends the bytes to the method _do_send_midi, which in turn sends the bytes to self._c_instance.send_midi (as you can see in the picture below):

Here’s where I think the problem happens (but I’m not entirely sure because I don’t fully understand how c_instance works):

_do_send_midi doesn’t send the bytes (AKA the SysEx message) to the c_instance of the file; instead, it sends the bytes to the c_instance of the Remotify script that has imported the file. Apparantly, these c_instances behave independently or something.

I’m taking a guess here but I think the c_instance creates a send_midi method whenever the _send_midi is called in its respective script. In other words, when calling _send_midi inside the file, the c_instance of the file gets a send_midi method, but the c_instance of the Remotify script that imports that file doesn’t get a send_midi method.

How to circumvent this problem:

Create your own send_midi method inside the class of the Remotify script, like this:

def send_midi(self, msg):

This way the _send_midi of the c_instance inside the Remotify script is called too.

The problem with this solution:

Whenever you will update your Remotify script, you’ll have to re-enter this piece of code.

I’ll send a feature request on the forum in the hope that the devs will implement some similar code to be added to each iteration of the script.

Glenn Verhaeghe Answered question June 30, 2024

Hello again,

I found a solution to the problem that occurred with the “solution” given in my first comment, namely that we’d have to manually insert the code everytime we’d regenerate our CSS script.

The solution is to make a Reaction that dynamically adds the “send_midi” method to the class instance.

You can find the details if you follow the link (need to scroll down a bit to the section after EDIT).

Glenn Verhaeghe Edited answer July 1, 2024