diff --git a/Takes Properties/amagalma_Draw Spectral Edits Tool.lua b/Takes Properties/amagalma_Draw Spectral Edits Tool.lua deleted file mode 100644 index f2271b3d4..000000000 --- a/Takes Properties/amagalma_Draw Spectral Edits Tool.lua +++ /dev/null @@ -1,21 +0,0 @@ --- @description Draw Spectral Edits Tool --- @author amagalma --- @version 1.02 --- @changelog - fix: script works even if the "freq log" slider in "View: Show peaks display settings" has not ever been used --- @link https://forum.cockos.com/showthread.php?t=257188 --- @screenshot https://www.youtube.com/watch?v=cFXMku0jtqM --- @donation https://www.paypal.me/amagalma --- @about --- Draw Spectral Edits Tool --- --- What it is: A tool for easy drawing spectral edits directly on items. --- --- Supports: a) items with more than one takes, b) multi-channel items, c) display modes with “freq log” different than zero (thanks Justin for the help!). --- --- Use: Just run the script and draw edits as needed (drawn spectral edits will have the default settings*). When finished, run the script again to disable drawing mode. A tooltip is shown near the mouse cursor to remind you that you are in drawing mode. --- --- * For drawing with settings saved in presets and for maximum speed, functionality and user experience, it is recommended to use the “Draw Spectral Edits Tool – Preset System” companion script, which is offered separately with a small fee. --- --- Requirements: JS_ReaScriptAPI, SWS Extension - -local aFL = reaper.get_ini_file() local nNcj = package.config:sub(1,1) local k3NO, Bj = reaper.BR_Win32_GetPrivateProfileString("\114\101\97\112\101\114", "\115\112\101\99\103\114\97\109\95\112\114\101\115\101\116\48", "", aFL ) local Ko = Bj == "" and 0 or tonumber( Bj:match("\91\37\100\37\46\93\43\32\91\37\100\37\46\93\43\32\91\37\100\37\46\93\43\32\40\91\37\100\37\46\93\43\41") ) local jL = .1 + Ko * Ko local jB = {105, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 202, 203, 204, 417, 418, 419, 420, 421, 429, 430, 431, 433, 434, 450, 453, 460, 461, 462, 463, 464, 465, 472, 473, 488, 502, 503, 515, 517, 525, 526, 528, 529, 530, 531, 532, 533, 534, 535, 599, 600, 601, 1009, 1010, 1011, 32642, 32643, 32644, 32645 } for KXb,wtzl in ipairs(jB) do local InN = reaper.JS_Mouse_LoadCursor( wtzl ) if InN then jB[InN] = true end jB[KXb] = nil end local axgI = reaper.GetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77", 0, "" ) local Tyx = reaper.GetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77\76\79\87\69\82", 0, "" ) if reaper.BR_Win32_GetPrivateProfileString("\77\77\95\67\84\88\95\73\84\69\77\76\79\87\69\82", "\109\109\95\48", "", reaper.GetResourcePath() .. nNcj .. "\114\101\97\112\101\114\45\109\111\117\115\101\46\105\110\105") == 0 then Tyx = "\45\49" end reaper.SetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77", 0, "\48" ) reaper.SetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77\76\79\87\69\82", 0, "\48" ) local k3NO, k3NO, hmY, enk = reaper.get_action_context() reaper.SetToggleCommandState( hmY, enk, 1 ) reaper.RefreshToolbar2( hmY, enk ) local rul if reaper.GetToggleCommandState( 42294 ) == 0 then local mlyT = {42301, 42073, 42295} for xFs = 1, 3 do if reaper.GetToggleCommandState( mlyT[xFs] ) == 1 then rul = mlyT[xFs] break end end reaper.Main_OnCommand( 42294, 0 ) end local v0vQ = reaper.JS_Window_FindChildByID( reaper.GetMainHwnd(), 1000 ) local k3NO, UH, tKV, V9w, j_, H0 local HB2Y, Hxrq, Jw local log, floor, min, abs, max = math.log, math.floor, math.min, math.abs, math.max local XT = math.exp(1) local T6 = false local Tzm = {} local BQ_ = {} local S0 = false local function YN( WA ) return floor( (WA - tKV) * UH + 0.5 ) end local function Hhc( XER9 ) return tKV + XER9 / UH end local function BAo( qH ) local qEAA = reaper.JS_LICE_CreateBitmap( true, 1, 1 ) reaper.JS_LICE_Clear(qEAA, qH or 0xFFFFFFFF) return qEAA end local qEAA = {} qEAA[1] = BAo( 0x3F000000 ) for xFs = 2, 5 do qEAA[xFs] = BAo() end local function D0U( nq9, dWLw, x1, CtyO ) reaper.JS_Composite( v0vQ, nq9, dWLw, x1, CtyO, qEAA[1], 0, 0, 1, 1, true ) reaper.JS_Composite( v0vQ, nq9, dWLw, x1, 1, qEAA[2], 0, 0, 1, 1, true ) reaper.JS_Composite( v0vQ, nq9, dWLw+CtyO, x1, 1, qEAA[3], 0, 0, 1, 1, true ) reaper.JS_Composite( v0vQ, nq9, dWLw, 1, CtyO, qEAA[4], 0, 0, 1, 1, true ) reaper.JS_Composite( v0vQ, nq9+x1, dWLw, 1, CtyO, qEAA[5], 0, 0, 1, 1, true ) end local function Jp() for xFs = 1, 5 do reaper.JS_Composite_Unlink( v0vQ, qEAA[xFs], true ) end end local function I5YB() if HB2Y then reaper.JS_WindowMessage_Release( v0vQ, "\87\77\95\76\66\85\84\84\79\78\68\79\87\78" ) end if Hxrq then reaper.JS_WindowMessage_Release( v0vQ, "\87\77\95\76\66\85\84\84\79\78\85\80" ) end end reaper.atexit(function() for xFs = 1, 5 do reaper.JS_LICE_DestroyBitmap( qEAA[xFs] ) end reaper.SetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77", 0, axgI ) reaper.SetMouseModifier( "\77\77\95\67\84\88\95\73\84\69\77\76\79\87\69\82", 0, Tyx ) I5YB() reaper.SetToggleCommandState( hmY, enk, 0 ) reaper.RefreshToolbar2( hmY, enk ) if rul then reaper.Main_OnCommand( rul, 0 ) end end) local function qh() k3NO, Bj = reaper.BR_Win32_GetPrivateProfileString("\114\101\97\112\101\114", "\115\112\101\99\103\114\97\109\95\112\114\101\115\101\116\48", "", aFL ) Ko = Bj == "" and 0 or tonumber( Bj:match("\91\37\100\37\46\93\43\32\91\37\100\37\46\93\43\32\91\37\100\37\46\93\43\32\40\91\37\100\37\46\93\43\41") ) jL = .1 + Ko * Ko Tzm.fImG = reaper.GetMediaItemTakeInfo_Value( Tzm.Ts, "\68\95\83\84\65\82\84\79\70\70\83" ) end local function ZF5P( qaH ) local T2 = qaH - Tzm.uLs if not S0 then S0 = T2 // Tzm.hSV7 end if S0 < 0 then S0 = 0 end local MgnN = floor(S0 * (Tzm.EK-1) / Tzm.uPRE + 0.5) + Tzm.uLs - 1 local EX = floor((S0+1) * (Tzm.EK-1) / Tzm.uPRE + 0.5) + Tzm.uLs local hSV7 = EX - MgnN if qaH <= MgnN then T2 = -1 elseif qaH >= EX then T2 = hSV7 else T2 = qaH - MgnN end local rO if Ko ~= 0 then local MKXw = hSV7 / log( 1 + jL ) rO = (XT ^( (hSV7 - T2 - 1.5) /MKXw ) - 1 ) * Tzm.c8gN / jL else rO = Tzm.c8gN * (hSV7 - T2 - 1) / hSV7 end if rO < 0 then return 0 elseif rO > Tzm.c8gN then return Tzm.c8gN else return rO end end local rS, j_i, nUt2, QKJZ, e8, b6, wben, TRq, Uj = 1, 0, 0, 0, 0, 1, 1, 0, 0 local function Um() local NMq = reaper.GetExtState( "\97\109\97\103\97\108\109\97\95\68\114\97\119\32\83\112\101\99\116\114\97\108\32\69\100\105\116\115\32\84\111\111\108", "\95" ) if NMq ~= "" then local ftjC, GsJ = {}, 0 for qUuc in NMq:gmatch("\91\94\a\93\43") do GsJ = GsJ + 1 ftjC[GsJ] = tonumber( qUuc ) end rS, j_i, nUt2, QKJZ, e8, b6, wben, TRq, Uj = table.unpack( ftjC ) end end local function IoX() Um() local hcz = string.format("\83\80\69\67\84\82\65\76\95\69\68\73\84\32\37\102\32\37\102\32\37\102\32\37\102\32\37\102\32\37\102\32\37\102\32\45\49\32\48\32\37\102\32\37\102\32\37\102\32\37\102\32\48\32\48\32\37\102\32\37\102", min(Tzm.cW, Tzm.VxS), abs(Tzm.cW - Tzm.VxS), rS, j_i, nUt2, min(Tzm.NltJ, Tzm.LnOh), max(Tzm.NltJ, Tzm.LnOh), QKJZ, e8, b6, wben, TRq, Uj ) local dY = ({reaper.GetItemStateChunk( Tzm.t6, "", false )})[2] local ftjC, GsJ = {}, 0 local eK99, gti = false, false for line in dY:gmatch("\91\94\n\93\43") do if not eK99 and line == "\71\85\73\68\32" .. reaper.BR_GetMediaItemTakeGUID( Tzm.Ts ) then eK99 = true end if not gti and eK99 then if line:match("\94\84\65\75\69") then GsJ = GsJ + 1 ftjC[GsJ] = hcz gti = true end end GsJ = GsJ + 1 ftjC[GsJ] = line end if eK99 and not gti then ftjC[GsJ] = hcz ftjC[GsJ+1] = "\62" end reaper.SetItemStateChunk( Tzm.t6, table.concat(ftjC, "\n"), false ) reaper.Undo_OnStateChange_Item( 0, "\65\100\100\32\115\112\101\99\116\114\97\108\32\101\100\105\116", Tzm.t6 ) end local eBE, cS6, Ctpq, XjX, hOU = 0, 0 local DDvP, NOs, MbN, Fw local wOCt local function uqX() local nq9, dWLw = reaper.GetMousePosition() local XER9, qaH = reaper.JS_Window_ScreenToClient( v0vQ, nq9, dWLw ) UH = reaper.GetHZoomLevel() tKV, V9w = reaper.GetSet_ArrangeView2( 0, 0, 0, 0 ) V9w = V9w - 18/UH k3NO, j_, H0 = reaper.JS_Window_GetClientSize( v0vQ ) local CLwe = reaper.JS_Mouse_GetState( 255 ) & 1 == 1 local aty = hOU == false and CLwe hOU = CLwe local t6, Ts = reaper.GetItemFromPoint( nq9, dWLw, true ) k3NO, k3NO, XjX = reaper.GetItemEditingTime2() if Ctpq ~= Ts then Ctpq = Ts cS6 = true else cS6 = false end if Tzm.Ts or Ts then if not T6 and cS6 then Tzm.rbJ = reaper.GetMediaItemInfo_Value( Tzm.t6 or t6, "\68\95\80\79\83\73\84\73\79\78" ) Tzm.aVw = Tzm.rbJ + reaper.GetMediaItemInfo_Value( Tzm.t6 or t6, "\68\95\76\69\78\71\84\72" ) Tzm.J63d = reaper.GetMediaItemTake_Source( Tzm.Ts or Ts ) Tzm.c8gN = reaper.GetMediaSourceSampleRate( Tzm.J63d ) / 2 Tzm.uPRE = reaper.GetMediaItemTakeInfo_Value( Tzm.Ts or Ts, "\73\95\67\72\65\78\77\79\68\69" ) < 2 and reaper.GetMediaSourceNumChannels( Tzm.J63d ) or 1 Tzm.SOJb = reaper.GetMediaItemTrack( Tzm.t6 or t6 ) end Tzm.Qg = reaper.GetMediaTrackInfo_Value( Tzm.SOJb, "\73\95\84\67\80\89" ) Tzm.uLs = Tzm.Qg + reaper.GetMediaItemTakeInfo_Value( Tzm.Ts or Ts, "\73\95\76\65\83\84\89" ) Tzm.EK = reaper.GetMediaItemTakeInfo_Value( Tzm.Ts or Ts, "\73\95\76\65\83\84\72" ) Tzm.hSV7 = floor(Tzm.EK / Tzm.uPRE + 0.5) if Tzm.rbJ < tKV then BQ_.OHS = 0 else BQ_.OHS = YN( Tzm.rbJ ) end if Tzm.aVw > V9w then BQ_.tbJ = j_ else BQ_.tbJ = YN( Tzm.aVw ) end BQ_.WDIx = Tzm.uLs if BQ_.WDIx < 0 then BQ_.WDIx = 0 end BQ_.LJ = Tzm.uLs + Tzm.EK if BQ_.LJ >= H0 then BQ_.LJ = H0-1 end end if not Tzm.Ts and not Ts then if BQ_.LJ then BQ_ = {} end if Tzm.J63d then Tzm = {} end end local eN = (BQ_.OHS and XER9 >= BQ_.OHS+7 and XER9 <= BQ_.tbJ-7 and qaH >= BQ_.WDIx and qaH <= BQ_.LJ) and XjX == 0 local UeIf = reaper.JS_Mouse_GetCursor() local LJRl = jB[UeIf] or false if T6 or (eN and LJRl == false) then reaper.TrackCtl_SetToolTip( "\68\114\97\119\32\83\112\101\99\116\114\97\108\32\69\100\105\116", nq9-52, dWLw-150, true ) wOCt = true if not Jw then Jw = true HB2Y = reaper.JS_WindowMessage_Intercept( v0vQ, "\87\77\95\76\66\85\84\84\79\78\68\79\87\78", false ) >= 0 Hxrq = reaper.JS_WindowMessage_Intercept( v0vQ, "\87\77\95\76\66\85\84\84\79\78\85\80", false ) >= 0 end else if wOCt then reaper.TrackCtl_SetToolTip( "", 0, 0, true ) wOCt = false end if Jw then Jw = false I5YB() end end if not Tzm.Ts then if aty and eN and LJRl == false then Tzm.Ts, Tzm.t6 = Ts, t6 qh() Tzm.CHm = (qaH - Tzm.uLs) / Tzm.EK Tzm.NltJ = ZF5P( qaH ) Tzm.cW = Hhc( XER9 ) NOs = Tzm.EK DDvP = Tzm.Qg T6 = true end end if T6 then local Szd = XER9 local d0M = qaH if XER9 < BQ_.OHS then Szd = BQ_.OHS end if XER9 > BQ_.tbJ then Szd = BQ_.tbJ end MbN = false if Tzm.Qg ~= DDvP then DDvP = Tzm.Qg MbN = true end if Tzm.EK ~= NOs then NOs = Tzm.EK MbN = true end local T2 = qaH - Tzm.uLs Tzm.Ip = MbN and Fw or T2 // Tzm.hSV7 if Tzm.Ip < 0 then Tzm.Ip = 0 end if MbN or not BQ_.jOpX then BQ_.jOpX = floor(Tzm.Ip * (Tzm.EK-1) / Tzm.uPRE + 0.5) + Tzm.uLs - 1 end if MbN or not BQ_.PXS then BQ_.PXS = floor((Tzm.Ip+1) * (Tzm.EK-1) / Tzm.uPRE + 0.5) + Tzm.uLs end if qaH < BQ_.jOpX then d0M = BQ_.jOpX end if d0M < 0 then d0M = 0 end if qaH > BQ_.PXS then d0M = BQ_.PXS end if d0M >= H0 then d0M = H0-1 end local ix = floor(Tzm.CHm * Tzm.EK + Tzm.uLs + 0.5) local rtG = YN( Tzm.cW ) Fw = Tzm.Ip local x1, CtyO = abs( Szd - rtG ), abs( d0M - ix ) if not CLwe then if x1*CtyO > 99 then Tzm.LnOh = ZF5P( d0M ) Tzm.VxS = Hhc( Szd ) Tzm.cW = Tzm.cW - Tzm.rbJ + Tzm.fImG Tzm.VxS = Tzm.VxS - Tzm.rbJ + Tzm.fImG IoX() end T6 = false Tzm.Ts, Tzm.t6 = nil, nil BQ_ = {} S0 = false Jp() else D0U( Szd < rtG and Szd or rtG, d0M < ix and d0M or ix, x1, CtyO ) end end reaper.defer(uqX) end uqX()