Old 06-24-2019, 10:39 AM   #1
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default reaper.GetSetProjectInfo usage

Hi, I'm trying to set render settings via script, but I'm unsure of how to use GetSetProjectInfo.



RENDER_SETTINGS: &(1|2)=0:master mix, &1=stems+master mix, &2=stems only, &4=multichannel tracks to multichannel files, &8=use render matrix, &16=tracks with only mono media to mono files, &32=selected media items; &64=selected media items via master

According to the documantation, the code below, by my understanding should set the checkbox "tracks with only mono media to mono files" to true, and then set the source to "selected media items via master"
What actually happens is that the checkbox is set and then immediately wiped by the second function

I must be misunderstanding the usage of this function, but I can't see how else to use it.


Code:
reaper.GetSetProjectInfo( 0, "RENDER_SETTINGS", 16, true )
reaper.GetSetProjectInfo( 0, "RENDER_SETTINGS", 64, true )
Travesty is offline   Reply With Quote
Old 06-24-2019, 02:35 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

It's a bitfield.
Also see schwa's comment here (post #3).

So in your case, to set bit 5 (&16) and bit 7 (&64) you'd do:

Code:
reaper.GetSetProjectInfo( 0, "RENDER_SETTINGS", 80, true) -- 16 + 64 = 80
https://www.binaryconvert.com/result...decimal=056048
nofish is offline   Reply With Quote
Old 06-25-2019, 03:18 AM   #3
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Right, ok that clears it up. I knew I must be missing something fundamental, cheers
Travesty is offline   Reply With Quote
Old 06-25-2019, 03:48 AM   #4
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

It doesn't seem to be possible to change anything in the WAV settings, for example bit depth or "Include project filename in BWF data". Is there another way to set this?
Travesty is offline   Reply With Quote
Old 06-25-2019, 03:53 AM   #5
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

This seems to be what I'm looking for, but I'm not sure how to set this information

https://github.com/Ultraschall/ultra...ruary-2019.txt
Travesty is offline   Reply With Quote
Old 06-25-2019, 04:30 AM   #6
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Quote:
Originally Posted by Travesty View Post
This seems to be what I'm looking for, but I'm not sure how to set this information
You have to use something like
Code:
 retval, valuestrNeedBig = reaper.GetSetProjectInfo_String( 0, 'RENDER_FORMAT', '', false )
then convert base64 to string using this

then (I did reverse engeeneer that myself, probably Ultrashall have more descriptions)

wav bit depth: 5th character
write BWF: 6th character & 1 (inverted)
Include project filename in BWF data: 6th character & 4
mpl is offline   Reply With Quote
Old 06-25-2019, 07:13 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You can use my Ultraschall-Api, which allows you to do all of that with much more comfort and full access.
It has also functions to generate a string needed for getsetprojectinfo_string, to set render-format settings, like wav, flac, mp3 etc.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-25-2019, 07:14 AM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You can use my Ultraschall-Api, which allows you to do all of that with much more comfort and full access.
It has also functions to generate a string needed for getsetprojectinfo_string, to set render-format settings, like wav, flac, mp3 etc.

Link in my signature.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-25-2019, 10:29 AM   #9
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Cool, thanks guys. I probably will end up using your extension Mesopotine, but I'm trying this manual approach first to avoid dependencies. Plus, it's useful to know how this stuff is put together
Travesty is offline   Reply With Quote
Old 06-25-2019, 10:36 AM   #10
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Ok, I'm lost

This seems to be a combination of the bitfield method used in RENDER_SETTINGS and something else.

Bitfield is simple to understand, I just add the options together to get an "address" of the combination I want. I take it that this isn't that simple?

What to I feed into a base64 encoder to get the string I need?
Travesty is offline   Reply With Quote
Old 06-25-2019, 10:39 AM   #11
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Ah, I get the string and then feed it into the base64 script? Trying that


Edit:

Tried decoding with all the decoder scripts on that page, and they all blew up at some point because of a nil value.

The top one gives "attempt to concatenate a nil value"

The string I'm feeding in is ZXZhdxAEAA==

Code:
function dec(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
        return string.char(c)
    end))
end

reaper.GetSetProjectInfo( 0, "RENDER_SETTINGS", 80, true )

reaper.GetSetProjectInfo( 0, "RENDER_TAILFLAG", 1, true )

reaper.GetSetProjectInfo( 0, "RENDER_CHANNELS", 2, true )

reaper.GetSetProjectInfo( 0, "RENDER_SRATE", 44100, true )

retval, valuestrNeedBig = reaper.GetSetProjectInfo_String( 0, "RENDER_FORMAT", "", false )

