|
|
|
06-06-2010, 12:30 PM
|
#1
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
|
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.
|
|
|
06-07-2010, 01:58 AM
|
#2
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
|
Quote:
Originally Posted by IXix
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.
|
|
|
06-07-2010, 05:58 AM
|
#3
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,821
|
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]
|
|
|
06-07-2010, 06:42 AM
|
#4
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
|
Thanks schwa I get it now. Shame about the labels though
|
|
|
08-10-2011, 04:35 AM
|
#5
|
Human being with feelings
Join Date: Mar 2010
Location: El Cajon, CA (San Diego)
Posts: 593
|
Quote:
Originally Posted by schwa
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
|
|
|
08-10-2011, 05:12 AM
|
#6
|
-blänk-
Join Date: Jun 2008
Posts: 11,359
|
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?
|
|
|
08-12-2011, 10:45 AM
|
#7
|
Human being with feelings
Join Date: Mar 2010
Location: El Cajon, CA (San Diego)
Posts: 593
|
Quote:
Originally Posted by gofer
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
|
|
|
01-12-2013, 03:15 PM
|
#8
|
Human being with feelings
Join Date: Aug 2009
Posts: 91
|
Quote:
Originally Posted by gofer
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.
|
|
|
01-13-2013, 03:35 AM
|
#9
|
-blänk-
Join Date: Jun 2008
Posts: 11,359
|
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.
|
|
|
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 01:38 AM.
|