Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER General Discussion Forum

Reply
 
Thread Tools Display Modes
Old 09-24-2023, 07:52 AM   #1
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default [Solved] API to get Wildcards out of the project

Hi

I asked for an API to get the Wildcards hoping to have into the 7.xx
the FR was here https://forum.cockos.com/showthread.php?t=282407
and I reminded it on the Dev 7.xx thread.

@Schwa quickly answered in this thread

https://forum.cockos.com/showpost.ph...4&postcount=41

and apparently it was ok but when I went to this page

https://www.reaper.fm/sdk/reascript/reascripthelp.html

to get the parameters for that function called

ResolveRenderPattern() I didn't find any

yes there is the GetSetProjectInfoString() but it's not what I need ...

can you help me on this please? I need to complete my script "ExportData" so that also the wildcards re resolved.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository

Last edited by BartR; 09-27-2023 at 04:55 AM.
BartR is offline   Reply With Quote
Old 09-24-2023, 08:20 AM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,733
Default

ResolveRenderPattern() is only available from extension callers, not reascript. From reascript you will have to use GetSetProjectInfo_String() to set the render pattern, and then get the render targets list.
schwa is offline   Reply With Quote
Old 09-24-2023, 08:58 AM   #3
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default

Quote:
Originally Posted by schwa View Post
ResolveRenderPattern() is only available from extension callers, not reascript. From reascript you will have to use GetSetProjectInfo_String() to set the render pattern, and then get the render targets list.
ok then I cannot solve the wildcards with the script I have made. that's why I specifically asked for an API that I can interrogate via reaScript so that for any wildcard I can get it's value.

In this moment, indeed, I just get printed things like "$author" and "$title" instead of the real name of the Author and the real name of the project title.

So the API should be easy (at least like I guessing it) just kind of

string value reaper.Wildcard(ReaProject proj, string wildcard)

or something like that
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 09-24-2023, 09:16 AM   #4
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,733
Default

There are about 100 supported wildcards, but only a few of them can be resolved at the global or project level. All of the others require more context. For example if you use the $track wildcard it will be resolved to whichever track is currently being rendered. So the only way to resolve most wildcards is within the context of a specific render setup. Which is why you have to use GetSetProjectInfo() and GetSetProjectInfo_String() to set up a specific project render and render pattern, then GetSetProjectInfo_String() to get the resolved filename list.
schwa is offline   Reply With Quote
Old 09-24-2023, 01:59 PM   #5
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default

Quote:
Originally Posted by schwa View Post
There are about 100 supported wildcards, but only a few of them can be resolved at the global or project level. All of the others require more context. For example if you use the $track wildcard it will be resolved to whichever track is currently being rendered. So the only way to resolve most wildcards is within the context of a specific render setup. Which is why you have to use GetSetProjectInfo() and GetSetProjectInfo_String() to set up a specific project render and render pattern, then GetSetProjectInfo_String() to get the resolved filename list.

I think it's better I give you a practical example

Here the metadata of a recent project:



here, instead, what I get by using my script, that uses the functions you suggested, but I don't get what ai need from them:



So, if ever I can get the values of the wildcards, I can print them, and I can use the generated document (that resumes all tehproject data, to be able to read them without to open the project itself). So with an API I can interrogate Reaper, get the values and use them.

In other words when I have the project opened and I activate the script, it geos to check the content of the fields and it prints them out.

I would like to modify my script to identify the wildcards (it's possible in an easy way) but then I need to send them to a function/api to get the related values.

So, instead to get printed "$artist", in this specific case I should have "barbara Vagnini" since her name is already written into the Project settings window (Alt+Enter)
As well as instead of "$title" i should get "Piove su di noi" which is already inside the dedicated field since the day 1 of this project.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository

Last edited by BartR; 09-24-2023 at 03:10 PM.
BartR is offline   Reply With Quote
Old 09-24-2023, 05:58 PM   #6
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,733
Default

You can get $author via GetSetProjectAuthor(), $title via GetProjectName(), $date trivially without an API call. Basically any wildcard that doesn't need any more context you can get in some way with existing API.

For wildcards that need more context, like $length in your example which varies depending on what is being rendered, you need to create the context in order to resolve the wildcard.

Code:
function resolve_wildcard(wildcard)
  ok,restore_path=reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "", 0)
  ok,restore_pattern=reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", "", 0)
  
  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "C:\\", 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", wildcard, 1);
  ok,resolved=reaper.GetSetProjectInfo_String(0, "RENDER_TARGETS", "", 0)
  resolved=string.sub(resolved, 4, string.len(resolved)-4)
  reaper.ShowConsoleMsg(wildcard .. ' : ' .. resolved.. '\n')

  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", restore_path, 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", restore_pattern, 1)
