local r = reaper; local function nothing() end; local function bla() r.defer(nothing) end
local env = r.GetSelectedEnvelope()
if not env then bla() return end
local points = r.CountEnvelopePoints(env)
if points == 0 then bla() return end
local cur = r.GetCursorPosition()
r.Undo_BeginBlock()
--r.PreventUIRefresh(1)
local found
for i = 0, points-1 do
local _, time, _, _, _, sel = r.GetEnvelopePoint(env,i)
if sel then
r.SetEditCurPos2(0, time, 0, 0)
found = 1; iter = i
break end
end
if not iter then bla() return end
local _, val, shape, tens
if found then
r.Main_OnCommand(41987,0)--Envelope: Edit envelope point value at cursor
_, _, val, shape, tens = r.GetEnvelopePoint(env, iter)
for i = iter+1, points-1 do
local _, _, _, _, _, sel = r.GetEnvelopePoint(env,i)
if sel then
r.SetEnvelopePoint(env, i, nil, val, shape, tens, nil, 0)
end
end
-- r.SetEditCurPos2(0, cur, 0, 0)
end
--r.PreventUIRefresh(-1)
r.UpdateArrange()
r.Undo_EndBlock('Edit sel envelope point', -1)