No internet connection
  1. Home
  2. How to

Toggling/setting mute & solo for tracks by name

In SoundFlow 2.2+ (in beta as if this writing) muting and soloing tracks by name will be simplified.

Here are different ways to achieve setting the mute state:


sf.ui.proTools.trackGetByName({ 
    name: 'Audio 3'
}).track.trackSetMute({ targetValue: 'Enable' });

sf.ui.proTools.trackSetMuteByName({
    name: 'Audio 3',
    targetValue: 'Enable'   //'Enable' for muting, 'Disable' for unmuting, 'Toggle' for toggling the state
});

And different ways of setting the solo state:


sf.ui.proTools.trackGetByName({ 
    name: 'Audio 3'
}).track.trackSetSolo({ targetValue: 'Enable' });

sf.ui.proTools.trackSetSoloByName({
    name: 'Audio 3',
    targetValue: 'Enable'
});

You can also check if a track is muted/soloed:

if (sf.ui.proTools.selectedTrack.isMuted)
    log('Is muted');
else
    log('Is not muted');

Or, for example get direct access to the muteButton/soloButton:

sf.ui.proTools.selectedTrack.muteButton...
Solved in post #2, click to view
  • 18 replies
  1. Solution above

    ReplySolution
    1. Dario Ramaglia @dario.ramaglia
        2019-04-18 06:04:03.170Z

        Which would be the best way to alternate between mute and solo on a selected track?

        1. if (sf.ui.proTools.selectedTrack.isMuted)
          {
              sf.ui.proTools.selectedTrack.trackSetSolo({ targetValue: 'Enable' });
              sf.ui.proTools.selectedTrack.trackSetMute({ targetValue: 'Disable' });
          }
          else if (sf.ui.proTools.selectedTrack.isSoloed)
          {
              sf.ui.proTools.selectedTrack.trackSetSolo({ targetValue: 'Disable' });
              sf.ui.proTools.selectedTrack.trackSetMute({ targetValue: 'Enable' });
          }
          
          1. Note if the track is neither muted nor soloed it won't do anything. To do something you'd change the if/else conditions to match the desired behavior.

            1. Dario Ramaglia @dario.ramaglia
                2019-04-18 13:49:07.557Z2019-04-18 13:51:44.798Z

                And of course if I want a particular track to act like that I should use trackGetByName.
                I think the following script covers also the situation when nothing is on (neither Mute or Solo):

                sf.ui.proTools.trackGetByName({
                    name: 'Audio Guide',
                    makeVisible: true
                }).track.buttons.getByTitle('Mute').elementClick();
                
                sf.ui.proTools.trackGetByName({
                    name: 'Audio Guide',
                    makeVisible: true
                }).track.buttons.getByTitle('Solo').elementClick();
                
                1. That script is just toggling both mute and solo states, so solo will end up taking precedence, but once you clear that solo the track will still be muted, if the incoming state was that neither solo nor mute was active.

                  Here's one that works for any case and that operates on a specific track. The last else block is run if neither mute nor solo was selected prior, in this I let it start with solo mode:

                  var track = sf.ui.proTools.trackGetByName({
                      name: 'Audio Guide',
                      makeVisible: true
                  }).track;
                  
                  if (track.isMuted)
                  {
                      track.trackSetSolo({ targetValue: 'Enable' });
                      track.trackSetMute({ targetValue: 'Disable' });
                  }
                  else if (track.isSoloed)
                  {
                      track.trackSetSolo({ targetValue: 'Disable' });
                      track.trackSetMute({ targetValue: 'Enable' });
                  }
                  else
                  {
                      track.trackSetSolo({ targetValue: 'Enable' });
                      track.trackSetMute({ targetValue: 'Disable' });
                  }
                  
                  1. Seperate note. You can add scripts correctly formatted in here by making a line of three back ticks ``` before your script, and then a line of three back ticks after your script ```.
                    If you edit your post you can see how I did it.

                    1. Dario Ramaglia @dario.ramaglia
                        2019-04-29 14:34:43.547Z

                        What if I want to apply this script on more than 1 track at the same time?
                        Let's say I want to Mute/Solo track A and B together.

                        1. @dario.ramaglia it depends on how you want it to work.
                          I'm assuming you want it to toggle them mutually exclusively, eg. it would always be either

                          state 1:
                          A mute
                          B solo

                          or state 2:
                          A solo
                          B mute

                          Or how should the command iterate through?

                          When you have 2 tracks that can each have 2 different states of 2 variables, you would technically have 222 = 8 different states altogether. I'm assuming you don't want to loop through all 8 states.
                          Do you need it to also work for 3 tracks? Then, should one track always be soloed and the others muted?

                          1. Dario Ramaglia @dario.ramaglia
                              2019-04-29 20:27:57.252Z

                              I'd like 2 tracks to work like 1 track so:

                              A - Solo
                              B - Solo

                              And

                              A - Mute
                              B - Mute

                              This is not relate to the previous questions of course. I'm just trying to improve my knowledge about SF while studying javascript through the website you suggested ;)

                              1. Dario Ramaglia @dario.ramaglia
                                  2019-04-29 20:29:27.404Z

                                  Once I know how to apply the same command to more than one track at the same time, i would to try it with other things, not just Solo/Mute toggling.

                                  1. In reply todario.ramaglia:

                                    Cool. So the tricky thing here is just to be clear of what you're trying to do before. Because the clearer the logic is (if you can write it in English as sort of ... if this then do that or else do this) then converting it to Javascript is easier.

                                    In this case the script above checks the state of 1 track, eg. if (track.isSoloed) and then uses that (eg. is this track soloed) to determine what to do.

                                    To write a script for what you're saying, there are still unanswered questions for the logic.

                                    Since the script uses the current state of the track to determine what to do (if track is soloed, it does 1 thing, if the track is muted it does another, etc.) - what track should it check the state of, if it should control two tracks?
                                    Should it just check if the first track is soloed, and then set the state for both tracks, ignoring whatever track 2's state was before?

                                    1. For example, this uses the current state of track1 - if (track1.isMuted) etc. - but sets the state on both track1 and track2.

                                      var track1 = sf.ui.proTools.trackGetByName({
                                          name: 'Audio Guide 1',
                                          makeVisible: true
                                      }).track;
                                      var track2 = sf.ui.proTools.trackGetByName({
                                          name: 'Audio Guide 2',
                                          makeVisible: true
                                      }).track;
                                      
                                      if (track1.isMuted)
                                      {
                                          track1.trackSetSolo({ targetValue: 'Enable' });
                                          track1.trackSetMute({ targetValue: 'Disable' });
                                          track2.trackSetSolo({ targetValue: 'Enable' });
                                          track2.trackSetMute({ targetValue: 'Disable' });
                                      }
                                      else if (track1.isSoloed)
                                      {
                                          track1.trackSetSolo({ targetValue: 'Disable' });
                                          track1.trackSetMute({ targetValue: 'Enable' });
                                          track2.trackSetSolo({ targetValue: 'Disable' });
                                          track2.trackSetMute({ targetValue: 'Enable' });
                                      }
                                      else
                                      {
                                          track1.trackSetSolo({ targetValue: 'Enable' });
                                          track1.trackSetMute({ targetValue: 'Disable' });
                                          track2.trackSetSolo({ targetValue: 'Enable' });
                                          track2.trackSetMute({ targetValue: 'Disable' });
                                      }
                                      
                                      1. Dario Ramaglia @dario.ramaglia
                                          2019-04-29 20:54:40.114Z

                                          You are right, this is totally true.
                                          What i want to achieve is: if Track A and Track B are Muted than Solo them. If Track A and B are Soloed then mute them. And that can be achieved with the script you just wrote because if Track A is muted so is Track B then it is not necessary to check the status of both track, i just need to check the status of track A and apply the action on Track A and B. Anyway with all the info you gave I can do all kind of things now. Thank you so much 👍

                                          1. Awesome! Was not sure if I phrased it so it could be understood haha. Great, keep asking if you want to know more.

                                            1. Dario Ramaglia @dario.ramaglia
                                                2019-04-29 21:00:26.408Z

                                                I will, at the moment I'm making atom and sublime text recognize if apples are fruits or vegetables 😂

                    2. In reply tochrscheuer:
                      Daniel Perez @daniel_perez
                        2023-02-19 10:44:48.602Z

                        @chrscheuer
                        can i get a macro/script for monitoring control? i want to press play and hear the guide track(s) without having to unmute and solo them. in the studio, the re-recording mixer had a button on his console for that. he set up a bus, the track(s) wheren't muted or soloed, and when pressing the button he could hear the guide track(s), instead of the clips i edited. that would be incredebly useful.

                        1. Better to start this as a new thread. I don't have time right now for individual script development, but hopefully the community can help :)