Old 03-23-2015, 09:38 AM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default Help: Get Take GUID (SOLVED)

Hi!

In the API we have, reaper.GetMediaItemTakeByGUID.
But how do get this GUID at first place ?

Does someone has any code snippet to share ?

You will make me save a lot of time if you already went through this and you are ready to share!

Thanks!

Edit: hmmm I think I will find another way to get my items. :P

Last edited by X-Raym; 02-20-2023 at 10:33 AM.
X-Raym is offline   Reply With Quote
Old 03-23-2015, 02:39 PM   #2
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

i'm not sure if this would work.
GetSetMediaItemTakeInfo_String(take, "GUID", guid, 0);

I also need to use GUID for the tracks in notes reader and Regions&Markers from items, because right now it is by idx and is not good.
heda is offline   Reply With Quote
Old 03-23-2015, 03:36 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

yep, I tried something similar without much success...

So I keep it simple: save all items item an array, an recall them from here after that.

thanks for your support!
X-Raym is offline   Reply With Quote
Old 03-23-2015, 03:47 PM   #4
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

I use take GUIDs for my Item Marker Tool.

It took me quite a while to work out how to extract them, and includes some hex extraction and byte reordering

Code:
function hex_vers_guid(g_take)
(
	#take_guid = ""; #temp_take_guid = ""; #hex_section = "";
  GetSetMediaItemTakeInfo_String(g_take, "GUID", #active_take_guid, 0);
	
	g_offset = 0;
	//str_setlen(#take_guid, strlen(#active_take_guid)*2);
	while (g_offset < strlen(#active_take_guid))
	(
		sprintf(#hex_char, "%02X", str_getchar(#active_take_guid, g_offset, 'cu'));
		g_offset +=1;
		#dum =  strcat(#hex_section, #hex_char);
	);
	#dum = strcat(#temp_take_guid, #hex_section);
	// now reorder bytes and delimit with "-"

	strcat(#take_guid, "{");
	strcpy_substr(#str, #temp_take_guid, 6, 2); //byte 04
	strcat(#take_guid, #str);
	strcpy_substr(#str, #temp_take_guid, 4, 2); //byte 03
	strcat(#take_guid, #str);
	strcpy_substr(#str, #temp_take_guid, 2, 2); //byte 02
	strcat(#take_guid, #str);
	strcpy_substr(#str, #temp_take_guid, 0, 2); //byte 01
	strcat(#take_guid, #str);
	strcat(#take_guid, "-");
	
	strcpy_substr(#str, #temp_take_guid, 10, 2); //byte 06
	strcat(#take_guid, #str);
	strcpy_substr(#str, #temp_take_guid, 8, 2); //byte 05
	strcat(#take_guid, #str);
	strcat(#take_guid, "-");
	
	strcpy_substr(#str, #temp_take_guid, 14, 2); //byte 08
	strcat(#take_guid, #str);
	strcpy_substr(#str, #temp_take_guid, 12, 2); //byte 07
	strcat(#take_guid, #str);
	strcat(#take_guid, "-");
	
	strcpy_substr(#str, #temp_take_guid, 16, 4); //bytes 09&10
	strcat(#take_guid, #str);
	strcat(#take_guid, "-");
	
	strcpy_substr(#str, #temp_take_guid, 20, 12); //bytes 11 to 16
	strcat(#take_guid, #str);
	strcat(#take_guid, "}");
	
);

I hope you can follow it, I did reasonably comment it for people to use the code. The whole script is downloadable via my sig. I think heda has been through it for marker code ideas, so he might be able to help.

Incidentally, if someone does get the mkrrgn GUIDs, I'd be interested in hearing -as heda says, it can be awkward as the markers jump indexes, and that was another reason I saved the marker/take "associations" in the actual marker name

nudge me if you need any help and I'll try and remember why I did stuff



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-23-2015, 07:40 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Ooh so all this is part of the process! I just use the first two lines during my research haha
All that code for that. This is perseverance
Thanks you for sharing this tip, I found an alternative solution but I know where to look if I need this again.
Cheers!
X-Raym is offline   Reply With Quote
Old 03-24-2015, 12:56 AM   #6
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

Are you sure we can't use these functions?

Lua: string gGUID reaper.stringToGuid(string str, string gGUID)

Lua: string destNeed64 reaper.guidToString(string gGUID, string destNeed64)

Lua: string gGUID reaper.genGuid(string gGUID)


I wonder what genGuid does. as usual.. no description.
heda is offline   Reply With Quote
Old 03-24-2015, 04:30 AM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@heda
Quote:
as usual.. no description.
;P

As far as I understand, GUID are not regular string, so there is functions for passing from one to the other, and functions to generate them.

I test to go from GUI to string all I got was {0000-000... } (approx).
It look close but... yes, a bit more doc can sometimes go a long way!

@planetnine
What did you need GUID in your script ? I'm curious.
X-Raym is offline   Reply With Quote
Old 03-24-2015, 04:38 AM   #8
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

It's a while ago, but I think we tried everything heda.

It was only by listing various "GUID" results against reading the RPP file GUID that I spotted patterns that showed how it was encoded. I had spk77 looking for me too. Argitoth later wrote a slightly different extraction version, but the bit swapping is still part of it

Any hey -it works. My item marker tool can read the data in from a marker title and find its associated take and item along with the offset so it can reposition itself correctly -even if it's just been freshly recalled from the marker/region manager It was horrifying to find that the normal item and marker id numbers refreshed themselves each project load!

If you do find a quicker/easier way I'd be interested, but this seemed to be the only way...



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-24-2015, 04:49 AM   #9
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@planetnine
Haha! This is so mad...

That's a high level of reverse engineering that you did. Well done :P
X-Raym is offline   Reply With Quote
Old 03-24-2015, 05:09 AM   #10
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

It comes in as a string of bytes in the "wrong" order. That function just turns them into ascii hex tuples and rearranges their order -the "icing on the cake" is a pair of curly brackets and hyphens for formatting so they look familiar to those used to project-file mining.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-24-2015, 05:16 AM   #11
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

I'm looking at this guid strings for Notes Reader,

GetTrackGUID(#retguid, selectedtrack);

returns a perfect string with the same order as it is in the RPP file. and it doesn't change on project load which is the purpose of the GUID I hope. So everything is good, at least for TrackGUID.
heda is offline   Reply With Quote
Old 03-24-2015, 06:25 AM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Hmmm... can you try with items and tell us if it works ?
X-Raym is offline   Reply With Quote
Old 03-24-2015, 07:26 AM   #13
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

I think it was either Take GUID or Take and Item GUID that gave us the problem.

I went through Element ID to Element GUID and Element GUID to Element ID for them all, and I'm sure it was take ID to Take GUID that was (almost) the show-stopper. Take was actually all I needed, as item, track, etc can be derived from the take.


Take ID from Take GUID was as simple as:

Code:
derived_take = GetMediaItemTakeByGUID(0, #ret_take_guid); // derive take from GUID
derived_item = GetMediaItemTake_Item(derived_take); // derive item from take
If you get the Take ID to Take GUID working without all of this, I'll be very interested as it will simplify and speed up that script tool


>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-24-2015, 08:02 AM   #14
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

We can export some guid functions (get element guid and get element from guid) from SWS if you need them. Just tell me exactly which ones do you need...As far as I remember we can access track/take/item GUID
Breeder is offline   Reply With Quote
Old 03-24-2015, 08:46 AM   #15
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

I think Take GUID from Take is the difficult one Dominik. A consistent method would be good for all of them though.

Do you have access to a markrgn GUID?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-24-2015, 08:54 AM   #16
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by planetnine View Post
I think Take GUID from Take is the difficult one Dominik. A consistent method would be good for all of them though.

Do you have access to a markrgn GUID?
>
Markers and regions don't have GUIDs - as far as I know only FXs, tracks, items and takes have one.

It's not hard at all from extension perspective since we can access all of them (good job on deducting how GUID is generated by the way...we never had to do something like that for SWS since API allows us to access it)...I'll check what's missing from native ReaScript API and add functions accordingly for the next release
Breeder is offline   Reply With Quote
Old 03-24-2015, 09:10 AM   #17
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

strange, the html documentation only specifies this in the description for GetSetMediaItemTakeInfo_String
P_NAME : char * to take name
heda is offline   Reply With Quote
Old 03-24-2015, 09:20 AM   #18
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

Some experimentation was done, and if you look throught the script request sticky, I think it was spk that put me on to such undocumented uses.

For a while, we really did think that it wasn't possible. Be good if Breeder can level the playing field with consistent functions.


Edit: Just seen your post, thank you for this, Dominik



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-24-2015, 10:08 AM   #19
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Thanks Breeder !
That's will open new possibilities for scripters, for sure!
X-Raym is offline   Reply With Quote
Old 07-02-2022, 12:18 PM   #20
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,132
Default

Quote:
Originally Posted by Mespotine
REAPER functions guidToString() and stringToGuid() what are they actually for? I've tried to make sense of them but couldn't, at least in Lua.
.................................................. ......
Quote:
Originally Posted by Justin
Dealing with string-representations of GUIDs. GUID is a unique (usually) identifier for identifying things
https://askjf.com/index.php?q=5250s
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file
Buy One is online now   Reply With Quote
Old 02-20-2023, 10:25 AM   #21
MonkeyBars
Human being with feelings
 
MonkeyBars's Avatar
 
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,630
Default

Just an update: Reaper's native API now exposes Take GUID via GetSetMediaItemTakeInfo_String()
MonkeyBars 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:57 AM.


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