From a828ca8dc0d031ded9f1fb885b31d1272dae8481 Mon Sep 17 00:00:00 2001 From: amagalma Date: Mon, 12 Feb 2024 16:46:21 +0200 Subject: [PATCH] Release Apply track fader volume to all items in selected tracks and reset faders to 0dB v1.0 (#1317) --- ...elected tracks and reset faders to 0dB.lua | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Items Properties/amagalma_Apply track fader volume to all items in selected tracks and reset faders to 0dB.lua diff --git a/Items Properties/amagalma_Apply track fader volume to all items in selected tracks and reset faders to 0dB.lua b/Items Properties/amagalma_Apply track fader volume to all items in selected tracks and reset faders to 0dB.lua new file mode 100644 index 000000000..f4adba7bf --- /dev/null +++ b/Items Properties/amagalma_Apply track fader volume to all items in selected tracks and reset faders to 0dB.lua @@ -0,0 +1,32 @@ +-- @description Apply track fader volume to all items in selected tracks and reset faders to 0dB +-- @author amagalma +-- @version 1.0 +-- @donation https://www.paypal.me/amagalma + +local sel_tracks = reaper.CountSelectedTracks( 0 ) + +if sel_tracks == 0 then + reaper.MB("No changes...", "No tracks selected!", 0 ) + reaper.defer(function() end) +end + +reaper.PreventUIRefresh( 1 ) +reaper.Undo_BeginBlock2( 0 ) + +for tr = 0, sel_tracks-1 do + local track = reaper.GetSelectedTrack( 0, tr ) + local tr_vol = reaper.GetMediaTrackInfo_Value( track, "D_VOL" ) + if tr_vol ~= 1 then + reaper.SetMediaTrackInfo_Value( track, "D_VOL", 1 ) + local item_cnt = reaper.CountTrackMediaItems( track ) + for it = 0, item_cnt-1 do + local item = reaper.GetTrackMediaItem( track, it ) + local it_vol = reaper.GetMediaItemInfo_Value( item, "D_VOL" ) + reaper.SetMediaItemInfo_Value( item, "D_VOL", it_vol*tr_vol ) + end + end +end + +reaper.PreventUIRefresh( -1 ) +reaper.UpdateArrange() +reaper.Undo_EndBlock2( 0, "Reset track faders to 0dB", 1|4 )