No internet connection
  1. Home
  2. How to

How to select an AudioSuite/Insert user preset via the Stream Deck

This script will allow you to select one of the first 15 user presets (preset not in a sub folder when clicking the preset drop down) via the Stream Deck.

function formatTitle(s) {
    var res = '', i = 0;
    while (s.length > 0 && i < 3) {
        res += s.substring(0, 7) + '\n';
        s = s.substring(7);
        i++;
    }
    return res;
}

sf.ui.proTools.appActivate();

//Find the top most floating window containing 'Plug-in:' and locate its preset selector
var win, btn;
{
    win = sf.ui.proTools.floatingWindows.whoseTitle.matches(/(^Plug-in|^Audio Suite)/g).first;    
    if (!win) throw 'Could not find a window';
    win.elementRaise({}, 'Could not raise window');
    sf.wait({ intervalMs: 50 });
    btn = win.popupButtons.whoseTitle.contains('Librarian menu').first;
    if (!btn.exists) btn = win.popupButtons.whoseTitle.contains('Preset').first;
}

//Get the presets
var items = btn.popupMenuFetchAllItems().menuItems.map(function (item) {
    return {
        title: formatTitle(item.names.join(' -> ')),
        value: item.names,
        color: {
            r: 100,
            g: 100,
            b: 100,
        }
    };
}).filter(function (item) { return item.value.length === 1; });

//Cancel popup
sf.keyboard.press({ keys: 'esc' });

//Choose a preset via the Stream Deck
var selectedPresetPath = sf.devices.streamDeck.firstDevice.showModal({
    items: items
}).selectedItem.value;

//Get focus back
sf.ui.proTools.appActivate();
sf.wait({ intervalMs: 50 });
win.elementRaise();
sf.wait({ intervalMs: 50 });

//Select the preset from the menu
btn.popupMenuSelect({
    menuPath: selectedPresetPath,
});
Solved in post #5, click to view
  • 16 replies
  1. Dario Ramaglia @dario.ramaglia
      2019-04-15 18:38:34.150Z

      Very cool. Just to let you know, this code doesn't recognize folders ;)

      1. That's what I was trying to write in the post - it will only take the root items as it is right now, yes.

        1. Dario Ramaglia @dario.ramaglia
            2019-04-15 18:50:31.872Z

            Maybe I should learn to read what you write and don't just look at the code ;)

        2. In reply tochrscheuer:

          Solution in the original post

          ReplySolution
          1. G
            In reply tochrscheuer:
            Gregor Arnold @Gregor_Arnold
              2019-10-11 08:22:37.507Z

              Hi, very cool script. I have put this in a command and made a button for stream deck called "select Audiouite preset" and layed that on a deck, where also other buttons are populated. When I press the button, the script works as intended: the buttons are populated with my presets and I can selesct one. But after that I would want the deck to return to the previous state. How could that be achieved? As for now the preset names stay on the buttons...

              1. Hi @Gregor_Arnold

                Yay that Dario's script is getting more attention :)
                The behavior you're seeing is a SoundFlow bug.
                We're looking into it.

                1. GGregor Arnold @Gregor_Arnold
                    2019-10-11 08:49:45.233Z

                    Allright then... I'll just have to wait then.

                    1. @Gregor_Arnold, one workaround might be to call a specific Deck from the script.
                      To do that, in a Macro use the "Show Deck on Stream Deck" action. Once you've set that up, copy the code to Javascript via the "..." button and insert in your script.
                      This might work :)

                      1. GGregor Arnold @Gregor_Arnold
                          2019-10-11 08:58:31.668Z

                          Yay... indeed it does work... Thanx...cool

                          1. Wohoo you're quick haha :) Great it worked (for now)!

                  • Z
                    In reply tochrscheuer:
                    Zahir Bandukwala @Zahir_Bandukwala
                      2020-03-12 13:50:04.087Z

                      HI ,
                      I am trying to load a preset named untitled in my Eq preset.
                      i get this error

                      This is the line , where the error occurs.

                      1. Hi Zahir

                        Thanks for reporting this. Can I get you to try to use the "Help/Issue" workflow for this so I can review the logs?
                        To get there, please click the SF icon, then click "Help/Issue" button and follow the instructions on screen.

                      2. In reply tochrscheuer:
                        Andrew Scheps @Andrew_Scheps
                          2020-03-12 20:11:21.158Z

                          This won't help with the error you're getting, but in an attempt to learn some more javascript I've done a version of the name formatting that makes things easier to read on the buttons. I'm sure there are cleaner ways to do this but it works.

                          function formatTitle(s) {
                              var res = '', i = 0;
                              var numDisplayLines = 0;
                              var maxLineLength = 7;
                              var splitPreset = s.split(" ");
                              if (splitPreset.length < 5) {
                                  for (i = 0; i < splitPreset.length - 1; i++) {
                                      res += splitPreset[i] + "\n";
                                  }
                                  res += splitPreset[splitPreset.length - 1];
                              } else {
                                  while (numDisplayLines < 5 && i < splitPreset.length - 1) {
                                      if (splitPreset[i].length + splitPreset[i + 1].length < maxLineLength) {
                                          res += splitPreset[i] + " " + splitPreset[i + 1] + "\n";
                                          i = i + 2;
                                      } else {
                                          res += splitPreset[i];
                                          i++;
                                      }
                                      numDisplayLines++
                                  }
                              }
                              return res;
                          }
                          
                          1. R
                            In reply tochrscheuer:
                            Robert Sörling @robertsorling
                              2021-03-18 22:36:14.965Z

                              Wow, found this by chance and it blew me away! So it made me think of something I’ve always wanted: Is it possible in the same manner to get the Stream Deck to dynamically show what inserts are open on a selected track, and by these buttons open an given insert by a press of a stream deck button? Maybe someone already did this (I’ve searched the forum with no luck). Or Maybe it’s not possible …?

                              1. O
                                In reply tochrscheuer:
                                Oscar Vargas @Oscar_Vargas
                                  2023-05-16 18:43:12.912Z2023-05-16 18:52:45.984Z

                                  This is amazing! Thanks @chrscheuer . How would I be able to modify so that it stays in the layout where it shows all the presets even after choosing one?
                                  I want to use it to denoise dialog (with Clarity - Waves), in my situation it makes sense to be able to try different percentages (every preset has a different percentage) before committing .

                                  1. N
                                    In reply tochrscheuer:
                                    Nick Leyers @Nick.Leyers
                                      2024-03-12 09:23:46.122Z

                                      Digging up this one. I have a audio suite-window trigger assigned for this script.
                                      That works, but I'm looking for a way to refresh every time I change windows. (so it follows me opening/focussing other audio suite windows)
                                      I can't make that work.

                                      My current workaround is pressing an empty slot on the dynamic SD. That gives me an error (index out of range) and then the script does a refresh on the new window.

                                      I've tried to add sf.ui.proTools.mainWindow.invalidate();but that doesn't do the trick because once the dynamic deck is visible, it stays there.

                                      Besides that: having 1 button on my stream deck that is not dynamic (for returning to another deck for example) might be handy. Can dynamic decks be combined with static buttons?