-
Notifications
You must be signed in to change notification settings - Fork 1
/
Globals.lua
95 lines (87 loc) · 2.18 KB
/
Globals.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function TRACE(...)
--print(...)
end
function LOG(...)
print(...)
end
function range(a, b, step)
if not b then
b = a
a = 1
end
step = step or 1
local f =
step > 0 and
function(_, lastvalue)
local nextvalue = lastvalue + step
if nextvalue <= b then return nextvalue end
end or
step < 0 and
function(_, lastvalue)
local nextvalue = lastvalue + step
if nextvalue >= b then return nextvalue end
end or
function(_, lastvalue) return lastvalue end
return f, nil, a - step
end
function format_for_display(text, max, justify)
if (text == nil) then
text = ""
end
if (justify == nil) then
justify = 0
end
if (#text == max) then
return text
elseif (#text > max) then
return text:sub(1, max)
elseif (#text < max) then
if (justify == 0) then
local fill = max - #text
local left = 1
local right = 1
while (fill > 0) do
if (fill > 0) then
right = right + 1
fill = fill - 1
end
if (fill > 0) then
left = left + 1
fill = fill - 1
end
end
return SPACES[left] .. text .. SPACES[right]
elseif (justify > 0) then
return text .. SPACES[(max - #text) + 1]
elseif (justify < 0) then
return SPACES[(max - #text) + 1] .. text
end
end
end
function get_master_track()
for i,v in pairs(renoise.song().tracks) do
if v.type == renoise.Track.TRACK_TYPE_MASTER then
return v
end
end
end
function get_master_track_index()
for i,v in pairs(renoise.song().tracks) do
if v.type == renoise.Track.TRACK_TYPE_MASTER then
return i
end
end
end
function send_track(send_index)
if (send_index <= renoise.song().send_track_count) then
-- send tracks are always behind the master track
local trk_idx = renoise.song().sequencer_track_count + 1 + send_index
return renoise.song():track(trk_idx)
else
return nil
end
end
function is_track_muted(track)
return track.mute_state == renoise.Track.MUTE_STATE_OFF
or track.mute_state == renoise.Track.MUTE_STATE_MUTED
end