-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPakettiRequests.lua
8961 lines (7455 loc) · 368 KB
/
PakettiRequests.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
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
renoise.tool():add_keybinding{
name="Pattern Editor:Paketti:Selection in Pattern to Group",
invoke=function()
if renoise.song().selection_in_pattern ~= nil then
local selection = renoise.song().selection_in_pattern
local groupPos = selection.end_track + 1
-- Ensure the group position is valid
if groupPos > renoise.song().sequencer_track_count then
groupPos = renoise.song().sequencer_track_count + 1
end
-- Insert the group at the adjusted position
renoise.song():insert_group_at(groupPos)
-- Add tracks to the group one by one, skipping Master and Send tracks
for i = selection.start_track, selection.end_track do
if i <= renoise.song().sequencer_track_count then
renoise.song():add_track_to_group(selection.start_track, groupPos)
end
end
end
end
}
renoise.tool():add_keybinding{
name="Pattern Matrix:Paketti:Selection in Pattern Matrix to Group",
invoke=function()
local song = renoise.song()
local selected_tracks = {}
-- Function to read selected tracks in the pattern matrix
local function read_pattern_matrix_selection()
local sequencer = song.sequencer
local total_tracks = song.sequencer_track_count
local total_patterns = #sequencer.pattern_sequence
-- Iterate over all tracks and patterns to find selected tracks
for track_index = 1, total_tracks do
for sequence_index = 1, total_patterns do
if sequencer:track_sequence_slot_is_selected(track_index, sequence_index) then
if not selected_tracks[track_index] then
table.insert(selected_tracks, track_index)
end
break -- Stop checking this track, as we already know it's selected
end
end
end
end
-- Read selection from the Pattern Matrix
read_pattern_matrix_selection()
-- Fallback to the currently selected track if no valid selection exists
if #selected_tracks == 0 then
table.insert(selected_tracks, song.selected_track_index)
end
-- Remove any invalid tracks (Send or Master Tracks)
for i = #selected_tracks, 1, -1 do
if selected_tracks[i] > song.sequencer_track_count then
table.remove(selected_tracks, i)
end
end
-- Ensure there are valid tracks to group
if #selected_tracks == 0 then return end
-- Insert the group after the last selected track
local groupPos = selected_tracks[#selected_tracks] + 1
if groupPos > song.sequencer_track_count then
groupPos = song.sequencer_track_count + 1
end
song:insert_group_at(groupPos)
-- Add selected tracks to the group in their original order
for _, track_index in ipairs(selected_tracks) do
-- Track position needs to be adjusted as we add to the group
local adjusted_group_pos = groupPos
song:add_track_to_group(track_index, adjusted_group_pos)
groupPos = groupPos + 1
end
end
}
function jenokiSystem(bpl,lpb,rowcount)
-- Set Transport LPB and Metronome LPB to x (lpb)
renoise.song().transport.lpb = lpb
renoise.song().transport.metronome_lines_per_beat = lpb
-- Set Transport TPL and Metronome Beats Ber Bar to y (bpl)
renoise.song().transport.tpl = bpl
renoise.song().transport.metronome_beats_per_bar = bpl
-- Set Pattern Row length to z (rowcount)
renoise.song().patterns[renoise.song().selected_pattern_index].number_of_lines=rowcount
end
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Set Time Signature 3/4 and 48 rows @ LPB 4",invoke=function() jenokiSystem(3,4,48) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Set Time Signature 7/8 and 56 rows @ LPB 8",invoke=function() jenokiSystem(7,8,56) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Set Time Signature 6/8 and 48 rows @ LPB 8",invoke=function() jenokiSystem(6,8,48) end}
-- Shortcuts as requested by Casiino
--
renoise.tool():add_keybinding{name="Global:Paketti:Computer Keyboard Velocity (-16)",invoke=function() computerKeyboardVolChange(-16) end}
renoise.tool():add_keybinding{name="Global:Paketti:Computer Keyboard Velocity (+16)",invoke=function() computerKeyboardVolChange(16) end}
renoise.tool():add_keybinding{name="Global:Paketti:BPM Decrease (-5)",invoke=function() adjust_bpm(-5, 0) end}
renoise.tool():add_keybinding{name="Global:Paketti:BPM Increase (+5)",invoke=function() adjust_bpm(5, 0) end}
function loopExitToggle()
if
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_release
then
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_release=false
else
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_release=true
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Selected Sample Exit Loop Note-Off Toggle",invoke=function() loopExitToggle() end}
renoise.tool():add_keybinding{name="Global:Paketti:Selected Sample Exit Loop Note-Off Off",invoke=function()
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_release=false
end}
renoise.tool():add_keybinding{name="Global:Paketti:Selected Sample Exit Loop Note-Off On",invoke=function()
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_release=true
end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Autofade On",invoke=function() renoise.song().selected_sample.autofade=true end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Autofade Off",invoke=function() renoise.song().selected_sample.autofade=false end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Finetune (-5)",invoke=function() selectedSampleFinetune(-5) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Finetune (+5)",invoke=function() selectedSampleFinetune(5) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Volume (+0.05)",invoke=function() selectedSampleVolume(0.05) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Volume (-0.05)",invoke=function() selectedSampleVolume(-0.05) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Panning (+0.05)",invoke=function() selectedSamplePanning(0.05) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Panning (-0.05)",invoke=function() selectedSamplePanning(-0.05) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Transpose (-5)",invoke=function() selectedSampleTranspose(-5) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Transpose (+5)",invoke=function() selectedSampleTranspose(5) end}
-- Function to assign a modulation set to the selected sample based on a given index
function selectedSampleMod(number)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if there are any modulation sets
if not instrument or #instrument.sample_modulation_sets == 0 then
print("No modulation sets available or no instrument selected.")
return
end
-- Get the number of available modulation sets
local num_modulation_sets = #instrument.sample_modulation_sets
-- Check if the provided index is within the valid range
-- Adjusting to include 0 in the check, as it represents no modulation set assigned
if number < 0 or number > num_modulation_sets then
-- print("Invalid modulation_set_index value '" .. number .. "'. Valid values are (0 to " .. num_modulation_sets .. ").")
return
end
-- Assign the modulation set index to the selected sample
-- This assignment now confidently allows setting the index to 0
instrument.samples[renoise.song().selected_sample_index].modulation_set_index = number
end
-- Function to assign an FX chain to the selected sample based on a given index
function selectedSampleFX(number)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if there are any FX chains
if not instrument or #instrument.sample_device_chains == 0 then
print("No FX chains available or no instrument selected.")
return
end
-- Get the number of available FX chains
local num_fx_sets = #instrument.sample_device_chains
-- Check if the provided index is within the valid range
-- Adjusting to include 0 in the check, as it represents no FX chain assigned
if number < 0 or number > num_fx_sets then
-- print("Invalid device_chain_index value '" .. number .. "'. Valid values are (0 to " .. num_fx_sets .. ").")
return
end
-- Assign the FX chain index to the selected sample
-- This assignment confidently allows setting the index to 0
instrument.samples[renoise.song().selected_sample_index].device_chain_index = number
end
for i = 0, 9 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Mod to 0" .. i,
invoke = function() selectedSampleMod(i) end}
end
for i = 10, 32 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Mod to " .. i,
invoke = function() selectedSampleMod(i) end}
end
for i = 0, 9 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample FX to 0" .. i,invoke=function() selectedSampleFX(i) end}
end
for i = 10, 32 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample FX to " .. i,invoke=function() selectedSampleFX(i) end}
end
-- Function to assign a modulation set index to all samples in the selected instrument
function selectedInstrumentAllMod(number)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
print("No samples are available or no instrument selected.")
return
end
-- Get the number of available modulation sets
local num_modulation_sets = #instrument.sample_modulation_sets
-- Check if the provided index is within the valid range
if number < 0 or number > num_modulation_sets then
print("Invalid modulation_set_index value '" .. number .. "'. Valid values are (0 to " .. num_modulation_sets .. ").")
return
end
-- Assign the modulation set index to each sample in the instrument
for i, sample in ipairs(instrument.samples) do
sample.modulation_set_index = number
end
end
for i = 0, 9 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Mod to 0" .. i,invoke=function() selectedInstrumentAllMod(i) end}
end
for i = 10, 32 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Mod to " .. i,invoke=function() selectedInstrumentAllMod(i) end}
end
-- Function to assign an FX chain index to all samples in the selected instrument
function selectedInstrumentAllFx(number)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
print("No samples are available or no instrument selected.")
return
end
-- Get the number of available FX chains
local num_fx_sets = #instrument.sample_device_chains
-- Check if the provided index is within the valid range
if number < 0 or number > num_fx_sets then
print("Invalid device_chain_index value '" .. number .. "'. Valid values are (0 to " .. num_fx_sets .. ").")
return
end
-- Assign the FX chain index to each sample in the instrument
for i, sample in ipairs(instrument.samples) do
sample.device_chain_index = number
end
end
for i = 1, 9 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Fx to 0" .. i,invoke=function() selectedInstrumentAllFx(i) end}
end
for i = 10, 32 do
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Fx to " .. i,invoke=function() selectedInstrumentAllFx(i) end}
end
-- Function to toggle the autofade setting for all samples in the selected instrument
function selectedInstrumentAllAutofadeToggle()
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
print("No samples are available or no instrument selected.")
return
end
-- Iterate through each sample in the instrument and toggle the autofade setting
for i, sample in ipairs(instrument.samples) do
sample.autofade = not sample.autofade
end
end
-- Function to set the autofade setting for all samples in the selected instrument based on a given state
function selectedInstrumentAllAutofadeControl(state)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
--print("No samples are available or no instrument selected.")
return
end
-- Convert numerical state to boolean for autofade
local autofadeState = (state == 1)
-- Iterate through each sample in the instrument and set the autofade setting
for i, sample in ipairs(instrument.samples) do
sample.autofade = autofadeState
end
end
function selectedInstrumentAllAutoseekToggle()
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
print("No samples are available or no instrument selected.")
return
end
-- Iterate through each sample in the instrument and toggle the autoseek setting
for i, sample in ipairs(instrument.samples) do
sample.autoseek = not sample.autoseek
end
end
function selectedInstrumentAllAutoseekControl(state)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Check if the instrument and samples are valid
if not instrument or #instrument.samples == 0 then
--print("No samples are available or no instrument selected.")
return
end
-- Convert numerical state to boolean for autoseek
local autoseekState = (state == 1)
-- Iterate through each sample in the instrument and set the autoseek setting
for i, sample in ipairs(instrument.samples) do
sample.autoseek = autoseekState
end
end
renoise.tool():add_menu_entry{name="Sample Navigator:Paketti..:Set Selected Instrument All Autofade On",invoke=function() selectedInstrumentAllAutofadeControl(1) end}
renoise.tool():add_menu_entry{name="Sample Navigator:Paketti..:Set Selected Instrument All Autoseek On",invoke=function() selectedInstrumentAllAutoseekControl(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autofade On/Off",invoke=function() selectedInstrumentAllAutofadeToggle() end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autofade On",invoke=function() selectedInstrumentAllAutofadeControl(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autofade Off",invoke=function() selectedInstrumentAllAutofadeControl(0) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autoseek On/Off",invoke=function() selectedInstrumentAllAutoseekToggle() end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autoseek On",invoke=function() selectedInstrumentAllAutoseekControl(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument All Autoseek Off",invoke=function() selectedInstrumentAllAutoseekControl(0) end}
-----------
function halveBeatsyncLinesAll()
local s = renoise.song()
local currInst = s.selected_instrument_index
if currInst == nil or not s.instruments[currInst] then
print("No instrument selected.")
return
end
local samples = s.instruments[currInst].samples
if #samples < 1 then
print("No samples available in the selected instrument.")
return
end
local start_index = 1
if #samples > 1 and #samples[1].slice_markers > 0 then
start_index = 2
end
local reference_sync_lines = samples[start_index].beat_sync_lines
if not samples[start_index].beat_sync_enabled then
samples[start_index].beat_sync_enabled = true
reference_sync_lines = samples[start_index].beat_sync_lines
end
if not reference_sync_lines then
print("No valid samples found to reference for beatsync lines.")
return
end
local new_sync_lines = math.max(math.floor(reference_sync_lines / 2), 1)
-- Apply new sync lines
for i = start_index, #samples do
if samples[i].sample_buffer and samples[i].sample_buffer.has_sample_data then
if not samples[i].beat_sync_enabled then
samples[i].beat_sync_enabled = true
end
samples[i].beat_sync_lines = new_sync_lines
end
end
renoise.app():show_status("Beatsync lines halved for all applicable samples from " .. reference_sync_lines .. " to " .. new_sync_lines)
end
function halveBeatsyncLinesSelected()
local s = renoise.song()
local currInst = s.selected_instrument_index
if currInst == nil or not s.instruments[currInst] then
print("No instrument selected.")
return
end
local samples = s.instruments[currInst].samples
local currSample = s.selected_sample_index
if currSample == nil or currSample < 1 or currSample > #samples then
print("Selected sample is invalid or does not exist.")
return
end
if not samples[currSample].sample_buffer or not samples[currSample].sample_buffer.has_sample_data then
print("Selected sample slot contains no sample data.")
return
end
if not samples[currSample].beat_sync_enabled then
samples[currSample].beat_sync_enabled = true
end
local reference_sync_lines = samples[currSample].beat_sync_lines
local new_sync_lines = math.max(math.floor(reference_sync_lines / 2), 1)
samples[currSample].beat_sync_lines = new_sync_lines
renoise.app():show_status("Beatsync lines halved for the selected sample from " .. reference_sync_lines .. " to " .. new_sync_lines)
end
function doubleBeatsyncLinesAll()
local s = renoise.song()
local currInst = s.selected_instrument_index
if currInst == nil or not s.instruments[currInst] then
print("No instrument selected.")
return
end
local samples = s.instruments[currInst].samples
if #samples < 1 then
print("No samples available in the selected instrument.")
return
end
local start_index = 1
if #samples > 1 and #samples[1].slice_markers > 0 then
start_index = 2
end
local reference_sync_lines = samples[start_index].beat_sync_lines
if not samples[start_index].beat_sync_enabled then
samples[start_index].beat_sync_enabled = true
reference_sync_lines = samples[start_index].beat_sync_lines
end
if not reference_sync_lines then
print("No valid samples found to reference for beatsync lines.")
return
end
if reference_sync_lines >= 512 then
renoise.app():show_status("Maximum Beatsync line amount is 512, cannot go higher.")
return
end
local new_sync_lines = math.min(reference_sync_lines * 2, 512)
if reference_sync_lines == 1 then new_sync_lines = 2 end
-- Apply new sync lines
for i = start_index, #samples do
if samples[i].sample_buffer and samples[i].sample_buffer.has_sample_data then
if not samples[i].beat_sync_enabled then
samples[i].beat_sync_enabled = true
end
samples[i].beat_sync_lines = new_sync_lines
end
end
renoise.app():show_status("Beatsync lines doubled for all applicable samples from " .. reference_sync_lines .. " to " .. new_sync_lines)
end
function doubleBeatsyncLinesSelected()
local s = renoise.song()
local currInst = s.selected_instrument_index
if currInst == nil or not s.instruments[currInst] then
print("No instrument selected.")
return
end
local samples = s.instruments[currInst].samples
local currSample = s.selected_sample_index
if currSample == nil or currSample < 1 or currSample > #samples then
print("Selected sample is invalid or does not exist.")
return
end
if not samples[currSample].sample_buffer or not samples[currSample].sample_buffer.has_sample_data then
print("Selected sample slot contains no sample data.")
return
end
if not samples[currSample].beat_sync_enabled then
samples[currSample].beat_sync_enabled = true
end
local reference_sync_lines = samples[currSample].beat_sync_lines
if reference_sync_lines >= 512 then
renoise.app():show_status("Maximum Beatsync line amount is 512, cannot go higher.")
return
end
local new_sync_lines = math.min(reference_sync_lines * 2, 512)
if reference_sync_lines == 1 then new_sync_lines = 2 end
samples[currSample].beat_sync_lines = new_sync_lines
renoise.app():show_status("Beatsync lines doubled for the selected sample from " .. reference_sync_lines .. " to " .. new_sync_lines)
end
-- Main Menu Entries
renoise.tool():add_menu_entry{name="--Main Menu:Tools:Paketti..:Instruments..:Beatsync Lines Halve (All)", invoke=function() halveBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Beatsync Lines Halve (Selected Sample)", invoke=function() halveBeatsyncLinesSelected() end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Beatsync Lines Double (All)", invoke=function() doubleBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Beatsync Lines Double (Selected Sample)", invoke=function() doubleBeatsyncLinesSelected() end}
-- Sample Editor Menu Entries
renoise.tool():add_menu_entry{name="Sample Editor:Paketti..:Beatsync Lines Halve (All)", invoke=function() halveBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Sample Editor:Paketti..:Beatsync Lines Halve (Selected Sample)", invoke=function() halveBeatsyncLinesSelected() end}
renoise.tool():add_menu_entry{name="Sample Editor:Paketti..:Beatsync Lines Double (All)", invoke=function() doubleBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Sample Editor:Paketti..:Beatsync Lines Double (Selected Sample)", invoke=function() doubleBeatsyncLinesSelected() end}
-- Sample Navigator Menu Entries
renoise.tool():add_menu_entry{name="--Sample Navigator:Paketti..:Beatsync Lines Halve (All)", invoke=function() halveBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Sample Navigator:Paketti..:Beatsync Lines Halve (Selected Sample)", invoke=function() halveBeatsyncLinesSelected() end}
renoise.tool():add_menu_entry{name="Sample Navigator:Paketti..:Beatsync Lines Double (All)", invoke=function() doubleBeatsyncLinesAll() end}
renoise.tool():add_menu_entry{name="Sample Navigator:Paketti..:Beatsync Lines Double (Selected Sample)", invoke=function() doubleBeatsyncLinesSelected() end}
-- Keybindings
renoise.tool():add_keybinding{name="Global:Paketti:Halve Beatsync Lines (All)", invoke=function() halveBeatsyncLinesAll() end}
renoise.tool():add_keybinding{name="Global:Paketti:Halve Beatsync Lines (Selected Sample)", invoke=function() halveBeatsyncLinesSelected() end}
renoise.tool():add_keybinding{name="Global:Paketti:Double Beatsync Lines (All)", invoke=function() doubleBeatsyncLinesAll() end}
renoise.tool():add_keybinding{name="Global:Paketti:Double Beatsync Lines (Selected Sample)", invoke=function() doubleBeatsyncLinesSelected() end}
renoise.tool():add_keybinding{name="Global:Paketti:Halve Halve Beatsync Lines (All)", invoke=function() halveBeatsyncLinesAll() halveBeatsyncLinesAll()end}
renoise.tool():add_keybinding{name="Global:Paketti:Halve Halve Beatsync Lines (Selected Sample)", invoke=function() halveBeatsyncLinesSelected() halveBeatsyncLinesSelected() end}
renoise.tool():add_keybinding{name="Global:Paketti:Double Double Beatsync Lines (All)", invoke=function() doubleBeatsyncLinesAll() doubleBeatsyncLinesAll() end}
renoise.tool():add_keybinding{name="Global:Paketti:Double Double Beatsync Lines (Selected Sample)", invoke=function() doubleBeatsyncLinesSelected() doubleBeatsyncLinesSelected() end}
function pitchedInstrument(st)
renoise.app():load_instrument("Presets/" .. st .. "st_Pitchbend.xrni")
renoise.song().selected_instrument.name=(st .. "st_Pitchbend Instrument")
renoise.song().instruments[renoise.song().selected_instrument_index].macros_visible = true
renoise.song().instruments[renoise.song().selected_instrument_index].sample_modulation_sets[1].name=(st .. "st_Pitchbend")
end
function pitchedDrumkit()
renoise.app():load_instrument("Presets/12st_Pitchbend_Drumkit_C0.xrni")
renoise.song().selected_instrument.name="Pitchbend Drumkit"
renoise.song().instruments[renoise.song().selected_instrument_index].macros_visible = true
renoise.song().instruments[renoise.song().selected_instrument_index].sample_modulation_sets[1].name=("Pitchbend Drumkit")
end
renoise.tool():add_menu_entry{name="--Main Menu:Tools:Paketti..:Instruments..:Initialize..:12st PitchBend Instrument Init",invoke=function() pitchedInstrument(12) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:24st PitchBend Instrument Init",invoke=function() pitchedInstrument(24) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:36st PitchBend Instrument Init",invoke=function() pitchedInstrument(36) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:48st PitchBend Instrument Init",invoke=function() pitchedInstrument(48) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:64st PitchBend Instrument Init",invoke=function() pitchedInstrument(64) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:96st PitchBend Instrument Init",invoke=function() pitchedInstrument(96) end}
renoise.tool():add_menu_entry{name="Main Menu:Tools:Paketti..:Instruments..:Initialize..:PitchBend Drumkit Instrument Init",invoke=function() pitchedDrumkit() end}
renoise.tool():add_menu_entry{name="--Instrument Box:Paketti..:Initialize..:12st PitchBend Instrument Init",invoke=function() pitchedInstrument(12) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:24st PitchBend Instrument Init",invoke=function() pitchedInstrument(24) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:36st PitchBend Instrument Init",invoke=function() pitchedInstrument(36) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:48st PitchBend Instrument Init",invoke=function() pitchedInstrument(48) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:64st PitchBend Instrument Init",invoke=function() pitchedInstrument(64) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:96st PitchBend Instrument Init",invoke=function() pitchedInstrument(96) end}
renoise.tool():add_menu_entry{name="Instrument Box:Paketti..:Initialize..:PitchBend Drumkit Instrument Init",invoke=function() pitchedDrumkit() end}
renoise.tool():add_keybinding{name="Global:Paketti:12st PitchBend Instrument Init", invoke=function() pitchedInstrument(12) end}
renoise.tool():add_keybinding{name="Global:Paketti:24st PitchBend Instrument Init", invoke=function() pitchedInstrument(24) end}
renoise.tool():add_keybinding{name="Global:Paketti:36st PitchBend Instrument Init", invoke=function() pitchedInstrument(36) end}
renoise.tool():add_keybinding{name="Global:Paketti:48st PitchBend Instrument Init", invoke=function() pitchedInstrument(48) end}
renoise.tool():add_keybinding{name="Global:Paketti:64st PitchBend Instrument Init", invoke=function() pitchedInstrument(64) end}
renoise.tool():add_keybinding{name="Global:Paketti:96st PitchBend Instrument Init", invoke=function() pitchedInstrument(96) end}
renoise.tool():add_keybinding{name="Global:Paketti:PitchBend Drumkit Instrument Init", invoke=function() pitchedDrumkit() end}
function transposeAllSamplesInInstrument(amount)
-- Access the currently selected instrument in Renoise
local instrument = renoise.song().selected_instrument
-- Iterate through all samples in the instrument
for i = 1, #instrument.samples do
-- Access each sample's transpose property
local currentTranspose = instrument.samples[i].transpose
local newTranspose = currentTranspose + amount
-- Clamp the transpose value to be within the valid range of -120 to 120
if newTranspose > 120 then
newTranspose = 120
elseif newTranspose < -120 then
newTranspose = -120
end
-- Apply the new transpose value to the sample
instrument.samples[i].transpose = newTranspose
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Transpose (-1)",invoke = function() transposeAllSamplesInInstrument(-1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Transpose (+1)",invoke = function() transposeAllSamplesInInstrument(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Transpose (-12)",invoke = function() transposeAllSamplesInInstrument(-12) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Transpose (+12)",invoke = function() transposeAllSamplesInInstrument(12) end}
function resetInstrumentTranspose(amount)
local instrument = renoise.song().selected_instrument
for i = 1, #instrument.samples do
instrument.samples[i].transpose = 0
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Transpose 0 (Reset)",
invoke=function() resetInstrumentTranspose(0) end}
---
--another from casiino:
-- Access the Renoise song API
-- Jump to Group experimental
--another from casiino
-- Velocity Tracking On/Off for each Sample in the Instrument:
function selectedInstrumentVelocityTracking(enable)
-- Access the selected instrument
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Determine the new state based on the passed argument
local newState = (enable == 1)
-- Iterate over all sample mapping groups
for group_index, sample_mapping_group in ipairs(instrument.sample_mappings) do
-- Iterate over each mapping in the group
for mapping_index, mapping in ipairs(sample_mapping_group) do
-- Set the map_velocity_to_volume based on newState
mapping.map_velocity_to_volume = newState
-- Optionally output the change to the terminal for confirmation
print(string.format("Mapping Group %d, Mapping %d: map_velocity_to_volume set to %s", group_index, mapping_index, tostring(mapping.map_velocity_to_volume)))
end
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Velocity Tracking On",
invoke=function() selectedInstrumentVelocityTracking(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Velocity Tracking Off",
invoke=function() selectedInstrumentVelocityTracking(0) end}
function selectedSampleVelocityTracking(enable)
-- Access the selected instrument
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
-- Get the selected sample index
local selected_sample_index = renoise.song().selected_sample_index
-- Determine the new state based on the passed argument
local newState = (enable == 1)
-- Iterate over all mappings in the selected instrument
for _, mapping in ipairs(instrument.sample_mappings[1]) do -- Assuming [1] is the correct layer, adjust if needed
-- Check if the mapping corresponds to the selected sample
if mapping.sample_index == selected_sample_index then
-- Set the map_velocity_to_volume based on newState
mapping.map_velocity_to_volume = newState
-- Optionally output the change to the terminal for confirmation
print(string.format("Mapping for Sample %d: map_velocity_to_volume set to %s", selected_sample_index, tostring(mapping.map_velocity_to_volume)))
end
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Toggle Selected Sample Velocity Tracking",
invoke=function()
if
renoise.song().instruments[renoise.song().selected_instrument_index].sample_mappings[1][renoise.song().selected_sample_index].map_velocity_to_volume==true
then renoise.song().instruments[renoise.song().selected_instrument_index].sample_mappings[1][renoise.song().selected_sample_index].map_velocity_to_volume=false
else renoise.song().instruments[renoise.song().selected_instrument_index].sample_mappings[1][renoise.song().selected_sample_index].map_velocity_to_volume=true
end
end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Velocity Tracking On",
invoke=function()
if renoise.song().selected_sample ~= nil then
renoise.song().instruments[renoise.song().selected_instrument_index].sample_mappings[1][renoise.song().selected_sample_index].map_velocity_to_volume=true
end
end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Sample Velocity Tracking Off",
invoke=function()
if renoise.song().selected_sample ~= nil then
renoise.song().instruments[renoise.song().selected_instrument_index].sample_mappings[1][renoise.song().selected_sample_index].map_velocity_to_volume=false
end
end}
-------------
function selectInstrumentShortcut(instrumentNumber)
local instrument = renoise.song().instruments[renoise.song().selected_instrument_index]
local instCount = #renoise.song().instruments
if instCount < instrumentNumber then
renoise.app():show_status("This Instrument Number does not exist: " .. instrumentNumber)
else
renoise.song().selected_instrument_index = instrumentNumber
end
end
for i = 0, 32 do
renoise.tool():add_keybinding{name="Global:Paketti:Select Instrument " .. formatDigits(2,i),invoke=function() selectInstrumentShortcut(i) end}
end
------
function selectNextGroupTrack()
local song = renoise.song()
local current_index = song.selected_track_index
local num_tracks = #song.tracks
-- Start from the next track of the currently selected one and loop around if necessary
for i = current_index + 1, num_tracks + current_index do
-- Use modulo operation to wrap around the track index when it exceeds the number of tracks
local track_index = (i - 1) % num_tracks + 1
if song.tracks[track_index].type == renoise.Track.TRACK_TYPE_GROUP then
song.selected_track_index = track_index
print("Moved to next group track: " .. song.tracks[track_index].name)
return -- Exit after finding and moving to the next group track
end
end
end
function selectPreviousGroupTrack()
local song = renoise.song()
local current_index = song.selected_track_index
local num_tracks = #song.tracks
-- Start from the track just before the currently selected one and loop around if necessary
for i = current_index - 1, current_index - num_tracks, -1 do
-- Use modulo operation to wrap around the track index when it goes below 1
local track_index = (i - 1) % num_tracks + 1
if song.tracks[track_index].type == renoise.Track.TRACK_TYPE_GROUP then
song.selected_track_index = track_index
print("Moved to previous group track: " .. song.tracks[track_index].name)
return -- Exit after finding and moving to the previous group track
end
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Select Group (Next)", invoke=function() selectNextGroupTrack() end}
renoise.tool():add_keybinding{name="Global:Paketti:Select Group (Previous)", invoke=function() selectPreviousGroupTrack() end}
renoise.tool():add_keybinding{name="Global:Paketti:Delete / Clear / Wipe Entire Row", invoke=function() renoise.song().selected_line:clear() end}
renoise.tool():add_keybinding{
name = "Global:Paketti:Delete / Clear / Wipe Selected Note Column with EditStep",
invoke = function()
local song = renoise.song()
local pattern = song.selected_pattern
local num_lines = pattern.number_of_lines
local edit_step = song.transport.edit_step
local line_index = song.selected_line_index
local note_column = song.selected_note_column
-- Ensure we have a selected note column
if note_column then
-- Wipe the selected note column contents (note, instrument, volume, panning, delay, samplefx)
note_column:clear()
end
-- Calculate the next line index
local next_line_index = line_index + edit_step
if next_line_index > num_lines then
next_line_index = next_line_index - num_lines
end
-- Move to the next line
song.selected_line_index = next_line_index
-- Show status to notify the action performed
renoise.app():show_status("Wiped selected note column and moved by edit step")
end
}
-----
renoise.tool():add_menu_entry{name="--Sample Editor:Paketti..:Set Selected Instrument Velocity Tracking On",invoke=function() selectedInstrumentVelocityTracking(1) end}
renoise.tool():add_menu_entry{name="Sample Editor:Paketti..:Set Selected Instrument Velocity Tracking Off",invoke=function() selectedInstrumentVelocityTracking(0) end}
renoise.tool():add_menu_entry{name="--Sample Mappings:Paketti..:Set Selected Instrument Velocity Tracking On",invoke=function() selectedInstrumentVelocityTracking(1) end}
renoise.tool():add_menu_entry{name="Sample Mappings:Paketti..:Set Selected Instrument Velocity Tracking Off",invoke=function() selectedInstrumentVelocityTracking(0) end}
function setInstrumentVolume(amount)
-- Access the currently selected instrument in Renoise
local instrument = renoise.song().selected_instrument
-- Iterate through all samples in the instrument
for i = 1, #instrument.samples do
-- Access each sample's volume property
local currentVolume = instrument.samples[i].volume
local newVolume = currentVolume + amount
-- Clamp the volume value to be within the valid range of 0.0 to 4.0
if newVolume > 4.0 then
newVolume = 4.0
elseif newVolume < 0.0 then
newVolume = 0.0
end
-- Apply the new volume value to the sample
instrument.samples[i].volume = newVolume
end
end
-- Keybindings to adjust the volume of all samples in the selected instrument
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Volume (All) (+0.01)",invoke=function() setInstrumentVolume(0.01) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Volume (All) (-0.01)",invoke=function() setInstrumentVolume(-0.01) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Volume Reset (All) (0.0dB)",invoke=function()
local instrument = renoise.song().selected_instrument
for i=1, #instrument.samples do instrument.samples[i].volume=1 end end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Volume (All) (-INF dB)",invoke=function()
local instrument = renoise.song().selected_instrument
for i=1, #instrument.samples do instrument.samples[i].volume=0 end end}
function setActualInstrumentVolume(amount)
local instrument = renoise.song().selected_instrument
if not instrument then
renoise.app():show_status("Cannot set volume: No instrument selected.")
return
end
local currentVolume = instrument.volume
local newVolume = currentVolume + amount
-- Clamp the volume value to be within the valid range of 0.0 to 1.99526
if newVolume > 1.99526 then
newVolume = 1.99526
elseif newVolume < 0.0 then
newVolume = 0.0
end
-- Apply the new volume value to the instrument
instrument.volume = newVolume
renoise.app():show_status("Instrument volume set to " .. newVolume)
end
renoise.tool():add_keybinding{name = "Global:Paketti:Set Selected Instrument Global Volume (+0.01)",invoke = function() setActualInstrumentVolume(0.01) end}
renoise.tool():add_keybinding{name = "Global:Paketti:Set Selected Instrument Global Volume (-0.01)",invoke = function() setActualInstrumentVolume(-0.01) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Global Volume (0.0dB)",invoke=function()
renoise.song().selected_instrument.volume=1 end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Global Volume (-INF dB)",invoke=function()
renoise.song().selected_instrument.volume=0 end}
function setInstrumentPanning(amount)
-- Access the currently selected instrument in Renoise
local instrument = renoise.song().selected_instrument
-- Iterate through all samples in the instrument
for i = 1, #instrument.samples do
-- Access each sample's panning property
local currentPanning = instrument.samples[i].panning
local newPanning = currentPanning + amount
-- Clamp the panning value to be within the valid range of 0.0 to 1.0
if newPanning > 1.0 then
newPanning = 1.0
elseif newPanning < 0.0 then
newPanning = 0.0
end
-- Apply the new panning value to the sample
instrument.samples[i].panning = newPanning
end
end
function setInstrumentPanningValue(value)
-- Access the currently selected instrument in Renoise
local instrument = renoise.song().selected_instrument
-- Iterate through all samples in the instrument
for i = 1, #instrument.samples do
-- Set the panning value to the sample
instrument.samples[i].panning = value
end
end
-- Keybindings to adjust the panning of all samples in the selected instrument
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Panning (+0.01)",invoke=function() setInstrumentPanning(0.01) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Panning (-0.01)",invoke=function() setInstrumentPanning(-0.01) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Panning Reset (Center)",invoke=function() setInstrumentPanningValue(0.5) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Panning 0.0 (Left)",invoke=function() setInstrumentPanningValue(0.0) end}
renoise.tool():add_keybinding{name="Global:Paketti:Set Selected Instrument Panning 1.0 (Right)",invoke=function() setInstrumentPanningValue(1.0) end}
---------
-- Global flag to track whether the Catch Octave notifier is enabled
catch_octave_enabled = false
-- Function to update the octave based on the note string of the currently selected note column
function update_octave_from_selected_note_column()
-- Check if renoise.song() is not nil
if not renoise.song() then
return
end
local song = renoise.song()
local window = renoise.app().window
-- Only proceed if the active middle frame is the Pattern Editor
if window.active_middle_frame ~= renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR then
return
end
local selected_line = song.selected_line
local selected_note_column_index = song.selected_note_column_index
local selected_effect_column_index = song.selected_effect_column_index
-- Check if the current selection is a note column and not an effect column
if selected_note_column_index > 0 and selected_effect_column_index == 0 then
local note_column = selected_line.note_columns[selected_note_column_index]
-- Check if the note string is not empty
if note_column.note_string ~= "" then
-- Extract the octave part from the note string (last character)
local note_string = note_column.note_string
local octave = tonumber(note_string:sub(-1))
-- Clamp the octave value to the range 0-8
if octave then
if octave > 8 then
octave = 8
end
song.transport.octave = octave
end
end
end
end
-- Function to add notifiers
function add_notifiers()
-- Check if renoise.song() is not nil
if not renoise.song() then
return
end
-- Add notifiers to trigger the function when the selected track or pattern changes
local song = renoise.song()
song.selected_track_index_observable:add_notifier(update_octave_from_selected_note_column)
song.selected_pattern_observable:add_notifier(update_octave_from_selected_note_column)
-- Periodic check for changes in the selected line index
renoise.tool().app_idle_observable:add_notifier(update_octave_from_selected_note_column)
end
-- Function to remove notifiers
function remove_notifiers()
-- Check if renoise.song() is not nil
if not renoise.song() then
return
end
-- Remove the notifiers
local song = renoise.song()
pcall(function() song.selected_track_index_observable:remove_notifier(update_octave_from_selected_note_column) end)
pcall(function() song.selected_pattern_observable:remove_notifier(update_octave_from_selected_note_column) end)
pcall(function() renoise.tool().app_idle_observable:remove_notifier(update_octave_from_selected_note_column) end)
end
-- Function to toggle the Catch Octave state
function toggle_catch_octave()
if catch_octave_enabled then
remove_notifiers()
catch_octave_enabled = false
renoise.app():show_status("Catch Octave disabled")
else
add_notifiers()
catch_octave_enabled = true
renoise.app():show_status("Catch Octave enabled")
end
end
-- Add a menu entry and key binding for toggling Catch Octave
renoise.tool():add_menu_entry{name="--Main Menu:Tools:Paketti..:Pattern Editor..:Catch Octave",invoke = toggle_catch_octave}
renoise.tool():add_menu_entry{name="--Main Menu:Tools:Paketti..:Clone Current Sequence",invoke=clone_current_sequence}
renoise.tool():add_keybinding{name="Global:Paketti:Catch Octave",invoke=toggle_catch_octave}
-- Initial call to add notifiers if enabled
if catch_octave_enabled then
add_notifiers()
end
-----
-- Function to adjust the slice marker by a specified delta
function adjustSliceKeyshortcut(slice_index, delta)
local song = renoise.song()
local sample = song.selected_sample
-- Ensure there is a selected sample and enough slice markers