markusschloesser / MackieC4_P3

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

ungrouping tracks produces KeyError #70

Closed markusschloesser closed 3 years ago

markusschloesser commented 3 years ago
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 276, in disconnect
RemoteScriptError: self.rem_mixer_listeners()
RemoteScriptError:   File "C:\ProgramData\Ableton\Live 11 Beta\Resources\MIDI Remote Scripts\MackieC4\MackieC4.py", line 526, in rem_mixer_listeners
RemoteScriptError: cb = self.mlisten[type][tr]
RemoteScriptError: KeyError
RemoteScriptError: <Track.Track object at 0x000000004AF86ED0>
BilldarBagdar commented 3 years ago

Please describe exactly what you mean by "ungrouping tracks". Or just agree with me (or not). :) If you mean not unhiding but actually ungrouping, then my intuition tells me this "missing track" issue is related to the "Group Track" that disappears. When you "group tracks", that Group Track gets created as if a Track had been added and is all that remains when the group is "hidden". When you ungroup a group that Group Track disappears from Live's track list as if a Track had been deleted.

cb = self.mlisten[type][tr]

I suspect self.mlisten is a "master list" of all "mixer listener reference types", and self.mlisten[type] points to another list of each Track with that listener type assigned, and finally self.mlisten[type][tr] is directly referencing that "missing track" or whatever the problem "track" is which is logged after the KeyError indicator. <Track.Track object at 0x000000004AF86ED0> I think that big hex number represents an address which generally indicates a valid "object". So, I suspect the Track.Track object is the Track represented by tr in cb = self.mlisten[type][tr]

That's about all I've got from that short error report snippet. I'll take a look at the surrounding code, but it seems like a quick fix would be wrapping that line in try/except

try:
    cb = self.mlisten[type][tr]
except KeyError:
    self.log_something()
    pass
markusschloesser commented 3 years ago

yep, actually just ungrouping. and yep, probably missing track. Yesterday I tried to massively change the way the whole track listener stuff is done, albeit unsuccessfully. But the current implementation is a mess, I mean just look at the amount of "remove track listener" code. Other scripts do this with 5 lines of code

BilldarBagdar commented 3 years ago

yes, I'm sure all the listener stuff is vintage Live 8, right? Neither of us has changed anything. I'm sure there are better ways, but I don't know a pattern to follow to successfully remove and replace that stuff. The best I can do right now is fix issues and make minor improvements. At some point all the little changes will start to pay dividends in the sense that simpler patterns are easier to spot, and the little changes can themselves combine into bigger changes, rinse and repeat.

Another perfectly valid way to go would be to just start over on a new script, "steal and adapt" a script for another 32 encoder controller, like the Behringer BCR2000, and go from there.

The script is less than ideal, for sure. but it's much less of a mess than it was a year ago. In fact, it's pretty functional for the simple songs I've been working with. (no m4l devices yet)

markusschloesser commented 3 years ago

Oh don't get me wrong, the C4 with the current state of the script is an absolute joy to use and basically fucking fantastic!!🤩☺ Even on my massive template, it usually works fine. And that includes tracks with 5 devices on them, each with dozens to 128 parameters. Lots of them m4l devices. One fantastic m4l to use with the C4 is Arp Control [https://www.maxforlive.com/library/device/5275/arp-control]. So while the use of the script is 😍, the code quality of the script (due to age) is what I was referring to earlier.

markusschloesser commented 3 years ago

yes, I'm sure all the listener stuff is vintage Live 8, right? Neither of us has changed anything. I'm sure there are better ways, but I don't know a pattern to follow to successfully remove and replace that stuff.

https://docs.google.com/document/d/1-r0w2E3IJiEtCIoQ9j-vnXadDUHAbiswE_HJ5iOh0Yk/edit is one way, but I currently am not capable of doing that. Also don't know if I should do this (https://github.com/markusschloesser/MackieC4_P3/discussions/69#discussioncomment-642778 ) first

markusschloesser commented 3 years ago

I think this might be fixed, needs testing

markusschloesser commented 3 years ago

tested, works fine Only one little problem: The display of the C4 shows a funny track name afterwards, no error thrown in Log and selecting another track works fine as well. So I will close this issue