This repository was archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMy Plugin Example.lua
More file actions
244 lines (218 loc) · 5.96 KB
/
My Plugin Example.lua
File metadata and controls
244 lines (218 loc) · 5.96 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
PluginInfo =
{
Name = "My Super Plugin v5.0",
Version = "5.0",
Id = "c2b08142-0435-48d8-b639-caad0cf9c0d4",
Description = "Plugin Example featuring the latest features in QSD 5.0",
ShowDebug = true
}
-- optional
function GetPrettyName(props)
return "My Super Plugin v5.0 with "..props["Input Count"].Value.." inputs"
end
function GetColor(props)
return { 240, 0, 240 }
end
function GetProperties()
props = {}
table.insert( props,
{
Name = "Input Count",
Type = "integer",
Min = 0,
Max = 128,
Value = 8,
})
for i = 1, 10 do
table.insert( props,
{
Name = string.format("Is really cool %i", i),
Type = "boolean",
Value = true,
});
end
return props
end
-- ControlType can be Button, Knob, Indicator or Text
-- ButtonType ( ControlType == Button ) can be Momentary, Toggle or Mute
-- IndicatorType ( ControlType == Indicator ) can be Led, Meter, Text or Status
-- ControlUnit ( ControlType == Knob ) can be Hz, Float, Integer, Pan, Percent, Position or Seconds
function GetControls(props)
return
{
{
Name = "inputgain", -- single word name chosen for simplicity in the runtime script
ControlType = "Knob",
ControlUnit = "dB",
Min = -6,
Max = 6,
Count = props["Input Count"].Value,
PinStyle = "Both",
UserPin = true -- UserPin allows pin choice to be added to the Control Pins section of the Properties
},
{
Name = "Mute",
ControlType = "Button",
ButtonType = "Toggle",
Count = 1,
PinStyle = "Output",
UserPin = false, -- No UserPin or UserPin=false with PinStyle means the pin is present with no option to remove it
},
}
end
function GetControlLayout(props)
-- make input gains
layout = {}
local i_count = props["Input Count"].Value
for i=1,i_count do
layout["inputgain"..tostring(i_count==1 and "" or " "..i)] = -- multiple controls are indexed with a space and the index
{
PrettyName = string.format("Input Gain~%i",i), -- The Tilde (~) creates a folder break for the Control Pin list
Style = "Fader",
Color = { 128, 255*(i-1)/i_count, 128 },
Position = { 10+32*(i-1), 115 },
Size = { 32, 128 },
IsReadOnly = i == 3,
ZOrder = 6 + i
}
end
layout["Mute"] =
{
Legend = "MUTE ME",
IsBold = true,
TextFontSize = 20,
Color = { 255, 0, 0 },
Margin = 0,
Radius = 0,
Position = { 10, 58 },
Size = { 32*i_count, 32 },
UnlinkOffColor = true,
OffColor = { 0, 255, 128 },
ZOrder = 5
}
graphics =
{
{
Type = "GroupBox",
Text = "A blue Groupbox for our control panel",
HTextAlign = "Left",
IsBold = true,
Fill = { 191, 226, 249 },
StrokeColor = { 0, 0, 0 },
StrokeWidth = 1,
CornerRadius = 8,
Position = { 0, 0 },
Size = { 20+32*i_count, 264 },
ZOrder = 1
},
{
Type = "Label",
Text = "Woohoo Label",
TextSize = 24,
IsBold = true,
Color = { 0, 255, 0 },
Fill = { 0, 123, 222 },
StrokeColor = { 255, 0, 255 },
StrokeWidth = 6,
CornerRadius = 15,
Position = { 10, 26 },
Size = { 32*i_count, 32 },
ZOrder = 2
},
{
Type = "Header",
Text = "Input Faders",
Position = { 10, 97 },
Size = { 32*i_count, 17 },
ZOrder = 3
},
}
if i_count>2 then
table.insert(graphics,
{
Type = "Label",
Text = "Disabled Control",
TextSize = 8,
Position = { 74, 243 },
Size = { 32, 21 },
ZOrder = 4
})
end
return layout, graphics
end
function GetPins(props)
local pins = {}
for i = 1,props["Input Count"].Value do
table.insert(pins,
{
Name = string.format("Input %i", i),
Direction = "input",
})
end
table.insert(pins,
{
Name = "Mix Output",
Direction = "output",
})
table.insert( pins, { Name = "sub in", Direction = "input"})
table.insert( pins, { Name = "sub out", Direction = "output"})
table.insert( pins, { Name = "a", Direction = "output"})
table.insert( pins, { Name = "c", Direction = "output"})
table.insert( pins, { Name = "b", Direction = "output"})
table.insert( pins, { Name = "input", Direction = "input", Domain = "serial" } )
return pins
end
function GetComponents(props)
return
{
{
Name = "main_mixer",
Type = "mixer",
Properties =
{
["n_inputs"] = props["Input Count"].Value, -- discover these property names using Named Component Lister
["n_outputs"] = 1, -- Only set the non-default values you need
}
}
}
end
function GetWiring(props)
local wiring = {}
for i = 1, props["Input Count"].Value do
table.insert( wiring, { string.format("Input %i", i), string.format("main_mixer Input %i", i) } )
end
table.insert( wiring, { "Mix Output", "main_mixer Output 1" } )
table.insert( wiring, { "sub in", "sub out" } )
return wiring
end
-- Controls only exist when plugin is actually running
-- we don't want to run this code during initialization
-- and property editing
if Controls then -- Start of runtime Lua code
local outputGain = main_mixer["output.1.gain"]
local outputMute = main_mixer["output.1.mute"]
-- set crosspoint gains to be 0
for i = 1,#Controls.inputgain do
main_mixer[string.format("input.%i.output.1.gain",i)].Value = 0
end
Controls.Mute.EventHandler= function( ctl )
print( "setting mute to ".. ctl.Value )
outputMute.Value = ctl.Value
if ser then
ser:Write(string.sub(data, idata, idata))
idata = idata + 1
if idata > #data then idata = 1 end
end
end
-- yet another worthless average function...
function av()
local sum = 0
for k,v in ipairs( Controls.inputgain ) do
sum = sum + v.Value
end
local average = sum / #Controls.inputgain
print("setting output to "..average)
outputGain.Value = average
end
for k,v in ipairs( Controls.inputgain ) do v.EventHandler = av end
end -- end of runtime Lua code