View Single Post
Old 05-11-2018, 04:14 PM   #1657
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Hi Triode. Quick easy version. I guess you could read RPP or something to get the numbers instead, but hopefully this is good enough.

If you use undo points for time selection, you could remove "--" from start of UndoBeginBlock and UndoEndBlock lines. If you do that, you could erase:
function noundo() end
reaper.defer(noundo)

but I don't think it's really necessary.


Code:
-- Coalesce two SWS time selection slots.lua
-- Don't use it if you don't have SWS...

function Fn_Coalesce()
  --reaper.Undo_BeginBlock2(0)
  
  reaper.PreventUIRefresh(1)
  local slot3ok
  local a,b = reaper.GetSet_LoopTimeRange(0, 0, 0, 0, 0)
  reaper.GetSet_LoopTimeRange(1, 0, 0, 0, 0)
  reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_RESTTIME3"),0)
  local c,d = reaper.GetSet_LoopTimeRange(0, 0, 0, 0, 0)
  if c~=d then
    a=c
    b=d
    slot3ok = true
  end
  
  reaper.GetSet_LoopTimeRange(1, 0, 0, 0, 0)
  reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_RESTTIME4"),0)
  local e,f = reaper.GetSet_LoopTimeRange(0, 0, 0, 0, 0)
  if e~=f then
    a=e
    b=f
    if slot3ok == true then
      if c<e then a=c end
      if d>f then b=d end
    end
  end
  
  reaper.GetSet_LoopTimeRange(1, 0, a, b, 0)
  reaper.PreventUIRefresh(-1)
  
  --reaper.Undo_EndBlock2(0, "coalesce time selections 3 and 4", -1)
end

function noundo() end
reaper.defer(noundo)

Fn_Coalesce()

Last edited by FnA; 05-11-2018 at 08:13 PM.
FnA is offline   Reply With Quote