-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgui.lua
More file actions
385 lines (332 loc) · 10.7 KB
/
gui.lua
File metadata and controls
385 lines (332 loc) · 10.7 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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
require"func"
require"crunch"
require"prefs"
vb = nil
WINDOW = nil
prefs = Prefs:new()
DEFAULT_MARGIN = renoise.ViewBuilder.DEFAULT_CONTROL_MARGIN
UNIT = renoise.ViewBuilder.DEFAULT_CONTROL_HEIGHT
function textfield(_text, _value, _notif)
return
end
function value_box(_text, _tip, _value, _min, _max, _steps, _notif, _tostring, _tonum, _width)
return vb:row {
vb:text {
text = _text.." "
},
vb:valuebox {
min = _min,
max = _max,
tostring = _tostring,
tonumber = _tonum,
notifier = _notif,
value = _value,
steps = _steps,
width = _width or UNIT*4,
tooltip = _tip
}
}
end
-- generic button matrix. Use this to create specific button matricies
function button_matrix(buttons, name, options, tooltip, callback)
local row = vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
mode = "distribute",
spacing = 1
}
-- callback is the is the callback the notifier should run
local notifier = function(button, name, callback)
-- do GUI work
toggle_button(button, name)
-- run callback
if callback then
print("Running callback for button matrix:", name)
callback()
end
end
for button = 0,#buttons do
local button = vb:button {
id = name.."_button_"..tostring(button),
text = buttons[button],
width = UNIT*1.5,
height = UNIT*1.5,
color = options[button] and C_PRESSED or C_NOT_PRESSED,
notifier = function(x) notifier(button, name, callback) end,
tooltip = tooltip
}
row:add_child(button)
end
return row
end
function note_matrix()
local tooltip = "Select notes that will be sampled in each octave."
return button_matrix(NOTES, "notes", OPTIONS.notes, tooltip)
end
function tag_matrix()
local tooltip = "Select tags to include in instrument name"
local callback = function () update_instrument_name() end
return button_matrix(TAGS, "tags", OPTIONS.tags, tooltip, callback)
end
function midi_list()
print("midi_device_index: ", STATE.midi_device_index)
if STATE.midi_device_index > #renoise.Midi.available_output_devices() then
reset_midi_device_state()
end
return vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
spacing = 1,
mode = "distribute",
vb:text {
width = "10%",
text = "Device"
},
vb:popup {
width = "50%",
items = renoise.Midi.available_output_devices(),
value = STATE.midi_device_index,
notifier = function(x)
select_midi_device(x)
end,
tooltip = "MIDI device to send MIDI signals to."
},
vb:text {
width = "15%",
text = "Channel"
},
vb:popup {
width = "15%",
value = 1,
items = {"1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15", "16"},
notifier = select_midi_channel,
tooltip = "Which MIDI channel to send signals over."
}
}
end
function show_menu()
vb = renoise.ViewBuilder()
local title = "Create Instrument From Hardware"
local content = vb:column {
margin = DEFAULT_MARGIN*2,
width = UNIT*24,
spacing = UNIT/2,
-- instrument naming
vb:column {
style = "panel",
margin = DEFAULT_MARGIN,
width = "100%",
vb:text {
text = "Name",
align = "center",
width = "100%"
},
vb:space {
height = UNIT/3
},
-- name
vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
vb:text {
text = "Instrument name ",
width = "25%"
},
vb:textfield {
id = "instrument_name_textfield",
value = OPTIONS.name,
notifier = function() update_instrument_name() end,
width = "50%",
tooltip = "Instrument name to set when sampling is over."
},
vb:button {
text = "Auto-Name",
notifier = autoname,
width = "25%",
tooltip = "Generate a random instrument name"
}
},
vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
vb:text {
text = "Hardware name ",
width = "25%"
},
vb:textfield {
id = "hardware_name_textfield",
value = OPTIONS.hardware_name,
notifier = function(x) update_instrument_name() end,
width = "50%",
tooltip = "Append the hardware device's name to further identify."
}
},
vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
vb:text {
text = "Tags:",
width = "25%"
}
},
-- produces the tag buttons
tag_matrix()
},
-- midi options
vb:column {
style = "panel",
margin = DEFAULT_MARGIN,
vb:text {
text = "Midi and note options",
align = "center",
width = "100%"
},
vb:space {
height = UNIT/3
},
-- midi device selection
midi_list(),
-- octave options
vb:horizontal_aligner {
mode = "center",
spacing = DEFAULT_MARGIN,
value_box("Low Octave", "The lowest octave from which to sample.", OPTIONS.low, 0, 9, {1, 2}, function(x) OPTIONS.low = x end, tostring, math.floor),
value_box("High Octave", "The highest octave from which to sample.", OPTIONS.high, 0, 9, {1, 2}, function(x) OPTIONS.high = x end, tostring, math.floor),
value_box("Vel. Layers", "How many different equally spaced velocities to sample for a given note.", OPTIONS.layers, 1, 32, {1, 2}, function(x) OPTIONS.layers = x end, tostring, math.floor),
value_box("R.R. Layers", "For each mapping, record this many samples and apply round robin selection to them.", OPTIONS.rrobin, 1, 32, {1, 2}, function(x) OPTIONS.rrobin = x end, tostring, math.floor)
},
-- notes selection
note_matrix(),
-- mapping style
vb:horizontal_aligner {
margin = DEFAULT_MARGIN,
spacing = DEFAULT_MARGIN,
vb:text {
text = "Mapping style:"
},
vb:switch {
width = "80%",
items = {"Down", "Middle", "Up"},
value = OPTIONS.mapping,
notifier = function(x) OPTIONS.mapping = x end,
tooltip = "How samples are mapped to keys.\n"..
"\nDown: Sampled notes will be mapped to their root note and to notes between the root and the next lowest sample.\n"..
"\nMiddle: Given a key, it will be mapped to the closest existing sample.\n"..
"\nUp: Sampled notes will be mapped to their root note and to notes between the root and the next highest sample."
}
},
-- sample length
vb:horizontal_aligner {
mode = "center",
spacing = DEFAULT_MARGIN,
value_box("Hold time", "How long the note on signal will be held.", OPTIONS.length, 0.1, 60, {0.1, 1}, function(x) OPTIONS.length = x end, function(x) return tostring(x).." s." end, tonumber),
value_box("Release time", "How long the tool will wait for the note to release after note off.", OPTIONS.release, 0.1, 60, {0.1, 1}, function (x) OPTIONS.release = x end, function(x) return tostring(x).." s." end, tonumber),
value_box("Between time", "Time between the end of each sample recording and the start of the next one. Increase this if you find that not every sample gets stored into its slot in time because Renoise is still processing the recorded sample when the next sample recording starts.", OPTIONS.between_time, 10, 1000, {10, 100}, function (x) OPTIONS.between_time = x end, function(x) return tostring(x).." ms." end, tonumber)
}
},
-- big buttons
vb:horizontal_aligner {
mode = "center",
width = "100%",
vb:button {
width = "33%",
height = 2*UNIT,
text = "Start",
notifier = go,
tooltip = "Start the recording process."
},
vb:button {
width = "33%",
height = 2*UNIT,
text = "Stop",
notifier = stop,
tooltip = "Stop the recording process."
},
vb:button {
width = "33%",
height = 2*UNIT,
text = "Recording Settings",
notifier = configure,
tooltip = "Open the Renoise sample recording window. Tweak your input settings to your liking here."
}
},
vb:horizontal_aligner {
spacing = UNIT,
margin = DEFAULT_MARGIN,
vb:row {
spacing = UNIT/3,
vb:checkbox {
value = OPTIONS.post_record_normalize_and_trim,
notifier = function(x) OPTIONS.post_record_normalize_and_trim = x end,
tooltip = "If checked, all samples will be normalized and trimmed after recording has completed."
},
vb:text {
text = "Normalize and Trim samples after recording"
}
},
},
-- sample processing
vb:column {
style = "panel",
width = "100%",
margin = DEFAULT_MARGIN,
vb:text {
text = "Post processing",
align = "center",
width = "100%"
},
vb:space {
height = UNIT/3
},
vb:horizontal_aligner {
spacing = UNIT,
margin = DEFAULT_MARGIN,
vb:row {
spacing = UNIT/3,
vb:checkbox{
value = OPTIONS.background,
notifier = function(x) OPTIONS.background = x end,
tooltip = "If checked, process the samples a little bit slower in order to make Renoise more usable while the processing is done."
},
vb:text {
text = "Process in background"
},
}
},
vb:horizontal_aligner {
spacing = UNIT,
margin = DEFAULT_MARGIN,
mode = "left",
vb:button {
text = "Normalize Sample Volumes",
notifier = normalize,
tooltip = "Raise the volume of each sample an equal amount. The amount will be the amount that the loudest sample can be raised before clipping."
},
vb:button {
text = "Trim Silences",
notifier = trim,
tooltip = "Remove any silence at the beginning of all samples."
}
},
vb:horizontal_aligner {
spacing = UNIT,
margin = DEFAULT_MARGIN,
width = "100%",
vb:row {
spacing = UNIT,
style = "group",
width = "100%",
vb:text {
text = "Status:"
},
vb:text {
text = "Waiting",
width = "90%",
id = "processing_status_text"
}
}
},
}
}
-- load the saved midi device. Default to device 1 if a preference doesn't exist
select_midi_device(prefs:read('midi_device_index'), 1)
WINDOW = renoise.app():show_custom_dialog(
title, content
)
end