-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Paketti0G01_Loader.lua
857 lines (781 loc) · 37 KB
/
Paketti0G01_Loader.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
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
local dialog
local vb = renoise.ViewBuilder()
local initial_value = nil
local dialog = nil
local pakettiDeviceChainPathDisplayId
local DEBUG = false
local filter_types = {"None", "LP Clean", "LP K35", "LP Moog", "LP Diode", "HP Clean","HP K35", "HP Moog", "BP Clean", "BP K35", "BP Moog", "BandPass","BandStop", "Vowel", "Comb", "Decimator", "Dist Shape", "Dist Fold","AM Sine", "AM Triangle", "AM Saw", "AM Pulse"}
local filter_type_map = {}
for i, v in ipairs(filter_types) do
filter_type_map[v] = i
end
-- Function to get the index of a filter type using the lookup table
local function get_filter_type_index(filter_type)
local index = filter_type_map[filter_type]
if index then
if DEBUG then
print("Found filter type: " .. filter_type .. " at index: " .. index)
end
return index
else
if DEBUG then
print("Filter type not found, defaulting to index 1 ('None').")
end
return 1 -- Default to "None" if not found
end
end
-- Initialize the filter index
local cached_filter_index = 1
local function my_keyhandler_func(dialog, key)
local closer = preferences.pakettiDialogClose.value
if key.modifiers == "" and key.name == closer then
dialog:close()
dialog = nil
return nil
end
if not (key.modifiers == "" and key.name == "exclamation") then
return key
else
dialog:close()
dialog = nil
return nil
end
end
local sample_rates = {22050, 44100, 48000, 88200, 96000, 192000}
-- Function to find the index of the sample rate
local function find_sample_rate_index(rate)
for i, v in ipairs(sample_rates) do
if v == rate then
return i
end
end
return 1 -- default to 22050 if not found
end
local os_name=os.platform()
local default_executable
if os_name=="WINDOWS"then default_executable="C:\\Program Files\\espeak\\espeak.exe"
elseif os_name=="MACINTOSH"then default_executable="/opt/homebrew/bin/espeak-ng"
else default_executable="/usr/bin/espeak-ng" end
-- Define the PakettiPluginEntry class
renoise.Document.create("PakettiPluginEntry") {
name = renoise.Document.ObservableString(),
path = renoise.Document.ObservableString(),
}
-- Function to create a new PakettiPluginEntry
function create_plugin_entry(name, path)
local entry = renoise.Document.instantiate("PakettiPluginEntry")
entry.name.value = name
entry.path.value = path
return entry
end
renoise.Document.create("PakettiDeviceEntry") {
name = renoise.Document.ObservableString(),
path = renoise.Document.ObservableString(),
device_type = renoise.Document.ObservableString(),
}
-- Function to create a new PakettiDeviceEntry
function create_device_entry(name, path, device_type)
local entry = renoise.Document.instantiate("PakettiDeviceEntry")
entry.name.value = name
entry.path.value = path
entry.device_type.value = device_type
return entry
end
preferences = renoise.Document.create("ScriptingToolPreferences") {
pakettiDialogClose="esc",
PakettiDeviceChainPath = "DeviceChains/",
upperFramePreference=0,
_0G01_Loader=false,
RandomBPM=false,
loadPaleGreenTheme=false,
PakettiStripSilenceThreshold=0.0121,
PakettiMoveSilenceThreshold=0.0121,
renderSampleRate=88200,
renderBitDepth=32,
renderBypass=false,
pakettiEditMode=1,
pakettiLoaderInterpolation=1,
pakettiLoaderFilterType="LP Clean",
pakettiLoaderOverSampling=true,
pakettiLoaderOneshot=false,
pakettiLoaderAutoFade=true,
pakettiLoaderAutoseek=false,
pakettiLoaderLoopMode=1,
pakettiLoaderNNA=2,
pakettiLoaderLoopExit=false,
selectionNewInstrumentSelect=false,
selectionNewInstrumentLoop=2,
selectionNewInstrumentInterpolation=4,
selectionNewInstrumentAutoFade=true,
selectionNewInstrumentAutoseek=false,
pakettiPitchbendLoaderEnvelope=false,
pakettiSlideContentAutomationToo=true,
pakettiDefaultXRNI="Presets/12st_Pitchbend.xrni",
pakettiDefaultDrumkitXRNI="Presets/12st_Pitchbend_Drumkit_C0.xrni",
UserPreferences = {
userPreferredDevice01 = "<None>",
userPreferredDevice02 = "<None>",
userPreferredDevice03 = "<None>",
userPreferredDevice04 = "<None>",
userPreferredDevice05 = "<None>",
userPreferredDevice06 = "<None>",
userPreferredDevice07 = "<None>",
userPreferredDevice08 = "<None>",
userPreferredDevice09 = "<None>",
userPreferredDevice10 = "<None>",
userPreferredDeviceLoad = true
},
WipeSlices = {
WipeSlicesLoopMode=2,
WipeSlicesLoopRelease=false,
WipeSlicesBeatSyncMode=1,
WipeSlicesOneShot=false,
WipeSlicesAutoseek=false,
WipeSlicesAutofade=true,
WipeSlicesMuteGroup=1,
WipeSlicesNNA=1,
WipeSlicesBeatSyncGlobal=false,
sliceCounter=1,
slicePreviousDirection=1
},
AppSelection = {
AppSelection1="",
AppSelection2="",
AppSelection3="",
AppSelection4="",
AppSelection5="",
AppSelection6="",
SmartFoldersApp1="",
SmartFoldersApp2="",
SmartFoldersApp3=""
},
pakettiThemeSelector = {
PreviousSelectedTheme = "",
FavoritedList = { "<No Theme Selected>" },
RenoiseLaunchFavoritesLoad = false,
RenoiseLaunchRandomLoad = false
},
UserDefinedSampleFolders01="",
UserDefinedSampleFolders02="",
UserDefinedSampleFolders03="",
UserDefinedSampleFolders04="",
UserDefinedSampleFolders05="",
UserDefinedSampleFolders06="",
UserDefinedSampleFolders07="",
UserDefinedSampleFolders08="",
UserDefinedSampleFolders09="",
UserDefinedSampleFolders10="",
pakettieSpeak = {
word_gap=3,
capitals=5,
pitch=35,
amplitude=05,
speed=150,
language=40,
voice=2,
text="Good afternoon, this is eSpeak, a Text-to-Speech engine, speaking. Shall we play a game?",
executable=default_executable,
clear_all_samples=true,
add_render_to_current_instrument=false,
render_on_change=false
},
OctaMEDPickPutSlots = {
SetSelectedInstrument=false,
UseEditStep=false,
Slot01="",
Slot02="",
Slot03="",
Slot04="",
Slot05="",
Slot06="",
Slot07="",
Slot08="",
Slot09="",
Slot10="",
RandomizeEnabled=false,
RandomizePercentage=10,
},
RandomizeSettings = {
pakettiRandomizeSelectedDevicePercentage=50,
pakettiRandomizeSelectedDevicePercentageUserPreference1=10,
pakettiRandomizeSelectedDevicePercentageUserPreference2=25,
pakettiRandomizeSelectedDevicePercentageUserPreference3=50,
pakettiRandomizeSelectedDevicePercentageUserPreference4=75,
pakettiRandomizeSelectedDevicePercentageUserPreference5=90,
pakettiRandomizeAllDevicesPercentage=50,
pakettiRandomizeAllDevicesPercentageUserPreference1=10,
pakettiRandomizeAllDevicesPercentageUserPreference2=25,
pakettiRandomizeAllDevicesPercentageUserPreference3=50,
pakettiRandomizeAllDevicesPercentageUserPreference4=75,
pakettiRandomizeAllDevicesPercentageUserPreference5=90,
pakettiRandomizeSelectedPluginPercentage=50,
pakettiRandomizeSelectedPluginPercentageUserPreference1=10,
pakettiRandomizeSelectedPluginPercentageUserPreference2=20,
pakettiRandomizeSelectedPluginPercentageUserPreference3=30,
pakettiRandomizeSelectedPluginPercentageUserPreference4=40,
pakettiRandomizeSelectedPluginPercentageUserPreference5=50,
pakettiRandomizeAllPluginsPercentage=50,
pakettiRandomizeAllPluginsPercentageUserPreference1=10,
pakettiRandomizeAllPluginsPercentageUserPreference2=20,
pakettiRandomizeAllPluginsPercentageUserPreference3=30,
pakettiRandomizeAllPluginsPercentageUserPreference4=40,
pakettiRandomizeAllPluginsPercentageUserPreference5=50
},
pakettiColuga = {
pakettiColugaLoopMode=2,
pakettiColugaClipLength=10,
pakettiColugaAmountOfVideos=1,
pakettiColugaLoadWholeVideo=true,
pakettiColugaOutputDirectory="Set this yourself, please.",
pakettiColugaFormatToSave=1,
pakettiColugaPathToSave="<No path set>",
pakettiColugaNewInstrumentOrSameInstrument=true,
pakettiColugaYT_DLPLocation="/opt/homebrew/bin/yt-dlp"
},
pakettiCheatSheet = {
pakettiCheatSheetRandomize=false,
pakettiCheatSheetRandomizeMin=0,
pakettiCheatSheetRandomizeMax=255,
pakettiCheatSheetFillAll=100,
pakettiCheatSheetRandomizeWholeTrack=false,
pakettiCheatSheetRandomizeSwitch=false,
pakettiCheatSheetRandomizeDontOverwrite=false
},
pakettiPhraseInitDialog = {
Autoseek = false,
VolumeColumnVisible = false,
PanningColumnVisible = false,
InstrumentColumnVisible = false,
DelayColumnVisible = false,
SampleFXColumnVisible = false,
NoteColumns = 1,
EffectColumns = 0,
Shuffle = 0,
LPB = 4,
Length = 64,
SetName = false,
Name = ""
},
pakettiTitler = {
textfile_path = "External/wordlist.txt",
notes_file_path = "External/notes.txt",
trackTitlerDateFormat = "YYYY_MM_DD",
},
pakettiMidiPopulator = {
volumeColumn = false,
panningColumn = false,
delayColumn = false,
sampleEffectsColumn = false,
noteColumns = 1.0,
effectColumns = 1.0,
collapsed = false,
incomingAudio = false,
populateSends = true
},
PakettiPluginLoaders = renoise.Document.DocumentList(),
PakettiDeviceLoaders = renoise.Document.DocumentList(),
PakettiDynamicViews = renoise.Document.DocumentList(),
UserDevices = {
Path = renoise.Document.ObservableString(""),
Slot01 = renoise.Document.ObservableString(""),
Slot02 = renoise.Document.ObservableString(""),
Slot03 = renoise.Document.ObservableString(""),
Slot04 = renoise.Document.ObservableString(""),
Slot05 = renoise.Document.ObservableString(""),
Slot06 = renoise.Document.ObservableString(""),
Slot07 = renoise.Document.ObservableString(""),
Slot08 = renoise.Document.ObservableString(""),
Slot09 = renoise.Document.ObservableString(""),
Slot10 = renoise.Document.ObservableString("")
},
UserInstruments = {
Path = renoise.Document.ObservableString(""),
Slot01 = renoise.Document.ObservableString(""),
Slot02 = renoise.Document.ObservableString(""),
Slot03 = renoise.Document.ObservableString(""),
Slot04 = renoise.Document.ObservableString(""),
Slot05 = renoise.Document.ObservableString(""),
Slot06 = renoise.Document.ObservableString(""),
Slot07 = renoise.Document.ObservableString(""),
Slot08 = renoise.Document.ObservableString(""),
Slot09 = renoise.Document.ObservableString(""),
Slot10 = renoise.Document.ObservableString("")
}}
renoise.tool().preferences = preferences
-- Accessing Segments
eSpeak = renoise.tool().preferences.pakettieSpeak
pakettiThemeSelector = renoise.tool().preferences.pakettiThemeSelector
WipeSlices = renoise.tool().preferences.WipeSlices
AppSelection = renoise.tool().preferences.AppSelection
RandomizeSettings = renoise.tool().preferences.RandomizeSettings
pakettiColuga = renoise.tool().preferences.pakettiColuga
DynamicViewPrefs = renoise.tool().preferences.PakettiDynamicViews
-- Function to initialize the filter index
local function initialize_filter_index()
if preferences.pakettiLoaderFilterType.value ~= nil then
cached_filter_index = get_filter_type_index(preferences.pakettiLoaderFilterType.value)
else
preferences.pakettiLoaderFilterType.value = "LP Moog"
cached_filter_index = get_filter_type_index("LP Moog")
end
end
initialize_filter_index()
local function pakettiGetXRNIDefaultPresetFiles()
local presetsFolder = "Presets/"
local files = os.filenames(presetsFolder, "*.xrni")
if not files or #files == 0 then
renoise.app():show_status("No .xrni preset files found in: " .. presetsFolder)
return { "<No Preset Selected>" }
end
-- Sort the files alphabetically for better user experience
table.sort(files, function(a, b) return a:lower() < b:lower() end)
-- Insert a default option at the beginning
table.insert(files, 1, "<No Preset Selected>")
return files
end
-- Function to create horizontal rule
function horizontal_rule()
return vb:horizontal_aligner{mode="justify", width="100%", vb:space{width=2}, vb:row{height=2, width="30%", style="panel"}, vb:space{width=2}}
end
-- Function to create vertical space
function vertical_space(height) return vb:row{height = height} end
-- Functions to update preferences
function update_interpolation_mode(value) preferences.pakettiLoaderInterpolation.value = value end
function update_autofade_mode(value) preferences.pakettiLoaderAutoFade.value = value end
function update_oversampling_mode(value) preferences.pakettiLoaderOverSampling.value=value end
function update_loop_mode(loop_mode_pref, value)
loop_mode_pref.value = value
preferences.pakettiLoaderLoopMode.value = value
end
function create_loop_mode_switch(preference)
return vb:switch{
items = {"Off", "Forward", "Backward", "PingPong"},
value = preference.value,
width = 400,
notifier = function(value)
update_loop_mode(preference, value)
end
}
end
-- Initialize filter index
if preferences.pakettiLoaderFilterType.value ~= nil then
initial_value = get_filter_type_index(preferences.pakettiLoaderFilterType.value)
else
preferences.pakettiLoaderFilterType.value ="LP Moog"
initial_value = get_filter_type_index("LP Moog")
end
local dialog_content = nil
function show_paketti_preferences()
local threshold_label = vb:text {
text = string.format("%.3f%%", preferences.PakettiStripSilenceThreshold.value * 100), width=100
}
local begthreshold_label = vb:text {
text = string.format("%.3f%%", preferences.PakettiMoveSilenceThreshold.value * 100), width=100
}
local pakettiDeviceChainPathDisplayId = "pakettiDeviceChainPathDisplay_" .. tostring(math.random(2, 30000))
local upperbuttonwidth=160
if dialog and dialog.visible then
dialog_content=nil
dialog:close()
return
end
local presetFiles = pakettiGetXRNIDefaultPresetFiles()
-- Get the initial value (index) for the popup
local pakettiDefaultXRNIDisplayId = "pakettiDefaultXRNIDisplay_" .. tostring(math.random(2,30000))
local pakettiDefaultDrumkitXRNIDisplayId = "pakettiDefaultDrumkitXRNIDisplay_" .. tostring(math.random(2,30000))
local dialog_content = vb:column {
margin=10,
-- Full-width row for buttons wrapped in a group
vb:column {
style="group",margin=10, width="100%",
vb:row {
vb:button{text="About Paketti/Donations", width=50, notifier=function() show_about_dialog() end},
vb:button{text="Theme Selector",width=upperbuttonwidth-100,notifier=function() pakettiThemeSelectorDialogShow() end},
vb:button{text="Gater",width=upperbuttonwidth-150,notifier=function()
local max_rows=nil
max_rows=renoise.song().selected_pattern.number_of_lines
if renoise.song() then
pakettiGaterDialog()
renoise.app().window.active_middle_frame=renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
end
end},
vb:button{text="Audio Processing",width=upperbuttonwidth-100,notifier=function() PakettiAudioProcessingToolsDialogShow() end},
vb:button{text="Effect CheatSheet",width=40,notifier=function() CheatSheet() end},
vb:button{text="Phrase Init Dialog",width=upperbuttonwidth-100,notifier=function() pakettiPhraseSettingsDialogShow() end},
vb:button{text="Randomize Plugins/Devices", width=50, notifier=function()
openCombinedRandomizerDialog() end},
vb:button{text="Configure Launch App Selection/Paths", width=50, notifier=function()
show_app_selection_dialog() end},
vb:button{text="MIDI Populator",width=upperbuttonwidth-100,notifier=function() generaMIDISetupShowCustomDialog() end},
vb:button{text="KeyBindings",width=upperbuttonwidth-100,notifier=function() showPakettiKeyBindingsDialog() end},
vb:button{text="Midi Mappings",width=upperbuttonwidth-100,notifier=function() show_midi_mappings_dialog() end}
}
},
-- Horizontal rule
horizontal_rule(),
vb:row {
vb:column {
margin=5,width=600,style="group",
vb:column {
style="group",margin=10, width="100%",
vb:text{style="strong",font="bold",text="Miscellaneous Settings"},
vb:row {
vb:text{text="Upper Frame",width=150},
vb:switch{items={"Off","Scopes","Spectrum"},value=preferences.upperFramePreference.value+1,width=200,
notifier=function(value) preferences.upperFramePreference.value=value-1 end}
},
-- Splitting and positioning the long text on a new row
vb:row {vb:text{style="strong",text="Whether F2,F3,F4,F11 change the Upper Frame Scope state or not"}},
vb:row {
vb:text{text="0G01 Loader",width=150},
vb:switch{items={"Off","On"},value=preferences._0G01_Loader.value and 2 or 1,width=200,
notifier=function(value)
preferences._0G01_Loader.value=(value==2)
update_0G01_loader_menu_entries()
end}
},
-- Splitting and positioning the long text on a new row
vb:row {vb:text{style="strong",text="Upon loading a Sample, inserts a C-4 and -G01 to New Track, Sample plays until end of length and triggers again."}},
vb:row {
vb:text{text="Random BPM",width=150},
vb:switch{items={"Off","On"},value=preferences.RandomBPM.value and 2 or 1,width=200,
notifier=function(value) preferences.RandomBPM.value=(value==2) update_random_bpm_preferences() end}
},
vb:row { vb:text{text="Pale Green Theme",width=150},vb:button{text="Load",width=100,notifier=function() update_loadPaleGreenTheme_preferences() end} },
vb:row { vb:text{text="Gifts: Plaid Zap .XRNI",width=150},vb:button{text="Load",width=100,notifier=function() renoise.app():load_instrument("Gifts/plaidzap.xrni") end} },
vb:row{vb:text{text="200 Drum Machines (.zip)", width=150},vb:button{text="Open URL",width=100,notifier=function()
renoise.app():open_url("http://www.hexawe.net/mess/200.Drum.Machines/") end}}},
horizontal_rule(),
vb:column{style = "group", margin = 10, width="100%",
vb:row{vb:text{text = "Create New Instrument & Loop from Selection", font="bold",style = "strong"}},
vb:row{vb:text{text = "Select Newly Created", width = 150},
vb:switch{items = {"Off", "On"},
value = preferences.selectionNewInstrumentSelect.value and 2 or 1,
width = 200,
notifier = function(value)
preferences.selectionNewInstrumentSelect.value = (value == 2)
end}},
vb:row { vb:text{text="Sample Interpolation",width=150},vb:switch{items={"None","Linear","Cubic","Sinc"},value=preferences.selectionNewInstrumentInterpolation.value,width=200,
notifier=function(value)
preferences.selectionNewInstrumentInterpolation.value = value end}
},
vb:row{vb:text{text = "Loop on Newly Created", width = 150},
create_loop_mode_switch(preferences.selectionNewInstrumentLoop)},
vb:row { vb:text{text="Autoseek",width=150},vb:switch{items={"Off","On"},value=preferences.selectionNewInstrumentAutoseek.value and 2 or 1,width=200,
notifier=function(value) preferences.selectionNewInstrumentAutoseek.value=(value ==2) end}
},
vb:row { vb:text{text="AutoFade",width=150},vb:switch{items={"Off","On"},value=preferences.selectionNewInstrumentAutoFade.value and 2 or 1,width=200,
notifier=function(value)
preferences.selectionNewInstrumentAutoFade.value=(value==2)
end}
}},
-- Render Settings wrapped in group
horizontal_rule(),
vb:column {
style="group",margin=10, width="100%",
vb:text{style="strong",font="bold",text="Render Settings"}, -- Applied bold and strong
vb:row { vb:text{text="Sample Rate",width=150},vb:switch{items={"22050","44100","48000","88200","96000","192000"},value=find_sample_rate_index(preferences.renderSampleRate.value),width=300,
notifier=function(value) preferences.renderSampleRate.value=sample_rates[value] end}
},
vb:row { vb:text{text="Bit Depth",width=150},vb:switch{items={"16","24","32"},value=preferences.renderBitDepth.value==16 and 1 or preferences.renderBitDepth.value==24 and 2 or 3,width=300,
notifier=function(value) preferences.renderBitDepth.value=(value==1 and 16 or value==2 and 24 or 32) end}
},
vb:row { vb:text{text="Bypass Devices",width=150},vb:switch{items={"Off","On"},value=preferences.renderBypass.value and 2 or 1,width=300,
notifier=function(value) preferences.renderBypass.value=(value==2) end}
}
},
-- Strip Silence / Move Beginning Silence to End wrapped in group
horizontal_rule(),
vb:column {
style = "group", margin = 10, width = "100%",
-- Title text
vb:text{style = "strong", font = "bold", text = "Silence Settings"},
-- First row for Strip Silence Threshold
vb:row {vb:text{text="Strip Silence Threshold:", width=150},
vb:minislider{
min=0,
max=1,
value=preferences.PakettiStripSilenceThreshold.value,
width=200,
notifier = function(value)
threshold_label.text = string.format("%.3f%%", value * 100) -- Update the label
preferences.PakettiStripSilenceThreshold.value = value
end
},threshold_label,
},
-- Second row for Move Silence Threshold
vb:row {
vb:text {text = "Move Silence Threshold:", width = 150},
vb:minislider {
min = 0,
max = 1,
value = preferences.PakettiMoveSilenceThreshold.value,
width = 200,
notifier = function(value)
begthreshold_label.text = string.format("%.3f%%", value * 100) -- Update the label
preferences.PakettiMoveSilenceThreshold.value = value
end
},begthreshold_label,
},
},
-- Edit Mode Coloring wrapped in group
horizontal_rule(),
vb:column {
style="group",margin=10, width="100%",
vb:text{style="strong",font="bold",text="Edit Mode Colouring"}, -- Applied bold and strong
vb:row { vb:text{text="Edit Mode",width=150},vb:switch{items={"None","Selected Track","All Tracks"},value=preferences.pakettiEditMode.value,width=300,
notifier=function(value) preferences.pakettiEditMode.value=value end}
},
vb:row { vb:text{style="strong",text="Enable Scope Highlight by going to Settings -> GUI -> Show Track Color Blends."} }
}
},
-- Column 2
vb:column {
style="group",margin=5,width=600,
-- Paketti Loader Settings wrapped in group
vb:column {
style="group",margin=10, width="100%",
vb:text{style="strong",font="bold",text="Paketti Loader Settings"},
vb:row { vb:text{text="Sample Interpolation",width=150},vb:switch{items={"None","Linear","Cubic","Sinc"},value=preferences.pakettiLoaderInterpolation.value,width=200,
notifier=function(value) update_interpolation_mode(value) end}
},
vb:row { vb:text{text="One-Shot",width=150},vb:switch{items={"Off","On"},value=preferences.pakettiLoaderOneshot.value and 2 or 1,width=200,
notifier=function(value) preferences.pakettiLoaderOneshot.value=(value==2) end}
},
vb:row { vb:text{text="Autoseek",width=150},vb:switch{items={"Off","On"},value=preferences.pakettiLoaderAutoseek.value and 2 or 1,width=200,
notifier=function(value) preferences.pakettiLoaderAutoseek.value=(value==2) end}
},
vb:row { vb:text{text="AutoFade",width=150},vb:switch{items={"Off","On"},value=preferences.pakettiLoaderAutoFade.value and 2 or 1,width=200,
notifier=function(value) preferences.pakettiLoaderAutoFade.value=(value==2) end}
},
vb:row { vb:text{text="New Note Action(NNA) Mode",width=150},vb:switch{items={"Cut","Note-Off","Continue"},value=preferences.pakettiLoaderNNA.value,width=300,
notifier=function(value) preferences.pakettiLoaderNNA.value=value end}
},
vb:row { vb:text{text="OverSampling",width=150},vb:switch{items={"Off","On"},value=preferences.pakettiLoaderOverSampling.value and 2 or 1,width=200,
notifier=function(value) preferences.pakettiLoaderOverSampling.value=(value==2) end}
},
vb:row { vb:text{text="Loop Mode",width=150},create_loop_mode_switch(preferences.pakettiLoaderLoopMode) },
vb:row { vb:text{text="Loop Release/Exit Mode",width=150},vb:checkbox{value=preferences.pakettiLoaderLoopExit.value,notifier=function(value) preferences.pakettiLoaderLoopExit.value=value end} },
vb:row { vb:text{text="Enable AHDSR Envelope",width=150},vb:checkbox{value=preferences.pakettiPitchbendLoaderEnvelope.value,notifier=function(value) preferences.pakettiPitchbendLoaderEnvelope.value=value end} },
vb:row {
vb:text{text="FilterType",width=150},
vb:popup{
items = filter_types,
value = cached_filter_index,
width = 200,
notifier = function(value)
preferences.pakettiLoaderFilterType.value = filter_types[value]
cached_filter_index = value -- Update the cached index
-- Removed print statements for performance
preferences:save_as("preferences.xml")
end
}
},
--[[ vb:row { vb:text{text="Default XRNI to use:",width=150},vb:textfield{text=preferences.pakettiDefaultXRNI.value:match("[^/\\]+$"),width=300,id=pakettiDefaultXRNIDisplayId,notifier=function(value) preferences.pakettiDefaultXRNI.value=value end},vb:button{text="Browse",width=100,notifier=function()
local filePath=renoise.app():prompt_for_filename_to_read({"*.XRNI"},"Paketti Default XRNI Selector Dialog")
if filePath and filePath~="" then preferences.pakettiDefaultXRNI.value=filePath vb.views[pakettiDefaultXRNIDisplayId].text=filePath:match("[^/\\]+$") else renoise.app():show_status("No XRNI Instrument was selected") end end} },
--]]
-- Generate a unique id based on timestamp or counter
vb:row {
vb:text {
text = "Default XRNI to use:",
width = 150
},
vb:textfield {
text = preferences.pakettiDefaultXRNI.value:match("[^/\\]+$"),
width = 300,
id = pakettiDefaultXRNIDisplayId, -- Use dynamic ID
notifier = function(value)
preferences.pakettiDefaultXRNI.value = value
end
},
vb:button {
text = "Browse",
width = 100,
notifier = function()
local filePath = renoise.app():prompt_for_filename_to_read({"*.XRNI"}, "Paketti Default XRNI Selector Dialog")
if filePath and filePath ~= "" then
preferences.pakettiDefaultXRNI.value = filePath
vb.views[pakettiDefaultXRNIDisplayId].text = filePath:match("[^/\\]+$")
else
renoise.app():show_status("No XRNI Instrument was selected")
end
end
}
},
vb:row { vb:text{text="Preset Files:",width=150},vb:popup{items=presetFiles,width=300,notifier=function(value)
local selectedFile=presetFiles[value]
preferences.pakettiDefaultXRNI.value="Presets/"..selectedFile
vb.views[pakettiDefaultXRNIDisplayId].text="Presets/"..selectedFile
end} },
vb:row { vb:text{text="Default Drumkit XRNI to use:",width=150},vb:textfield{text=preferences.pakettiDefaultDrumkitXRNI.value:match("[^/\\]+$"),width=300,id=pakettiDefaultDrumkitXRNIDisplayId,notifier=function(value) preferences.pakettiDefaultDrumkitXRNI.value=value end},vb:button{text="Browse",width=100,notifier=function()
local filePath=renoise.app():prompt_for_filename_to_read({"*.XRNI"},"Paketti Default Drumkit XRNI Selector Dialog")
if filePath and filePath~="" then preferences.pakettiDefaultDrumkitXRNI.value=filePath vb.views[pakettiDefaultDrumkitXRNIDisplayId].text=filePath:match("[^/\\]+$") else renoise.app():show_status("No XRNI Drumkit Instrument was selected") end end} },
vb:row { vb:text{text="Preset Files:",width=150},vb:popup{items=presetFiles,width=300,notifier=function(value)
local selectedFile=presetFiles[value]
preferences.pakettiDefaultDrumkitXRNI.value="Presets/"..selectedFile
vb.views[pakettiDefaultDrumkitXRNIDisplayId].text="Presets/"..selectedFile
end} }
},
-- Wipe & Slice Settings wrapped in group
horizontal_rule(),
vb:column {
style="group",margin=10, width="100%",
vb:text{style="strong",font="bold",text="Wipe & Slices Settings"},
vb:row { vb:text{text="Slice Loop Mode",width=150},create_loop_mode_switch(preferences.WipeSlices.WipeSlicesLoopMode) },
vb:row { vb:text{text="Slice Loop Release/Exit Mode",width=150},vb:checkbox{value=preferences.WipeSlices.WipeSlicesLoopRelease.value,notifier=function(value) preferences.WipeSlices.WipeSlicesLoopRelease.value=value end} },
vb:row { vb:text{text="Slice BeatSync Mode",width=150},vb:switch{items={"Repitch","Time-Stretch (Percussion)","Time-Stretch (Texture)","Off"},value=preferences.WipeSlices.WipeSlicesBeatSyncMode.value,width=420,
notifier=function(value) preferences.WipeSlices.WipeSlicesBeatSyncMode.value=value end}
},
vb:row { vb:text{text="Slice One-Shot",width=150},vb:switch{items={"Off","On"},value=preferences.WipeSlices.WipeSlicesOneShot.value and 2 or 1,width=200,
notifier=function(value) preferences.WipeSlices.WipeSlicesOneShot.value=(value==2) end}
},
vb:row { vb:text{text="Slice Autoseek",width=150},vb:switch{items={"Off","On"},value=preferences.WipeSlices.WipeSlicesAutoseek.value and 2 or 1,width=200,
notifier=function(value) preferences.WipeSlices.WipeSlicesAutoseek.value=(value==2) end}
},
vb:row { vb:text{text="Slice Autofade",width=150},vb:switch{items={"Off","On"},value=preferences.WipeSlices.WipeSlicesAutofade.value and 2 or 1,width=200,
notifier=function(value) preferences.WipeSlices.WipeSlicesAutofade.value=(value==2) end}
},
vb:row { vb:text{text="New Note Action(NNA) Mode",width=150},vb:switch{items={"Cut","Note-Off","Continue"},value=preferences.WipeSlices.WipeSlicesNNA.value,width=300,
notifier=function(value) preferences.WipeSlices.WipeSlicesNNA.value=value end}
},
vb:row { vb:text{text="Mute Group",width=150},vb:switch{items={"Off","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"},value=preferences.WipeSlices.WipeSlicesMuteGroup.value+1,width=400,
notifier=function(value) preferences.WipeSlices.WipeSlicesMuteGroup.value=value-1 end}
}
},
-- },
vb:text{style="strong", font="bold", text="Random Device Chain Loader Path"},
vb:row{
vb:textfield{
text = preferences.PakettiDeviceChainPath.value,
width = 300,
id = pakettiDeviceChainPathDisplayId,
notifier = function(value)
preferences.PakettiDeviceChainPath.value = value
end
},
vb:button{
text = "Browse",
width = 60,
notifier = function()
local path = renoise.app():prompt_for_path("Select Device Chain Path")
if path and path ~= "" then
preferences.PakettiDeviceChainPath.value = path
vb.views[pakettiDeviceChainPathDisplayId].text = path
else
renoise.app():show_status("No path was selected, returning to default.")
preferences.PakettiDeviceChainPath.value = "DeviceChains/"
vb.views[pakettiDeviceChainPathDisplayId].text = "DeviceChains/"
end
end
},
vb:button{
text = "Reset to Default",
width = 100,
notifier = function()
preferences.PakettiDeviceChainPath.value = "DeviceChains/"
vb.views[pakettiDeviceChainPathDisplayId].text = "DeviceChains/"
end
},
vb:button{text="Load Random Chain",width=100,notifier=function()
PakettiRandomDeviceChain(preferences.PakettiDeviceChainPath.value)
end
}}
},
},
-- Bottom Buttons
vb:horizontal_aligner { mode="distribute",
vb:button{text="OK",width="50%",notifier=function()
preferences:save_as("preferences.xml")
print (preferences.pakettiDefaultXRNI.value)
print (preferences.pakettiLoaderFilterType.value)
dialog:close()
end},
vb:button{text="Cancel",width="50%",notifier=function() dialog:close() end}
}
}
dialog = renoise.app():show_custom_dialog("Paketti Preferences", dialog_content, my_keyhandler_func)
end
function on_sample_count_change()
if not preferences._0G01_Loader.value then return end
local song = renoise.song()
if not song or #song.tracks == 0 or song.selected_track.type ~= renoise.Track.TRACK_TYPE_SEQUENCER then return end
local selected_track_index = song.selected_track_index
local new_track_idx = selected_track_index + 1
song:insert_track_at(new_track_idx)
local line = song.patterns[song.selected_pattern_index].tracks[new_track_idx]:line(1)
song.selected_track_index = new_track_idx
line.note_columns[1].note_string = "C-4"
line.note_columns[1].instrument_value = song.selected_instrument_index - 1
line.effect_columns[1].number_string = "0G"
line.effect_columns[1].amount_value = 01
end
function manage_sample_count_observer(attach)
local song = renoise.song()
local instr = song.selected_instrument
if attach then
if not instr.samples_observable:has_notifier(on_sample_count_change) then
instr.samples_observable:add_notifier(on_sample_count_change)
end
else
if instr.samples_observable:has_notifier(on_sample_count_change) then
instr.samples_observable:remove_notifier(on_sample_count_change)
end
end
end
function update_dynamic_menu_entries()
local enableMenuEntryName = "Main Menu:Tools:Paketti..:!Preferences..:0G01 Loader Enable"
local disableMenuEntryName = "Main Menu:Tools:Paketti..:!Preferences..:0G01 Loader Disable"
if preferences._0G01_Loader.value then
if renoise.tool():has_menu_entry(enableMenuEntryName) then
renoise.tool():remove_menu_entry(enableMenuEntryName)
end
if not renoise.tool():has_menu_entry(disableMenuEntryName) then
renoise.tool():add_menu_entry{name = disableMenuEntryName,
invoke = function()
preferences._0G01_Loader.value = false
update_dynamic_menu_entries()
if dialog and dialog.visible then
dialog:close()
show_paketti_preferences()
end
end}
end
else
if renoise.tool():has_menu_entry(disableMenuEntryName) then
renoise.tool():remove_menu_entry(disableMenuEntryName)
end
if not renoise.tool():has_menu_entry(enableMenuEntryName) then
renoise.tool():add_menu_entry{name = enableMenuEntryName,
invoke = function()
preferences._0G01_Loader.value = true
update_dynamic_menu_entries()
if dialog and dialog.visible then
dialog:close()
show_paketti_preferences()
end
end}
end
end
end
function update_0G01_loader_menu_entries()
manage_sample_count_observer(preferences._0G01_Loader.value)
update_dynamic_menu_entries()
end
function initialize_tool()
update_0G01_loader_menu_entries()
end
function safe_initialize()
if not renoise.tool().app_idle_observable:has_notifier(initialize_tool) then
renoise.tool().app_idle_observable:add_notifier(initialize_tool)
end
load_Pakettipreferences()
initialize_filter_index() -- Ensure the filter index is initialized
end
function load_Pakettipreferences()
if io.exists("preferences.xml") then preferences:load_from("preferences.xml") end
end
function update_loadPaleGreenTheme_preferences() renoise.app():load_theme("Themes/Lackluster - Pale Green Renoise Theme.xrnc") end
safe_initialize()
renoise.tool():add_menu_entry{name = "Main Menu:Tools:Paketti..:!Preferences..:Paketti Preferences...", invoke = show_paketti_preferences}
renoise.tool():add_keybinding{name = "Global:Paketti:Show Paketti Preferences...", invoke = show_paketti_preferences}