user.py: _send_midi denied
Hi,
the user.py 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 user.py file. But i get an error-log kind´a:
..\..\..\output\Live\win_64_static\Release\python-bundle\MIDI Remote Scripts\_Framework\ControlSurface.py”, 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 user.py function?
Regards
Dieter
Hi,
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 user.py file; instead, it sends the bytes to the c_instance
of the Remotify script that has imported the user.py file. Apparantly, these c_instance
s 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 user.py file, the c_instance
of the user.py file gets a send_midi method, but the c_instance
of the Remotify script that imports that user.py 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): self._send_midi(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.
Sign up
User registration is currently not allowed.