Function Keys as "Modes"
Is it possible at all to set function keys to effectively act as a mode, or activate a button on a stream deck that changes the behaviour of certain key commands (in my case,m wanting to change the behaviour of keyboard numbers 1-9?) I realise this would be quite easy to create using Streamdeck panels, but I really am a shortcut keyboard kind of guy! I'll try to explain what I want to achieve....
I'd like to be able to hit and release F1 then the number buttons act as marker point recall 1-9. And that works constantly whatever else I carry on doing, until I hit for example F2 and then the number buttons change behaviour and they now act as bypass toggles for inserts 1-9. Then it stays in that mode until either I hit F2 again to disable that mode completely, or I hit for example F3 and now numbers 1-9 correlate to Window configurations etc.
The idea was inspired by a script that used "runforever" and I wondered if there's such a command as "run until F2 is pressed" for example. There are a lot of different scenarios where using number keys makes the most sense, but with only so many modifier combinations it's easy to run out, or find yourself in an unpractical left hand claw where you don't remember which modifier does what.
I guess a 2nd part to this question is - is there anyway that key command assignments can be dynamic? As maybe then you have one set of commands that are related to editing, and another set that are more mix based, without changing the user profile in Soundflow - and this would all tie into the above idea of "modes". This could also be things like - IF an audiosuite window is open, then hitting Apple+Return renders it, but then IF an insert window is open then it toggles the bypass. Just an example - and I know these can be achieved by just using different key commands, I'm just curious if it's possible.
Thanks in advance
- OOwen Granich-Young @Owen_Granich_Young
Cool workflow idea! It can be done with
globalstate
This should get you started :Here's the script that will go on your F keys, generate as many "Modes" as you want by duplicating this script and chaning the
'Mode #'
For this example I've given you 2 modes but you can expand as much as you wantSET MODE 1 (Put this on your F1 or stream deck or wherever you want to switch modes)
globalState.modeChoice = 'Mode 1';
Here's the Button for SET Mode 2
globalState.modeChoice = 'Mode 2';
As you can see you can make any number more of scripts to increase your mode numbers by simply duplicating and changing the number in the text.
Then here's the script you would duplicate and populate to your numeric 1-9 which reads the
globalstate.modeChoice
and triggers the approriate
'behaviour'.if (globalState.modeChoice === 'Mode 1'){ log('Mode 1') /// Replace this log with the function (behavior) you want in MODE 1 } if (globalState.modeChoice === 'Mode 2'){ log ('mode 2') /// Replace this log with the function (behavior) you want in MODE 2 } if (!globalState.modeChoice){ log ('No Mode Yo') /// This one is here to tell you you have not enabled a globalstate yet. }
As you can see you can add any more number of
if (globalState.modeChoice === 'Mode #'){ ///Your code Goes here }
As you'd like, to increase the number of modes along with the Globalstate mode Buttons.
The time consuming part is going to be building your 1-9 buttons each with all the correct funcitons in each slot.
Really cool workflow idea though, I may try and template this to work with commandID's for easy plug and play for people when I find myself with some free time.
Bests,
OwenChristian Scheuer @chrscheuer2022-02-20 22:10:24.108Z
Owen, thanks for sharing!
One important thing - the code for setting the modes should just be a single line with no if blocks, just:
globalState.modeChoice = 'Mode 1';
The if blocks don't make sense / are unnecessary in this case :)
- OOwen Granich-Young @Owen_Granich_Young
Nice! TBH I just copy pasted my first learning of global state which was based around true false from @Kitch to work off, I'll update the above now so it looks like I knew that all along :P
Christian Scheuer @chrscheuer2022-02-20 22:15:40.667Z
Haha yea I thought that's what happened :) Totally cool to edit.
- PIn reply toPete_Watson⬆:Pete Watson @Pete_Watson
Thanks so much for getting me started guys...I'm still tip toeing into the scripting, quite good at editing existing ones, but nowhere near the point of creating them from scratch so this is a massive help!
I haven't explored creating custom surfaces yet, but presumably this would also be easy enough to create a small overlay window that could sit in the blank space to the right of the transport, showing the mode name that I'm currently in? Colour coded for each one etc.
This could be homework for the next few days!
- OOwen Granich-Young @Owen_Granich_Young
I have Zero Surface Experience, but that sounds cool, post it here if you figure it out!
- PIn reply toPete_Watson⬆:Pete Watson @Pete_Watson
Edit.... I got that working pretty fast thanks to your help. A followup question;
Is it possible to define these globalState via different kinds of actions other than keystrokes? Such as clicking a certain part of the UI, or a certain condition like a particular plugin window is open? Or a clip being selected in the arrange page? I presume it's possible and these will all have very different codings to define them, so any pointers on where to find a summary of these would be useful.
I need to dig into the surface readout for the mode I'm in, but I presume that is possible?
Finally is it possible to have keystrokes behave as an on off toggle? So hitting F1 puts it into mode 1, but hitting F1 again takes it out of Mode 1 and back into No Mode Defined? This could be useful for this but also for showing and hiding the onscreen Decks just on one key
Thanks again
Christian Scheuer @chrscheuer2022-02-20 23:53:29.659Z
Hi Pete,
For various types of triggers, make sure to check that out via our videos here:
https://www.youtube.com/playlist?list=PLKWpZOwx5Z3jxnpNo_dQPhDQNRwp7DCNjYou could set up a Window Trigger to run a script every time a specific window gets focused.
For more dynamic readings of states to determine which action to take, using globalState may not be the best way - you might instead want to read the state (for example which clip is selected etc.) in the script assigned to the specific shortcut.. Since that discussion could become pretty theoretical, my recommendation would be to take it step by step and ask for help with the specific workflow you'd have in mind - as giving a general response would be difficult. Different scenarios could have differing implementations.
For surfaces, currently you wouldn't be able to make a dynamic surface as this is currently reserved for SoundFlow Developers. You could instead have different surfaces that you show or hide, or use the "log" function to display a brief notification when you switch modes.
Yes, you could do toggles and any complex behavior of switching between modes.
You'll get the best help if you ask in separate threads for each specific question as you get to them. This helps keeps threads organized and makes it easier for others to find the information in the future :)
Good luck with it!
- In reply toPete_Watson⬆:OOwen Granich-Young @Owen_Granich_Young
Certainly Window triggers when you open a specfic plugin.
I have no idea about if a certain UI is clicked though. Looking through the trigger options nothing jumped out at me.
I don't know the command to 'clear global state' but if I did the If/Else script would be easy to write.
Anyone want to tell us how to clear
globalstate
?bests,
Owen- OOwen Granich-Young @Owen_Granich_Young
Ha didn't see the pro had already responded!