-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomColoring.lua
More file actions
111 lines (98 loc) · 2.57 KB
/
Copy pathcustomColoring.lua
File metadata and controls
111 lines (98 loc) · 2.57 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
reaper.Undo_BeginBlock()
local function hsv(hue, saturation, value)
local c = value * saturation
local x = c * (1 - math.abs((hue / 60) % 2 - 1))
local r, g, b = 0, 0, 0
if hue < 60 then
r, g, b = c, x, 0
elseif hue < 120 then
r, g, b = x, c, 0
elseif hue < 180 then
r, g, b = 0, c, x
elseif hue < 240 then
r, g, b = 0, x, c
elseif hue < 300 then
r, g, b = x, 0, c
else
r, g, b = c, 0, x
end
return reaper.ColorToNative(math.floor(255*(r + value - c)),
math.floor(255*(g + value - c)),
math.floor(255*(b + value - c)))
end
local track_color_indices = {
dru = 0,
per = 10,
iqa = 20,
efx = 40,
vox = 60,
voc = 60,
syn = 90,
pad = 110,
win = 140,
gui = 200,
bas = 230,
pia = 260,
key = 280,
vid = 320,
}
local default_color_indices = {
a = 5,
b = 15,
c = 25,
d = 35,
e = 45,
f = 55,
g = 65,
h = 75,
i = 85,
j = 95,
k = 105,
l = 115,
m = 125,
n = 135,
o = 145,
p = 155,
q = 165,
r = 175,
s = 185,
t = 195,
u = 205,
v = 215,
w = 225,
x = 235,
y = 245,
z = 255,
[" "] = 200
}
local last_color_index = {0,0,0}
local saturation = 0.45
local value = 0.8
local num_tracks = reaper.CountTracks()
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local status, track_name = reaper.GetTrackName(track)
if status then
local folder_depth1 = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local folder_depth2 = reaper.GetTrackDepth(track)
if folder_depth1 == 1 or folder_depth2 == 0 then
last_color_index = { track_color_indices[track_name:sub(1,3)],
saturation,
value }
if not last_color_index[1] then
last_color_index = { default_color_indices[track_name:sub(1,1)],
saturation,
value }
end
if not last_color_index[1] then
last_color_index = { 0, 0, 0.5 }
end
end
reaper.SetTrackColor(track, hsv(last_color_index[1],
last_color_index[2],
last_color_index[3]))
last_color_index[1] = (last_color_index[1]+3) % 360
last_color_index[3] = last_color_index[3]*0.97
end
end
reaper.Undo_EndBlock("Custom Coloring", 1)