Old 07-06-2016, 03:13 PM   #1
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default X-Raym's - Avoid Using Native/SWS Action

I wonder if every action can be replaced by scripting. I want to make a script that cycles through toolbars, but I did not find any API to open toolbar x.

Is every action replaceable by scripting? Apparently not, but I want to be sure from you, scripting gurus.

Thanks
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-06-2016, 03:29 PM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

There are a number of things that we don't have API commands for (yet). However, using Main_OnCommand to do things is perfectly fine - you aren't going to kill your performance or anything.
Lokasenna is offline   Reply With Quote
Old 07-06-2016, 03:58 PM   #3
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

Thanks Lokasenna. I suspected, but is better to hear from a scripting-savvy.
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-06-2016, 04:20 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,517
Default

In fact this "guideline" was to outline the fact that if you use SWS actions like "Save current itme selection to Slot 1", "save current cursor position", you may erase a precious selection for the user.
And writing this kind of action with dedicated function is as simple as a simple code snippet.

But feel free to use native actions,
sometimes it is both more efficient and more simpler to code !

Just don't forget to place undo blcoks at the right place to not create 50 undo points if the action call is inside a loop.
X-Raym is offline   Reply With Quote
Old 07-06-2016, 04:50 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,517
Default

Actually for performance, creating items with scripts functions was approx 10 times faster than using native actions to set track as last touched, set a time a selection, insert item into time selection, move time selection and repeat.


So yes, native actions can be really bad for performance in some case.
X-Raym is offline   Reply With Quote
Old 07-06-2016, 05:01 PM   #6
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

Quote:
Originally Posted by X-Raym View Post
Actually for performance, creating items with scripts functions was approx 10 times faster than using native actions to set track as last touched, set a time a selection, insert item into time selection, move time selection and repeat.


So yes, native actions can be really bad for performance in some case.
I understand, it's that the statement in your blog made me consider there was always a substitute. Now I see it's only preferable when it's available.
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-06-2016, 07:06 PM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by X-Raym View Post
So yes, native actions can be really bad for performance in some case.
Only if you're doing a) a lot of stuff at once or b) stuff while the audio is playing. If the project is stopped and you're just running a series of actions, you're never going to notice.

10x faster than "a few ms" isn't a difference worth caring about, to me. As long as the programmer knows what sort of situation their script is being used in, it should never be an issue.
Lokasenna is offline   Reply With Quote
Old 07-07-2016, 03:45 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,517
Default

@Lokasenna
I don't have the benchmark, but the action was use to create items for subtitling,
the first version used native action to insert empty items,
the second use custom functions,
and the difference was something around 10 times faster (it took 10 seconds with v1, only 1 in v2). 10 seconds for an action without REAPER responding is enough to make the user worried about what is going on.
Audio was not playing.

Sure, in most case, you should not notice a difference in performance, but in some case, you will :P
X-Raym is offline   Reply With Quote
Old 07-07-2016, 04:15 AM   #9
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Ah, fair enough.
Lokasenna is offline   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 07:51 PM.


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