Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- USER CONFIG
- local filename = "footswitch_render"
- --- END USER CONFIG
- function enc(data) -- http://lua-users.org/wiki/BaseSixtyFour
- 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
- function setFormatMP3()
- local form_conf = { [1]=128,
- [2]=0,
- [5]=232,
- [6]=3,
- [9]=2,
- [13]=255,
- [14]=255,
- [15]=255,
- [16]=255,
- [17]=4,
- [21]=128,
- len = 28}
- out_str = ''
- for i = 1, form_conf.len do
- if not form_conf[i] then form_conf[i] = 0 end
- out_str = out_str..tostring(form_conf[i]):char()
- end
- reaper.GetSetProjectInfo_String(0, 'RENDER_FORMAT', enc('l3pm'..out_str), true)
- end
- function setRenderBoundsTime()
- reaper.GetSetProjectInfo(0, 'RENDER_BOUNDSFLAG', 2, true)
- end
- function setRenderPattern(name)
- local pr_path = reaper.GetProjectPathEx( 0, '' )
- reaper.GetSetProjectInfo_String(0, 'RENDER_FILE', pr_path, true)
- reaper.GetSetProjectInfo_String(0, 'RENDER_PATTERN', name, true)
- end
- function setRenderSourceMaster()
- reaper.GetSetProjectInfo(0, 'RENDER_SETTINGS', 0, true) -- set to master
- end
- function main()
- local playstate = reaper.GetPlayStateEx( 0 )
- if (playstate >> 2) == 1 then -- if currently recording
- reaper.Main_OnCommand(1016, 0) -- stop
- reaper.Main_OnCommand(40290, 0) -- time selection from items
- setRenderSourceMaster()
- setFormatMP3()
- setRenderBoundsTime()
- setRenderPattern(filename)
- reaper.Main_OnCommand(42230, 0) -- render using current settings
- else
- reaper.Main_OnCommand(1013, 0) -- record
- end
- end
- main()
Add Comment
Please, Sign In to add comment