Old 09-23-2019, 08:50 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default Lua: Generate script from custom action

I've seen this requested a few times, mostly because scripts are so much easier to share with other users.









Lokasenna_Generate script from custom action is available now on your friendly neighbourhood ReaPack.

Last edited by Lokasenna; 09-25-2019 at 06:51 AM.
Lokasenna is online now   Reply With Quote
Old 09-23-2019, 10:19 PM   #2
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 7,245
Default

No way. Does it work for cycle actions? Trying this now...

Damn. Doesn't work. Would love to turn all my CA into scripts... Thanks anyway.
__________________
Myyy Wyyyrd Music
foxAsteria is online now   Reply With Quote
Old 09-24-2019, 05:57 AM   #3
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

I did mention that in the OP. :P The file format for cycle actions is really easy, so I'm hoping to have one for them some time soon.
Lokasenna is online now   Reply With Quote
Old 09-24-2019, 07:31 AM   #4
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 7,245
Default

Derp. I'll learn how to read one of these days, I swear.... But seriously, that might be enough for me to get my head around scripting.

No more opening that clunky CA editor and I'll finally be able to keep all the unnecessary ones out of the Undo History.
__________________
Myyy Wyyyrd Music
foxAsteria is online now   Reply With Quote
Old 09-24-2019, 10:21 AM   #5
todoublez
Human being with feelings
 
todoublez's Avatar
 
Join Date: Aug 2019
Location: beijing
Posts: 129
Default

Holy molly...
Much appreciated !
Gonna try this for sure tomorrow.
Thx for yíall talents...
Life saver lol
todoublez is offline   Reply With Quote
Old 09-24-2019, 10:25 AM   #6
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,684
Default

If I get it right, it creates a script which runs the given actions just like the "regular-actions-combination-concept" in Reaper?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 09-24-2019, 10:33 AM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Pretty much - it just reads reaper-kb.ini to get the list of commands and spits out the Main_OnCommand for them, with options for PreventUIRefresh and Undo_BeginBlock.
Lokasenna is online now   Reply With Quote
Old 09-25-2019, 01:51 AM   #8
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,932
Default

Quote:
Originally Posted by Lokasenna View Post
I've seen this requested a few times, mostly because scripts are so much easier to share with other users.

1. Run the script.
2. Paste the ID for a custom action. (No cycle actions... yet)
3. Press 'Go'.
4. Go find your new file in the same folder as the script.

Lokasenna_Generate script from custom action is available now on your friendly neighbourhood ReaPack.
What is this script doing? If I have a custom action 40 actions, will this script combine them in such a way, I have only a single new script which does exactly same? If yes, how does it do this magic? It can not be just a simple copy and paste?
TonE is offline   Reply With Quote
Old 09-25-2019, 01:58 AM   #9
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,932
Default

Quote:
Originally Posted by foxAsteria View Post
No way. Does it work for cycle actions? Trying this now...
Anything should be possible what is possible with lua.

Rather than being "only" a recreation of original custom action, it could go one step beyond, by allowing certain extras, like checking for certain cases then doing different things for each. I have no good example now, but what comes to my mind something general like:
- detecting peak/resonant frequencies first
- then doing for each peak/resonant frequency something, like adding a sharp notch

Or frequency sweeping, then doing something with the peaks.
TonE is offline   Reply With Quote
Old 09-25-2019, 06:28 AM   #10
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Quote:
Originally Posted by TonE View Post
What is this script doing? If I have a custom action 40 actions, will this script combine them in such a way, I have only a single new script which does exactly same? If yes, how does it do this magic? It can not be just a simple copy and paste?
Exactly that.

Quote:
Originally Posted by TonE View Post
Anything should be possible what is possible with lua.

Rather than being "only" a recreation of original custom action, it could go one step beyond, by allowing certain extras, like checking for certain cases then doing different things for each. I have no good example now, but what comes to my mind something general like:
- detecting peak/resonant frequencies first
- then doing for each peak/resonant frequency something, like adding a sharp notch

Or frequency sweeping, then doing something with the peaks.
That's definitely a LOT more complicated, but I've been toying with a similar idea for ages - look at Cubase's Project Logical Editor for an example of what could be done.
Lokasenna is online now   Reply With Quote
Old 09-25-2019, 06:35 AM   #11
todoublez
Human being with feelings
 
todoublez's Avatar
 
Join Date: Aug 2019
Location: beijing
Posts: 129
Default

Generate script from custom action.lua:28: attempt to call a nil value.

is it something I'm missing here ?
I'm using mac btw.
couldnt find this script on my ReaPack browser so I searched it from GitHub.
:/
todoublez is offline   Reply With Quote
Old 09-25-2019, 06:47 AM   #12
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

