martinpechmann / APC400000

A custom remote script for the APC40 Mk1, incorporating sequencing capabilities from Ableton Push
7 stars 1 forks source link

Update to Ableton 11 (Python2 to 3) #4

Open kaisernero opened 1 year ago

kaisernero commented 1 year ago

Hi,

I really would like to use the script in Ableton 11, but it doesn't show in the list. I guess that is because the script is written in python2 and Ableton 11 only supports python3. I already tried converting the script automatically with 2to3, but it still doesn't show in Ableton.

Are there any hints how I could update the script so I can use it in Ableton 11?

Thanks kaisernero

markusschloesser commented 1 year ago

what does the ableton log file complain about? it's not my repo and the amount of files is huge, but from my experiences with other scripts, the main things to fix/change is

  1. replace xrange with range ( just checked, there's tons of xrange in the script)
  2. you might need to change the way modules are imported
  3. there's no unicode in py 3, if you see that somewhere, replace it with str.
  4. there's more but you can also google that or even ask chatgpt to fix/convert the script for you
markusschloesser commented 1 year ago

oh and if you use a proper IDE, it will tell you what's wrong as well. I recommend Pycharm

kaisernero commented 1 year ago

Alright, thanks for the advice! I'll have a look into that.

kaisernero commented 1 year ago

So I updated the files, but Ableton still doesn't show the script. Below you see the section of Log.txt which seems relevant to me. Pycharm marks the line with the import as error as well, but so does it with some other lines (e.g. import Live). As I haven't got any experience in coding MIDI remote scripts, I don't know if there are any libraries which can be loaded without being in the actual python installation. For me it seems like something like that is the case.

Any suggestions what could be the problem here? Thanks in advance.

2023-04-15T02:00:38.884834: info: RemoteScriptError: Traceback (most recent call last):

2023-04-15T02:00:38.884864: info: RemoteScriptError:   File "<string>", line 1, in <module>

2023-04-15T02:00:38.885006: info: RemoteScriptError:   File "/Applications/Ableton Live 11 Suite.app/Contents/App-Resources/MIDI Remote Scripts/APC400000/__init__.py", line 2, in <module>

2023-04-15T02:00:38.885118: info: RemoteScriptError:     
2023-04-15T02:00:38.885140: info: RemoteScriptError: from APC400000 import APC400000
2023-04-15T02:00:38.885153: info: RemoteScriptError: 

2023-04-15T02:00:38.885169: info: RemoteScriptError:   File "/Applications/Ableton Live 11 Suite.app/Contents/App-Resources/MIDI Remote Scripts/APC400000/APC400000.py", line 14, in <module>

2023-04-15T02:00:38.885258: info: RemoteScriptError:     
2023-04-15T02:00:38.885278: info: RemoteScriptError: from _Framework.M4LInterfaceComponent import M4LInterfaceComponent
2023-04-15T02:00:38.885291: info: RemoteScriptError: 

2023-04-15T02:00:38.885306: info: RemoteScriptError: ModuleNotFoundError
2023-04-15T02:00:38.885319: info: RemoteScriptError: : 
2023-04-15T02:00:38.885332: info: RemoteScriptError: No module named '_Framework.M4LInterfaceComponent'
2023-04-15T02:00:38.885343: info: RemoteScriptError: 
markusschloesser commented 1 year ago

M4LInterfaceComponent seems to have been removed/replaced after 9.6, let me check if I can find the replacement

UPDATE: this is really a shot in the dark, but try changing the import from: from _Framework.M4LInterfaceComponent import M4LInterfaceComponent to from _MxDCore.MxDControlSurfaceAPI import MxDControlSurfaceAPI

and then in APC400000.py change

def _create_m4l_interface(self):
        self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard, priority=DEFAULT_PRIORITY+1)
        self.get_control_names = self._m4l_interface.get_control_names
        self.get_control = self._m4l_interface.get_control
        self.grab_control = self._m4l_interface.grab_control
        self.release_control = self._m4l_interface.release_control

to:

def _create_m4l_interface(self, mxdcore=None):
    self._m4l_interface = MxDControlSurfaceAPI(mxdcore)
    self.get_control_names = self._m4l_interface.object_get_control_names
    self.get_control = self._m4l_interface.object_get_control
    self.grab_control = self._m4l_interface.object_grab_control
    self.release_control = self._m4l_interface.object_release_control

this probably won't work, but it's getting late here and it might give us more hints.

kaisernero commented 1 year ago

Thanks, now I get a different error:

2023-04-15T14:40:22.912834: info: RemoteScriptError: Traceback (most recent call last):

2023-04-15T14:40:22.912857: info: RemoteScriptError:   File "<string>", line 1, in <module>

2023-04-15T14:40:22.912953: info: RemoteScriptError:   File "/Users/nero/Music/Ableton/User Library/Remote Scripts/APC400000/__init__.py", line 2, in <module>

