Cockos Incorporated Forums GetSetProjectInfo_String Bit Depth and REAPER UI
 Register Search Today's Posts Mark Forums Read

 03-17-2024, 02:05 PM #1 daniellumertz Human being with feelings     Join Date: Dec 2017 Location: Brazil Posts: 2,024 GetSetProjectInfo_String Bit Depth and REAPER UI Updating the bit depth using reaper.GetSetProjectInfo_String(proj, 'RECORD_FORMAT', bit) or reaper.GetSetProjectInfo_String(proj, 'RENDER_FORMAT', bit). Dont change the REAPER UI on the top right Code to test Code: ``` ---@param data string ---@return string function EncoderBase64(data) local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 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 ---@param data string ---@return string function DecoderBase64(data) local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 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 ---Set the bitdepth of a project ---@param proj project|number|nil ---@param key string 'RECORD_FORMAT' or 'RENDER_FORMAT' ---@param bitdepth number 8,16,24,32,666 ... function SetBitDepth(proj, key, bitdepth) local _, current = reaper.GetSetProjectInfo_String( proj, key, '', false ) -- about https://mespotin.uber.space/Ultraschall/misc_docs/RENDER_How_RenderCFG-Base64-strings_are_encoded.txt local decoded = DecoderBase64(current) local d1 = decoded:sub(1,4) local d2 = decoded:sub(6) local bit = string.char(bitdepth) local new_d = d1..bit..d2 new_d = EncoderBase64(new_d) reaper.GetSetProjectInfo_String(proj, key, new_d, true ) end local proj = 0 SetBitDepth(proj, 'RECORD_FORMAT', 16) SetBitDepth(proj, 'RENDER_FORMAT', 16)``` Before running : After running : But if open / close the project settings / Reaper settings OR start recording it will update: So I wonder, is this just an UI bug or does REAPER need to Update something. Am I missing some update in the code? __________________ How to Reascript| MIDI Transfer| Item Sampler| Track Snapshot| ReaShare| Sample Organizer| Microrhythms| Bartoker| Markov Chains| MIDI Toolkit| Fake Grids| Adaptative Music| It's Gonna Phase