If it's crashing there you probably don't have my GUI library installed, but it should be giving you a specific error message telling you that.

- Run Extensions -> ReaPack -> Synchronize packages
- Open the ReaPack browser
- Search for "Lokasenna's GUI library v2 for Lua" and select it to install
- Search for "Generate script from custom action" and select it to install (I just checked and it IS showing up on ReaPack)
- In your action list, run "Set Lokasenna_GUI v2 library path".
- You should be able to run "Generate script from custom action" now.
Lokasenna is online now   Reply With Quote
Old 09-25-2019, 06:51 AM   #13
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Added some example images to the OP since my explanation apparently sucked.
Lokasenna is online now   Reply With Quote
Old 09-25-2019, 10:33 PM   #14
todoublez
Human being with feelings
 
todoublez's Avatar
 
Join Date: Aug 2019
Location: beijing
Posts: 129
Default

Quote:
Originally Posted by Lokasenna View Post
- In your action list, run "Set Lokasenna_GUI v2 library path".
- You should be able to run "Generate script from custom action" now.
thanx!
Ah-ha! it works now, thanx for the tip!
Didn't know I gotta run "Set Lokasenna_GUI v2 library path" 1st.
Many thanx! Much appreciated.
todoublez is offline   Reply With Quote
Old 09-26-2019, 04:22 AM   #15
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 431
Default

Didnít try it yet, but does it work with CAs that have some CONSOLE actions in them?
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 09-26-2019, 04:37 AM   #16
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 791
Default

Holy Moly!!!

Absolutely brilliant idea!!
__________________
Cheers,
Andrew K
v5.983+dev0922 - September 22 2019 ē Mac 10.12.+ ē i7 Quad 2.9GHz ē 24GB
Thonex is offline   Reply With Quote
Old 09-26-2019, 05:59 AM   #17
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Quote:
Originally Posted by lexaproductions View Post
Didnít try it yet, but does it work with CAs that have some CONSOLE actions in them?
I don't see why it wouldn't.
Lokasenna is online now   Reply With Quote
Old 09-26-2019, 07:01 AM   #18
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 431
Default

Well I didnít even know you could address the reaconsole from the lua API
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 09-26-2019, 07:57 AM   #19
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 168
Default

Thanks for the great script!

Sorry for the semi-offtopic. But, I'm curious. What is the advantage of scripts over customs? Is it just convenience, or are there any technically important details?
cool is offline   Reply With Quote
Old 09-26-2019, 08:04 AM   #20
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,932
Default

There are no advantages, except it is a single file, but custom actions are maybe also a single file somewhere, not sure, if not that would be one advantage. Weakness is still this script is still dependent on possible many other scripts. Cool would be if this dependency would be removed, what I thought first. So from my perspective there are no advantages.
TonE is offline   Reply With Quote
Old 09-26-2019, 08:32 AM   #21
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Quote:
Originally Posted by lexaproductions View Post
Well I didnít even know you could address the reaconsole from the lua API
You can't - this is just using whatever commands are in your custom action. There are actions for things like "Open ReaConsole with 'v' to do whatever it is that 'v' does" - are we talking about something more than that?

Quote:
Originally Posted by cool View Post
Sorry for the semi-offtopic. But, I'm curious. What is the advantage of scripts over customs? Is it just convenience, or are there any technically important details?
1. Sharing.

Custom actions are all stored in one .ini file, so you would have to open that file, find the right action, copy the entire line and post it somewhere. Then someone else would have to copy it, open their copy of that file, paste it in, and reload Reaper. I'm not even sure if that works because Reaper generates a custom ID for the script, so copy/pasting to a different machine might cause trouble.

In contrast, a script is just a file that you load from the action list. Or upload to ReaPack.

2. Efficiency.

Some custom actions, especially if they're doing more things or being used in a larger project, might take a bit of time to operate - you can sometimes even see it doing X to one track at a time. This is because Reaper updates its UI each time you do something, and UI updates are really "expensive" compared to just shuffling information around under the hood.

Scripts can tell Reaper to pause the UI while they run so all of that appears to happen at once. I've had scripts take 30 seconds because of UI updates and drop down to less than 1 with the UI paused.

Quote:
Originally Posted by TonE View Post
Weakness is still this script is still dependent on possible many other scripts. Cool would be if this dependency would be removed, what I thought first.
That would be pretty cool. I'll add it to my giant list of ideas.
Lokasenna is online now   Reply With Quote
Old 09-26-2019, 09:36 AM   #22
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 168
Default

