Hi,
Is it possible to cycle through Commands?
For example, I’d like one button on my Stream Deck to cycle these Automation modes:
- Automation Read (Selected Tracks)
- Automation Touch (Selected Tracks)
- Automation Trim (Selected Tracks)
- Christian Scheuer @chrscheuer2019-12-26 08:26:59.678Z2019-12-26 09:10:11.496Z
Hi Jon.
It's definitely possible to cycle through commands to invoke. And this can be done in a lot of ways.
You can read some examples of this by searching for toggle in the forum:
https://forum.soundflow.org/-/search?q=toggleHere's a bit more explanation of the different solution types:
Using internal script state in a variable
The command itself can hold a state in a number variable for example, and just toggle between running each of the three commands you put here.
The pseudo code for such a command would be:
- Increase my internal state number
- If my internal state number is more than 3, set it back to 1
- Depending on the value of my internal state number, being 1, 2 or 3, perform 1 of 3 tasks.
The problem of having state in more than one place
But what if the script itself was at state 2 and ready to change to Automation Touch but that something else had already changed the state in Pro Tools so that the tracks were in Automation Touch. Then the script would try to change to Automation Touch which was already there, so in other words it would feel to the user as if the script was failing.
This is due to having the state of the system represented both in Pro Tools and in the script.Solving it by reading the Pro Tools state
But the best results you'll get by having a script that checks the current state in Pro Tools, and then reacts to that state. This way the script doesn't have a variable that holds a "copy" of the state (since we demonstrated having two copies of state that go out of sync is bad). We just read the state directly from Pro Tools.
Such a script is not universal in that the code will have to be tailored to reading the specific state that you're using in the script.
In this case you'd need to read the automation mode of the selected track(s), and then set up some logic based on that.For example, the pseudo code (logic) could be:
- If the current track is in automation mode READ (no trim), switch all selected tracks to TOUCH (no trim).
- If the current track is in automation mode TOUCH (no trim), switch all selected tracks to TOUCH (trim enabled).
- If the current track is in automation mode TOUCH (trim enabled), switch all selected tracks to READ (no trim).
- If none of the above conditions are true, switch all selected tracks to READ (no trim).
A different variation on this logic could be:
- If any of the selected tracks is in automation mode READ (no trim), switch all selected tracks to TOUCH (no trim).
- If any of the selected tracks is in automation mode TOUCH (no trim), switch all selected tracks to TOUCH (trim enabled).
- If any of the selected tracks is in automation mode TOUCH (trim enabled), switch all selected tracks to READ (no trim).
- If none of the above conditions are true, switch all selected tracks to READ (no trim).
Note how I've also mapped out the Trim mode to be applied together with touch, since there's no such thing as just being in trim mode, it's always combined with one of the "major" modes of read, touch, latch, touch/latch, etc.
Once you've decided on the specific logic you want, we could implement the script based on that logic.
- JJon Shamieh @Jon_Shamieh
Very helpful! I see your point with Trim and makes more sense to have it as a separate button so it can be applied to whatever major Automation mode I am in.
Christian Scheuer @chrscheuer2019-12-26 18:53:02.942Z
Gotcha. Then you can use the built in Automation Trim (Selected Tracks) to toggle the trim setting.
To cycle between read and touch on one key, your logic would then be something like:
- If the first selected track is in automation READ, set all selected tracks to TOUCH
- or, If the first selected track is in automation TOUCH, set all selected tracks to READ
- else (if the first selected track is neither in read nor in touch), set all selected tracks to READ.
Since the action is the same for step 2 and step 3, this can be boiled down to:
- If the first selected track is in automation READ, set all selected tracks to TOUCH
- else (if the first selected track is not in read), set all selected tracks to READ.
And now let's look at how to script that:
if (sf.ui.proTools.selectedTrack.automationModeButton.value.invalidate().value === 'read') { sf.ui.proTools.selectedTrack.automationModeSet({ automationModeName: 'touch', trackTargetMode: 'SelectedTracks' }); } else { sf.ui.proTools.selectedTrack.automationModeSet({ automationModeName: 'read', trackTargetMode: 'SelectedTracks' }); }
- JJon Shamieh @Jon_Shamieh
This works, but if I select Trim while in Read, let's say, I can't switch to Touch without Toggling out of Trim.. Possible to be able to switch to Touch /Trim from Read / Trim with same toggle button?
Christian Scheuer @chrscheuer2019-12-26 19:35:25.910Z
Gotcha, then try this:
if (sf.ui.proTools.selectedTrack.automationModeButton.value.invalidate().value.indexOf('read') >= 0) { sf.ui.proTools.selectedTrack.automationModeSet({ automationModeName: 'touch', trackTargetMode: 'SelectedTracks' }); } else { sf.ui.proTools.selectedTrack.automationModeSet({ automationModeName: 'read', trackTargetMode: 'SelectedTracks' }); }
- JJon Shamieh @Jon_Shamieh
Ding ding ding - perfect, there it is! Very much appreciated Christian.
- In reply tochrscheuer⬆:JJon Shamieh @Jon_Shamieh
Is there a way to make this apply to all selected tracks instead of just a single track?