Skip to content

Commit

Permalink
Release Smart split items using mouse cursor context (also edit curso…
Browse files Browse the repository at this point in the history
…r, razor area and time selection) v3.1 (#1332)

- fixed bug when razor area covers envelope
  • Loading branch information
AZpercussion authored Mar 8, 2024
1 parent 5227b2c commit d195023
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions Items Editing/az_Smart split items by mouse cursor.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
-- @description Smart split items using mouse cursor context (also edit cursor, razor area and time selection)
-- @author AZ
-- @version 3.0
-- @changelog
-- Major update to version 3.0
-- - A lot of options stored in user config
-- - Options window
-- - Many new features and bug fixes
-- @version 3.1
-- @changelog - fixed bug when razor area covers envelope
-- @provides [main] az_Smart split items by mouse cursor/az_Open options for az_Smart split items by mouse cursor.lua
-- @link Forum thread https://forum.cockos.com/showthread.php?t=259751
-- @donation Donate via PayPal https://www.paypal.me/AZsound
Expand Down Expand Up @@ -678,7 +674,7 @@ function GetRazorEdits()
if not isEnvelope then
--reaper.ShowConsoleMsg(areaTop.." "..areaBottom.."\n\n")
items = GetItemsInRange(track, areaStart, areaEnd, areaTop, areaBottom)
if #items > 0 then AnythingForSplit = true end
if not AnythingForSplit and #items > 0 then AnythingForSplit = true end
else
envelope = reaper.GetTrackEnvelopeByChunkName(track, GUID:sub(2, -2))
local ret, envName = reaper.GetEnvelopeName(envelope)
Expand All @@ -687,7 +683,8 @@ function GetRazorEdits()
envelopePoints = GetEnvelopePointsInRange(envelope, areaStart, areaEnd)
end

local areaData = {
if not isEnvelope then
local areaData = {
areaStart = areaStart,
areaEnd = areaEnd,
areaTop = areaTop,
Expand All @@ -702,9 +699,10 @@ function GetRazorEdits()
envelopeName = envelopeName,
envelopePoints = envelopePoints,
GUID = GUID:sub(2, -2)
}
}

table.insert(areaMap, areaData)
table.insert(areaMap, areaData)
end

i=i+1
end
Expand Down Expand Up @@ -738,7 +736,7 @@ function GetRazorEdits()

if not isEnvelope then
items = GetItemsInRange(track, areaStart, areaEnd)
if #items > 0 then AnythingForSplit = true end
if not AnythingForSplit and #items > 0 then AnythingForSplit = true end
else
envelope = reaper.GetTrackEnvelopeByChunkName(track, GUID:sub(2, -2))
local ret, envName = reaper.GetEnvelopeName(envelope)
Expand All @@ -747,7 +745,8 @@ function GetRazorEdits()
envelopePoints = GetEnvelopePointsInRange(envelope, areaStart, areaEnd)
end

local areaData = {
if not isEnvelope then
local areaData = {
areaStart = areaStart,
areaEnd = areaEnd,

Expand All @@ -760,9 +759,10 @@ function GetRazorEdits()
envelopeName = envelopeName,
envelopePoints = envelopePoints,
GUID = GUID:sub(2, -2)
}
}

table.insert(areaMap, areaData)
table.insert(areaMap, areaData)
end

j = j + 3
end
Expand Down Expand Up @@ -1714,10 +1714,14 @@ end

------------------
-------START------
version = reaper.GetExtState(ExtStateName, "version")
if version ~= "3.0" then
updateMSG()
reaper.SetExtState(ExtStateName, "version", "3.0", true)
CurVers = 3.1
version = tonumber( reaper.GetExtState(ExtStateName, "version") )
if version ~= CurVers then
if version < 3 then
updateMSG()
else reaper.ShowMessageBox('The script was updated to version '..CurVers ,'Smart split',0)
end
reaper.SetExtState(ExtStateName, "version", CurVers, true)
reaper.defer(function()end)
else
if reaper.APIExists( 'BR_GetMouseCursorContext' ) ~= true then
Expand Down

0 comments on commit d195023

Please sign in to comment.