Old 04-24-2008, 03:13 AM   #1
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default Query REAPER possible??

Hi,

Is it possible to query the state of an action/function of a currently-loaded REAPER project?

Specifically I want to find out whether the project has loop/cycle enabled.

I want to know this when the project loads, or shortly after.

The reason I want to know this is that, I am initialising my 'loop variable' to zero (in my .cpp) which is good as long as the project is Saved without Loop/Cycle mode enabled.

If Loop/Cycle is enabled when the project is saved, the next time I start the project the status of the Loop LED (on the control surface) is inverted. i.e. The LED=OFF when loop is enabled, and LED=ON when loop is disabled.

I'll give it some more thought, but, at present the only way around this I can think of is that I need to query the state the project's Loop/Cycle status and set my 'loop variable' accordingly.

Anyone know if this is possible, or have another solution for this?

Clearly this also applies to any toggle-state within the project...

Any help, as always, greatly appreciated!

Many thanks,

Deric.
__________________
REAPER? Oh yes...

Last edited by Deric; 04-24-2008 at 03:19 AM.
Deric is offline   Reply With Quote
Old 04-24-2008, 07:42 AM   #2
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

Deric, use the GetSetRepeat function from the API.

Make sure you have used GetFunc("GetSetRepeat") then:
Code:
int state = GetSetRepeat(-1);
sws is offline   Reply With Quote
Old 04-24-2008, 08:21 AM   #3
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Hi SWS

Thanks! I'll try that right now!

Cheers SWS!

__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-24-2008, 10:35 AM   #4
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Quote:
Originally Posted by sws View Post
Deric, use the GetSetRepeat function from the API.

Make sure you have used GetFunc("GetSetRepeat") then:
Code:
int state = GetSetRepeat(-1);

SWS, sorry about this...

How do I use GetFunc?

I get errors (Identifier not found) for both GetFunc and GetSetRepeat

Do I need to do a #include or something?

Deric.
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-24-2008, 11:27 AM   #5
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

To be able to use any of the API functions you need to 1) define the function and 2) get its address from REAPER. I think you're using the csurf stuff, so to make the magic happen, 1) put this line near the top of csurf_main.cpp:
Code:
int (*GetSetRepeat)(int val);
and 2) put this line in at the bottom after the group of other IMPAPI stuff:
Code:
IMPAPI(GetSetRepeat)
That will define GetSetRepeat so you can use it in your code.
sws is offline   Reply With Quote
Old 04-24-2008, 11:41 AM   #6
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

SWS,

Thanks!

Do I type it exactly as you've written? i.e. Do I type "int val"?

Sorry... but I really am pretty new to this stuff and every time I meet something new/different it's like knowing *nothing* again...


Edit: I had been putting the stuff in the 01X.cpp (was MCU.cpp)...
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-24-2008, 12:06 PM   #7
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

Short answer: Yes. I pasted it from reaper_plugin_functions.h.

Way too long answer: The first line of code defines a function pointer. The second line is used to what makes the function pointer "point" into the proper place in the REAPER process space. That way, when you call the function, you're executing REAPER code. The function pointer definition (like a function prototype) actually doesn't care about the "val" name for the integer parameter, so much so that just writing:
Code:
int (*GetSetRepeat)(int);
is sufficient.
sws is offline   Reply With Quote
Old 04-24-2008, 12:40 PM   #8
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

SWS,

Thanks a lot. I like the long answer - but will need to read it a few more times, and then study a bit more.

Thanks for you help, patience, and assistance - you've been great!

Cheers SWS!

Deric.
__________________
REAPER? Oh yes...
Deric 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:48 PM.


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