Toggle The Plugin Render Mode
Hi All, hope All is well on your side.
Searched but couldn't find a way to toggle with same button depending on the number of hits
Meaning: In a timeframe of 2s if I click the First time on X I get:
Create Individual Files + Clip by Clip
2nd Time I hit X I Get
Create Continuous File + Entire Selection
3rd time
Create Individual Files + Entire Selection
Linked from:
- Raphael Sepulveda @raphaelsepulveda2021-11-03 20:44:30.081Z2021-11-03 23:32:18.166Z
Hey Victor!
I like the concept of a multi-use button! Here's how I tackled it:
/** Counts the amount of times this function is called during a fixed amount of time * and passes that value to a callback from which different actions can take place. * @param {object} args * @param {string} args.name - Name for this instance. * @param {number} args.waitTime - Amount of time to wait in milliseconds. * @param {function} args.action - Callback to execute when the waitTime is over. Counter value will be passed as an argument. */ function actionCounter({ name, waitTime, action }) { let actionCounter; if (!globalState.actionCounter) globalState.actionCounter = {}; actionCounter = globalState.actionCounter; if (!actionCounter[name]) { actionCounter[name] = { i: 1 }; } else { actionCounter[name].i++ return; } sf.engine.runInBackground(() => { sf.wait({ intervalMs: waitTime, executionMode: "Background" }); try { action(actionCounter[name].i); } finally { delete globalState.actionCounter } }); } /** * @param {object} args * @param {'Input' | 'Output'} args.type * @param {'overwrite files' | 'create individual files'| 'create continuous file' | 'entire selection' | 'clip by clip'} args.mode */ function setAudioSuiteProcessingMode({ type, mode }) { const audioSuiteWin = sf.ui.proTools.firstAudioSuiteWindow; const modePopupBtn = audioSuiteWin.popupButtons.whoseTitle.is(`Processing ${type} Mode`).first; sf.ui.proTools.appActivateMainWindow(); if (modePopupBtn.value.value === mode) return; modePopupBtn.popupMenuSelect({ menuPath: [mode] }); } actionCounter({ name: 'switchBetweenAudioSuiteRenderModes', waitTime: 2000, action: i => { switch (i) { case 1: setAudioSuiteProcessingMode({ type: 'Output', mode: 'create individual files' }); setAudioSuiteProcessingMode({ type: 'Input', mode: 'clip by clip' }); break; case 2: setAudioSuiteProcessingMode({ type: 'Output', mode: 'create continuous file' }) setAudioSuiteProcessingMode({ type: 'Input', mode: 'entire selection' }) break; case 3: setAudioSuiteProcessingMode({ type: 'Output', mode: 'create individual files' }) setAudioSuiteProcessingMode({ type: 'Input', mode: 'entire selection' }) } } });
Assign this script to a button or keyboard shortcut and depending on the number of times you press it within two seconds it will perform the AudioSuite actions you requested. If two seconds is too long of a wait, you can change that by adjusting the
waitTime
value, which is in milliseconds. In my testing, I found that a value of 1000 (1 sec) felt pretty good too!Hope that helps!
- OOwen Granich-Young @Owen_Granich_Young
This is a mighty powerful function!
This makes me have a question, is there a way to make a template of this that the
case 1, 2, and 3
can be templated to trigger user defined macros? I have no idea if templates have a way to point to Marcos (yet) but that'd be some epic functionality.Raphael Sepulveda @raphaelsepulveda2021-11-03 22:27:02.264Z
I like the way you think! This is currently not supported but I will be all over it once it is!
- OOwen Granich-Young @Owen_Granich_Young
Can it point to another script? I've seen in Nick Leyers AudioSuite package in the store he has scripts that point to packages which come out as a crazy string of info :
Not sure how or where he even finds this package:xxxxxxx name to point to, in theory though that's the concept right?
Raphael Sepulveda @raphaelsepulveda2021-11-03 23:13:15.537Z2021-11-03 23:20:41.693Z
Ah, nice workaround! Yes, you can!
If you use the script above and change the ending to look like this:
const { command1, command2, command3 } = event.props; actionCounter({ name: 'actionCounterInstance', waitTime: 1000 action: i => { switch (i) { case 1: sf.soundflow.runCommand({ commandId: command1 }); break; case 2: sf.soundflow.runCommand({ commandId: command2 }); break; case 3: sf.soundflow.runCommand({ commandId: command3 }); } } });
And then, on the template, you make three of these (with different property names, of course):
You'll end up with something that looks like this:
So now all you'd have to do is copy/paste the command IDs.
This is easily done by selecting the script or macro you want, and then going to "Command" > "Copy Command ID" on SoundFlows main menu.
That will copy the Command ID to the clipboard, so now you can paste it into the template!
- OOwen Granich-Young @Owen_Granich_Young
ROCK ON BUD!
Very COOL!
- In reply toraphaelsepulveda⬆:OOwen Granich-Young @Owen_Granich_Young
I put it in the store in a package called 'Multi-Function Buttons for Dummys'
Also incldued wait time in the template properties.
Credit given 100% to you obviously!Raphael Sepulveda @raphaelsepulveda2021-11-04 21:58:28.880Z
Sounds good, thanks!
- In reply toOwen_Granich_Young⬆:JJonathan Johnson @Jonathan_Johnson
Embarrassed to admit this... Looking now of your script for the 'multi function button for dummies' - have downloaded it, but can't find it in all my other scripts!
I see your on line now, what is the title for me to search to find this? Im not seeing it...
Wonder if my SoundFlow is glitching......
- OOwen Granich-Young @Owen_Granich_Young
Yeah sometimes quit SF completely and re-open. I've had trouble finding packages I've just downloaded before as well.
- JJonathan Johnson @Jonathan_Johnson
I just Tried it re starting and it came up perfect!
was going to text you but you beat me to it.
Thanks!!!
- VIn reply toVictor_Bresse⬆:Victor Bresse @Victor_Bresse
WOW Amazing Thank you both Very Much for your help and Ideas, I was thinking to make another one for the extra Handles seconds in Audio suite, Like 1 buttons To choose between, 0sec, 5sec and whole file!
Thanks a million For your Input! - VIn reply toVictor_Bresse⬆:Victor Bresse @Victor_Bresse
Hello Lovely Peops,
I think since I upgraded To PT 22.5 This function stopped working; Actually it works on the First Drop Down; the "Create Individual Files" But the Entire Selection" Vs "Clip by Clip" stopped working ...
Anything I should Change in the Script?Raphael Sepulveda @raphaelsepulveda2022-06-22 19:20:58.992Z
Hey @Victor_Bresse, are you on SoundFlow v5.1.5? If not, get it from the following link: https://my.soundflow.org/install
That should fix the issue!