Quote:
Originally Posted by Lokasenna View Post

1. Sharing.

Custom actions are all stored in one .ini file, so you would have to open that file, find the right action, copy the entire line and post it somewhere. Then someone else would have to copy it, open their copy of that file, paste it in, and reload Reaper. I'm not even sure if that works because Reaper generates a custom ID for the script, so copy/pasting to a different machine might cause trouble.

In contrast, a script is just a file that you load from the action list. Or upload to ReaPack.

2. Efficiency.

Some custom actions, especially if they're doing more things or being used in a larger project, might take a bit of time to operate - you can sometimes even see it doing X to one track at a time. This is because Reaper updates its UI each time you do something, and UI updates are really "expensive" compared to just shuffling information around under the hood.

Scripts can tell Reaper to pause the UI while they run so all of that appears to happen at once. I've had scripts take 30 seconds because of UI updates and drop down to less than 1 with the UI paused.
Thanks for the detailed answer!
cool is offline   Reply With Quote
Old 09-26-2019, 01:15 PM   #23
Nostrap
Human being with feelings
 
Join Date: Dec 2017
Posts: 99
Default

This script is awesome thanks so much!
Nostrap is offline   Reply With Quote
Old 09-26-2019, 02:40 PM   #24
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Just outside of Glacier National Park
Posts: 12,680
Default

Hi Loka, this is great, I've got hundreds, and hundreds, and hundreds of custom actions and there's several of the I'd like to put in a script.

Question: Do the Command IDs stay the same if I send them to somebody or will they be different?
__________________
Kontakt Vid Tutorials->Create Outputs / Create Templates -|- SMDrums Free drums -|- Elk Video Productions -|- Tod's Music
Tod is offline   Reply With Quote
Old 09-26-2019, 03:06 PM   #25
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Quote:
Originally Posted by Tod View Post
Question: Do the Command IDs stay the same if I send them to somebody or will they be different?
Any actions from Reaper or SWS will be fine. Scripts might cause trouble, although if both you and the other user installed them via ReaPack I think they'll be okay because the IDs are (AFAIK) generated based on the file path and ReaPack is consistent in that regard.
Lokasenna is online now   Reply With Quote
Old 11-04-2019, 03:29 PM   #26
Buy One
Human being with feelings
 
Join Date: Sep 2019
Posts: 79
Default

Thank you, great idea.

One question, i see that scripts which have long alphanumeric IDs are referenced with nice 5 digit long IDs in the generated scripts which aren't found with a simple search in the reaper-kb.ini. How does this work?
Buy One is offline   Reply With Quote
Old 11-04-2019, 03:41 PM   #27
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

It takes the IDs from reaper-kb.ini and passes them to reaper.NamedCommandLookup. I guess Reaper processes the long names into a shorter ID internally, and that's what it gives back.
Lokasenna is online now   Reply With Quote
Old 11-05-2019, 07:43 AM   #28
Buy One
Human being with feelings
 
Join Date: Sep 2019
Posts: 79
Default

Quote:
Originally Posted by Lokasenna View Post
It takes the IDs from reaper-kb.ini and passes them to reaper.NamedCommandLookup. I guess Reaper processes the long names into a shorter ID internally, and that's what it gives back.
and i gather that these are not cross machine compatible even when another user has the same individual scripts but hosted at different paths, or are they and scripts IDs don't depend on the location or other contingencies and are the same across the board?

Last edited by Buy One; 11-05-2019 at 07:51 AM.
Buy One is offline   Reply With Quote
Old 11-05-2019, 07:52 AM   #29
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

I... don't actually know.
Lokasenna is online now   Reply With Quote
Old 11-05-2019, 01:01 PM   #30
Buy One
Human being with feelings
 
Join Date: Sep 2019
Posts: 79
Default

Alright, thank you for the explanation
Buy One is offline   Reply With Quote
Old 11-05-2019, 02:12 PM   #31
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,186
Default

schwa says here that the command ID numbers for custom actions/scripts are generated at Reaper startup and aren't fixed (unlike for native actions).

edit:
Just to be clear, as mentioned above, the command ID strings are deterministic.
https://forum.cockos.com/showpost.ph...7&postcount=19

Last edited by nofish; 11-05-2019 at 02:36 PM.
nofish is offline   Reply With Quote
Old 11-05-2019, 02:17 PM   #32
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,434
Default

Quote:
Originally Posted by nofish View Post
schwa says here that the command ID numbers for custom actions/scripts are generated at Reaper startup and aren't fixed (unlike for native actions).
Thanks. I should probably not have the script use those then... :P
Lokasenna is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.