markusschloesser / MackieC4_P3

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

"Lock" to Device (or Track) #67

Open markusschloesser opened 3 years ago

markusschloesser commented 3 years ago

implement functionality to be able to lock the current device or track by pressing "Lock". Changing the device/track/chain in Live's GUI should not change the device (/ track) on the C4

possible Code

    def lock_to_device(self, device):
        if device:
            self._Encoders__device_locked = True
            self._Encoders__change_appointed_device(device)

    def unlock_from_device(self, device):
        if device:
            if device == self._Encoders__selected_device:
                self._Encoders__device_locked = False
                if not self._Encoders__parent.song().appointed_device == self._Encoders__selected_device:
                    self._Encoders__parent.request_rebuild_midi_map()

    def set_appointed_device(self, device):
        if not self._Encoders__device_locked:
            self._Encoders__change_appointed_device(device)
BilldarBagdar commented 3 years ago

I guess an implementation depends on the functionality you want to achieve. One of the more simple implementations would be to use a class level flag. When the Lock button LED is lit, whatever channel or device mode "page" you are looking at on the C4 can't be updated. I mean, I think, for example, if you just stop doing "reassign encoder parameters" stuff if DEVICE_IS_LOCKED == self.__lock_status and also ignore changing modes when the Lock button is engaged, that would probably get you pretty far along toward the goal.

This is kind of based on the fact that our "big list db" has "DeviceParameter" objects that "show" the "midi feedback" data. I think those "DeviceParameter" objects are fixed in the sense that they are directly linked to the device instance within Live and its parameters. If you stop reassigning the encoders to different parameters, the encoders will continue their current assignments, even as you change selected tracks and/or do other stuff in Live, or maybe not, but I would think they should.

The danger of course would be where it always is, when objects are deleted. What if you are Locked to a device and "parameter page 2" and that device gets deleted? Would the C4 automatically "unlock" the view?

markusschloesser commented 3 years ago

there's existing code for that, will try to implement. It's the difference between appointed and selected device (just now understood the purpose of "appointed device")

markusschloesser commented 3 years ago

https://github.com/markusschloesser/AbletonRemoteScriptsPY/blob/main/ableton/v2/control_surface/device_provider.py is perfect for that I guess

markusschloesser commented 2 years ago

from https://github.com/xot/ElectraOne/blob/main/DOCUMENTATION.md