No internet connection
  1. Home
  2. How to

Toggle between Timecode and Bars|Beats grid

By Chris Atkins @iamchrisatkins
    2020-10-16 05:44:13.407Z

    Hey I have seen a few posts similar to this, but nothing seemed to do what i wanted. I would love to be able to toggle through > Timecode 1 sec > timecode 1 frame and bars|beats 1/4 notes.

    Solved in post #2, click to view
    • 6 replies
    1. Kitch Membery @Kitch2020-10-16 06:59:28.269Z2020-10-16 07:51:58.410Z

      Hi Chris,

      Something like this should do it;

      const toggleObject = {
         oneSecond: { time: "1 second", counter: "Timecode" },
         oneFrame: { time: "1 frame", counter: "Timecode" },
         quarterNote: { time: "1/4 note", counter: "Bars|Beats" }
      };
      
      function selectMenuItem(selection) {
          const { time, counter } = selection;
          const gridValueField = sf.ui.proTools.mainWindow.groups.whoseTitle.is('Grid/Nudge Cluster').first.popupButtons.whoseTitle.is('Grid Value').first;
      
          gridValueField.popupMenuSelect({
              menuPath: [counter],
          });
      
          gridValueField.popupMenuSelect({
              menuPath: [time],
          });
      }
      
      function main() {
          sf.ui.proTools.appActivateMainWindow();
      
          const readOut = sf.ui.proTools.mainWindow.groups.whoseTitle.is('Grid/Nudge Cluster').first.popupButtons.whoseTitle.is('Grid Value').first.value.invalidate().value;
      
          switch (readOut) {
              case "00:00:01:00.00":
                  selectMenuItem(toggleObject.oneFrame);
                  break;
              case "00:00:00:01.00":
                  selectMenuItem(toggleObject.quarterNote);
                  break;
              case "1/4 note":
                  selectMenuItem(toggleObject.oneSecond);
                  break;
              default:
                  selectMenuItem(toggleObject.oneSecond);
          }
      }
      
      main();
      
      Reply3 LikesSolution
      1. Mike Cave @Mike_Cave
          2021-03-09 13:11:51.542Z

          Hi @Kitch is there a way to modify this script to toggle between Bars/Beats & Mins:secs? (pls see attached pic)

          Thanks :)
          Mike

          1. samuel henriques @samuel_henriques
              2021-03-09 21:10:32.658Z2021-03-09 21:32:07.272Z

              hello @Mike_Cave,

              Kitch might be busy doing awesome stuff for the next soundFlow update :)

              This works for me:

              //  function to change values
              function setValue(value) {
                  sf.ui.proTools.mainCounterSetValue({ targetValue: value })
              }
              
              // get current counter
              const mainCounter = sf.ui.proTools.getCurrentTimecode().stringValue
              
              /// if main counter is Bars Beats change to min secs else chage to Bars Beats
              mainCounter.match(/\|/i) !== null ? setValue("Min:Secs") : setValue("Bars|Beats")
              
              
              1. Kitch Membery @Kitch2021-03-09 21:13:25.054Z

                Thanks, @samuel_henriques,

                @Mike_Cave, that should do the trick.

                Nice one!!!

                1. samuel henriques @samuel_henriques
                    2021-03-09 21:15:37.314Z

                    update: missed the mainCounter variable

                    1. Mike Cave @Mike_Cave
                        2021-03-10 01:05:19.975Z

                        Awesome!! Thank you so much @samuel_henriques & @Kitch_Membery ....i've been wishing for this for years! :)

                        Best
                        Mike