Selected Track Listener in Reactions

51 viewsGeneral
0

Most of the problems i have so far with trying to do my template for touchosc with CSS comes from the fact that when i try to use “selected_track” to create a listener in a reaction it seems that it only works for the currently selected track when the script is initialized.
For exemple creating a reaction with “Track’s name value has changed” (self.song().view.selected_track.add_name_listener) works fine but only for the track selected on init().

Is this a bug or the intented behaviour ?
would like to know.
Thanks!

admin Changed status to publish May 22, 2024
Attached Files:
0

If I understand you correctly, you’re saying that only the track which is selected when the script is initialised is classed as the selected track (changing the selected track has no effect)?

If you add a new track to the session, does it update?

admin Changed status to publish May 22, 2024
Attached Files:
0

Hi John!

Selected track works for all the controls i use in my template (volumes, mutes, sends…) but not when used as a listener for example when the selected track name has changed.
It works only for 1 track, the one selected on init() and if i add a new track to the session like you said it updates but then it only works for the newly created track.

admin Changed status to publish May 22, 2024
0

Something like that would work i think :

def set_selected_track_listeners(self):
if(self.song().view.selected_track.name_has_listener(self.custom_listener)):
self.song().view.selected_track.remove_name_listener(self.custom_listener)
self.song().view.selected_track.add_name_listener(self.custom_listener)

Also when trying to get the id of the selected track (get_selected_track_num) it does not work for return tracks, your script returns false because it cannot find it.
You may want to add a function to check if the selected track is a return track before :

def is_return_track(self, track):
rt = self.song().return_tracks
for i in range(0, len(rt)):
if (rt[i] == track):
return(True)
return(False)

maybe there’s a better way but that’s what i’ve done so far.

admin Changed status to publish May 22, 2024
Attached Files:
0
admin Changed status to publish May 22, 2024
Attached Files:
0

Same problem here 🙂

admin Changed status to publish May 22, 2024
Attached Files: