Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Set render matrix by comparing track names and region names with subfolder v1.0 #1486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
-- @description Set render matrix by comparing track names and region names with subfolder
-- @author Edson Del Santoro
-- @version 1.0
-- @about -- This is a modified version of Mordi's script, that will compare all region names to track names. When it finds a match, it will edit the region render matrix to render that region through that track and subfolder tracks. This makes my workflow of setting 30+ tracks and subfolder tracks to their corresponding regions much much easier.



SCRIPT_NAME = "Set render matrix by comparing track names and region names with subfolder"

reaper.ClearConsole()

function Msg(variable)
reaper.ShowConsoleMsg(tostring(variable).."\n")
end

-- Begin undo-block
reaper.Undo_BeginBlock2(0)

-- Get number of regions
retval, num_markers, num_regions = reaper.CountProjectMarkers(0)

-- Get number of tracks
num_tracks = reaper.CountTracks(0)

-- Loop through all markers and regions
for i = 0, num_regions+num_markers-1 do
retval, isrgn, pos, rgnend, rgnName, rgnIndex = reaper.EnumProjectMarkers(i)

-- Check if this marker is a region
if isrgn then

-- Loop through all tracks
for n=0, num_tracks-1 do

-- Get track
track = reaper.GetTrack(0, n)

-- Get name of track
retval, trackName = reaper.GetTrackName(track, "")

-- Get folder depth of track
folderDepth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")

-- Check if names match
if rgnName == trackName and folderDepth == 1 then

-- Tick the corresponding box in the region render matrix
reaper.SetRegionRenderMatrix(0, rgnIndex, track, 1)
end

end
end
end

-- Initialize array for storing list of regions which are not ticked for rendering
deadRegions = {}
deadRegionsIndex = 0

-- Loop through all markers and regions
for i = 0, num_regions+num_markers-1 do
retval, isrgn, pos, rgnend, rgnName, rgnIndex = reaper.EnumProjectMarkers(i)

-- Check if this marker is a region
if isrgn then

-- Get first track which this region will be rendering through (if any)
track = reaper.EnumRegionRenderMatrix(0, rgnIndex, 0)

-- If no track was found...
if track == nil then

-- Format position to hh:mm:ss
time = reaper.format_timestr(pos, "")

-- Add name of region to array
deadRegions[deadRegionsIndex] = rgnIndex .. " - " .. rgnName .. " (" .. time .. ")"
deadRegionsIndex = deadRegionsIndex + 1

end
end
end

-- Show a message if any regions will not be rendered
if deadRegionsIndex > 0 then

str = deadRegionsIndex .. " region(s) have not been tagged for rendering:"

-- Max number of regions to display in message
maxRegionsInList = 10

-- Loop through dead regions array
for i = 0, deadRegionsIndex-1 do

-- Check if number of regions listed are over the maximum
if i >= maxRegionsInList then
str = str .. "\n" .. "...and " .. (deadRegionsIndex - maxRegionsInList) .. " more."
break
else
str = str .. "\n" .. deadRegions[i]
end
end

reaper.ShowMessageBox(str, "Set render matrix by comparing track names and region names", 0)

end

-- End undo-block
reaper.Undo_EndBlock2(0,SCRIPT_NAME,-1)
Loading