generated from cfillion/reapack-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create smandrap_Apply x db to send y on selected tracks.lua
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Various/smandrap_Apply x db to send y on selected tracks.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- @description Apply x db to send y on selected tracks | ||
-- @author smandrap | ||
-- @version 1.0 | ||
-- @donation https://paypal.me/smandrap | ||
-- @about | ||
-- Bassman002 request. https://forum.cockos.com/showthread.php?p=2718351#post2718351 | ||
-- | ||
-- Db to value (and viceversa) functions are taken from the forums. Can't remember where sorry. | ||
-- If someone can point it out, i will give credit. | ||
-- | ||
-- Usage: | ||
-- Duplicate the script and change DB_AMOUNT and SEND_IDX to taste. | ||
-- | ||
-- Known issues: | ||
-- Undo doesn't work correctly | ||
|
||
--------------------- | ||
|
||
-- CHANGE THESE: | ||
|
||
local DB_AMOUNT = -1 | ||
local SEND_IDX = 1 -- Target send, 1 based | ||
|
||
|
||
--------------------- | ||
|
||
|
||
local LN10_OVER_TWENTY = 0.11512925464970228420089957273422 | ||
local TWENTY_OVER_LN10 = 8.6858896380650365530225783783321 | ||
local MINUS_INFINITY_TRESHOLD = 0.0000000298023223876953125 | ||
|
||
local function DbToValue(db) return math.exp(db * LN10_OVER_TWENTY) end | ||
|
||
local function ValueToDb(value) | ||
if value < MINUS_INFINITY_TRESHOLD then return -150 end | ||
return math.max(-150, math.log(value) * TWENTY_OVER_LN10) | ||
end | ||
|
||
local function main() | ||
local sel_tr_cnt = reaper.CountSelectedTracks() | ||
if sel_tr_cnt == 0 then return end | ||
|
||
for i = 0, sel_tr_cnt - 1 do | ||
local tr = reaper.GetSelectedTrack(0, i) | ||
local send_vol = reaper.GetTrackSendInfo_Value(tr, 0, SEND_IDX - 1, 'D_VOL') | ||
local new_vol = DbToValue(ValueToDb(send_vol) + DB_AMOUNT) | ||
|
||
reaper.SetTrackSendInfo_Value(tr, 0, SEND_IDX - 1, 'D_VOL', new_vol) | ||
end | ||
end | ||
|
||
reaper.Undo_BeginBlock() | ||
main() | ||
reaper.Undo_EndBlock("Apply "..DB_AMOUNT.." db to Send "..SEND_IDX.." on selected tracks", -1) |