|
|
|
09-12-2019, 06:52 PM
|
#1
|
Human being with feelings
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 115
|
Trigger Action/Run Script on Transport Play/Pause/Stop/Record, etc.
Does anyone know if it's possible to trigger an action/run a script when any of the transport buttons are pressed?
I found GetPlayState() but that assumes you are periodically polling for any state change.
Is there another way?
Thanks,
Ken
|
|
|
09-13-2019, 06:04 AM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Unfortunately Reaper doesn't have any event hooks, so a background script that polls the current state is all you can do.
|
|
|
09-13-2019, 09:01 AM
|
#3
|
Human being with feelings
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 115
|
Quote:
Originally Posted by Lokasenna
Unfortunately Reaper doesn't have any event hooks, so a background script that polls the current state is all you can do.
|
Thank @Lokasenna. I suspected as much.
Is there any examples of background scripts? Do I just start a script that never ends with something like "while(1) do" or do I need to use the defer() or runloop() API functions for this? Obviously my code needs to be nice as to not load the system down.
Thanks again,
Ken
|
|
|
09-13-2019, 09:51 AM
|
#4
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Scripts are run in the main thread, so a loop will freeze Reaper. :P Deferring is the way to go.
Code:
local function main()
-- check stuff
if stuff then
-- do stuff
end
reaper.defer(main)
end
main()
Just be aware that your polling will take resources away from Reaper, so depending on the time resolution you need it may be a good idea to only do the polling every second, or every third loop, etc.
|
|
|
09-13-2019, 10:10 AM
|
#5
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
example script which could be used for 'relaxed polling' (what Lokasenna said above):
https://forum.cockos.com/showthread.php?t=168270
(post #14)
|
|
|
09-13-2019, 10:37 AM
|
#6
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by nofish
|
Schwa's comment in the example code about needing to use "Terminate all running scripts" to stop it is thankfully outdated - the Actions menu now lists all running scripts at the bottom, and clicking one will stop it.
|
|
|
09-13-2019, 08:06 PM
|
#7
|
Human being with feelings
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 115
|
Thanks All. This has been very helpful. I now have a working background script that doesn't cause Reaper to grind to a halt.
BTW, my scripting is just to prototype what I ultimately want to re-implement in an extension.
The wall I have to climb is the fact that I don't know C++.
Thanks again,
Ken
|
|
|
09-13-2019, 08:24 PM
|
#8
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
That could be a pretty hefty wall. What are you trying to do?
|
|
|
09-14-2019, 09:24 AM
|
#9
|
Human being with feelings
Join Date: Dec 2011
Location: San Jose, CA, USA
Posts: 115
|
Quote:
Originally Posted by Lokasenna
That could be a pretty hefty wall. What are you trying to do?
|
Hi @Lokasenna,
It's probably easier to show you. I want to do this (or at least some of it) except with Reaper: https://www.youtube.com/watch?v=OGEHenHxpVk
I've started documenting my research here: https://forum.cockos.com/showthread.php?t=224472 and here: https://github.com/kmitch95120/Reaper-ATOM-Integration
While I know I can do a lot with scripts, it concerns me that all scripts run in the same thread and deferred scripts run in the GUI thread. I've been a user for a while now, but I'm just starting to get into the expansion/integration side of things. For example, I'm not sure what the differences are, if any, between an extension and a control surface plugin.
I regularly work with Python for my day job so I want to do this project in anything but Python. I also have several co-workers who are C++ experts so I plan/hope to lean on them for help when I need it.
Ken
|
|
|
09-14-2019, 11:42 AM
|
#10
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
For your goal the C++ route seems indeed the way to go, because this way you can utilize callbacks from Reaper (rather than polling) which is not possible via scripts, as been mentioned.
https://forum.cockos.com/showthread.php?t=209187
Last edited by nofish; 09-14-2019 at 11:53 AM.
|
|
|
09-14-2019, 01:07 PM
|
#11
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by kenm
Does anyone know if it's possible to trigger an action/run a script when any of the transport buttons are pressed?
I found GetPlayState() but that assumes you are periodically polling for any state change.
Is there another way?
Thanks,
Ken
|
I'm working on such a feature for my Ultraschall-API. Watch out for it...
Hope I can put it already in the next release...
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:57 AM.
|