Focusing on named device
Hello gurus,
I can’t figure out how to focus on a named device regardless his position in group/chain or not.
Any clue ?
Tutorial somewhere ?
Thx
Glenn V. Answered question
Answering to myself it seems to be on the right way like this:
# Récupérer la première piste visible
track = self.song().visible_tracks[self.track_num(0)]
# Fonction récursive pour chercher un device nommé "FIRST"
def find_first_device(devices, path_prefix):
for index, device in enumerate(devices):
device_name = str(device.name)
current_path = f"{path_prefix}[{index}]"
# Si le nom du device est "FIRST", on retourne son chemin
if device_name == "FIRST":
return current_path
# Si le device contient des chaînes, on les explore
if device.can_have_chains:
for chain_index, chain in enumerate(device.chains):
sub_devices = chain.devices
sub_path_prefix = f"{current_path}.chains[{chain_index}].devices"
result = find_first_device(sub_devices, sub_path_prefix)
if result:
return result # Si trouvé dans une chaîne
return None # Si rien trouvé
# Lancer la recherche sur les devices de la piste
directory_first = find_first_device(track.devices, "self.song().visible_tracks[self.track_num(0)].devices")
# Affichage dans les logs
if directory_first:
self.log_message("csslog: FOUND FIRST at " + directory_first)
else:
self.log_message("csslog: FIRST not found")
Fabrice Planquette Edited comment
Sign up
User registration is currently not allowed.
The limit of this method is the directory is not updated when you move the device in the chain or you move the chain itself… Because I can’t figure out how to set a dynamic Listener for this chain… Or at least a dynamic Listener for this named device.
The workaround is to put midi controllers as Listener. Moving a controller will relaunch the script…