Quote:
Originally Posted by Arranger
Hi, A newbie to scripting here.
I took a look at the api but I can't find exactly what I need so I thought I would ask before I spend to much time maybe for nothing.
I would like to bypass an fx which is on a track which I would determine by its name or its position but not by being selected...
|
Hi, here's how to find a track by name:
Code:
function get_track_by_name(track_name_str)
local tr_count = reaper.CountTracks(0)
if tr_count == 0 then
return
end
local tr_found = false
for i = 1, tr_count - 1 do
local tr = reaper.GetTrack(0, i-1)
if tr then
local ret, current_tr_name = reaper.GetSetMediaTrackInfo_String(tr, "P_NAME", "", false)
if ret then
-- 1. exact match:
--if current_tr_name == track_name_str then
-- 2. if "track_name_str" in track name (case sensitive):
--if current_tr_name:find(track_name_str) then
-- 3. if "track_name_str" in track name (case insensitive)
if current_tr_name:lower():find(track_name_str:lower()) then
reaper.ShowConsoleMsg(track_name_str .. "-track found. Track number: " .. i .. ")\n")
tr_found = true
break
end
end
end
end
if not tr_found then
reaper.ShowConsoleMsg("Couldn't find " .. track_name_str .. "\n" )
end
end
get_track_by_name("BASS")