msg(valuestrNeedBig)

dec(valuestrNeedBig)

Last edited by Travesty; 06-25-2019 at 10:49 AM.
Travesty is offline   Reply With Quote
Old 06-25-2019, 02:35 PM   #12
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

it uses this in global variable:

Code:
-- character table string
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
it will return you some non-printed characters and reversed format like 'evaw' for wav, you can test it as table of values for example like

Code:
 -- character table string
 local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
 
 -- encoding
 function enc(data)
     return ((data:gsub('.', function(x) 
         local r,b='',x:byte()
         for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
         return r;
     end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
         if (#x < 6) then return '' end
         local c=0
         for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
         return b:sub(c+1,c+1)
     end)..({ '', '==', '=' })[#data%3+1])
 end
 
 -- decoding
 function dec(data)
     data = string.gsub(data, '[^'..b..'=]', '')
     return (data:gsub('.', function(x)
         if (x == '=') then return '' end
         local r,f='',(b:find(x)-1)
         for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
         return r;
     end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
         if (#x ~= 8) then return '' end
         local c=0
         for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
         return string.char(c)
     end))
 end
 
------------------------------------------------------------------------
-- store values to table
 retval, valuestrNeedBig = reaper.GetSetProjectInfo_String( 0, 'RENDER_FORMAT', '', false )
 dec_s = dec(valuestrNeedBig)
 t = {}
 for i = 1, dec_s:len() do
  t[#t+1] = string.byte(dec_s:sub(i,i))
 end

  -------------------------------------------- 
 -- do here whatever to modify table
 -------------------------------------------- 

-- pass values back
  out_str = ''
  for i =1, #t do
    out_str = out_str .. string.char(t[i])
  end
  out_str64 = enc(out_str)

Last edited by mpl; 06-25-2019 at 02:43 PM.
mpl is offline   Reply With Quote
Old 06-26-2019, 06:13 AM   #13
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Whoops, I missed that, thanks

Ok, that works, decoding the string output from I get evaw


So what format am I writing the code in to pass into the encoder?

What kind of input does each byte take? Does anyone have an example of a code with it's expected outcome?
I've tried hex, but that had random outcomes

edit:

Didn't see the code you added at the bottom.
I can see from the readout that you are filling a table with what look like sensible numbers.
In the modify table section, how do I enter each byte into the string, how do I separate the bytes?

Last edited by Travesty; 06-26-2019 at 06:22 AM.
Travesty is offline   Reply With Quote
Old 06-26-2019, 08:22 AM   #14
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

With a bitfield you learned before
mpl is offline   Reply With Quote
Old 06-26-2019, 10:47 AM   #15
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Ok, I was misunderstanding the script. I didn't get that I was supposed to manually edit the table, I was trying to append the string by adding bitfield values to out_str = ''


Got this working now, thanks for all your help.

Code:
 -- character table string
 local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
 
 -- encoding
 function enc(data)
     return ((data:gsub('.', function(x) 
         local r,b='',x:byte()
         for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
         return r;
     end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
         if (#x < 6) then return '' end
         local c=0
         for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
         return b:sub(c+1,c+1)
     end)..({ '', '==', '=' })[#data%3+1])
 end
 
 -- decoding
 function dec(data)
     data = string.gsub(data, '[^'..b..'=]', '')
     return (data:gsub('.', function(x)
         if (x == '=') then return '' end
         local r,f='',(b:find(x)-1)
         for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
         return r;
     end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
         if (#x ~= 8) then return '' end
         local c=0
         for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
         return string.char(c)
     end))
 end
 
------------------------------------------------------------------------
-- store values to table
 retval, valuestrNeedBig = reaper.GetSetProjectInfo_String( 0, 'RENDER_FORMAT', '', false )
 dec_s = dec(valuestrNeedBig)
 t = {}
 for i = 1, dec_s:len() do
  t[#t+1] = string.byte(dec_s:sub(i,i))
 end

  -------------------------------------------- 
 -- do here whatever to modify table
 -------------------------------------------- 
t[1] = 101
t[2] = 118
t[3] = 97
t[4] = 119
t[5] = 16
t[6] = 28
t[7] = 0

-- pass values back
  out_str = ''
  for i =1, #t do
    out_str = out_str .. string.char(t[i])
  end
  out_str64 = enc(out_str)
  ----------------------------
  -- send string to reaper
  -----------------------------
  reaper.GetSetProjectInfo_String( 0, 'RENDER_FORMAT', out_str64, true )
Travesty 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:04 AM.


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