Old 09-27-2019, 09:07 AM   #1
wwcdgm
Human being with feelings
 
Join Date: Oct 2018
Posts: 10
Default The script is running too slowly, how can I get faster?

Hello everyone, I have a very slow script.

This script(lua) is used in the MIDI editor, but there is a 2 second delay for each run. This is fatal speed. How can I improve?

PS:
I found that only the windows system will be so slow, there is no problem with the MAC.

Code:
cur_editor = reaper.MIDIEditor_GetActive()
reaper.MIDIEditor_OnCommand(cur_editor, 39707)
reaper.MIDIEditor_OnCommand(cur_editor, 39487)
reaper.MIDIEditor_OnCommand(cur_editor, 39354)
reaper.MIDIEditor_OnCommand(cur_editor, 39402)
reaper.MIDIEditor_OnCommand(cur_editor, 39673)
reaper.MIDIEditor_OnCommand(cur_editor, 39289)
wwcdgm is offline   Reply With Quote
Old 09-27-2019, 09:21 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,281
Default

I'm not sure why those commands would be slowing things down, but try wrapping it with:
Code:
reaper.PreventUIRefresh(1) -- any number you want here
-- your code
reaper.PreventUIRefresh(-1) -- must be minus-the-same-number
reaper.UpdateArrange() -- can also use reaper.UpdateTimeline() if not everything is updating
This pauses the UI while the script is running, and since UI updates are one of the most expensive things for Reaper to do it can take some tasks from 30s down to almost nothing. As I said, I can't think of a reason why "Set mouse modifier..." commands would be taking any time at all, but it's worth a try.

Last edited by Lokasenna; 09-27-2019 at 09:26 AM.
Lokasenna is online now   Reply With Quote
Old 09-28-2019, 09:23 AM   #3
wwcdgm
Human being with feelings
 
Join Date: Oct 2018
Posts: 10
Default

Thank you very much, Dear Lokasenna. I tried your method and the problem was not solved.
I think it should be a problem with "Set mouse modifier..." itself.
wwcdgm is offline   Reply With Quote
Old 09-28-2019, 09:38 AM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,281
Default

I would suggest opening a bug report - there's no way that's intentional or expected behavior.
Lokasenna is online now   Reply With Quote
Old 09-29-2019, 06:14 AM   #5
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,572
Default

You can try to nail it down.

Comment out all the lines and try if it's still with the 2 seconds-lag.

If yes, then it's not the code.
If not, uncomment it line for line and see, when the lag appears.

Maybe this gives some hints at the actual problem.
__________________
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-29-2019, 08:29 PM   #6
wwcdgm
Human being with feelings
 
Join Date: Oct 2018
Posts: 10
Default

Thanks!

Comment out all the lines without any problems. It can be confirmed that it is a problem of "Set mouse modifier...".
wwcdgm 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 04:37 PM.


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