No internet connection
  1. Home
  2. How to

Mute and or Unmute during Playback/Record

By Aaron Hasson @Aaron_Hasson
    2025-09-13 21:35:39.477Z

    Hi There, I do not know java at all and trying to create scripts for ADR style recording. I tried to find something similar and make it my own but just need a little help. I just want a script that can mute/unmute tracks when transport goes into record and or playback.
    Thanks

    Solved in post #4, click to view
    • 5 replies
    1. D
      danielkassulke @danielkassulke
        2025-09-13 23:11:47.471Z2025-09-14 06:30:51.684Z

        Hi Aaron,

        Here's a script that does what you want, with a big caveat: the script will keep running forever because it has to constantly evaluate whether pro tools is recording or stopped, which might inhibit your ability to use trigger other soundflow actions at the same time:

        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.invalidate();
        
        while (true) {
            sf.ui.proTools.invalidate();
            const allTrackNames = sf.ui.proTools.trackNames;
        // track name to unmute in line below
            const matchingTrackNames = allTrackNames.filter(name => name === "your track name here");
        
            if (matchingTrackNames.length > 0) {
                if (sf.ui.proTools.isPlaying) {
                    sf.app.proTools.setTrackMuteState({
                        trackNames: matchingTrackNames,
                        enabled: true
                    });
                } else {
                    sf.app.proTools.setTrackMuteState({
                        trackNames: matchingTrackNames,
                        enabled: false
                    });
                }
            }
        
            sf.wait({ intervalMs: 100 });
        }
        

        I've happily used a surface/deck button as a latching talkback mute/unmute toggle, which frees up soundflow:

        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.invalidate();
        
        // track to unmute here
        const trackName = "your track name here";
        
        if (sf.ui.proTools.trackNames.includes(trackName)) {
            const track = sf.ui.proTools.trackGetByName({
                name: trackName,
                makeVisible: true
            }).track;
        
            const muteButton = track.buttons.getByTitle("Mute");
            const muteStateValue = muteButton.invalidate().value.value;
            const isMuted = muteStateValue === "on state";
        
            sf.app.proTools.setTrackMuteState({
                trackNames: [trackName],
                enabled: !isMuted
            });
        }
        
        1. AAaron Hasson @Aaron_Hasson
            2025-09-15 18:25:25.780Z

            This is awesome thank you. Can I ask one more thing? How can I have it so the track mutes on Record?

            1. Ddanielkassulke @danielkassulke
                2025-09-15 20:46:55.919Z

                Hi Aaron,

                Within the first script on line 8, you need to add the track name that you want to mute. The second script asks the same on line 5. As I mentioned, the first script will do that for you, with a big functional caveat for soundflow usage. Using a script that is always listening to a track's record enabled state means that soundflow is constantly running that script, and must be manually stopped by you. During that runforever script, any other soundflow scripts you attempt to run may not work, or may be unreliable.

                ReplySolution
                1. AAaron Hasson @Aaron_Hasson
                    2025-09-15 21:25:28.462Z

                    Yes Your second script is really how I want the script to behave; when PT goes into record sound flow sends a mute command to a track. So on your second script how can I change the mute state uppon record and not play?

                    Thank you very much

              • A
                In reply toAaron_Hasson:
                Aaron Hasson @Aaron_Hasson
                  2025-09-15 22:44:01.121Z

                  Hi Daniel,

                  Actually, if I use your second script and hit the button twice the mute is now off; so that will not work.

                  Is there is a way to:

                  If Transport is in record certain tracks mute and if the transport is in play certain tracks mute.