No internet connection
  1. Home
  2. How to

How to make a toggle Stream Deck button

Asked by @Sander_Houtman on FB:

Hi Christian,
Is it possible to make a multi switch via streamdeck?
For instance I press a button on the streamdeck <> it opens RX ambience match and learns what I've got selected in Pro tools. I select a part where I want the amb match to fill and press the same streamdeck button again (instead of a seperate render button) and it closes the amb match window.
thanks!

Solved in post #5, click to view
  • 8 replies
  1. The beauty of asking here on the forum is that you'll see there have already been questions asked about this in the past:

    1. The way to do this is to make a condition in your script that determines which of the actions you want to happen.
      In your case, you want to just toggle between 2 actions, but you won't be able to read the state of the RX ambience match (ie. has it learned or not) so you'll have to keep track of that state yourself.
      This is achievable via globalState.

      1. Here's an example of how to do it if you can read the state - for example if X do A, else do B:
        https://forum.soundflow.org/-1048#post-2

        1. In your case we can't read the state, so we can save it ourselves, like this:

          if (globalState.hasLearnedRXMatch) {
              //We have already learned. So insert render code here
          } else {
              //We have not learned yet. So insert learn code here.
          }
          globalState.hasLearnedRXMatch = !globalState.hasLearnedRXMatch;
          
          
          ReplySolution
        2. In reply tochrscheuer:
          SSander Houtman @Sander_Houtman
            2019-11-21 09:02:00.082Z

            Thanks.
            I'm not into scripting (yet). I'm using the actions only so far. Is it possible for you to add this function to the actions in a future update?

            1. Hi Sander.

              We will add control flow in the actions some time next year yes.
              For now, you can create your actions in the macro editor and then just copy/paste the Javascript code from the actions in the script where I put "insert X code here".

              1. SSander Houtman @Sander_Houtman
                  2019-11-21 09:11:20.878Z

                  Great thanks, will try this out now! Working on an M+E track so I have to amb match and fill a lot.

                  1. Cool :) Let me know if you get stuck.