2023-04-15T14:40:22.913063: info: RemoteScriptError:     
2023-04-15T14:40:22.913080: info: RemoteScriptError: from APC400000 import APC400000
2023-04-15T14:40:22.913091: info: RemoteScriptError: 

2023-04-15T14:40:22.913103: info: RemoteScriptError:   File "/Users/nero/Music/Ableton/User Library/Remote Scripts/APC400000/APC400000.py", line 24, in <module>

2023-04-15T14:40:22.913201: info: RemoteScriptError:     
2023-04-15T14:40:22.913218: info: RemoteScriptError: from Actions import DuplicateLoopComponent, UndoRedoComponent
2023-04-15T14:40:22.913228: info: RemoteScriptError: 

2023-04-15T14:40:22.913240: info: RemoteScriptError: ModuleNotFoundError
2023-04-15T14:40:22.913250: info: RemoteScriptError: : 
2023-04-15T14:40:22.913260: info: RemoteScriptError: No module named 'Actions'
2023-04-15T14:40:22.913268: info: RemoteScriptError: 

Is there any documentation for writing MIDI remote scripts? I haven't found anything in the internet yet. Where did you learn that M4LInterfaceComponent is discontinued?

markusschloesser commented 1 year ago

now I get a different error:

that's not a different error, we fixed the first import for m4l devices (which will probably fail once you actually start USING m4l devices) and now it is the next error :-)

Is there any documentation for writing MIDI remote scripts?

not really, but have a look at my github repo at https://github.com/markusschloesser/MackieC4_P3 . In the wiki and in the issues and discussions, you'll find some resources. Other than that the main source of info is other remote scripts here on Github, the Ableton forums, but imho the best source is looking at code-commented other scripts for example Julian Bayle https://structure-void.com/ableton-live-push-and-scripts/
https://structure-void.com/PythonLiveAPI_documentation/Live11.0.xml , also check https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006921160-virtual-environment-for-developing-Ableton-Live-Midi-Remote-scripts-in-PyCharm https://forum.ableton.com/viewtopic.php?p=1629556#p1629556 https://forum.ableton.com/viewtopic.php?t=200623

I can also send you an invite to a private repo, where I have all decompiled scripts from 9.6 - 11.2.

Where did you learn that M4LInterfaceComponent is discontinued?

I searched all my decompiled remote scripts and only found it in the 9.6 versions.

with this page you can check what was added/removed etc https://nsuspray.github.io/Live_API_Doc/

markusschloesser commented 1 year ago

change from Actions import DuplicateLoopComponent, UndoRedoComponent to from .Actions import DuplicateLoopComponent, UndoRedoComponent

kaisernero commented 1 year ago

Thanks! These are the current error messages, but with your resources, I'll try to have a look into that myself.

2023-04-17T11:36:57.177084: info: RemoteScriptError: Traceback (most recent call last):

2023-04-17T11:36:57.177101: info: RemoteScriptError:   File "<string>", line 1, in <module>

2023-04-17T11:36:57.177333: info: RemoteScriptError:   File "/Users/nero/Music/Ableton/User Library/Remote Scripts/APC400000/__init__.py", line 2, in <module>

2023-04-17T11:36:57.177495: info: RemoteScriptError:     
2023-04-17T11:36:57.177527: info: RemoteScriptError: from APC400000 import APC400000
2023-04-17T11:36:57.177536: info: RemoteScriptError: 

2023-04-17T11:36:57.177562: info: RemoteScriptError:   File "/Users/nero/Music/Ableton/User Library/Remote Scripts/APC400000/APC400000.py", line 24, in <module>

2023-04-17T11:36:57.177671: info: RemoteScriptError:     
2023-04-17T11:36:57.177700: info: RemoteScriptError: from .Actions import DuplicateLoopComponent, UndoRedoComponent
2023-04-17T11:36:57.177708: info: RemoteScriptError: 

2023-04-17T11:36:57.177735: info: RemoteScriptError:   File "/Users/nero/Music/Ableton/User Library/Remote Scripts/APC400000/Actions.py", line 2, in <module>

2023-04-17T11:36:57.177799: info: RemoteScriptError:     
2023-04-17T11:36:57.177812: info: RemoteScriptError: from itertools import izip, count
2023-04-17T11:36:57.177819: info: RemoteScriptError: 

2023-04-17T11:36:57.177829: info: RemoteScriptError: ImportError
2023-04-17T11:36:57.177836: info: RemoteScriptError: : 
2023-04-17T11:36:57.177844: info: RemoteScriptError: cannot import name 'izip' from 'itertools' (unknown location)
2023-04-17T11:36:57.177850: info: RemoteScriptError: 
markusschloesser commented 1 year ago

from itertools import izip, count I'd recommend using ChatGPT for your issues, it can be really helpful and also explains (if you ask). Been using it myself. in this case https://stackoverflow.com/questions/59135563/can-not-import-from-itertools-izip-on-python-3