Prev Previous Post   Next Post Next
Old 08-29-2019, 01:34 PM   #1
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,585
Default Lua: "Solo dim" -slider

Haven't been coding for a while, so I guess it's time to test something.

Solo dim slider - smooth transition from "True solo" to "Dim unsoloed tracks by x decibels"



Code:
-- Solo dim slider by spk77 29-Aug-2019 (Thanks Lokasenna for the GUI Library)

-- The Core library must be loaded prior to anything else

local lib_path = reaper.GetExtState("Lokasenna_GUI", "lib_path_v2")
if not lib_path or lib_path == "" then
    reaper.MB("Couldn't load the Lokasenna_GUI library. Please run 'Script: Set Lokasenna_GUI v2 library path.lua' in your Action List.", "Whoops!", 0)
    return
end
loadfile(lib_path .. "Core.lua")()

GUI.req("Classes/Class - Slider.lua")()

-- If any of the requested libraries weren't found, abort the script nicely.
if missing_lib then return 0 end


------------------------------------
-------- Window settings -----------
------------------------------------


GUI.name = "Solo dim slider"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 256+40, 100
GUI.anchor, GUI.corner = "screen", "C"

------------------------------------
-------- GUI Elements --------------
------------------------------------

--[[  

  Slider    z,   x,   y,   w,   caption, min, max, defaults[, inc, dir]
  
]]--

GUI.New("sldr_dim", "Slider", 1, 20, 50, 256, "True solo", -30, -0.1, 0, 0.1, "h")
local sldr_dim = GUI.elms.sldr_dim
sldr_dim.show_values = false

------------------------------------
-------- Functions  ----------------
------------------------------------

function GUI.elms.sldr_dim:ondrag()
  GUI.Slider.ondrag(self)
  local thresh = GUI.Val("sldr_dim")
  if thresh == sldr_dim.min then
    if reaper.GetToggleCommandState(40745) == 1 then
      reaper.Main_OnCommand(40745, 0)
      sldr_dim.caption = "True solo"
    end
 else
    if reaper.GetToggleCommandState(40745) == 0 then
      reaper.Main_OnCommand(40745, 0)
    end
    sldr_dim.caption = "Dim unsoloed tracks by " .. thresh .. "dB"
  end
  reaper.SNM_SetIntConfigVar("solodimdb10", thresh*10)
end


------------------------------------
-- Init ----------------------------
------------------------------------

function init()
  if reaper.GetToggleCommandState(40745) == 1 then
    reaper.Main_OnCommand(40745, 0)
    sldr_dim.caption = "True solo"
  end
end

GUI.Init()
GUI.Main()
init()
spk77 is offline   Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.