markusschloesser / MackieC4_P3

A Mackie C4 Midi Remote Script for Ableton 11
20 stars 2 forks source link

very frequent ocb KeyError #66

Closed markusschloesser closed 2 years ago

markusschloesser commented 3 years ago

after working quite a bit with the script, this keeps popping up frequently:

RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 364, in track_change
RemoteScriptError: self.__encoder_controller.track_added(selected_index - 1)  # MS this get called when moving clip to another existing track, why?
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\EncoderController.py", line 309, in track_added
RemoteScriptError: MackieC4Component.refresh_state(self)  # MS why do we delegate to component, which in turn delegates to main??
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4Component.py", line 74, in refresh_state
RemoteScriptError: self.__main_script.refresh_state()
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 319, in refresh_state
RemoteScriptError: self.add_device_listeners()
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 840, in add_device_listeners
RemoteScriptError: self.rem_device_listeners()
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 876, in rem_device_listeners
RemoteScriptError: ocb = self.plisten[de]
RemoteScriptError: KeyError
RemoteScriptError: <PluginDevice.PluginDevice object at 0x0000000080CDA4A8>

referring to https://github.com/markusschloesser/MackieC4_P3/blob/78e323a9f34618539afd68eac2c70aa0cd77e6b4/wip/MackieC4/MackieC4.py#L876

ToDo: either fix it, or it will be fixed with @listener stuff

markusschloesser commented 3 years ago

I assume most of theses came when track changing from/in GUI. That was also the time, when the selected device on the C4 was not anymore the selected device in Live. IMHO this relates to https://github.com/markusschloesser/MackieC4_P3/issues/16 https://github.com/markusschloesser/MackieC4_P3/issues/53 https://github.com/markusschloesser/MackieC4_P3/issues/58

Have a look at https://github.com/markusschloesser/AbletonRemoteScriptsPY/blob/main/Push2/track_selection.py that's how Push 2 does is (relies on event object in v2 https://github.com/markusschloesser/AbletonRemoteScriptsPY/blob/main/ableton/v2/base/event.py )

markusschloesser commented 3 years ago

So how would one start replacing the old track stuff and do it like Push does it? From my understanding it relies on events (EventObject)and listens (listenable_property, ObservablePropertyAlias) to those (coming from Live), and when "things" change, all listeners get notified (but through an intermediary (liveobj_valid, liveobj_changedetc) and do their thing without the need to keep track of indexes

BilldarBagdar commented 3 years ago

There are two ways, at least. Starting over from scratch, building up from a clean base. The other way is to work with what you have and replace piece by piece or whatever.

I mean you could start from a blank sheet of paper, or for example, you could start with a method like "handle bank switch IDs" The "bank/page incrementing" part is all about data related to "remembering where you were", but the other part the "changing the current selected device" with the "single" buttons part. Has places where LOM data is updated and where the local data is updated. self.song().view.select_device(current_selected_device) is making the change in Live and the rest of the code is about updating the script. These three methods do the heavy lifting

self.__chosen_plugin = current_selected_device             
self.__reorder_parameters()                                
self.__reassign_encoder_parameters(for_display_only=False) 

of updating the script "database", and then the "midi map" gets rebuilt. There isn't a lot of fat to trim.

I just found ../ableton/v2/control_surface/internal_parameter.py This looks like exactly what we need in cases where we want to "map with feedback" without also having a "DeviceParameter" object to pass to the mapper method. We can pass a subclass or instance of InternalParameter that we create ourselves.

markusschloesser commented 2 years ago

haven't seen this error in ages, so closing issue