-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotherboard_def.lua
319 lines (280 loc) · 9.13 KB
/
motherboard_def.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
format_version = "1.0"
local maxArraySize = 256
local maxArrayValue = 512
local propArrayStartTag = 2000
local rtOwnerProperties = {}
for i = 1, maxArraySize do
rtOwnerProperties["prop_array_" .. i] = jbox.number {
property_tag = propArrayStartTag + i,
default = 0,
steps = maxArrayValue,
ui_name = jbox.ui_text("propertyname prop_array_" .. i),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
end
rtOwnerProperties["prop_array_start"] = jbox.number {
property_tag = 3000,
steps = maxArraySize,
default = 0,
ui_name = jbox.ui_text("propertyname prop_array_start"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
rtOwnerProperties["prop_array_size"] = jbox.number {
property_tag = 3001,
steps = maxArraySize + 1,
default = maxArraySize,
ui_name = jbox.ui_text("propertyname prop_array_size"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- to display the line for soft clipping
rtOwnerProperties["prop_soft_clipping_level_display"] = jbox.number {
steps = maxArrayValue,
default = 0,
ui_name = jbox.ui_text("propertyname prop_soft_clipping_level_display"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- to display the max level in window 1
rtOwnerProperties["prop_max_level_window_1_value"] = jbox.number {
default = 0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_1_value"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- state of prop_max_level_window_1 0 = ok, 1 = soft clipping, 2 = hard clipping
rtOwnerProperties["prop_max_level_window_1_state"] = jbox.number {
default = 0,
steps = 3,
ui_name = jbox.ui_text("propertyname prop_max_level_window_1_state"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- to display the max level in window 2
rtOwnerProperties["prop_max_level_window_2_value"] = jbox.number {
default = 0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_2_value"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- state of prop_max_level_window_2 0 = ok, 1 = soft clipping, 2 = hard clipping
rtOwnerProperties["prop_max_level_window_2_state"] = jbox.number {
default = 0,
steps = 3,
ui_name = jbox.ui_text("propertyname prop_max_level_window_2_state"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- to display the max level in window 3
rtOwnerProperties["prop_max_level_window_3_value"] = jbox.number {
default = 0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_3_value"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- state of prop_max_level_window_3 0 = ok, 1 = soft clipping, 2 = hard clipping
rtOwnerProperties["prop_max_level_window_3_state"] = jbox.number {
default = 0,
steps = 3,
ui_name = jbox.ui_text("propertyname prop_max_level_window_3_state"),
ui_type = jbox.ui_linear { min = 0.0, max = 1.0 }
}
-- represents the total volume (accounts for volume 1 and volume 2)
rtOwnerProperties["prop_total_volume"] = jbox.number {
default = 0.49,
ui_name = jbox.ui_text("propertyname prop_total_volume"),
ui_type = jbox.ui_nonlinear{
-- convert data range 0-1 to dB value using an x^3 curve. 0.49 is 0dB (2 volumes multiplied!).
data_to_gui = function(data_value)
local gain = math.pow(data_value / 0.49, 3)
local ui_value = 20 * math.log10(gain)
return ui_value
end,
-- convert UI dB value to data range 0-1
gui_to_data = function(gui_value)
local data_value = math.pow(math.pow(10, gui_value / 20), 1/3) * 0.49
return data_value
end,
units = {
{min_value=0, unit = {template=jbox.ui_text("ui_type template prop_total_volume"), base=1}, decimals=2},
},
}
}
local softClippingLevelA = 0.1
local softClippingLevelB = -24
local documentOwnerProperties = {
prop_zoom_level = jbox.number {
property_tag = 3002,
steps = 126,
default = 75,
ui_name = jbox.ui_text("propertyname prop_zoom_level"),
ui_type = jbox.ui_linear {
min = 5.0, max = 30.0,
units = {
{min_value=0, unit = {template=jbox.ui_text("ui_type template prop_zoom_level"), base=1}, decimals=1},
},
}
},
prop_soft_clipping_level = jbox.number {
property_tag = 3003,
steps = 241,
default = 180,
ui_name = jbox.ui_text("propertyname prop_soft_clipping_level"),
ui_type = jbox.ui_nonlinear{
-- convert to db
data_to_gui = function(data_value)
return (softClippingLevelA * data_value) + softClippingLevelB
end,
-- convert from db
gui_to_data = function(gui_value)
return (gui_value - softClippingLevelB) / softClippingLevelA
end,
units = {
{min_value=0, unit = {template=jbox.ui_text("ui_type template prop_volume"), base=1}, decimals=2},
},
}
},
-- window 1
prop_max_level_window_1_size = jbox.number {
property_tag = 3004,
steps = 257,
default = 10.0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_1_size"),
ui_type = jbox.ui_linear { min = 0.0, max = 256.0 }
},
-- window 2
prop_max_level_window_2_size = jbox.number {
property_tag = 3006,
steps = 257,
default = 50.0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_2_size"),
ui_type = jbox.ui_linear { min = 0.0, max = 256.0 }
},
-- window 3
prop_max_level_window_3_size = jbox.number {
property_tag = 3008,
steps = 257,
default = 256.0,
ui_name = jbox.ui_text("propertyname prop_max_level_window_3_size"),
ui_type = jbox.ui_linear { min = 0.0, max = 256.0 }
},
-- 0 means off (no hud)
prop_lcd_hud_alpha = jbox.number {
steps = 256,
default = 200.0,
ui_name = jbox.ui_text("propertyname prop_lcd_hud_alpha"),
ui_type = jbox.ui_percent()
},
}
for i = 1, 2 do
-- number, nonlinear decibel:
documentOwnerProperties["prop_volume_" .. i] = jbox.number{
property_tag = 3009 + i,
default = 0.7,
ui_name = jbox.ui_text("propertyname prop_volume_" .. i),
ui_type = jbox.ui_nonlinear{
-- convert data range 0-1 to dB value using an x^3 curve. Data value 0.7 is 0 dB.
data_to_gui = function(data_value)
local gain = math.pow(data_value / 0.7, 3)
local ui_value = 20 * math.log10(gain)
return ui_value
end,
-- convert UI dB value to data range 0-1
gui_to_data = function(gui_value)
local data_value = math.pow(math.pow(10, gui_value / 20), 1/3) * 0.7
return data_value
end,
units = {
{min_value=0, unit = {template=jbox.ui_text("ui_type template prop_volume"), base=1}, decimals=2},
},
}
}
end
--[[
Custom properties
--]]
custom_properties = jbox.property_set {
document_owner = {
properties = documentOwnerProperties
},
rtc_owner = {
properties = {
instance = jbox.native_object{ },
}
},
rt_owner = {
properties = rtOwnerProperties
}
}
--[[
Inputs/Outputs
--]]
audio_outputs = {
audioOutputLeft = jbox.audio_output {
ui_name = jbox.ui_text("audio output main left")
},
audioOutputRight = jbox.audio_output {
ui_name = jbox.ui_text("audio output main right")
}
}
audio_inputs = {
audioInputLeft = jbox.audio_input {
ui_name = jbox.ui_text("audio input main left")
},
audioInputRight = jbox.audio_input {
ui_name = jbox.ui_text("audio input main right")
}
}
-- defines routing pairs for stereo (Reason will wire left and right automatically)
jbox.add_stereo_audio_routing_pair {
left = "/audio_outputs/audioOutputLeft",
right = "/audio_outputs/audioOutputRight"
}
jbox.add_stereo_audio_routing_pair {
left = "/audio_inputs/audioInputLeft",
right = "/audio_inputs/audioInputRight"
}
-- The 45 should be routed as a stereo instrument
jbox.add_stereo_effect_routing_hint{
type = "true_stereo",
left_input = "/audio_inputs/audioInputLeft",
right_input = "/audio_inputs/audioInputRight",
left_output = "/audio_outputs/audioOutputLeft",
right_output = "/audio_outputs/audioOutputRight"
}
-- Sockets on the back panel of the 45 that the host can auto-route to
jbox.add_stereo_audio_routing_target{
signal_type = "normal",
left = "/audio_outputs/audioOutputLeft",
right = "/audio_outputs/audioOutputRight",
auto_route_enable = true
}
jbox.add_stereo_audio_routing_target{
signal_type = "normal",
left = "/audio_inputs/audioInputLeft",
right = "/audio_inputs/audioInputRight",
auto_route_enable = true
}
-- handle no license case
jbox.set_effect_auto_bypass_routing {
{
"/audio_inputs/audioInputLeft",
"/audio_outputs/audioOutputLeft"
},
{
"/audio_inputs/audioInputRight",
"/audio_outputs/audioOutputRight"
}
}
-- allow for automation
midi_implementation_chart = {
midi_cc_chart = {
[12] = "/custom_properties/prop_volume_1",
[13] = "/custom_properties/prop_volume_2",
}
}
remote_implementation_chart = {
["/custom_properties/prop_volume_1"] = {
internal_name = "Volume 1",
short_ui_name = jbox.ui_text("short property name remote prop_volume_1"),
shortest_ui_name = jbox.ui_text("shortest property name remote prop_volume_1")
},
["/custom_properties/prop_volume_2"] = {
internal_name = "Volume 2",
short_ui_name = jbox.ui_text("short property name remote prop_volume_2"),
shortest_ui_name = jbox.ui_text("shortest property name remote prop_volume_2")
},
}