Skip to content

Commit

Permalink
1808
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPilyavskiy committed Aug 18, 2018
1 parent c224e3e commit 9201898
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 32 deletions.
49 changes: 33 additions & 16 deletions Stretch Markers/mpl_Copy selected item stretch markers.lua
@@ -1,9 +1,9 @@
-- @description Copy selected item stretch markers
-- @version 1.0
-- @version 1.01
-- @author MPL
-- @website http://forum.cockos.com/showthread.php?t=188335
-- @changelog
-- + init
-- # use native chunk functions, REAPER 5.95pre3+

-- NOT gfx NOT reaper
local scr_title = 'Copy selected item stretch markers'
Expand All @@ -17,7 +17,7 @@
local tk = GetActiveTake( item )
if tk then

local chunk = eugen27771_GetObjStateChunk(item)
local retval, chunk = GetItemStateChunk( item, '', false )
local tk_GUID = BR_GetMediaItemTakeGUID( tk )
local takeSTR = chunk:match(literalize(tk_GUID)..'.*SM.-\n')
if takeSTR then
Expand All @@ -29,27 +29,44 @@
end
end


--------------------------------------------------------
if not APIExists( 'CF_GetClipboard' ) then
MB('Require SWS v2.9.5+', 'Error', 0)
else
SEfunc_path = GetResourcePath()..'/Scripts/MPL Scripts/Functions/mpl_Various_functions.lua'
---------------------------------------------------------------------
function CheckFunctions(str_func)
local SEfunc_path = reaper.GetResourcePath()..'/Scripts/MPL Scripts/Functions/mpl_Various_functions.lua'
local f = io.open(SEfunc_path, 'r')
if f then
f:close()
dofile(SEfunc_path)

if not eugen27771_GetObjStateChunk then
MB('Update '..SEfunc_path:gsub('%\\', '/')..' to newer version', '', 0)
if not _G[str_func] then
reaper.MB('Update '..SEfunc_path:gsub('%\\', '/')..' to newer version', '', 0)
else
--Undo_BeginBlock()
main()
--Undo_EndBlock( scr_title, -1 )
return true
end

else
MB(SEfunc_path:gsub('%\\', '/')..' missing', '', 0)
end
reaper.MB(SEfunc_path:gsub('%\\', '/')..' missing', '', 0)
end
end
---------------------------------------------------
function CheckReaperVrs(rvrs)
local vrs_num = GetAppVersion()
vrs_num = tonumber(vrs_num:match('[%d%.]+'))
if rvrs > vrs_num then
reaper.MB('Update REAPER to newer version '..'('..rvrs..' or newer)', '', 0)
return
else
return true
end
end

--------------------------------------------------------
if not reaper.APIExists( 'CF_GetClipboard' ) then
MB('Require SWS v2.9.5+', 'Error', 0)
else
local ret = CheckFunctions('Action')
local ret2 = CheckReaperVrs(5.95)
if ret and ret2 then main() end
end



@@ -1,13 +1,12 @@
-- @description Paste and replace stretch markers to selected items
-- @version 1.0
-- @version 1.01
-- @author MPL
-- @website http://forum.cockos.com/showthread.php?t=188335
-- @changelog
-- + init
-- # use native chunk functions, REAPER 5.95pre3+

-- NOT gfx NOT reaper
local scr_title = 'Paste and replace stretch markers to selected items'
for key in pairs(reaper) do _G[key]=reaper[key] end


-------------------------------------------------------
Expand All @@ -20,7 +19,7 @@
if item then
local tk = GetActiveTake( item )
if tk then
local chunk = eugen27771_GetObjStateChunk( item)
local retval, chunk = GetItemStateChunk( item, '', false )
local tk_GUID = BR_GetMediaItemTakeGUID( tk )
local takeSTR = chunk:match(literalize(tk_GUID)..'.*SM.-\n')
if takeSTR then
Expand All @@ -42,24 +41,43 @@
end


--------------------------------------------------------
if not APIExists( 'CF_GetClipboard' ) then
MB('Require SWS v2.9.5+', 'Error', 0)
else
SEfunc_path = GetResourcePath()..'/Scripts/MPL Scripts/Functions/mpl_Various_functions.lua'
---------------------------------------------------------------------
function CheckFunctions(str_func)
local SEfunc_path = reaper.GetResourcePath()..'/Scripts/MPL Scripts/Functions/mpl_Various_functions.lua'
local f = io.open(SEfunc_path, 'r')
if f then
f:close()
dofile(SEfunc_path)
if not eugen27771_GetObjStateChunk then
MB('Update '..SEfunc_path:gsub('%\\', '/')..' to newer version', '', 0)

if not _G[str_func] then
reaper.MB('Update '..SEfunc_path:gsub('%\\', '/')..' to newer version', '', 0)
else
Undo_BeginBlock()
main()
Undo_EndBlock( scr_title, -1 )
return true
end

else
MB(SEfunc_path:gsub('%\\', '/')..' missing', '', 0)
end
reaper.MB(SEfunc_path:gsub('%\\', '/')..' missing', '', 0)
end
end
---------------------------------------------------
function CheckReaperVrs(rvrs)
local vrs_num = GetAppVersion()
vrs_num = tonumber(vrs_num:match('[%d%.]+'))
if rvrs > vrs_num then
reaper.MB('Update REAPER to newer version '..'('..rvrs..' or newer)', '', 0)
return
else
return true
end
end

--------------------------------------------------------
if not reaper.APIExists( 'CF_GetClipboard' ) then
MB('Require SWS v2.9.5+', 'Error', 0)
else
local ret = CheckFunctions('Action')
local ret2 = CheckReaperVrs(5.95)
if ret and ret2 then main() end
end


0 comments on commit 9201898

Please sign in to comment.