Repository navigation
Expand file tree
/
Copy pathPakettiGater.lua
More file actions
1841 lines (1641 loc) · 63.2 KB
/
Copy pathPakettiGater.lua
File metadata and controls
1841 lines (1641 loc) · 63.2 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
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
local vb = renoise.ViewBuilder()
local dialog
local checkboxes = {}
local retrig_checkboxes = {}
local playback_checkboxes = {}
local num_checkboxes = 16
local max_rows = 64
local column_choice = "FX Column"
local retrig_value = 4
local retrig_column_choice = "FX Column"
local active_steps_volume = num_checkboxes
local active_steps_retrig = num_checkboxes
local active_steps_playback = num_checkboxes
local panning_left_checkboxes = {}
local panning_center_checkboxes = {}
local panning_right_checkboxes = {}
local panning_buttons = {}
local active_steps_panning = num_checkboxes
local panning_column_choice = "FX Column"
local initializing = false -- Flag to control printing during initialization or fetching
-- Add at the top with other globals
local auto_grab = false
local previous_track_index = nil
local track_notifier = nil
-- Colors for buttons
local normal_color = nil
local highlight_color = {0x22, 0xaa, 0xff}
-- Initialize buttons and checkboxes
local buttons = {}
local retrig_buttons = {}
local playback_buttons = {}
-- Paketti Gater Device Script
local function initialize_checkboxes(count)
checkboxes = {}
retrig_checkboxes = {}
playback_checkboxes = {}
buttons = {}
retrig_buttons = {}
playback_buttons = {}
panning_left_checkboxes = {}
panning_center_checkboxes = {}
panning_right_checkboxes = {}
panning_buttons = {}
for i = 1, count do
local is_highlight = (i == 1 or i == 5 or i == 9 or i == 13)
buttons[i] = vb:button {
text = string.format("%02d", i),
width = 30,
color = is_highlight and highlight_color or normal_color
}
retrig_buttons[i] = vb:button {
text = string.format("%02d", i),
width = 30,
color = is_highlight and highlight_color or normal_color
}
playback_buttons[i] = vb:button {
text = string.format("%02d", i),
width = 30,
color = is_highlight and highlight_color or normal_color
}
checkboxes[i] = vb:checkbox {
value = false,
width = 30,
notifier = function()
if not initializing then
insert_commands()
end
end
}
retrig_checkboxes[i] = vb:checkbox {
value = false,
width = 30,
notifier = function()
if not initializing then
insert_commands()
end
end
}
playback_checkboxes[i] = vb:checkbox {
value = false,
width = 30,
notifier = function()
if not initializing then
insert_commands()
end
end
}
end
for i = 1, count do
panning_left_checkboxes[i] = vb:checkbox {
value = false,
width = 30,
notifier = function()
if panning_left_checkboxes[i].value then
panning_center_checkboxes[i].value = false
panning_right_checkboxes[i].value = false
end
if not initializing then
insert_commands()
end
end
}
panning_center_checkboxes[i] = vb:checkbox {
value = true,
width = 30,
notifier = function()
if panning_center_checkboxes[i].value then
panning_left_checkboxes[i].value = false
panning_right_checkboxes[i].value = false
end
if not initializing then
insert_commands()
end
end
}
panning_right_checkboxes[i] = vb:checkbox {
value = false,
width = 30,
notifier = function()
if panning_right_checkboxes[i].value then
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = false
end
if not initializing then
insert_commands()
end
end
}
panning_buttons[i] = vb:button {
text = string.format("%02d", i),
width = 30,
color = (i == 1 or i == 5 or i == 9 or i == 13) and highlight_color or normal_color
}
end
end
initialize_checkboxes(num_checkboxes)
-- Set active steps based on the valuebox
local function set_active_steps_volume(value)
active_steps_volume = value
renoise.app():show_status("Volume Gater: Step count set to " .. value)
if not initializing then
insert_commands()
end
end
local function set_active_steps_retrig(value)
active_steps_retrig = value
if not initializing then
insert_commands()
end
end
local function set_active_steps_playback(value)
active_steps_playback = value
if not initializing then
insert_commands()
end
end
local function set_active_steps_panning(value)
active_steps_panning = value
if not initializing then
insert_commands()
end
end
-- Receive Volume checkboxes state
local function receive_volume_checkboxes()
if not renoise.song() then return end
initializing = true -- Halt printing during fetching
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
local visible_note_columns = track.visible_note_columns
for i = 1, num_checkboxes do
local line_index = 1 + i -1
if line_index <= max_rows then
local line = pattern:track(track_index):line(line_index)
if column_choice == "FX Column" then
checkboxes[i].value = (line.effect_columns[1].number_string == "0C" and line.effect_columns[1].amount_string == "0F")
elseif column_choice == "Volume Column" then
checkboxes[i].value = false
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
if note_column.volume_string == "80" then
checkboxes[i].value = true
break
end
end
elseif column_choice == "FX Column (L00)" then
checkboxes[i].value = (line.effect_columns[1].number_string == "0L" and line.effect_columns[1].amount_string == "C0")
end
end
end
-- IMPORTANT: Don't call insert_commands() here as it would overwrite other effects
-- Instead, only write the volume pattern to the first active_steps_volume rows
local pattern_length = pattern.number_of_lines
-- Only write volume effects, don't clear other effects
local any_checkbox_checked = false
for i = 1, num_checkboxes do
if checkboxes[i].value then
any_checkbox_checked = true
break
end
end
if any_checkbox_checked then
-- Only write up to active_steps_volume
for i = 1, active_steps_volume do
local line = pattern:track(track_index):line(i)
-- Get the actual checkbox index, looping if needed
local checkbox_idx = ((i - 1) % active_steps_volume) + 1
if column_choice == "FX Column" then
if checkboxes[checkbox_idx].value then
line.effect_columns[1].number_string = "0C"
line.effect_columns[1].amount_string = "0F"
else
line.effect_columns[1].number_string = "0C"
line.effect_columns[1].amount_string = "00"
end
elseif column_choice == "Volume Column" then
track.volume_column_visible = true
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
-- Only update if not used by retrig
if retrig_column_choice ~= "Volume Column" or
string.sub(note_column.volume_string, 1, 1) ~= "R" then
if checkboxes[checkbox_idx].value then
note_column.volume_string = "80"
else
note_column.volume_string = "00"
end
end
end
elseif column_choice == "FX Column (L00)" then
if checkboxes[checkbox_idx].value then
line.effect_columns[1].number_string = "0L"
line.effect_columns[1].amount_string = "C0"
else
line.effect_columns[1].number_string = "0L"
line.effect_columns[1].amount_string = "00"
end
end
end
-- Replicate the volume pattern to the rest of the pattern
for row = active_steps_volume + 1, pattern_length do
local dest_line = pattern:track(track_index):line(row)
local source_row = ((row - 1) % active_steps_volume) + 1
local source_line = pattern:track(track_index):line(source_row)
if column_choice == "FX Column" or column_choice == "FX Column (L00)" then
dest_line.effect_columns[1]:copy_from(source_line.effect_columns[1])
elseif column_choice == "Volume Column" then
for col = 1, visible_note_columns do
-- Only copy if not a retrig value
if retrig_column_choice ~= "Volume Column" or
string.sub(source_line:note_column(col).volume_string, 1, 1) ~= "R" then
dest_line:note_column(col).volume_string = source_line:note_column(col).volume_string
end
end
end
end
end
initializing = false
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.app():show_status("Received Volume Gater pattern")
end
-- Receive Retrig checkboxes state
local function receive_retrig_checkboxes()
if not renoise.song() then return end
initializing = true
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
local visible_note_columns = track.visible_note_columns
local pattern_length = pattern.number_of_lines
-- First, read the current pattern to set checkbox states
for i = 1, num_checkboxes do
local line_index = 1 + i - 1
if line_index <= max_rows then
local line = pattern:track(track_index):line(line_index)
if retrig_column_choice == "FX Column" then
retrig_checkboxes[i].value = (line.effect_columns[2].number_string == "0R")
elseif retrig_column_choice == "Volume Column" then
retrig_checkboxes[i].value = false
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
if string.sub(note_column.volume_string, 1, 1) == "R" then
retrig_checkboxes[i].value = true
break
end
end
elseif retrig_column_choice == "Panning Column" then
renoise.song().selected_track.panning_column_visible = true
retrig_checkboxes[i].value = false
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
if string.sub(note_column.panning_string, 1, 1) == "R" then
retrig_checkboxes[i].value = true
break
end
end
end
end
end
-- Now write the retrig pattern based on checkboxes, but don't call insert_commands()
-- Clear the retrig columns first
if retrig_column_choice == "FX Column" then
clear_retrig()
elseif retrig_column_choice == "Volume Column" then
-- Only clear volume column if not used by volume gater
if column_choice ~= "Volume Column" then
clear_volume_column()
end
elseif retrig_column_choice == "Panning Column" then
-- Only clear panning column if not used by panning gater
if panning_column_choice ~= "Panning Column" then
clear_panning_column()
end
end
-- Write retrig pattern based on checkboxes
local retrig_is_empty = true
for i = 1, num_checkboxes do
if retrig_checkboxes[i].value then
retrig_is_empty = false
break
end
end
if not retrig_is_empty then
-- Only write up to active_steps_retrig
for i = 1, active_steps_retrig do
local line = pattern:track(track_index):line(i)
-- Get the actual checkbox index, looping if needed
local checkbox_idx = ((i - 1) % active_steps_retrig) + 1
if retrig_checkboxes[checkbox_idx].value then
if retrig_column_choice == "FX Column" then
line.effect_columns[2].number_string = "0R"
line.effect_columns[2].amount_string = string.format("%02X", retrig_value)
elseif retrig_column_choice == "Volume Column" then
track.volume_column_visible = true
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
-- Only update if not used by volume gater
if column_choice ~= "Volume Column" or
note_column.volume_string == "" or
note_column.volume_string == "00" or
note_column.volume_string == "80" then
note_column.volume_string = string.format("R%X", retrig_value)
end
end
elseif retrig_column_choice == "Panning Column" then
renoise.song().selected_track.panning_column_visible = true
for j = 1, visible_note_columns do
local note_column = line:note_column(j)
-- Only update if not used by panning gater
if panning_column_choice ~= "Panning Column" or
note_column.panning_string == "" or
note_column.panning_string == "40" or
note_column.panning_string == "00" or
note_column.panning_string == "80" then
note_column.panning_string = string.format("R%X", retrig_value)
end
end
end
end
end
-- Replicate the retrig pattern to the rest of the pattern
for row = active_steps_retrig + 1, pattern_length do
local dest_line = pattern:track(track_index):line(row)
local source_row = ((row - 1) % active_steps_retrig) + 1
local source_line = pattern:track(track_index):line(source_row)
if retrig_column_choice == "FX Column" then
dest_line.effect_columns[2]:copy_from(source_line.effect_columns[2])
elseif retrig_column_choice == "Volume Column" then
for col = 1, visible_note_columns do
if string.sub(source_line:note_column(col).volume_string, 1, 1) == "R" then
dest_line:note_column(col).volume_string = source_line:note_column(col).volume_string
end
end
elseif retrig_column_choice == "Panning Column" then
for col = 1, visible_note_columns do
if string.sub(source_line:note_column(col).panning_string, 1, 1) == "R" then
dest_line:note_column(col).panning_string = source_line:note_column(col).panning_string
end
end
end
end
end
initializing = false
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.app():show_status("Received Retrig Gater pattern")
end
-- Receive Playback checkboxes state
local function receive_playback_checkboxes()
if not renoise.song() then return end
initializing = true
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
local pattern_length = pattern.number_of_lines
-- First, read the current pattern to set checkbox states
for i = 1, num_checkboxes do
local line_index = 1 + i - 1
if line_index <= max_rows then
local line = pattern:track(track_index):line(line_index)
playback_checkboxes[i].value = (line.effect_columns[3].number_string == "0B" and line.effect_columns[3].amount_string == "00")
end
end
-- IMPORTANT: Don't call clear_playback_effect() as it would wipe the content
-- Instead, only update the existing pattern without clearing
-- Write playback pattern based on checkboxes
local any_playback_checked = false
for i = 1, num_checkboxes do
if playback_checkboxes[i].value then
any_playback_checked = true
break
end
end
if any_playback_checked then
-- Only write up to active_steps_playback
for i = 1, active_steps_playback do
local line = pattern:track(track_index):line(i)
-- Get the actual checkbox index, looping if needed
local checkbox_idx = ((i - 1) % active_steps_playback) + 1
-- Ensure the third effect column is visible
if track.visible_effect_columns < 3 then
track.visible_effect_columns = 4
end
if playback_checkboxes[checkbox_idx].value then
line.effect_columns[3].number_string = "0B"
line.effect_columns[3].amount_string = "00"
else
line.effect_columns[3].number_string = "0B"
line.effect_columns[3].amount_string = "01"
end
end
-- Replicate the playback pattern to the rest of the pattern
for row = active_steps_playback + 1, pattern_length do
local dest_line = pattern:track(track_index):line(row)
local source_row = ((row - 1) % active_steps_playback) + 1
local source_line = pattern:track(track_index):line(source_row)
dest_line.effect_columns[3]:copy_from(source_line.effect_columns[3])
end
end
initializing = false
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.app():show_status("Received Playback Gater pattern")
end
-- Receive Panning checkboxes state
local function receive_panning_checkboxes()
if not renoise.song() then return end
initializing = true
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
local pattern_length = pattern.number_of_lines
-- First, read the current pattern to set checkbox states
for i = 1, num_checkboxes do
local line = pattern:track(track_index):line(i)
if panning_column_choice == "Panning Column" then
renoise.song().selected_track.panning_column_visible = true
if line:note_column(1).panning_string == "00" then
panning_left_checkboxes[i].value = true
panning_center_checkboxes[i].value = false
panning_right_checkboxes[i].value = false
elseif line:note_column(1).panning_string == "80" then
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = false
panning_right_checkboxes[i].value = true
elseif line:note_column(1).panning_string == "40" then
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = true
panning_right_checkboxes[i].value = false
end
elseif panning_column_choice == "FX Column" then
if line.effect_columns[4].number_string == "0P" then
if line.effect_columns[4].amount_string == "00" then
panning_left_checkboxes[i].value = true
panning_center_checkboxes[i].value = false
panning_right_checkboxes[i].value = false
elseif line.effect_columns[4].amount_string == "FF" then
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = false
panning_right_checkboxes[i].value = true
elseif line.effect_columns[4].amount_string == "7F" then
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = true
panning_right_checkboxes[i].value = false
end
end
end
end
-- Now write the panning pattern based on checkboxes, but don't call insert_commands()
-- Clear the panning columns first
if panning_column_choice == "FX Column" then
clear_effect_column_4()
elseif panning_column_choice == "Panning Column" then
-- Only clear if not used by retrig
if retrig_column_choice ~= "Panning Column" then
clear_panning_column()
end
end
-- Write panning pattern based on checkboxes
local all_panning_center = true
for i = 1, num_checkboxes do
if panning_left_checkboxes[i].value or panning_right_checkboxes[i].value then
all_panning_center = false
break
end
end
if not all_panning_center then
-- Only write up to active_steps_panning
for i = 1, active_steps_panning do
local line = pattern:track(track_index):line(i)
-- Get the actual checkbox index, looping if needed
local checkbox_idx = ((i - 1) % active_steps_panning) + 1
if panning_column_choice == "Panning Column" then
renoise.song().selected_track.panning_column_visible = true
if panning_left_checkboxes[checkbox_idx].value then
line:note_column(1).panning_string = "00"
elseif panning_right_checkboxes[checkbox_idx].value then
line:note_column(1).panning_string = "80"
else
line:note_column(1).panning_string = "40"
end
elseif panning_column_choice == "FX Column" then
if panning_left_checkboxes[checkbox_idx].value then
line.effect_columns[4].number_string = "0P"
line.effect_columns[4].amount_string = "00"
elseif panning_right_checkboxes[checkbox_idx].value then
line.effect_columns[4].number_string = "0P"
line.effect_columns[4].amount_string = "FF"
else
line.effect_columns[4].number_string = "0P"
line.effect_columns[4].amount_string = "7F"
end
end
end
-- Replicate the panning pattern to the rest of the pattern
for row = active_steps_panning + 1, pattern_length do
local dest_line = pattern:track(track_index):line(row)
local source_row = ((row - 1) % active_steps_panning) + 1
local source_line = pattern:track(track_index):line(source_row)
if panning_column_choice == "FX Column" then
dest_line.effect_columns[4]:copy_from(source_line.effect_columns[4])
elseif panning_column_choice == "Panning Column" then
for col = 1, #source_line.note_columns do
-- Only copy panning values, not retrig values
if string.sub(source_line:note_column(col).panning_string, 1, 1) ~= "R" then
dest_line:note_column(col).panning_string = source_line:note_column(col).panning_string
end
end
end
end
end
initializing = false
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.app():show_status("Received Panning Gater pattern")
end
local function rand_volume_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while setting values
for i = 1, num_checkboxes do
checkboxes[i].value = (i <= active_steps_volume) and (math.random() > 0.5) or false
end
initializing = false
insert_commands() -- Single update at the end
end
-- Randomize Retrig checkboxes
local function rand_retrig_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while setting values
for i = 1, num_checkboxes do
retrig_checkboxes[i].value = (i <= active_steps_retrig) and (math.random() > 0.5) or false
end
initializing = false
insert_commands() -- Single update at the end
end
-- Randomize Playback checkboxes
local function rand_playback_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while setting values
for i = 1, num_checkboxes do
playback_checkboxes[i].value = (i <= active_steps_playback) and (math.random() > 0.5) or false
end
initializing = false
insert_commands() -- Single update at the end
end
-- Randomize Panning checkboxes
local function rand_panning_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while setting values
for i = 1, num_checkboxes do
if i <= active_steps_panning then
local rand_choice = math.random(1, 3)
panning_left_checkboxes[i].value = (rand_choice == 1)
panning_center_checkboxes[i].value = (rand_choice == 2)
panning_right_checkboxes[i].value = (rand_choice == 3)
else
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = true
panning_right_checkboxes[i].value = false
end
end
initializing = false
insert_commands() -- Single update at the end
end
-- Clear Volume Gater
local function clear_volume_gater()
if not renoise.song() then return end
initializing = true -- Prevent updates while clearing checkboxes
-- Clear checkboxes
for i = 1, num_checkboxes do
checkboxes[i].value = false
end
-- Clear the actual pattern content
if column_choice == "FX Column" or column_choice == "FX Column (L00)" then
clear_effect_columns()
elseif column_choice == "Volume Column" then
clear_volume_column()
end
initializing = false
insert_commands() -- Single update at the end
end
-- Clear Retrig checkboxes
local function clear_retrig_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while clearing checkboxes
-- Clear checkboxes
for i = 1, num_checkboxes do
retrig_checkboxes[i].value = false
end
-- Clear the actual pattern content
if retrig_column_choice == "FX Column" then
clear_retrig()
elseif retrig_column_choice == "Volume Column" then
if column_choice ~= "Volume Column" then -- Only if not used by volume gater
clear_volume_column()
end
elseif retrig_column_choice == "Panning Column" then
if panning_column_choice ~= "Panning Column" then -- Only if not used by panning gater
clear_panning_column()
end
end
initializing = false
insert_commands() -- Single update at the end
end
-- Clear Playback checkboxes
local function clear_playback_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while clearing checkboxes
-- Clear checkboxes
for i = 1, num_checkboxes do
playback_checkboxes[i].value = false
end
-- Clear the actual pattern content
clear_playback_effect()
initializing = false
insert_commands() -- Single update at the end
end
-- Clear Panning checkboxes
local function clear_panning_checkboxes()
if not renoise.song() then return end
initializing = true -- Prevent updates while clearing checkboxes
-- Clear checkboxes
for i = 1, num_checkboxes do
panning_left_checkboxes[i].value = false
panning_center_checkboxes[i].value = true
panning_right_checkboxes[i].value = false
end
-- Clear the actual pattern content
if panning_column_choice == "FX Column" then
clear_effect_column_4()
elseif panning_column_choice == "Panning Column" then
if retrig_column_choice ~= "Panning Column" then -- Only if not used by retrig
clear_panning_column()
end
end
initializing = false
insert_commands() -- Single update at the end
end
-- Shift checkboxes left or right
local function shift_checkboxes(direction)
if not renoise.song() then return end
local shifted = {}
if direction == "left" then
for i = 1, num_checkboxes do
shifted[i] = checkboxes[(i % num_checkboxes) + 1].value
end
elseif direction == "right" then
for i = 1, num_checkboxes do
shifted[i] = checkboxes[((i - 2) % num_checkboxes) + 1].value
end
end
for i = 1, num_checkboxes do
checkboxes[i].value = shifted[i] and i <= active_steps_volume
end
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
if not initializing then
insert_commands()
end
end
-- Shift retrig checkboxes left or right
local function shift_retrig_checkboxes(direction)
if not renoise.song() then return end
local shifted = {}
if direction == "left" then
for i = 1, num_checkboxes do
shifted[i] = retrig_checkboxes[(i % num_checkboxes) + 1].value
end
elseif direction == "right" then
for i = 1, num_checkboxes do
shifted[i] = retrig_checkboxes[((i - 2) % num_checkboxes) + 1].value
end
end
for i = 1, num_checkboxes do
retrig_checkboxes[i].value = shifted[i] and i <= active_steps_retrig
end
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
if not initializing then
insert_commands()
end
end
-- Shift playback checkboxes left or right
local function shift_playback_checkboxes(direction)
if not renoise.song() then return end
local shifted = {}
if direction == "left" then
for i = 1, num_checkboxes do
shifted[i] = playback_checkboxes[(i % num_checkboxes) + 1].value
end
elseif direction == "right" then
for i = 1, num_checkboxes do
shifted[i] = playback_checkboxes[((i - 2) % num_checkboxes) + 1].value
end
end
for i = 1, num_checkboxes do
playback_checkboxes[i].value = shifted[i] and i <= active_steps_playback
end
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
if not initializing then
insert_commands()
end
end
-- Shift panning checkboxes left or right
local function shift_panning_checkboxes(direction)
if not renoise.song() then return end
local shifted_left = {}
local shifted_center = {}
local shifted_right = {}
if direction == "left" then
for i = 1, num_checkboxes do
shifted_left[i] = panning_left_checkboxes[(i % num_checkboxes) + 1].value
shifted_center[i] = panning_center_checkboxes[(i % num_checkboxes) + 1].value
shifted_right[i] = panning_right_checkboxes[(i % num_checkboxes) + 1].value
end
elseif direction == "right" then
for i = 1, num_checkboxes do
shifted_left[i] = panning_left_checkboxes[((i - 2) % num_checkboxes) + 1].value
shifted_center[i] = panning_center_checkboxes[((i - 2) % num_checkboxes) + 1].value
shifted_right[i] = panning_right_checkboxes[((i - 2) % num_checkboxes) + 1].value
end
end
for i = 1, num_checkboxes do
panning_left_checkboxes[i].value = shifted_left[i]
panning_center_checkboxes[i].value = shifted_center[i]
panning_right_checkboxes[i].value = shifted_right[i]
end
if not initializing then
insert_commands()
end
end
-- Clear Effect Columns
function clear_effect_columns()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
for j = 1, #line.effect_columns do
if line.effect_columns[j].number_string == "0C" or line.effect_columns[j].number_string == "0L" then
line.effect_columns[j].number_string = ""
line.effect_columns[j].amount_string = ""
end
end
end
renoise.app():show_status("Cleared FX Column")
end
-- Add this at the top of the file with other globals
local suppress_status_messages = false
-- Modify the clear_retrig function to respect the suppress flag
function clear_retrig()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
line.effect_columns[2].number_string = ""
line.effect_columns[2].amount_string = ""
end
if not suppress_status_messages then
renoise.app():show_status("Cleared Retrig Effect")
end
end
-- Similarly modify other clear functions to respect the suppress flag
function clear_volume_column()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
for j = 1, track.visible_note_columns do
line:note_column(j).volume_string = ""
end
end
if not suppress_status_messages then
renoise.app():show_status("Cleared Volume Column")
end
end
function clear_panning_column()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
local track = renoise.song().selected_track
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
for j = 1, track.visible_note_columns do
line:note_column(j).panning_string = ""
end
end
if not suppress_status_messages then
renoise.app():show_status("Cleared Panning Column")
end
end
-- Clear Playback Effect
function clear_playback_effect()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
line.effect_columns[3].number_string = ""
line.effect_columns[3].amount_string = ""
end
if not suppress_status_messages then
renoise.app():show_status("Cleared Playback Effect")
end
end
-- Clear Effect Column 4
function clear_effect_column_4()
if not renoise.song() then return end
local pattern = renoise.song().selected_pattern
local track_index = renoise.song().selected_track_index
for i = 1, max_rows do
local line = pattern:track(track_index):line(i)
if line.effect_columns[4] then
if line.effect_columns[4].number_string == "0P" then
line.effect_columns[4].number_string = ""
line.effect_columns[4].amount_string = ""
end
end
end
renoise.app():show_status("Cleared Effect Column 4")
end
-- Now modify the insert_commands function to be more efficient
function insert_commands()
max_rows = renoise.song().selected_pattern.number_of_lines
if not renoise.song() then return end
-- Suppress status messages during batch operations
suppress_status_messages = true
local pattern = renoise.song().selected_pattern
local track = renoise.song().selected_track
local track_index = renoise.song().selected_track_index
local visible_note_columns = track.visible_note_columns
-- IMPORTANT: Only clear retrig columns if we're actually writing to them
local retrig_is_empty = true
for i = 1, num_checkboxes do
if retrig_checkboxes[i].value then