-
Notifications
You must be signed in to change notification settings - Fork 0
/
JL_toggle track height on all visible tracks in tcp.lua
76 lines (62 loc) · 2.23 KB
/
JL_toggle track height on all visible tracks in tcp.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-- Script functionality:
-- Toggles between two different heights for visible tracks in tcp.
-- It reads the all visible tracks height and if their height differs it sets all visible tracks to track_height_a.
-- If track heights match each other and match either track_height_a or track_height_b it toggles to the opposite track height.
-- USER CONFIG AREA -----------------------------------------------------------
-- Set Track Height A in pixels(default)
track_height_a = 116
-- Set Track Height B in pixels
track_height_b = 500
------------------------------------------------------- END OF USER CONFIG AREA
function CountVisibleTracks()
local trackSum = reaper.CountTracks(0)
visibleTrackTable = {}
visibleTrackIDTable = {}
for i = 1, trackSum do
local trackID = reaper.GetTrack(0, i - 1)
boolTest = reaper.IsTrackVisible(trackID, 0)
if (boolTest == true) then
table.insert(visibleTrackTable, i - 1)
table.insert(visibleTrackIDTable, trackID)
end
end
visibleTrackSum = #visibleTrackTable
end
function GetTrackHeight()
trackHeightTable = {}
for i = 1, visibleTrackSum do
trackHeight = reaper.GetMediaTrackInfo_Value(visibleTrackIDTable[i], "I_TCPH")
table.insert(trackHeightTable, trackHeight)
end
end
function TrackHeightMatch()
firstTrackHeight = trackHeightTable[1]
for i,v in ipairs(trackHeightTable) do
if (firstTrackHeight ~= v) then
trackHeightMatch = false
break
else
trackHeightMatch = true
end
end
end
function SetTrackHeight()
if (trackHeightMatch == true and firstTrackHeight == track_height_a) then
for i = 1, visibleTrackSum do
reaper.SetMediaTrackInfo_Value(visibleTrackIDTable[i], "I_HEIGHTOVERRIDE", track_height_b)
end
else
for i = 1, visibleTrackSum do
reaper.SetMediaTrackInfo_Value(visibleTrackIDTable[i], "I_HEIGHTOVERRIDE", track_height_a)
end
end
end
-- execute functions
CountVisibleTracks()
GetTrackHeight()
TrackHeightMatch()
SetTrackHeight()
-- update GUI
reaper.TrackList_AdjustWindows(0)
reaper.UpdateArrange()
reaper.UpdateTimeline()