|
|
|
03-15-2024, 11:06 AM
|
#1
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Getting Project from MediaItem or MediaTrack
Hey all!
Is there any way to get the ReaProject object that a respective track or media item exist in? I know that the parameter "P_PROJECT" exists for MediaTracks but that just gives a number value, and to the best of my knowledge I don't know how to associate that with a ReaProject. Anyone know of a way to get this information from the track or item? Or do I just have to check every project's tracks/items to see if the track or item are in it, then break early when the track/item is found?
Last edited by jkooks; 03-15-2024 at 12:04 PM.
|
|
|
03-15-2024, 12:11 PM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Quote:
Originally Posted by jkooks
Hey all!
Is there any way to get the ReaProject object that a respective track or media item exist in? I know that the parameter "P_PROJECT" exists for MediaTracks but that just gives a number value, and to the best of my knowledge I don't know how to associate that with a ReaProject. Anyone know of a way to get this information from the track or item? Or do I just have to check every project's tracks/items to see if the track or item are in it, then break early when the track/item is found?
|
Looking at the API, GetMediaTrackInfo_Value(track, "P_PROJECT") should return (a pointer to, hence the "P") the ReaProject object. Are you saying that this is not the case?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
03-15-2024, 04:44 PM
|
#3
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
I don't believe it does - in Lua, for example, it returns a number value and not a userdata type. Wasn't sure if there was an extra step I had to do to get the appropriate ReaProject object that was associated with the number value.
|
|
|
03-15-2024, 04:56 PM
|
#4
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by jkooks
I don't believe it does - in Lua, for example, it returns a number value and not a userdata type. Wasn't sure if there was an extra step I had to do to get the appropriate ReaProject object that was associated with the number value.
|
Just use the returned number as ReaProject-parameter.
For instance, the following code gets the project of the first track and writes a text into the project's notes:
Code:
A,B,C=reaper.GetMediaTrackInfo_Value(reaper.GetTrack(0,0), "P_PROJECT")
reaper.GetSetProjectNotes(B, true, "Set this to the notes")
Never noticed this, btw but since the function returns a number all the time it probably is logical that it uses a number to describe the project.
Though I don't know, how the number is created. It's not the opened project-tab so it must be something else.
At least it looks like from my tests...
|
|
|
03-15-2024, 06:25 PM
|
#5
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Oh, interesting, I will check that out then! I tried to get the actual ReaProject using EnumProjects and passing the number as the index, but as I expected it didn't actually work like that and just returned an empty ReaProject. I will test just passing the number to each function by itself and see how that works.
|
|
|
03-15-2024, 06:30 PM
|
#6
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by Meo-Ada Mespotine
Though I don't know, how the number is created. It's not the opened project-tab so it must be something else.
|
It's the same memory location, just either in decimal or hex.
|
|
|
03-16-2024, 11:24 AM
|
#7
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Curious as to why there is no similar value for media items and only tracks. I assume it is because it is easy enough to write a function that grabs the track for the item and gets the project from the track, but curious if there is a deeper technical reason why items don't have project associations (or at least exposed ones).
|
|
|
03-16-2024, 12:07 PM
|
#8
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Quote:
Originally Posted by jkooks
Curious as to why there is no similar value for media items and only tracks. I assume it is because it is easy enough to write a function that grabs the track for the item and gets the project from the track, but curious if there is a deeper technical reason why items don't have project associations (or at least exposed ones).
|
You can write your own function:
Code:
local function ItemToProject(item)
local mediatrack = reaper.GetMediaItem_Track(tem)
return reaper.GetMediaTrackInfo_Value(mediatrack, "P_PROJECT")
end
I do not see much use in the API having a specific function for this two-line code.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
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:47 AM.
|