generated from cfillion/reapack-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add field for earliest item in changing items' volume linearly; Add s…
…cript for changing item's volume linearly with no inputs
- Loading branch information
1 parent
bc45efc
commit 2d033dd
Showing
3 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
Utilities/MB_Change selected items' volume linearly from earliest to latest item volumes.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,32 @@ | ||
-- @noindex | ||
|
||
reaper.Undo_BeginBlock() | ||
reaper.PreventUIRefresh(1) | ||
|
||
local num_selected_items, first_item, last_item, first_item_vol, last_item_vol, first_item_pos, last_item_pos, slope | ||
|
||
num_selected_items = reaper.CountSelectedMediaItems(0) | ||
|
||
if num_selected_items < 2 then return end | ||
|
||
first_item = reaper.GetSelectedMediaItem(0, 0) | ||
last_item = reaper.GetSelectedMediaItem(0, num_selected_items - 1) | ||
first_item_vol = reaper.GetMediaItemInfo_Value(first_item, "D_VOL") | ||
last_item_vol = reaper.GetMediaItemInfo_Value(last_item, "D_VOL") | ||
first_item_pos = reaper.GetMediaItemInfo_Value(first_item, "D_POSITION") | ||
last_item_pos = reaper.GetMediaItemInfo_Value(last_item, "D_POSITION") | ||
slope = (last_item_vol - first_item_vol) / (last_item_pos - first_item_pos) | ||
|
||
for i = 0, num_selected_items - 1 do | ||
local item, item_pos, new_vol | ||
|
||
item = reaper.GetSelectedMediaItem(0, i) | ||
item_pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION") | ||
new_vol = first_item_vol + slope * (item_pos - first_item_pos) | ||
|
||
reaper.SetMediaItemInfo_Value(item, "D_VOL", new_vol) | ||
end | ||
|
||
reaper.UpdateTimeline() | ||
reaper.PreventUIRefresh(-1) | ||
reaper.Undo_EndBlock("MB_Change selected items' volume linearly from earliest to latest item volumes", -1) |
5 changes: 3 additions & 2 deletions
5
...ties/MB_Select child (descendent) track(s) & deselect selected parent folder track(s).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