Skip to content

Commit

Permalink
Add panning based on track name
Browse files Browse the repository at this point in the history
  • Loading branch information
chmaha committed Feb 13, 2025
1 parent 01cb239 commit b03e0a8
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion ReaClassical/ReaClassical_Auto Set Recording Inputs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If not, see <https://www.gnu.org/licenses/>.

for key in pairs(reaper) do _G[key] = reaper[key] end

local main, trim_prefix, assign_input, create_mixer_table
local main, trim_prefix, assign_input, create_mixer_table, set_pan

local pair_words = {
"2ch", "pair", "paire", "paar", "coppia", "par", "пара", "", "ペア",
Expand All @@ -33,6 +33,16 @@ local pair_words = {
"สเตอริโอ", "âm thanh nổi"
}

local left_words = {
"l", "left", "gauche", "sinistra", "izquierda", "esquerda", "ліворуч", "слева", "vlevo", "balra", "vänster",
"vasakule", "venstre", "vänstra", "levý", "левый", "lijevo", "stânga", "sol", "kushoto", "ซ้าย", "बाएँ", "बायां"
}

local right_words = {
"r", "right", "droite", "destra", "derecha", "direita", "праворуч", "справа", "vpravo", "jobbra", "höger",
"paremale", "høyre", "högra", "pravý", "правый", "desno", "dreapta", "sağ", "kulia", "ขวา", "दाएँ", "दायां"
}

---------------------------------------------------------------------
local MAX_INPUTS = GetNumAudioInputs() -- Retrieve hardware inputs

Expand Down Expand Up @@ -81,6 +91,8 @@ function main()

local input_track = GetTrack(0, track_index - 1)

set_pan(mixer_track, mixer_trackname)

if input_channel < MAX_INPUTS then
local new_input_channel = assign_input(input_track, is_pair, input_channel)
if new_input_channel then
Expand Down Expand Up @@ -128,6 +140,7 @@ function main()
for i, track in ipairs(previous_inputs) do
local revert_track = GetTrack(0, i - 1)
SetMediaTrackInfo_Value(revert_track, "I_RECINPUT", track)
SetMediaTrackInfo_Value(track, "D_PAN", 0)
end
end
end
Expand Down Expand Up @@ -175,4 +188,22 @@ end

---------------------------------------------------------------------

function set_pan(track, name)
local lower_name = name:lower()
for _, word in ipairs(left_words) do
if lower_name:match("%s" .. word .. "$") then
SetMediaTrackInfo_Value(track, "D_PAN", -1.0) -- 100% Left
return
end
end
for _, word in ipairs(right_words) do
if lower_name:match("%s" .. word .. "$") then
SetMediaTrackInfo_Value(track, "D_PAN", 1.0) -- 100% Right
return
end
end
end

---------------------------------------------------------------------

main()

0 comments on commit b03e0a8

Please sign in to comment.