/
TJF temp script.lua
46 lines (26 loc) · 1.05 KB
/
TJF temp script.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function GetInfo(i) -- builds and returns 2 tables
local info = {}
info.ID = reaper.GetSelectedMediaItem( 0, i)
info.length = reaper.GetMediaItemInfo_Value(info.ID, "D_LENGTH")
return info
end -- end of function
function Main()
local items = {}
local itemcount = reaper.CountSelectedMediaItems()
if itemcount > 0 then
for i=1, itemcount do
local info = {}
info.ID = reaper.GetSelectedMediaItem( 0, i-1) -- since selected items starts at 0, we adjust here
info.length = reaper.GetMediaItemInfo_Value(info.ID, "D_LENGTH")
table.insert(items, info)
--items[i] = info <-- could also fill the table this way... you are filling the table entry
end
end
if #items > 0 then
for i = 1, #items do -- this loop starts at 1
reaper.SetMediaItemInfo_Value(items[i].ID, "D_FADEOUTLEN", (items[i].length/2))
end
end
end
Main()
reaper.UpdateArrange()