local FXNAME = 'utility/volume_pan_sample_accurate_auto';
local PARAM = 0;
--[-------------------------------------------------------------
local fxfloat = reaper.SNM_GetIntConfigVar('fxfloat_focus',0);
if fxfloat&4 == 4 then;
local fxfloat2 = fxfloat&~(fxfloat&4);
reaper.SNM_SetIntConfigVar('fxfloat_focus',fxfloat2);
reaper.defer(function()reaper.SNM_SetIntConfigVar('fxfloat_focus',fxfloat)end);
end;
--]]-------------------------------------------------------------
local CountSelTrack = reaper.CountSelectedTracks(0);
if CountSelTrack > 0 then;
----
reaper.PreventUIRefresh(1);
reaper.Undo_BeginBlock();
----
for i = 1,CountSelTrack do;
local SelTrack = reaper.GetSelectedTrack(0,i-1);
local vol = reaper.GetMediaTrackInfo_Value(SelTrack,'D_VOL');
if vol ~= 1 then
local FX = reaper.TrackFX_AddByName(SelTrack,FXNAME,false,1);
if FX > -1 then;
local DB = 20*math.log(vol,10);
local retval,minval,maxval = reaper.TrackFX_GetParam(SelTrack,FX,PARAM);
local newVal = retval+DB;
reaper.TrackFX_SetParam(SelTrack,FX,PARAM,newVal);
reaper.SetMediaTrackInfo_Value(SelTrack,'D_VOL',1);
---
newVal = tonumber(string.format("%.1f",newVal))
xpos,ypos = reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip('Volume\n'..newVal,xpos+10,ypos-25,false)
---
end;
end;
end;
----
reaper.Undo_EndBlock("Set vol",-1);
reaper.PreventUIRefresh(-1);
----
else;
reaper.defer(function()end);
end;