199 lines
6.6 KiB
Lua
199 lines
6.6 KiB
Lua
--------------------------------------
|
|
----------// HEADER //----------------
|
|
--------------------------------------
|
|
--[[
|
|
* REALIVE: Reaper Setup for a Complete Live Playback Engine
|
|
* ReaScript Name: Realive_ProjectTabsList_OpenTab.lua
|
|
* Description: Realive_ProjectTabsList_OpenTab
|
|
* Instructions:
|
|
* Author: Alex Paquette
|
|
* Repository:
|
|
* Repository URI:
|
|
* File URI:
|
|
* Licence: GPL v3
|
|
* Forum Thread:
|
|
* Forum Thread URI:
|
|
* REAPER: 5
|
|
* Extensions: SWS/S&M
|
|
* Version: 1.0
|
|
--]]
|
|
|
|
--[[
|
|
* Changelog:
|
|
* v1.0 (2019-06-02)
|
|
+ Initial Release
|
|
--]]
|
|
|
|
|
|
--------------------------------------
|
|
----------// VARIABLES //-------------
|
|
--------------------------------------
|
|
|
|
local reaper = reaper -------// Performance Enhancement //----------
|
|
|
|
-----// Window Set Numbers //------------------------------
|
|
local PlayViewWindowSet = 01 -- Enter Window Set Number Used for the "Live Play" View
|
|
local AllTracksViewWindowSet = 02 -- Enter the Window Set Number for the "Show All Tracks" View
|
|
local WindowSetBaseNumber = 40453
|
|
local PlayView_cmdID = WindowSetBaseNumber+PlayViewWindowSet
|
|
local AllView_cmdID = WindowSetBaseNumber+AllTracksViewWindowSet
|
|
|
|
-----// Other Variables //------------------------------
|
|
local repeatScriptState_Disable = reaper.NamedCommandLookup("_RS24446d8435cd186efe8d61c5b1da7b00a11c959c")
|
|
local debug = false
|
|
local ClickTracks = "ClickMaster"
|
|
local CueTracks = "QsMaster"
|
|
|
|
|
|
-----// Zoom Variables //------------------------------
|
|
local Zoom2Amount = 100
|
|
local Zoom2Forceset = 1
|
|
local Zoom2Doupd = false
|
|
local Zoom2Centermode = -1-- 0=EditCursor,
|
|
|
|
-----------------------------------------------------------
|
|
|
|
|
|
-----// gmem Variables //------------------------------
|
|
local gmemSect = 'Realive_Gmem'
|
|
local gmem_idx_PlaylistState = 11
|
|
local gmem_idx_Management = 12
|
|
local gmem_idx_PlaylistState_Clean = 32
|
|
local gmem_idx_PlaylistCount_Reaper = 30
|
|
local gmem_idx_PlaylistCount_Realive = 31
|
|
local gmemPlaylist_SaveRequest = 1
|
|
local gmemPlaylist_SaveRefused = 2
|
|
local gmemPlaylist_Initialize = 3
|
|
local gmemPlaylist_RealiveListItem_Remove = 4
|
|
local gmemPlaylist_RealiveListItem_Add = 5
|
|
local gmemPlaylist_RealiveListItem_Update = 6
|
|
local gmemPlaylist_ProjectTabs_CleanStatus = 9
|
|
local gmem_idxRead_Mngmt = reaper.gmem_read(gmem_idx_Management)
|
|
|
|
|
|
|
|
-----------------------------------------------------------
|
|
-----// DEBUG FUNCTION //----------------------------------
|
|
-----------------------------------------------------------
|
|
if debug then reaper.ShowConsoleMsg("") end
|
|
function Msg(value)
|
|
if debug then
|
|
reaper.ShowConsoleMsg(tostring(value) .. "\n")
|
|
end
|
|
end
|
|
|
|
|
|
|
|
function getTrackByName(name)
|
|
reaper.Main_OnCommand(40297, 0) -- Unselect all tracks
|
|
local CountTrack = reaper.CountTracks( 0 )
|
|
if CountTrack == 0 then
|
|
return
|
|
end
|
|
|
|
if not name then name = "{$[(*)]*[}{(*)]$}" end
|
|
for i = 1,CountTrack do
|
|
local track_search = reaper.GetTrack( 0, i-1 )
|
|
local retval, buf = reaper.GetTrackName( track_search, "" )
|
|
if buf == name then
|
|
reaper.SetOnlyTrackSelected(track_search)
|
|
end
|
|
end
|
|
end
|
|
|
|
function UnMuteTrackByName(TrackToBeUnMuted)
|
|
reaper.Main_OnCommand(40297, 0) -- Unselect all tracks
|
|
local CountTrack = reaper.CountTracks( 0 )
|
|
if CountTrack == 0 then
|
|
return
|
|
end
|
|
|
|
if not TrackToBeUnMuted then TrackToBeUnMuted = "{$[(*)]*[}{(*)]$}" end
|
|
for i = 1,CountTrack do
|
|
local Track = reaper.GetTrack( 0, i-1 )
|
|
local retval, buf = reaper.GetTrackName( Track, "" )
|
|
if buf == TrackToBeUnMuted then
|
|
reaper.SetMediaTrackInfo_Value(Track, "B_MUTE", 0)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------
|
|
-----// OPEN File FUNCTION //-------------------------------
|
|
-----------------------------------------------------------
|
|
function OpenFile()
|
|
|
|
local lastProjPath = reaper.GetExtState('Realive_Projects', 'last_opened_proj')
|
|
local curProjPath_retval, curProjPath = reaper.EnumProjects(-1, '' )
|
|
if curProjPath ~= '' then
|
|
projPath = curProjPath
|
|
else
|
|
projPath = lastProjPath
|
|
end
|
|
|
|
local r, fn = reaper.JS_Dialog_BrowseForOpenFiles('Open RPP', ('/'..projPath), '', 'Reaper files (.RPP)\0*.RPP;*.rpp-bak\0\0', false)
|
|
Msg('r: '..r)
|
|
|
|
if r == 1 then
|
|
reaper.Main_openProject(fn)
|
|
reaper.SetExtState('Realive_Projects', 'last_opened_proj', tostring(fn), true)
|
|
else
|
|
return
|
|
end
|
|
return r
|
|
end
|
|
-----------------------------------------------------------
|
|
-----------------------------------------------------------
|
|
|
|
|
|
function ScreensetSetUp()
|
|
reaper.Main_OnCommand(PlayView_cmdID, 0) --Load Play View Window Set
|
|
reaper.SetCursorContext(1) --Focus Arrange Window
|
|
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_HIDEMASTER"), 0) --Hide Master Track in TCP
|
|
getTrackByName("Structure")
|
|
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_VZOOMFIT_NO_ENV"), 0) --Vertical Zoom to Selected tracks
|
|
if reaper.GetToggleCommandState(40390) == 0 then reaper.Main_OnCommand(40390, 0) end -- Enable Smooth Seek
|
|
reaper.Main_OnCommand(40340, 0) --Unsolo all tracks
|
|
reaper.Main_OnCommand(40769, 0) --Unselect all everything
|
|
reaper.Main_OnCommand(40635, 0) --Remove Time Selection
|
|
--reaper.Main_OnCommand(reaper.NamedCommandLookup("_XENAKIOS_TVPAGEHOME"), 0) --Scroll Track View To Home
|
|
reaper.Main_OnCommand(40923, 0) --Grid Set To Measure
|
|
reaper.Main_OnCommand(40754, 0) --Snapping Enable Snap
|
|
if reaper.GetToggleCommandState(40145) == 0 then reaper.Main_OnCommand(40145, 0) end --Enable Gridlines
|
|
if reaper.GetToggleCommandState(42328) == 0 then reaper.Main_OnCommand(42328, 0) end -- Enable Marker And Region Gridlines
|
|
reaper.Main_OnCommand(40634, 0) -- Remove Loop Points Time Selection
|
|
reaper.SNM_SetIntConfigVar('playcursormode', 15)
|
|
reaper.SetExtState('Realive', 'currentView', 'live', false)
|
|
reaper.SetExtState('Realive', 'CursorChasing', 'Enabled', false)
|
|
|
|
reaper.Main_OnCommand(41746,0) --Disable Metronome
|
|
reaper.Main_OnCommand(repeatScriptState_Disable, 0) --Repeat State Disable
|
|
UnMuteTrackByName(CueTracks)
|
|
UnMuteTrackByName(ClickTracks)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------
|
|
---------// RUN FUNCTION //--------------
|
|
------------------------------------------
|
|
function run()
|
|
-- reaper.Main_OnCommand(40025, 0) -- Open New Project
|
|
if OpenFile() == 1 then
|
|
reaper.gmem_write(gmem_idx_Management, gmemPlaylist_RealiveListItem_Update)
|
|
ScreensetSetUp()
|
|
reaper.adjustZoom(Zoom2Amount, Zoom2Forceset, Zoom2Doupd, Zoom2Centermode)
|
|
reaper.SetEditCurPos(0, true, true)
|
|
end
|
|
end
|
|
|
|
------------------------------------------
|
|
---------// RUNTIME //-------------------
|
|
------------------------------------------
|
|
reaper.gmem_attach(gmemSect)
|
|
run() |