Old 06-06-2010, 12:30 PM   #1
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default ReaScript: RPR_EnumProjectMarkers2() bug?

I'm trying to get to grips with this function. It seems to me that it's behaving oddly but it may just be that I've not understood how it works. If I load the attached project and run the script below, I get the following output...

Code:
Marker: (1, '(void*)0x0', 0, 0, 0.0, 0.0, '(char**)0x0', 1)
Region: (2, '(void*)0x0', 1, 1, 1.0, 2.0, '(char**)0x0', 1)
Marker: (4, '(void*)0x0', 2, 0, 3.0, 0.0, '(char**)0x0', 2)
Marker: (4, '(void*)0x0', 3, 0, 3.0, 0.0, '(char**)0x0', 2)
Regions: 1
Markers: 3
...which is incorrect as there are two markers and one region. If I then drag the region past the second marker (dropping it at 4.0 seconds) and run the script again I get...

Code:
Marker: (1, '(void*)0x0', 0, 0, 0.0, 0.0, '(char**)0x0', 1)
Marker: (2, '(void*)0x0', 1, 0, 2.0, 0.0, '(char**)0x0', 2)
Region: (3, '(void*)0x0', 2, 1, 3.0, 4.0, '(char**)0x0', 1)
Regions: 1
Markers: 2
...which is correct. Is this a bug or have I misunderstood the function? Also, why are the labels listed as '(char**)0x0' ? Can someone help me out?

Code:
numRegions = 0
numMarkers = 0

idx = 0
mrId = 1
while mrId != 0 :
	mrInf = RPR_EnumProjectMarkers2(0, idx, 0, 0, 0, 0, 0)
	mrId = mrInf[7]
	if(mrId != 0) :
		idx += 1
		if(mrInf[3]) :
			RPR_ShowConsoleMsg('Region: ')
			numRegions += 1
		else :
			RPR_ShowConsoleMsg('Marker: ')
			numMarkers += 1
			
		RPR_ShowConsoleMsg(str(inf) + '\n')
		
RPR_ShowConsoleMsg('Regions: ' + str(numRegions) + '\n')
RPR_ShowConsoleMsg('Markers: ' + str(numMarkers) + '\n')

Last edited by IXix; 06-07-2010 at 12:20 PM.
IXix is offline   Reply With Quote
Old 06-07-2010, 01:58 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by IXix View Post
Code:
Marker: (1, '(void*)0x0', 0, 0, 0.0, 0.0, '(char**)0x0', 1)
Region: (2, '(void*)0x0', 1, 1, 1.0, 2.0, '(char**)0x0', 1)
Marker: (4, '(void*)0x0', 2, 0, 3.0, 0.0, '(char**)0x0', 2)
Marker: (4, '(void*)0x0', 3, 0, 3.0, 0.0, '(char**)0x0', 2)
Regions: 1
Markers: 3
...which is incorrect as there are two markers and one region.
By which I meant that the data is correct but the second marker is returned twice, which is what's bugging me.
IXix is offline   Reply With Quote
Old 06-07-2010, 05:58 AM   #3
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,821
Default

This API function is not ReaScript friendly, because of the way it handles strings -- from C++ you would send a pointer to a pointer to a char (char**), which Reaper would re-point at the name of the marker. That won't work from ReaScript, so you can't get the marker names back from this function, instead you just get (char**)0x0.

The rest of the oddness is basically an implementation detail: the function usage would be something like:
Code:
nextidx = 0
while 1:
  ret = RPR_EnumProjectMarkers2(0, nextidx, 0, 0, 0, 0, 0)
  if !ret[0]:
    break
  thisidx = ret[2]
  isregion = ret[3]
  markerpos = ret[4]
  regionend = ret[5]
  nextidx = ret[0]
schwa is offline   Reply With Quote
Old 06-07-2010, 06:42 AM   #4
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Thanks schwa I get it now. Shame about the labels though
IXix is offline   Reply With Quote
Old 08-10-2011, 04:35 AM   #5
bblue
Human being with feelings
 
Join Date: Mar 2010
Location: El Cajon, CA (San Diego)
Posts: 593
Default

Quote:
Originally Posted by schwa View Post
This API function is not ReaScript friendly, because of the way it handles strings -- from C++ you would send a pointer to a pointer to a char (char**), which Reaper would re-point at the name of the marker. That won't work from ReaScript, so you can't get the marker names back from this function, instead you just get (char**)0x0.
So, would there be *any* way to come up with marker names in a Python Reascript? If not, would it be possible to make this API a bit friendlier to Reascript?

--Bill
bblue is offline   Reply With Quote
Old 08-10-2011, 05:12 AM   #6
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Ah-ha!. That explains some things. Thanks for bumping this.

Schwa, should we officially request an alternative way to get project marker and region names from ReaScrit API, or is it in the plans anyway?
gofer is offline   Reply With Quote
Old 08-12-2011, 10:45 AM   #7
bblue
Human being with feelings
 
Join Date: Mar 2010
Location: El Cajon, CA (San Diego)
Posts: 593
Default

Quote:
Originally Posted by gofer View Post
Ah-ha!. That explains some things. Thanks for bumping this.

Schwa, should we officially request an alternative way to get project marker and region names from ReaScrit API, or is it in the plans anyway?
Failing any 'official' response, can anyone think of a work-around for this? Maybe a C++ API kludge that gets the marker names and either returns them on its output or writes them to disk? ...Anything?

--Bill
bblue is offline   Reply With Quote
Old 01-12-2013, 03:15 PM   #8
Xane002
Human being with feelings
 
Join Date: Aug 2009
Posts: 91
Default

Quote:
Originally Posted by gofer View Post
Ah-ha!. That explains some things. Thanks for bumping this.

Schwa, should we officially request an alternative way to get project marker and region names from ReaScrit API, or is it in the plans anyway?
Sorry to dig up an old post but...

Any plans yet?

Given the current OSC implementation, I would like to be able to extract the last, or current marker/region name and change a track's name - and then deliver the track name to the OSC device. I want to be able to show the name of the song that is playing.
Xane002 is offline   Reply With Quote
Old 01-13-2013, 03:35 AM   #9
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

No change from Cockos' side yet .

But SWS extensions pre release versions add some highly useful ReaScript functions (thanks again SWS crew for all the effort this took/takes), amongst them

SNM_GetProjectMarkerName(ReaProject* proj, int num, bool isrgn, WDL_FastString* name)

with which you can get marker/region names. But it's not yet in the official release of SWS extensions.
gofer 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 01:38 AM.


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