I'd like to make a separate button on my device for each track to toggle mute state.
I have a very basic script that stores the first 6 track names into variables.
//Get the track names of first 6 tracks
var selectedTrackName1 = sf.ui.proTools.selectedTrackNames[0];
var selectedTrackName2 = sf.ui.proTools.selectedTrackNames[1];
var selectedTrackName3 = sf.ui.proTools.selectedTrackNames[2];
var selectedTrackName4 = sf.ui.proTools.selectedTrackNames[3];
var selectedTrackName5 = sf.ui.proTools.selectedTrackNames[4];
var selectedTrackName6 = sf.ui.proTools.selectedTrackNames[5];
var selectedTrackName7 = sf.ui.proTools.selectedTrackNames[6];
so...for the script below, instead of toggling mute for 'Audio 3' I'd like to toggle mute for selectedTrackName(1-6)
Please excuse my beginner coding skills. Just getting my head around some of this stuff.
sf.ui.proTools.trackGetByName({
name: 'Audio 3'
}).track.trackSetMute({ targetValue: 'Enable' });
sf.ui.proTools.trackSetMuteByName({
name: 'Audio 3',
targetValue: 'Toggle'
});
- Chris Shaw @Chris_Shaw2022-02-07 23:05:11.119Z2022-02-07 23:23:54.199Z
This should do it:
Create a copy of this script for each selected track number you want to mute and changetoggleTrackMute = #
accordingly.This script will toggle the first selected track.
Creating a copy of this script and changingtoggleTrackMute
to 2 will mute the second selected track and so on.Assign each copy to a button on your deck and you should be good to go.
const toggleTrackMute = 1 sf.ui.proTools.appActivate() var selectedTracks = sf.ui.proTools.selectedTrackNames // Make sure that the selected track to mute exists if (toggleTrackMute > selectedTracks.length){ log (`There are only ${selectedTracks.length} tracks selected.`, `Track ${toggleTrackMute} can't be muted`); throw 0 }; // Mute track sf.ui.proTools.trackSetMuteByName({ name: selectedTracks[toggleTrackMute - 1], targetValue: 'Toggle' });
Chris Shaw @Chris_Shaw2022-02-07 23:20:39.636Z
I've re-edited the code to check that it is possible to mute the track # you want.
- LLes Cooper @Les_Cooper
Hey Chris. Thank so much for looking at this.
I think that I've caused a bit of confusion by naming my variables too close to the name of the selectedTrackNames action. I've changed the name of the variables to be copiedName(1-6) now
I think that this script may make more sense.
My hope is to be able to set the track names for the first 6 tracks (in this case) to variables and then at any point, even if I move the tracks, be able to mute or solo them.//Get the track names of first 6 tracks var copiedName1 = sf.ui.proTools.selectedTrackNames[0]; var copiedName2 = sf.ui.proTools.selectedTrackNames[1]; var copiedName3 = sf.ui.proTools.selectedTrackNames[2]; var copiedName4 = sf.ui.proTools.selectedTrackNames[3]; var copiedName5 = sf.ui.proTools.selectedTrackNames[4]; var copiedName6 = sf.ui.proTools.selectedTrackNames[5]; // code should toggle the mute state for whichever track is stored in the variable // so it should do the following // toggleTrackMute = whatever the string/name is of the track that is stored in copiedName1 // how do I assign that variable to the toggleTrackMute command?
Chris Shaw @Chris_Shaw2022-02-08 00:30:32.136Z2022-02-08 00:53:37.905Z
I see what you're trying to do. However every time you run this script it's going to overwrite the names (
copiedName
) from whatever tracks are selected at the time the script is run. If different tracks are selected the next time you run this script then the variables will not be the same.I'm not at my computer at the moment but this could be done.
You'll need two distinct scripts: one to store / update the names intoglobalSate
which will retain their values after the script is run, and another to select/retrieve the track names fromglobalState
and mute them (similar to the script I wrote above.Chris Shaw @Chris_Shaw2022-02-08 00:50:02.860Z
Use this script to get the track names to be muted and save them into a globalState:
sf.ui.proTools.appActivate() globalState.lcTracksToMute = sf.ui.proTools.selectedTrackNames
then use this to mute them (again changing the
toggleMute
value where needed)const toggleTrackMute = 1 sf.ui.proTools.appActivate() // Make sure that the selected track to mute exists if (toggleTrackMute > globalState.lcTracksToMute.length){ log (`There are only ${globalState.lcTracksToMute.length} tracks selected.`, `Track ${toggleTrackMute} can't be muted`); throw 0 }; // Mute track sf.ui.proTools.trackSetMuteByName({ name: globalState.lcTracksToMute[toggleTrackMute - 1], targetValue: 'Toggle' });
Now, once you set the names of the tracks to be muted you'll be able to use the second script to mute them even if you move them.
Chris Shaw @Chris_Shaw2022-02-08 00:51:48.208Z
Because other scripts can store values in
globalState
I prepended the global state variableTracksToMute
with your initials to make it more unique.
- In reply toChris_Shaw⬆:LLes Cooper @Les_Cooper
This is so great Chris!
I'm attempting to recreate my S3 on a surface and your script gets me a lot closer!My end goal, and this is likely a lot more involved,
- find a way to have the buttons reflect the mute/solo state of the tracks. ie. change color or show an M or an S
- dynamically populate buttons on my surface with the track names from the global name pull.
I'm not even sure if all of this is possible but it would be very cool if it was.
One can dream.