Last active
April 25, 2024 09:14
-
-
Save oiwn/c1abaf849fdc7b64ed2dd864f7ae25a0 to your computer and use it in GitHub Desktop.
Reaper DAW lua script to cycle through track names (now with support of all selected tracks!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Define the list of names to cycle through | |
local trackNames = {"Drums", "Kick", "Hat", "Snare"} | |
-- Function to get the next name for the track | |
function getNextName(currentName) | |
for i, name in ipairs(trackNames) do | |
if name == currentName then | |
return trackNames[(i % #trackNames) + 1], (i % #trackNames) + 1 | |
end | |
end | |
return trackNames[1], 1 | |
end | |
-- Number of selected tracks | |
local numSelectedTracks = reaper.CountSelectedTracks(0) | |
if numSelectedTracks > 0 then | |
local firstTrack = reaper.GetSelectedTrack(0, 0) | |
_, currentName = reaper.GetSetMediaTrackInfo_String(firstTrack, "P_NAME", "", false) | |
local nextName, nextPosition = getNextName(currentName) | |
for i = 0, numSelectedTracks - 1 do | |
local track = reaper.GetSelectedTrack(0, i) | |
if track then | |
reaper.GetSetMediaTrackInfo_String(track, "P_NAME", nextName, true) | |
end | |
end | |
reaper.UpdateArrange() | |
else | |
reaper.ShowMessageBox("No tracks selected.", "Error", 0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment