No internet connection
  1. Home
  2. Packages
  3. Dreamcatcher ADPTR Metric A/B Toggle Switch

ADPTR MetricAB Toggle

By Nathan Salefski @nathansalefski
    2023-08-05 15:15:51.732Z

    Anyone know why this isn't working? It can easily switch from B to A (the 'AXDecrement') but can't seem to go from A to B (the 'AXIncrement'). Is it somehow the initValue is not 0?

    var pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first
    var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
    if (!pluginView.exists) throw "Could Not Find MetricAB";
    
    //Use this to log a list of all parameter names:
    //log(pluginView.children.map(c => c.title.value).join('\n'));
    //throw 0;
    
    var parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
    
    //Toggle A/B
    if (parameterControl.value.invalidate().intValue === 0) {
        parameterControl.elementClick({
            actionName: 'AXIncrement'
        });
    } else {
        parameterControl.elementClick({
            actionName: 'AXDecrement'
        });
    }
    
    Solved in post #7, click to view
    • 32 replies

    There are 32 replies. Estimated reading time: 23 minutes

    1. S
      SoundFlow Bot @soundflowbot
        2023-08-05 15:15:53.171Z

        Thanks for posting a question or an issue related to the 'Dreamcatcher ADPTR Metric A/B Toggle Switch' package.
        This package is made by @Dreamcatcher_Studio. We're auto-tagging them here so that they will hopefully be able to help you.

        Please note, that the best way to get help with a script, macro or other content installed from the Store is to select the script you installed, then click the red Need help button, and then click "Get help with this script or macro".
        By using this workflow, the developer of the package will get access to more information so they'll be able to help you quicker.
        You can read more about how to best get help in this article: bit.ly/sfscripthelp

        1. Dustin Harris @Dustin_Harris
            2023-08-05 19:39:51.079Z

            Maybe it’s a checkbox instead of a ‘slider’?

            1. Nathan Salefski @nathansalefski
                2023-08-05 19:52:19.936Z

                I tried 'AXPress' as well but that didn't seem to work. How do I word it to work for something that is a checkbox?

                1. Dustin Harris @Dustin_Harris
                    2023-08-08 19:25:53.936Z

                    try this; Its a shot in the dark since I don't have this plugin:

                    var pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first
                    var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                    if (!pluginView.exists) throw "Could Not Find MetricAB";
                    
                    var parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                    
                    parameterControl.checkboxSet({
                        targetValue: "Toggle"
                    })
                    
                    1. Nathan Salefski @nathansalefski
                        2023-08-08 21:06:10.561Z

                        Unfortunately that's not working either. It's a very strange behavior. If I manually click the button once (switching it from A to B), parameterControl.elementClick({actionName: 'AXIncrement'});, parameterControl.elementClick({actionName: 'AXDecrement'}); and parameterControl.elementClick({actionName: 'AXPress'}); all work perfectly to switch it back (switching from B to A). I have no idea what the issue could be. @chrscheuer any ideas?

                        1. Dustin Harris @Dustin_Harris
                            2023-08-08 22:01:56.541Z

                            I downloaded the plugin, the button is actually a slider with two values: A is 0, and B is 2047. They are not settable director or with AXPress. SO, you can do a mouse click element conditionally:

                            var pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first
                            var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                            if (!pluginView.exists) throw "Could Not Find MetricAB";
                            
                            //Use this to log a list of all parameter names:
                            //log(pluginView.children.map(c => c.title.value).join('\n'));
                            //throw 0;
                            
                            var parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                            
                            if (parameterControl.value.invalidate().intValue === 0) {
                                log('Button set to A')
                            
                            } else if ((parameterControl.value.invalidate().intValue === 2047)) {
                                log('Button set to B')
                            }
                            
                            Reply1 LikeSolution
                            1. Nathan Salefski @nathansalefski
                                2023-08-08 22:20:29.534Z

                                Thanks for taking the time to do that! I knew something had to be weird about it. I heard SoundFlow will soon be able to change Stream Deck icons based on the status of a script, is that functionality out yet? If not is there a way to have momentary alerts that dismiss by themselves? For instance:

                                var pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first
                                var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                                if (!pluginView.exists) throw "Could Not Find MetricAB";
                                
                                //Use this to log a list of all parameter names:
                                //log(pluginView.children.map(c => c.title.value).join('\n'));
                                //throw 0;
                                
                                pluginWin.getElement("AXCloseButton").mouseClickElement({ relativePosition: {"x":143,"y":572},});
                                
                                var parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                                
                                if (parameterControl.value.invalidate().intValue === 0) {
                                     alert('Main Mix')
                                
                                } else if ((parameterControl.value.invalidate().intValue === 2047)) {
                                    alert('Reference')
                                }
                                
                                1. Dustin Harris @Dustin_Harris
                                    2023-08-08 22:25:56.406Z

                                    Yeah, using log() instead of alert() produces a momentary notification :)

                                    1. Nathan Salefski @nathansalefski
                                        2023-08-08 22:30:50.047Z

                                        Awesome thank you!

                                        1. In reply toDustin_Harris:
                                          Nathan Salefski @nathansalefski
                                            2023-08-08 23:13:13.314Z

                                            Any idea when Icon Status changes will be implemented?

                                            1. Dustin Harris @Dustin_Harris
                                                2023-08-08 23:17:44.938Z

                                                Not sure to be honest, that’s a @Kitch question :)

                                                1. In reply tonathansalefski:
                                                  Kitch Membery @Kitch2023-08-08 23:39:34.885Z

                                                  Hi @nathansalefski,

                                                  Meta Command functionality that was introduced in SoundFlow 5.4 allows for the creation of single dynamic commands, however, due to the complexity of creating Meta Commands is reserved for developers only. If you have suggestions/requests for this sort of functionality please be sure to ask in the ideas section of the forum, that way they'll be logged for consideration in future versions of SoundFlow.

                                                  Thanks in advance.

                                                  1. Nathan Salefski @nathansalefski
                                                      2023-08-09 01:02:10.666Z

                                                      Understood. While I have you here, @Dustin_Harris mentioned the parameter I'm trying to control is a slider. I saw here you were able to adjust the value of a slider in RX here RX Gain #post-11. Is it possible to do this in this instance?

                                                      sf.ui.proTools.appActivateMainWindow();
                                                      sf.ui.proTools.invalidate()
                                                      
                                                      //Click AB Function
                                                      function aB() {
                                                          var pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first
                                                      
                                                          var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                                                      
                                                          var parameterControl = pluginView.sliders.whoseTitle.is('AB Switch').first;
                                                      
                                                          const currentValue = Number(parameterControl.value.invalidate().intValue);
                                                          if (currentValue === 0) {
                                                              //Set Value to 2047 then log('Reference')
                                                      
                                                          } else if ((currentValue === 2047)) {
                                                              //Set Value to 0 then log('Main Mix')
                                                          }
                                                      }
                                                      
                                                      aB();
                                                      
                                                      1. Dustin Harris @Dustin_Harris
                                                          2023-08-09 01:42:59.903Z

                                                          For that particular ‘slider’ seems to have 11-bit resolution but only two values (0, 2047) so even if you could use AxIncrement/decrement (which I don’t think you can?) you’d have to run it in a loop 2048 times. It’s much easier to use elementClick as you already have the element as a variable :)

                                                          1. In reply tonathansalefski:
                                                            Kitch Membery @Kitch2023-08-09 02:19:23.504Z

                                                            Hi @nathansalefski,

                                                            This is probably something that we'd need to implement internally as the slider values are bespoke for most parameters and the script would require some more complex logic. But it's certainly something that we'll look into. :-)

                                                            1. Nathan Salefski @nathansalefski
                                                                2023-08-09 02:48:15.403Z

                                                                Fantastic. Thank you both very much @Dustin_Harris @Kitch. I put up a post for full integration in the ideas forum as suggested. If you’re not a user this plugin is incredibly helpful. I can’t mix without it

                                                                1. Dustin Harris @Dustin_Harris
                                                                    2023-08-09 02:51:09.703Z

                                                                    The plug-in looks cool and well-designed, but I’m a post editor :)

                                                                    1. Nathan Salefski @nathansalefski
                                                                        2023-08-09 12:32:21.138Z

                                                                        That's awesome. It could still have some use to reference previous versions of your edits to the current but I definitely think it's more geared towards mixing music.

                                                                        1. Dustin Harris @Dustin_Harris
                                                                            2023-08-09 13:19:27.831Z

                                                                            here's a version of the script I made out of interest. It's using a newer version of the plugin so some of the element names have changed, but I think you'll be able to adapt it for your needs :)

                                                                            function clickAbButton() {
                                                                                let position = sf.mouse.getPosition().position;
                                                                                let pluginWin = sf.ui.proTools.getAudioSuiteWindow("ADPTR MetricAB");
                                                                                let f = pluginWin.frame;
                                                                            
                                                                                sf.mouse.setPosition({
                                                                                    position: { x: f.x + 145, y: f.y + 601 }
                                                                                });
                                                                            
                                                                                sf.mouse.click({
                                                                                    position: { x: f.x + 145, y: f.y + 601 }
                                                                                });
                                                                            
                                                                                sf.mouse.setPosition({position});
                                                                            }
                                                                            
                                                                            function main() {
                                                                                sf.ui.proTools.appActivateMainWindow();
                                                                            
                                                                                let pluginWin = sf.ui.proTools.getAudioSuiteWindow("ADPTR MetricAB");
                                                                                let controlGroup = pluginWin.groups.whoseTitle.is("PluginView").first;
                                                                                let abSwitch = controlGroup.children.whoseTitle.is('AB Switch').first;
                                                                            
                                                                                clickAbButton();
                                                                            
                                                                                if (abSwitch.value.invalidate().intValue === 0) {
                                                                                    log('Button set to A')
                                                                            
                                                                                } else if ((abSwitch.value.invalidate().intValue === 2047)) {
                                                                                    log('Button set to B')
                                                                                }
                                                                            }
                                                                            
                                                                            
                                                                            main();
                                                                            
                                                                            1. Nathan Salefski @nathansalefski
                                                                                2023-08-09 14:23:41.675Z

                                                                                Amazing. Thanks! I had something similar but implementing the secondary function is working great. The only gripe I have is when switching back and fourth frequently the log ends up taking up a lot of screen space. Other than that it's working perfectly.

                                                                                sf.ui.proTools.appActivateMainWindow();
                                                                                sf.ui.proTools.invalidate()
                                                                                
                                                                                let pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first;
                                                                                
                                                                                function clickButton() {
                                                                                    let position = sf.mouse.getPosition().position;
                                                                                    let f = pluginWin.frame;
                                                                                
                                                                                    sf.mouse.setPosition({
                                                                                        position: { x: f.x + 145, y: f.y + 601 }
                                                                                    });
                                                                                
                                                                                    sf.mouse.click({
                                                                                        position: { x: f.x + 145, y: f.y + 601 }
                                                                                    });
                                                                                
                                                                                    sf.mouse.setPosition({position});
                                                                                }
                                                                                
                                                                                function aB() {
                                                                                
                                                                                    clickButton();
                                                                                
                                                                                    var pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                                                                                
                                                                                    var parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                                                                                
                                                                                    if (parameterControl.value.invalidate().intValue === 0) {
                                                                                        log('Main Mix')
                                                                                
                                                                                    } else if ((parameterControl.value.invalidate().intValue === 2047)) {
                                                                                        log('Reference')
                                                                                    }
                                                                                }
                                                                                
                                                                                function main() {   
                                                                                    //Select Monitor Track
                                                                                    sf.ui.proTools.trackSelectByName({ names: ["MONITOR"],});
                                                                                    
                                                                                    //Open "Insert 1"
                                                                                    sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1,});
                                                                                
                                                                                    //Wait for Plugin Window to Appear
                                                                                    pluginWin.elementWaitFor({waitType: "Appear"});
                                                                                
                                                                                    //AB Function
                                                                                     aB();
                                                                                
                                                                                    //Close "Insert 1"
                                                                                    sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1,});
                                                                                
                                                                                    //Wait for Plugin Window to Disappear
                                                                                    pluginWin.elementWaitFor({waitType: "Disappear"});
                                                                                }
                                                                                
                                                                                main();
                                                                                
                                                2. M
                                                  In reply tonathansalefski:
                                                  Marek Romanowski @Marek_Romanowski
                                                    2024-07-12 13:54:09.609Z

                                                    Hi, I follow your advices guys and still can't get it work...
                                                    Behaviour of this script - "....It can easily switch from B to A (the 'AXDecrement') but can't seem to go from A to B (the 'AXIncrement')..."
                                                    Could you please give me entire script?
                                                    Maybe I am doing something wrong when pasting...
                                                    @nathansalefski ? @Dustin_Harris ?

                                                    1. Nathan Salefski @nathansalefski
                                                        2024-07-12 14:39:26.786Z2024-07-12 14:56:51.624Z

                                                        You're not. Internally the value for A is 0 but the value for B is 2047. 'AXIncrement' increases values by 1 so you'd need to 'AXIncrement' 2047 times in order to get from A to B. A work around for me is simply clicking the UI itself, like below.

                                                        function clickButton(buttonPosition) {
                                                            let position = sf.mouse.getPosition().position;
                                                        
                                                            sf.mouse.setPosition({
                                                                position: buttonPosition
                                                            });
                                                        
                                                            sf.mouse.click({
                                                                position: buttonPosition
                                                            });
                                                        
                                                            sf.mouse.setPosition({ position });
                                                        }
                                                        
                                                        function aB(pluginWin, buttonPosition) {
                                                            // Clicks A|B Button
                                                            clickButton(buttonPosition);
                                                        
                                                            // Logs Button State
                                                            let pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                                                            let parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                                                        
                                                            if (parameterControl.value.invalidate().intValue === 0) {
                                                                log('Main Mix');
                                                            } else if (parameterControl.value.invalidate().intValue === 2047) {
                                                                log('Reference');
                                                            }
                                                        }
                                                        
                                                        function main() {
                                                            sf.ui.proTools.appActivateMainWindow();
                                                            sf.ui.proTools.invalidate();
                                                        
                                                            let pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first;
                                                            let buttonPosition = { x: pluginWin.frame.x + 145, y: pluginWin.frame.y + 601 };
                                                        
                                                            const monitorTrack = sf.ui.proTools.trackGetByName({ name: "MONITOR" }).track;
                                                        
                                                            // Select Track by Name: 'Monitor'
                                                            if (!monitorTrack.isSelected) {
                                                                sf.ui.proTools.trackSelectByName({ names: ["MONITOR"] });
                                                            }
                                                        
                                                            // Toggle Insert: 1
                                                            sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1 });
                                                        
                                                            // Wait for Plugin Window to Appear
                                                            pluginWin.elementWaitFor();
                                                        
                                                            // A|B Function: Clicks A|B button and logs button state
                                                            aB(pluginWin, buttonPosition);
                                                            // If you'd rather not log button state, use: 
                                                            // clickButton(buttonPosition);
                                                            
                                                        
                                                            // Toggle Insert: 1
                                                            sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1 });
                                                        
                                                            // Wait for Plugin Window to Disappear
                                                            pluginWin.elementWaitFor({ waitType: "Disappear" });
                                                        }
                                                        
                                                        main(); 
                                                        
                                                        1. MMarek Romanowski @Marek_Romanowski
                                                            2024-07-12 15:06:16.175Z

                                                            Thanks a lot sir!

                                                        2. A
                                                          In reply tonathansalefski:
                                                          Asi Tal @Asi_Tal
                                                            2024-08-10 13:51:29.727Z

                                                            Hey,, Did you solved this issue? I have a script that can only switch from B to A.
                                                            I would appreciate it a lot if you could help me with this issue.
                                                            Thanks!!
                                                            @nathansalefski

                                                            1. In reply toAsi_Tal:
                                                              Nathan Salefski @nathansalefski
                                                                2024-08-10 14:16:31.287Z

                                                                This should do the trick ADPTR MetricAB Toggle #post-23

                                                                1. AAsi Tal @Asi_Tal
                                                                    2024-08-10 14:41:02.136Z

                                                                    Thanks.. unfortunatly I keep getting error messages..

                                                                    1. AAsi Tal @Asi_Tal
                                                                        2024-08-10 14:45:45.216Z

                                                                        Is this the entire script you uses? (ADPTR MetricAB Toggle #post-23)
                                                                        @nathansalefski

                                                                        1. Nathan Salefski @nathansalefski
                                                                            2024-08-10 14:47:33.083Z
                                                                            function clickButton(buttonPosition) {
                                                                                let position = sf.mouse.getPosition().position;
                                                                            
                                                                                sf.mouse.setPosition({
                                                                                    position: buttonPosition
                                                                                });
                                                                            
                                                                                sf.mouse.click({
                                                                                    position: buttonPosition
                                                                                });
                                                                            
                                                                                sf.mouse.setPosition({ position });
                                                                            }
                                                                            
                                                                            function aB(pluginWin, buttonPosition) {
                                                                                // Clicks A|B Button
                                                                                clickButton(buttonPosition);
                                                                            
                                                                                // Logs Button State
                                                                                let pluginView = pluginWin.groups.whoseTitle.is("FXTDMEditView").first
                                                                                let parameterControl = pluginView.children.whoseTitle.is('AB Switch').first;
                                                                            
                                                                                if (parameterControl.value.invalidate().intValue === 0) {
                                                                                    log('Main Mix');
                                                                                } else if (parameterControl.value.invalidate().intValue === 2047) {
                                                                                    log('Reference');
                                                                                }
                                                                            }
                                                                            
                                                                            function main() {
                                                                                sf.ui.proTools.appActivateMainWindow();
                                                                                sf.ui.proTools.invalidate();
                                                                            
                                                                                let pluginWin = sf.ui.proTools.windows.whoseTitle.is("Plug-in: ADPTR MetricAB").first;
                                                                                let buttonPosition = { x: pluginWin.frame.x + 145, y: pluginWin.frame.y + 601 };
                                                                            
                                                                                const monitorTrack = sf.ui.proTools.trackGetByName({ name: "MONITOR" }).track;
                                                                            
                                                                                // Select Track by Name: 'Monitor'
                                                                                if (!monitorTrack.isSelected) {
                                                                                    sf.ui.proTools.trackSelectByName({ names: ["MONITOR"] });
                                                                                }
                                                                            
                                                                                // Toggle Insert: 1
                                                                                sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1 });
                                                                            
                                                                                // Wait for Plugin Window to Appear
                                                                                pluginWin.elementWaitFor();
                                                                            
                                                                                // A|B Function: Clicks A|B button and logs button state
                                                                                aB(pluginWin, buttonPosition);
                                                                                // If you'd rather not log button state, use: 
                                                                                // clickButton(buttonPosition);
                                                                                
                                                                            
                                                                                // Toggle Insert: 1
                                                                                sf.ui.proTools.selectedTrack.trackInsertToggleShow({ insertNumber: 1 });
                                                                            
                                                                                // Wait for Plugin Window to Disappear
                                                                                pluginWin.elementWaitFor({ waitType: "Disappear" });
                                                                            }
                                                                            
                                                                            main(); 
                                                                            
                                                                            1. AAsi Tal @Asi_Tal
                                                                                2024-08-10 15:04:00.057Z

                                                                                Thanks. still getting error message. I guess I'm doing something wrong.
                                                                                The ADPTR plugin is on my Master and on slot 6 (if it helps)
                                                                                @nathansalefski

                                                                                1. Nathan Salefski @nathansalefski
                                                                                    2024-08-10 16:02:32.090Z

                                                                                    There are specific parameter you may need to adjust for it to work with your personal workflow like changing the track name in lines 37 and 41 and the insert number on lines 45 and 57.

                                                                                    1. AAsi Tal @Asi_Tal
                                                                                        2024-08-10 16:26:25.850Z

                                                                                        Yes, sorry , I'm really new with Soundflow and scripts.
                                                                                        I succeeded to over come this. Now It works but only if I manually click the AB plugin just to open it after I press the trigger.
                                                                                        I recorded my screen for reference . (link below)

                                                                                        on 0:03 I press the trigger key
                                                                                        on 0:04 I click manually on the adptr plugin.

                                                                                        and on the second try I didn't click manually on the plugin to open it and you can see the error message.

                                                                                        0:09 I press the trigger again
                                                                                        0:12 I receive the error message.

                                                                                        Is there any way to fix it so I wouldn't need to click the AB plugin every time?

                                                                                        Thanks again for your help.

                                                                                        @nathansalefski

                                                                                        1. In reply tonathansalefski:
                                                                                          AAsi Tal @Asi_Tal
                                                                                            2024-08-10 16:52:36.323Z

                                                                                            Solved!!!
                                                                                            Needed to add this after line 45:

                                                                                            targetValue: "Enable"

                                                                                            Thanks for your time!