end

resolve_wildcard('$author')
resolve_wildcard('$date')
resolve_wildcard('$length')
schwa is offline   Reply With Quote
Old 09-25-2023, 12:13 AM   #7
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default

Quote:
Originally Posted by schwa View Post
You can get $author via GetSetProjectAuthor(), $title via GetProjectName(), $date trivially without an API call. Basically any wildcard that doesn't need any more context you can get in some way with existing API.

For wildcards that need more context, like $length in your example which varies depending on what is being rendered, you need to create the context in order to resolve the wildcard.

Code:
function resolve_wildcard(wildcard)
  ok,restore_path=reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "", 0)
  ok,restore_pattern=reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", "", 0)
  
  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "C:\\", 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", wildcard, 1);
  ok,resolved=reaper.GetSetProjectInfo_String(0, "RENDER_TARGETS", "", 0)
  resolved=string.sub(resolved, 4, string.len(resolved)-4)
  reaper.ShowConsoleMsg(wildcard .. ' : ' .. resolved.. '\n')

  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", restore_path, 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", restore_pattern, 1)
end

resolve_wildcard('$author')
resolve_wildcard('$date')
resolve_wildcard('$length')
Watching your example, I think I understood why I couldn't get what I needed.
A kind of misinterpretation of the instructions in this page https://www.reaper.fm/sdk/reascript/...ectInfo_String

The 4th element on the function GetSetProjectInfo_String(), for instance, it's written "may contain wildcard" and I interpreted it as "hey the string you retrieve can have wildcars on it" ... I didn't interpreted it as: "write here the wildcard and you can retrieve it's content".

Your code above solved my misunderstanding.

Thank you so much Schwa you were really helpful now it's time to work to my script to solve this gap it has.

I save your message on my OneNote and I will work on it.

If I have any other question I will pop up in this thread.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 09-27-2023, 04:55 AM   #8
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default

Quote:
Originally Posted by schwa View Post
You can get $author via GetSetProjectAuthor(), $title via GetProjectName(), $date trivially without an API call. Basically any wildcard that doesn't need any more context you can get in some way with existing API.

For wildcards that need more context, like $length in your example which varies depending on what is being rendered, you need to create the context in order to resolve the wildcard.

Code:
function resolve_wildcard(wildcard)
  ok,restore_path=reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "", 0)
  ok,restore_pattern=reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", "", 0)
  
  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "C:\\", 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", wildcard, 1);
  ok,resolved=reaper.GetSetProjectInfo_String(0, "RENDER_TARGETS", "", 0)
  resolved=string.sub(resolved, 4, string.len(resolved)-4)
  reaper.ShowConsoleMsg(wildcard .. ' : ' .. resolved.. '\n')

  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", restore_path, 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", restore_pattern, 1)
end

resolve_wildcard('$author')
resolve_wildcard('$date')
resolve_wildcard('$length')
Im' working on this and yes I'm able to get the required data.
Now I'm busy to analyze any string (when containin gmore than 1 wildcard), explode them and rebuild the string with the content.
great

I'm very glad for this. This will solve everything

Thank you Schwa

Ah important about wildcards, because it's realted, this request please (not clue if it can be full filled but ti wil be a very nice-to-have)

please here the link https://forum.cockos.com/showthread.php?t=282408
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 02-25-2024, 07:52 AM   #9
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Belgium
Posts: 1,607
Default

Quote:
Originally Posted by schwa View Post
You can get $author via GetSetProjectAuthor(), $title via GetProjectName(), $date trivially without an API call. Basically any wildcard that doesn't need any more context you can get in some way with existing API.

For wildcards that need more context, like $length in your example which varies depending on what is being rendered, you need to create the context in order to resolve the wildcard.

Code:
function resolve_wildcard(wildcard)
  ok,restore_path=reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "", 0)
  ok,restore_pattern=reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", "", 0)
  
  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", "C:\\", 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", wildcard, 1);
  ok,resolved=reaper.GetSetProjectInfo_String(0, "RENDER_TARGETS", "", 0)
  resolved=string.sub(resolved, 4, string.len(resolved)-4)
  reaper.ShowConsoleMsg(wildcard .. ' : ' .. resolved.. '\n')

  reaper.GetSetProjectInfo_String(0, "RENDER_FILE", restore_path, 1)
  reaper.GetSetProjectInfo_String(0, "RENDER_PATTERN", restore_pattern, 1)
end

resolve_wildcard('$author')
resolve_wildcard('$date')
resolve_wildcard('$length')
Good news.

I eventually had the time to get into it, and to sucessfully implement the code.
I'm testing it.
If not bugs are detected I will release the new version soon.
If I have some bug I will solve it first.

However I have put you into the credits.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR 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 10:05 PM.


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