--[[
Reset Volume & Pan on Selected Tracks
-------------------------------------
This ReaScript (Lua) will set the volume of every selected track to 1.0
(0 dB) and reset its pan to 0.0 (center).
It runs inside REAPER, so you can save it as a *.lua file or paste it into
the built‑in ReaScript editor.
Usage:
1. Select one or more tracks in the track list.
2. Run this script from Actions → Show action list → ReaScripts.
3. All selected tracks will be reset to normal volume and centered pan.
Note: The script wraps changes in a single Undo block, so you can undo
everything with one step (Ctrl+Z / Cmd+Z).
--]]
-- Helper function to set track properties safely
local function resetTrackProperties(track)
-- Volume: "D_VOL" accepts linear value (1.0 = 0 dB)
reaper.SetMediaTrackInfo_Value(track, "D_VOL", 1.0)
-- Pan: "C_PAN" expects a value from -1.0 (left) to +1.0 (right). 0 is center.
reaper.SetMediaTrackInfo_Value(track, "D_PAN", 0.0)
end
-- Main routine
local function main()
local selectedCount = reaper.CountSelectedTracks(0) -- project index 0 means current project
if selectedCount == 0 then
reaper.ShowMessageBox("No tracks are selected.", "Reset Volume & Pan", 0)
return
end
-- Start an undo block so the user can revert all changes at once
reaper.Undo_BeginBlock()
for i = 0, selectedCount - 1 do
local tr = reaper.GetSelectedTrack(0, i)
if tr then
resetTrackProperties(tr)
end
end
-- Update the UI to show changes immediately
reaper.UpdateArrange()
reaper.Undo_EndBlock("Reset Volume & Pan on selected tracks", -1)
end
-- Execute
main()