Skip to content

Commit

Permalink
Release Apply track volume to Items v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Neftovsky committed Feb 3, 2025
1 parent 07e6b3f commit bd52630
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Items Properties/neftovsky_Apply track volume to Items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- @description Apply track volume to Items
-- @author Neftovsky
-- @version 1.0
-- @about
-- Apply track volume to Items
--
-- Applies selected track volume to its items (takes) and resets track fader to 0 dB.
-- Compensates item volume (Pre-FX) based on track fader volume.
--
-- Usage:
-- 1. Select tracks.
-- 2. Run the script.
-- 3. Track volume resets to 0 dB, item volumes adjust accordingly.

local selected_track_count = reaper.CountSelectedTracks(0)

if selected_track_count > 0 then
for t = 0, selected_track_count - 1 do
local track = reaper.GetSelectedTrack(0, t)

if track then
local track_volume = reaper.GetMediaTrackInfo_Value(track, "D_VOL")

local item_count = reaper.CountTrackMediaItems(track)
for i = 0, item_count - 1 do
local item = reaper.GetTrackMediaItem(track, i)
if item then
local take = reaper.GetActiveTake(item)
if take then
local item_vol = reaper.GetMediaItemTakeInfo_Value(take, "D_VOL")
local compensated_vol = item_vol * track_volume
reaper.SetMediaItemTakeInfo_Value(take, "D_VOL", compensated_vol)
end
end
end

reaper.SetMediaTrackInfo_Value(track, "D_VOL", 1.0)
end
end
else
reaper.ShowMessageBox("No tracks selected!", "Error", 0)
end

reaper.UpdateArrange()

0 comments on commit bd52630

Please sign in to comment.