No internet connection
  1. Home
  2. How to

"Output window Follows selection(Toggle)" command stopped working after 4.1.1

By Emil Isaksson @studiomollan
    2020-09-17 11:22:19.380Z

    You helped me with a script a while back. Has worked great up until 4.1.1.

    It throws the error;
    Error: Object reference is not set to an instance of an object.
    (Output Window Follows Selection (toggle) line 25.)

    I'm not skilled enough in javascript to sort this out.

    var lastFocusedTrackName;
    
    function main() {
        try {
    
            var newName = sf.ui.proTools.selectedTrackNames[0];
            if (newName === lastFocusedTrackName || newName === undefined) return;
    
            lastFocusedTrackName = newName;
    
            if (!globalState.isFollowFocusedTrackActive) return;
    
            if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open')
                sf.ui.proTools.selectedTrack.trackOutputToggleShow({ onError: 'Continue' });
    
        } catch (err) {
        }
    }
    
    function runForever(name, action, interval, timeout) {
        var now = (new Date).valueOf();
        if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout
    
        globalState[name] = now;
        sf.engine.runInBackground(function () {
            try {
                while (true) {
                    sf.engine.checkForCancellation();
                    globalState[name] = (new Date).valueOf();
    
                    action();
    
                    sf.wait({ intervalMs: interval, executionMode: 'Background' });
                }
            } finally {
                globalState[name] = null;
            }
        });
    }
    
    runForever("isFollowFocusedTrackRunning", main, 500, 5000);
    
    
    • 20 replies

    There are 20 replies. Estimated reading time: 6 minutes

    1. S
      Emil Isaksson @studiomollan
        2020-09-17 11:31:15.417Z
        1. Thanks for reporting, Emil.

          Can I get you to log an additional report through this? Then I'll get your log files which hopefully will reveal some more info.
          Please click here to send us the information we need

          1. SEmil Isaksson @studiomollan
              2020-09-18 09:13:13.637Z

              Done

              1. Ah, my bad. Thanks for the report.

                1. Hi Emil,

                  I'm having trouble reproducing this here.
                  Can you share the exact code you have in the script "Output Window Follows Selection (toggle)"?

                  1. SEmil Isaksson @studiomollan
                      2020-09-22 13:20:48.247Z

                      sure;
                      ’’’
                      globalState.isFollowFocusedTrackActive = !globalState.isFollowFocusedTrackActive;

                      log(Follow Focused Track is now: ${globalState.isFollowFocusedTrackActive ? 'ON' : 'OFF'});
                      ’’’

                      1. SEmil Isaksson @studiomollan
                          2020-09-22 13:27:58.727Z

                          This is what i get when i turn it on.

                          1. SEmil Isaksson @studiomollan
                              2020-09-22 13:29:18.778Z

                              Should i maybe just reinstall SoundFlow?

                              1. Hi Emil.

                                Thank you for this. What confused me is that the line in the error message says line 25 but there are only a few lines in your script.
                                Your feedback gave me an idea though as to what may be going on. I'll try to go down that road to see if I'm right and get back to you.

                                1. And FWIW I don't think the error is on your end. I think it's a bug. Just trying to figure out where it comes from.

                                  1. SEmil Isaksson @studiomollan
                                      2020-09-22 14:48:18.194Z

                                      Ok cool.Thanks!

                                      1. In reply tochrscheuer:
                                        samuel henriques @samuel_henriques
                                          2020-09-23 19:18:12.960Z

                                          Hey Christian,
                                          I'm using a version of the same code and am getting an error as well.

                                          Error: Object reference not set to an instance of an object.
                                          (Track Output Folow track selection line 27)

                                          I'm stoping all soundflow commands and restarting the script and woks again for a wile.

                                          I'll put this on a Help/Issue if you prefer

                                          Thank you

                                          var lastFocusedTrackName;
                                          
                                          function main() {
                                              try {
                                          
                                                  var newName = sf.ui.proTools.selectedTrackNames[0];
                                                  if (newName === lastFocusedTrackName || newName === undefined) return;
                                          
                                                  lastFocusedTrackName = newName;
                                          
                                                  if (sf.ui.proTools.mainTrackOutputWindow.invalidate().exists && sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open' && (newName.indexOf('_MUSICA') == 0 || newName.indexOf('_FX') == 0))
                                              sf.ui.proTools.selectedTrack.trackOutputToggleShow();
                                           
                                           
                                              //sf.ui.proTools.selectedTrack.trackInsertToggleShow({
                                          //});    
                                          
                                              } catch (err) {
                                              }
                                          }
                                          
                                          function runForever(name, action, interval, timeout) {
                                              var now = (new Date).valueOf();
                                              if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout
                                          
                                              globalState[name] = now;
                                              sf.engine.runInBackground(function () {
                                                  try {
                                                      while (true) {
                                                          sf.engine.checkForCancellation();
                                                          globalState[name] = (new Date).valueOf();
                                          
                                                          action();
                                          
                                                          sf.wait({ intervalMs: interval, executionMode: 'Background' });
                                                      }
                                                  } finally {
                                                      globalState[name] = null;
                                                  }
                                              });
                                          }
                                          
                                          runForever("isScrollToFocusedTrackRunning", main, 500, 5000);
                                          
                                          
                                          1. Hi Samuel.

                                            Thanks! I'm pretty sure I have an idea of what causes this, but thanks for offering a Help/Issue report. I'll ask for it if we need more help but for now we're all set :)

                      2. S
                        In reply tostudiomollan:
                        Emil Isaksson @studiomollan
                          2020-09-17 11:32:21.690Z

                          and one more thing.
                          I tried asking for help in the SF app but it gave me Error no window reference, or something similar.

                          1. S
                            In reply tostudiomollan:
                            Emil Isaksson @studiomollan
                              2020-11-08 12:09:08.741Z

                              Still the same for me. FYI. It generally works but i get "Error: Object reference is not set to an instance of an object." whenver im in finder and go back to pro tools. And sometimes within pro tools as well i think.

                              1. Hi Emil,

                                What's your SF version?

                                1. SEmil Isaksson @studiomollan
                                    2020-11-08 12:33:10.141Z

                                    4,1,4

                                    1. Thanks - please check if a manual upgrade to 4.1.6 helps (it should):

                                      https://soundflow.org/cp/install
                                      1. SEmil Isaksson @studiomollan
                                          2020-11-08 12:38:41.613Z

                                          cool . will do and report back.

                                        • In reply tostudiomollan:
                                          SEmil Isaksson @studiomollan
                                            2020-11-08 12:37:19.881Z

                                            Restart SF and it works for a while. Can't say what's the trigger for the error message. It feels random.