-----DEBUG CONTROL-------------------------------------------------------------- debug_output = true -- true/false --display debug messages in the console -----DISPLAY CONSOLE MESSAGE---------------------------------------------------- -- Display a message in the console for debugging, message can be a number variable -- or a string but not mixed. No line feed character is added. function Msg(value) --returns nothing if debug_output then --check if flag is set true (at the start of this script) reaper.ShowConsoleMsg(tostring(value).."\n") end end -- NoIndex: true --[[ Lokasenna_GUI example - Getting user input before running an action; i.e. replacing GetUserInputs ]]-- -------------------------------- --REATRAK LOCAL GUI LIBRARY start -------------------------------- local info = debug.getinfo(1,'S'); script_path = info.source:match[[^@?(.*[\/])[^\/]-$]] --Msg("script_path "..script_path) local lib_path = script_path --reaper.GetExtState("Lokasenna_GUI", "lib_path_v2") --if not lib_path or lib_path == "" then --reaper.MB("Couldn't load the ReaTrak Lokasenna_GUI library. Please check Scripts/ReaTrak/ReaTrak_Classes/", "Whoops!", 0) --return --end loadfile(script_path .. "ReaTrak_Core.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Label.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Knob.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Tabs.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Slider.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Button.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Menubox.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Textbox.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Frame.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Options.lua")() GUI.req(script_path .. "ReaTrak_Classes/Class - Window.lua")() -------------------------------- --REATRAK LOCAL GUI LIBRARY end -------------------------------- --]] -------------------------------- --LOKASENNA GUI LIBRARY start -------------------------------- -- NoIndex: true --[[ Lokasenna_GUI example - Getting user input before running an action; i.e. replacing GetUserInputs ]]-- --[[ -- The Core library must be loaded prior to anything else reaper.MB("Using Lokasenna_GUI library", "Notice", 0) 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 - Label.lua")() GUI.req("Classes/Class - Knob.lua")() GUI.req("Classes/Class - Tabs.lua")() GUI.req("Classes/Class - Slider.lua")() GUI.req("Classes/Class - Button.lua")() GUI.req("Classes/Class - Menubox.lua")() GUI.req("Classes/Class - Textbox.lua")() GUI.req("Classes/Class - Frame.lua")() GUI.req("Classes/Class - Options.lua")() GUI.req("Classes/Class - Window.lua")() -------------------------------- --LOKASENNA GUI LIBRARY end -------------------------------- --]] -- If any of the requested libraries weren't found, abort the script nicely. if missing_lib then return 0 end -- Button Colors = {r, g, b, transparency} GUI.colors["count_in"] = {255, 124, 192, 255} GUI.colors["intro_post_fill"] = {119, 17, 174, 255} GUI.colors["intro"] = {159, 22, 232, 255} GUI.colors["intro_fill"] = {183, 128, 237, 255} GUI.colors["verse_post_fill"] = {17, 39, 174, 255} GUI.colors["verse"] = {55, 118, 235, 255} GUI.colors["verse_fill"] = {113, 190, 241, 255} GUI.colors["verse_ending"] = {151, 208, 245, 255} GUI.colors["bridge_post_fill"] = {206, 105, 20, 255} GUI.colors["bridge"] = {234, 133, 48, 255} GUI.colors["bridge_fill"] = {239, 164, 100, 255} GUI.colors["pre_chorus_post_fill"] = {206, 179, 20, 255} GUI.colors["pre_chorus"] = {234, 208, 48, 255} GUI.colors["pre_chorus_fill"] = {244, 231, 151, 255} GUI.colors["chorus_post_fill"] = {11, 116, 39, 255} GUI.colors["chorus"] = {17, 174, 59, 255} GUI.colors["chorus_fill"] = {80, 237, 123, 255} GUI.colors["chorus_ending"] = {158, 254, 182, 255} GUI.colors["play_anywhere"] = {228, 26, 39, 250} GUI.colors["drum_riff"] = {115, 23, 17, 255} GUI.colors["hold"] = {191, 191, 191, 255} GUI.colors["shot"] = {127, 127, 127, 255} GUI.colors["rest"] = {0, 0, 0, 255} --Text Colors GUI.colors["btn_txt1"] = {255, 255, 255, 255} --white GUI.colors["btn_txt2"] = {155, 155, 155, 255} --gray GUI.colors["btn_txt3"] = {0, 0, 0, 255} --black ------------------------------------ -------- Functions ---------------- ------------------------------------ function active() if active_state == 1 then get_region_name() end if reaper.GetToggleCommandState(1068) == 1 then repeat_onstate = "verse_ending" start_pos, end_pos = reaper.GetSet_LoopTimeRange(true, true, pos, rgnend, 0) else repeat_onstate = "rest" reaper.Main_OnCommand(40635, 0) -- Time selection: Remove time selection end GUI.elms.btn_loop:ondelete() GUI.New("btn_loop", "Button", 1, 210, 100, 84, 24, "Loop", btn_loop) GUI.elms.btn_loop.col_txt = "btn_txt1" GUI.elms.btn_loop.col_fill = repeat_onstate GUI.elms.btn_loop.font = 3 GUI.elms.btn_loop:init() reaper.Main_OnCommand(1, 0) -- Transport: Play if reaper.GetPlayState() == 1 then play_state = "chorus" else play_state = "rest" end GUI.elms.btn_play:ondelete() GUI.New("btn_play", "Button", 1, 10, 100, 84, 24, "Play", btn_play) GUI.elms.btn_play.col_txt = "btn_txt1" GUI.elms.btn_play.col_fill = play_state GUI.elms.btn_play.font = 3 GUI.elms.btn_play:init() if reaper.GetPlayState() == 1 then stop_state = "rest" else stop_state = "play_anywhere" end GUI.elms.btn_stop:ondelete() GUI.New("btn_stop", "Button", 1, 110, 100, 84, 24, "Stop", btn_stop) GUI.elms.btn_stop.col_txt = "btn_txt1" GUI.elms.btn_stop.col_fill = stop_state GUI.elms.btn_stop.font = 3 GUI.elms.btn_stop:init() end local function btn_go() if active_state == 0 then GUI.elms.btn_go:ondelete() GUI.New("btn_go", "Button", 1, 10, 50, 84, 24, "Active", btn_go) GUI.elms.btn_go.col_txt = "btn_txt1" GUI.elms.btn_go.col_fill = "chorus" GUI.elms.btn_go.font = 3 GUI.elms.btn_go:init() active_state = 1 reaper.Main_OnCommand(40297, 0) -- Track: Unselect all tracks elseif active_state == 1 then GUI.elms.btn_go:ondelete() GUI.New("btn_go", "Button", 1, 10, 50, 84, 24, "In-Active", btn_go) GUI.elms.btn_go.col_txt = "btn_txt1" GUI.elms.btn_go.col_fill = "play_anywhere" GUI.elms.btn_go.font = 3 GUI.elms.btn_go:init() active_state = 0 end end function selected_track() sel_track = reaper.GetSelectedTrack2( 0, 0, 0 ) if sel_track ~= previous_track then commandID2 = reaper.NamedCommandLookup("_S&M_WNCLS3") reaper.Main_OnCommand(commandID2, 0) -- SWS/S&M: Close all floating FX windows commandID1 = reaper.NamedCommandLookup("_S&M_FLOATFX1") reaper.Main_OnCommand(commandID1, 0) -- SWS/S&M: Float FX 1 for selected tracks previous_track = sel_track end end function get_region_name() --if reaper.GetPlayState() ~= 1 then goto skip end count_markers_regions, num_markers, num_regions = reaper.CountProjectMarkers(0) retval, num_markers, num_regionsOut = reaper.CountProjectMarkers(0) time = reaper.GetPlayPosition2() time2 = reaper.GetCursorPosition() if reaper.GetPlayState() ~= 1 then time_source = time2 else time_source = time end markeridx, regionidx = reaper.GetLastMarkerAndCurRegion(0, time_source) --print("Region "..regionidx) retval, isrgn, pos, rgnend, region_name, markrgnindexnumber, color = reaper.EnumProjectMarkers3(0, regionidx) --Msg("Region Name= ".. region_name) for i = 1, reaper.CountTracks(0) do tr = reaper.GetTrack(0, i - 1) _, name = reaper.GetTrackName(tr, "") if not sel_track then tr = reaper.GetTrack(0, 1) if not tr then goto finish end reaper.SetTrackSelected( tr, 1 ) end sel_track = reaper.GetSelectedTrack2( 0, 0, 0 ) if name == region_name then sel_track = reaper.GetSelectedTrack2( 0, 0, 0 ) reaper.SetTrackSelected( sel_track, 0 ) reaper.SetTrackSelected( tr, 1 ) selected_track() goto finish break end end ::skip:: selected_track() ::finish:: end function btn_zoom_in() start_pos, end_pos = reaper.GetSet_LoopTimeRange(true, true, pos, rgnend, 0) reaper.Main_OnCommand(40031, 0) -- View: Zoom time selection if reaper.GetToggleCommandState(1068) == 0 then reaper.Main_OnCommand(40635, 0) -- Time selection: Remove time selection end end function btn_zoom_out() commandID3 = reaper.NamedCommandLookup("_SWS_UNDOZOOM") reaper.Main_OnCommand(commandID3, 0) -- SWS: Undo zoom end function btn_play() reaper.Main_OnCommand(1007, 0) -- Transport: Play if reaper.GetPlayState() == 1 then play_state = "chorus" else play_state = "rest" end GUI.elms.btn_play:ondelete() GUI.New("btn_play", "Button", 1, 10, 100, 84, 24, "Play", btn_play) GUI.elms.btn_play.col_txt = "btn_txt1" GUI.elms.btn_play.col_fill = play_state GUI.elms.btn_play.font = 3 GUI.elms.btn_play:init() end function btn_stop() reaper.Main_OnCommand(1016, 0) -- Transport: Stop if reaper.GetPlayState() == 1 then stop_state = "rest" else stop_state = "play_anywhere" end GUI.elms.btn_stop:ondelete() GUI.New("btn_stop", "Button", 1, 110, 100, 84, 24, "Stop", btn_stop) GUI.elms.btn_stop.col_txt = "btn_txt1" GUI.elms.btn_stop.col_fill = stop_state GUI.elms.btn_stop.font = 3 GUI.elms.btn_stop:init() end function btn_loop() reaper.Main_OnCommand(1068, 0) -- Transport: Toggle repeat if reaper.GetToggleCommandState(1068) == 1 then repeat_onstate = "verse_ending" start_pos, end_pos = reaper.GetSet_LoopTimeRange(true, true, pos, rgnend, 0) else repeat_onstate = "rest" reaper.Main_OnCommand(40635, 0) -- Time selection: Remove time selection end GUI.elms.btn_loop:ondelete() GUI.New("btn_loop", "Button", 1, 210, 100, 84, 24, "Loop", btn_loop) GUI.elms.btn_loop.col_txt = "btn_txt1" GUI.elms.btn_loop.col_fill = repeat_onstate GUI.elms.btn_loop.font = 3 GUI.elms.btn_loop:init() --reaper.Main_OnCommand(40031, 0) -- View: Zoom time selection end GUI.func = active -- GUI.func will run on every loop -- Use this to set the poll time in seconds: GUI.freq = .5 -- .05 ------------------------------------ -------- Window settings ----------- ------------------------------------ GUI.name = "ReaTrak BB Plugin Song Sections" GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 310, 200 GUI.anchor, GUI.corner = "mouse", "C" ------------------------------------ -------- GUI Elements -------------- ------------------------------------ --[[ Button z, x, y, w, h, caption, func[, ...] Checklist z, x, y, w, h, caption, opts[, dir, pad] Menubox z, x, y, w, h, caption, opts, pad, noarrow] Slider z, x, y, w, caption, min, max, defaults[, inc, dir] ]]-- --GUI.New("mnu_mode", "Menubox", 1, 64, 32, 72, 20, "Mode:", "Auto,Punch,Step") --GUI.New("chk_opts", "Checklist", 1, 192, 32, 192, 96, "Options", "Only in time selection,Only on selected track,Glue items when finished", "v", 4) --GUI.New("sldr_thresh", "Slider", 1, 32, 96, 128, "Threshold", -60, 0, 48, nil, "h") --GUI.elms.acid_root_label:ondelete() --GUI.New("active_label", "Label", 1, 100, 10, "Active" , true, 1) --GUI.elms.acid_root_label:init() GUI.New("bb_label", "Label", 1, 20, 10, "BB Plugin Song Sections" , true, 1, "white", "wnd_bg" ) GUI.elms.bb_label.col_txt = "verse_fill" GUI.elms.bb_label.font = {"Arial", 25, "bi"} GUI.New("btn_go", "Button", 1, 10, 50, 84, 24, "Active", btn_go) GUI.elms.btn_go.col_txt = "btn_txt1" GUI.elms.btn_go.col_fill = "chorus" GUI.elms.btn_go.font = 3 GUI.New("btn_zoom_in", "Button", 1, 110, 50, 84, 24, "Zoom In", btn_zoom_in) GUI.New("btn_zoom_out", "Button", 1, 210, 50, 84, 24, "Zoom Out", btn_zoom_out) GUI.New("btn_play", "Button", 1, 10, 100, 84, 24, "Play", btn_play) GUI.elms.btn_play.col_txt = "btn_txt1" GUI.elms.btn_play.col_fill = "rest" GUI.elms.btn_play.font = 3 GUI.New("btn_stop", "Button", 1, 110, 100, 84, 24, "Stop", btn_stop) GUI.elms.btn_stop.col_txt = "btn_txt1" GUI.elms.btn_stop.col_fill = "play_anywhere" GUI.elms.btn_stop.font = 3 if reaper.GetToggleCommandState(1068) == 1 then repeat_onstate = "verse_ending" else repeat_onstate = "rest" end GUI.New("btn_loop", "Button", 1, 210, 100, 84, 24, "Loop", btn_loop) GUI.elms.btn_loop.col_txt = "btn_txt1" GUI.elms.btn_loop.col_fill = repeat_onstate GUI.elms.btn_loop.font = 3 --GUI.Val("active_label") --GUI.New("my_txt", "Textbox", 1, 50, 130, 120, 20, "Text:", 4) active_state = 1 --GUI.Val("my_txt") --Returns the contents of the textbox. --GUI.Val("my_txt", "Hello, world!") --Sets the contents of the textbox. GUI.Init() GUI.Main()