-
Notifications
You must be signed in to change notification settings - Fork 14
/
encoder_actions.lua
executable file
·1277 lines (1199 loc) · 52.7 KB
/
encoder_actions.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
local encoder_actions = {}
local ea = encoder_actions
ea.sc = {}
function encoder_actions.init(n,d)
if menu == "macro_config" then
macros.enc(n,d)
elseif menu == "MIDI_config" then
mc.midi_config_enc(n,d)
elseif menu == "transport_config" then
transport.enc(n,d)
end
local function returns_target(i)
if bank[i].focus_hold then
return bank[i].focus_pad
elseif page.loops.frame == 1 then
return bank[i].id
elseif page.loops.frame == 2 then
if grid_pat[i].play == 0 and midi_pat[i].play == 0 and not arp[i].playing and rytm.track[i].k == 0 then
return bank[i].id
else
if key1_hold and page.loops.meta_sel == i then
return bank[i].focus_pad
else
return bank[i].id
end
end
end
end
local function adjust_loops(d,func)
if page.loops.frame == 2 then
if page.loops.meta_sel ~= 4 then
local i = page.loops.meta_sel
local resolution = key1_hold and 100 or 10
ea[func](bank[i][returns_target(i)],d/resolution)
if bank[i].focus_hold == false or bank[i].focus_pad == bank[i].id then
ea.sc[func](i)
end
else
if func == "move_start" then
ea.move_rec_start(d)
elseif func == "move_end" then
ea.move_rec_end(d)
elseif func == "move_play_window" then
ea.move_rec_window(rec[rec.focus],d)
if rec.play_segment == rec.focus then
ea.sc.move_rec_window(rec[rec.focus])
end
end
end
end
end
if n == 1 then
if menu == 1 then
page.main_sel = util.clamp(page.main_sel+d,1,9)
elseif menu == 2 then
if page.loops.frame == 1 then
if key1_hold then
page.loops.top_option_set[page.loops.sel] = util.clamp(page.loops.top_option_set[page.loops.sel] + d,1,2)
else
page.loops.sel = util.clamp(page.loops.sel+d,1,5)
end
elseif page.loops.frame == 2 then
local id = page.loops.sel
if id < 4 then
if key1_hold then
ea.change_pad(id,d)
elseif key2_hold then
page.loops.top_option_set[page.loops.sel] = util.clamp(page.loops.top_option_set[page.loops.sel] + d,1,2)
else
-- local which_pad = nil
-- if bank[id].focus_hold == false then
-- which_pad = bank[id].id
-- else
-- which_pad = bank[id].focus_pad
-- end
local which_pad;
if bank[id].focus_hold then
which_pad = bank[id].focus_pad
elseif grid_pat[id].play == 0 and midi_pat[id].play == 0 and not arp[id].playing and rytm.track[id].k == 0 then
which_pad = bank[id].id
else
which_pad = bank[id].focus_pad
end
local resolution = loop_enc_resolution[id]
ea.move_play_window(bank[id][which_pad],d/resolution)
if bank[id].focus_hold == false then
ea.sc.move_play_window(id)
end
end
elseif id == 4 then
if key1_hold then
ea.change_buffer(rec[rec.focus],d)
else
ea.move_rec_window(rec[rec.focus],d)
if rec.play_segment == rec.focus then
ea.sc.move_rec_window(rec[rec.focus])
end
end
elseif id == 5 then
if key1_hold and not key2_hold then
if page.loops.meta_sel < 4 then
ea.change_pad(page.loops.meta_sel,d)
elseif page.loops.meta_sel == 4 then
rec.focus = util.clamp(rec.focus + d,1,3)
end
grid_dirty = true
elseif not key1_hold and not key2_hold then
page.loops.meta_sel = util.clamp(page.loops.meta_sel + d,1,4)
elseif key2_hold and not key1_hold then
adjust_loops(d,"move_play_window")
end
end
end
elseif menu == 6 then
page.delay.focus = util.clamp(page.delay.focus+d,1,2)
elseif menu == 7 then
page.time_sel = util.clamp(page.time_sel+d,1,6)
elseif menu == 8 then
rytm.track_edit = util.clamp(rytm.track_edit+d,1,3)
elseif menu == 9 then
page.arp_page_sel = util.clamp(page.arp_page_sel+d,1,3)
elseif menu == 10 then
page.rnd_page = util.clamp(page.rnd_page+d,1,3)
-- elseif menu == "MIDI_config" then
-- if page.midi_focus == "header" then
-- page.midi_bank = util.clamp(page.midi_bank + d,1,3)
-- else
-- local i = page.midi_bank
-- mc.numbers[i]:set_index_delta(d)
-- mc.midi_notes[i]:set_index_delta(d)
-- mc.midi_notes_channels[i]:set_index_delta(d)
-- mc.midi_notes_velocities[i]:set_index_delta(d)
-- mc.midi_ccs[i]:set_index_delta(d)
-- mc.midi_ccs_channels[i]:set_index_delta(d)
-- mc.midi_ccs_values[i]:set_index_delta(d)
-- end
end
end
if n == 2 then
if menu == 1 then
page.main_sel = util.clamp(page.main_sel+d,1,9)
elseif menu == 2 then
local focused_pad;
local id = page.loops.sel
if id < 4 then -- if banks
if bank[page.loops.sel].focus_hold then
focused_pad = bank[id].focus_pad
elseif grid_pat[page.loops.sel].play == 0 and midi_pat[page.loops.sel].play == 0 and not arp[page.loops.sel].playing and rytm.track[page.loops.sel].k == 0 then
focused_pad = bank[id].id
else
focused_pad = bank[id].focus_pad
end
if page.loops.frame == 1 then
if page.loops.top_option_set[page.loops.sel] == 1 then
ea.change_pad_clip(id,d)
-- if key1_hold then
for i = 1,16 do
if i ~= focused_pad then
if bank[id][focused_pad].mode ~= bank[id][i].mode then
local old_mode = bank[id][i].mode
bank[id][i].mode = bank[id][focused_pad].mode
change_mode(bank[id][i],old_mode)
end
jump_clip(id,i,bank[id][focused_pad].clip)
end
end
-- end
elseif page.loops.top_option_set[page.loops.sel] == 2 then
-- if not bank[id].focus_hold then
if bank[id].focus_hold then
local rates ={-4,-2,-1,-0.5,-0.25,-0.125,0,0.125,0.25,0.5,1,2,4}
if bank[id][focused_pad].fifth then
bank[id][focused_pad].fifth = false
end
if tab.key(rates,bank[id][focused_pad].rate) == nil then
bank[id][focused_pad].rate = 1
end
bank[id][focused_pad].rate = rates[util.clamp(tab.key(rates,bank[id][focused_pad].rate)+d,1,#rates)]
if bank[id][focused_pad].pause == false and bank[id].id == focused_pad then
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
end
elseif grid_pat[id].play == 0 and midi_pat[id].play == 0 and not arp[id].playing and rytm.track[id].k == 0 then
params:delta("rate "..id,d)
else
local rates ={-4,-2,-1,-0.5,-0.25,-0.125,0,0.125,0.25,0.5,1,2,4}
if bank[id][focused_pad].fifth then
bank[id][focused_pad].fifth = false
end
if tab.key(rates,bank[id][focused_pad].rate) == nil then
bank[id][focused_pad].rate = 1
end
bank[id][focused_pad].rate = rates[util.clamp(tab.key(rates,bank[id][focused_pad].rate)+d,1,#rates)]
if bank[id][focused_pad].pause == false and bank[id].id == focused_pad then
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
end
end
-- if key1_hold then
for i = 1,16 do
if i ~= focused_pad then
bank[id][i].rate = bank[id][focused_pad].rate
end
end
-- end
end
elseif page.loops.frame == 2 then
if key2_hold then
if page.loops.top_option_set[page.loops.sel] == 1 then
ea.change_pad_clip(id,d)
elseif page.loops.top_option_set[page.loops.sel] == 2 then
if bank[id].focus_hold then
local rates ={-4,-2,-1,-0.5,-0.25,-0.125,0,0.125,0.25,0.5,1,2,4}
if bank[id][focused_pad].fifth then
bank[id][focused_pad].fifth = false
end
if tab.key(rates,bank[id][focused_pad].rate) == nil then
bank[id][focused_pad].rate = 1
end
bank[id][focused_pad].rate = rates[util.clamp(tab.key(rates,bank[id][focused_pad].rate)+d,1,#rates)]
if bank[id][focused_pad].pause == false and bank[id].id == focused_pad then
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
end
elseif grid_pat[id].play == 0 and midi_pat[id].play == 0 and not arp[id].playing and rytm.track[id].k == 0 then
params:delta("rate "..id,d)
else
local rates ={-4,-2,-1,-0.5,-0.25,-0.125,0,0.125,0.25,0.5,1,2,4}
if bank[id][focused_pad].fifth then
bank[id][focused_pad].fifth = false
end
if tab.key(rates,bank[id][focused_pad].rate) == nil then
bank[id][focused_pad].rate = 1
end
bank[id][focused_pad].rate = rates[util.clamp(tab.key(rates,bank[id][focused_pad].rate)+d,1,#rates)]
if bank[id][focused_pad].pause == false and bank[id].id == focused_pad then
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
end
end
end
else
local resolution = loop_enc_resolution[id] * (key1_hold and 10 or 1)
local rs = {1,2,4}
local rate_mod = rs[params:get("live_buff_rate")]
ea.move_start(bank[id][focused_pad],d/(resolution * rate_mod))
if bank[id].focus_hold == false then
ea.sc.move_start(id)
end
end
end
elseif id == 4 then
if page.loops.frame == 1 and page.loops.top_option_set[id] == 1 then
params:delta("live_rec_feedback_"..rec.focus,d)
elseif page.loops.frame == 1 and page.loops.top_option_set[id] == 2 then
params:delta("rec_loop_"..rec.focus,d)
elseif page.loops.frame == 2 then
ea.move_rec_start(d)
if key1_hold then
update_waveform(1,rec[rec.focus].start_point,rec[rec.focus].end_point,128)
end
end
elseif id == 5 then
adjust_loops(d,"move_start")
end
elseif menu == 6 then
if page.delay.section == 1 then
page.delay[page.delay.focus].menu = util.clamp(page.delay[page.delay.focus].menu+d,1,3)
elseif page.delay.section == 2 then
local max_items = {5,6,7}
local target = page.delay[page.delay.focus].menu_sel[page.delay[page.delay.focus].menu]
page.delay[page.delay.focus].menu_sel[page.delay[page.delay.focus].menu] = util.clamp(target+d,1,max_items[page.delay[page.delay.focus].menu])
end
elseif menu == 7 then
local page_line = page.time_page_sel
local pattern_page = page.time_sel
if pattern_page < 4 then
page_line[pattern_page] = util.clamp(page_line[pattern_page]+d,1,6)
if page_line[pattern_page] < 4 then
page.time_scroll[pattern_page] = 1
elseif page_line[pattern_page] < 7 then
page.time_scroll[pattern_page] = 2
elseif page_line[pattern_page] >= 7 then
page.time_scroll[pattern_page] = 3
end
elseif pattern_page >=4 then
page_line[pattern_page] = util.clamp(page_line[pattern_page]+d,1,7)
local target = page.time_sel-3
if g.device == nil and page_line[pattern_page] <= 4 then
if page_line[pattern_page] == 1 then
arc_param[target] = page.time_arc_loop[pattern_page-3]
else
arc_param[target] = page_line[pattern_page]+2
end
end
end
elseif menu == 8 then
if not key1_hold then
if rytm.screen_focus == "right" then
-- rytm.track[rytm.track_edit].rotation = util.clamp(rytm.track[rytm.track_edit].rotation + d, 0, 16)
-- rytm.track[rytm.track_edit].s = rytm.rotate_pattern(rytm.track[rytm.track_edit].s, rytm.track[rytm.track_edit].rotation)
params:delta("euclid_rotation_"..rytm.track_edit,d)
else
params:delta("euclid_pulses_"..rytm.track_edit,d)
-- rytm.track[rytm.track_edit].k = util.clamp(rytm.track[rytm.track_edit].k+d,0,rytm.track[rytm.track_edit].n)
end
elseif key1_hold then
if rytm.screen_focus == "left" then
-- if d > 0 then
-- rytm.track[rytm.track_edit].mode = "span"
-- elseif d < 0 then
-- rytm.track[rytm.track_edit].mode = "single"
-- end
params:delta("euclid_mode_"..rytm.track_edit,d)
else
params:delta("euclid_auto_rotation_"..rytm.track_edit,d)
-- rytm.track[rytm.track_edit].auto_rotation = util.clamp(rytm.track[rytm.track_edit].auto_rotation + d, 0, 16)
end
end
elseif menu == 9 then
page.arp_param[page.arp_page_sel] = util.clamp(page.arp_param[page.arp_page_sel] + d,1,5)
elseif menu == 10 then
local selected_slot = page.rnd_page_sel[page.rnd_page]
if page.rnd_page_section == 1 then
page.rnd_page_sel[page.rnd_page] = util.clamp(selected_slot+d,1,#rnd[page.rnd_page])
page.rnd_page_edit[page.rnd_page] = 1
elseif page.rnd_page_section == 2 then
local selected_slot = page.rnd_page_sel[page.rnd_page]
local current_param = rnd[page.rnd_page][selected_slot].param
local reasonable_max = (current_param == "semitone offset" and 5) or ((current_param == "loop" or current_param == "delay send") and 4 or 6)
page.rnd_page_edit[page.rnd_page] = util.clamp(page.rnd_page_edit[page.rnd_page]+d,1,reasonable_max)
end
-- elseif menu == "MIDI_config" then
-- local i = page.midi_bank
-- if page.midi_focus == "notes" then
-- ea.delta_MIDI_values(mc.midi_notes[i],d)
-- elseif page.midi_focus == "ccs" then
-- ea.delta_MIDI_values(mc.midi_ccs[i],d)
-- elseif page.midi_focus == "alt" then
-- ea.delta_MIDI_values(mc.midi_notes_channels[i],d)
-- end
end
end
if n == 3 then
if menu == 2 then
local focused_pad;
local id = page.loops.sel
if id < 4 then -- if banks
if bank[page.loops.sel].focus_hold then
focused_pad = bank[id].focus_pad
elseif grid_pat[page.loops.sel].play == 0 and midi_pat[page.loops.sel].play == 0 and not arp[page.loops.sel].playing and rytm.track[page.loops.sel].k == 0 then
focused_pad = bank[id].id
else
focused_pad = bank[id].focus_pad
end
if page.loops.frame == 1 then
if page.loops.top_option_set[page.loops.sel] == 1 then
local current_offset = (math.log(bank[id][focused_pad].offset)/math.log(0.5))*-12
current_offset = util.clamp(current_offset+d/32,-36,24)
if current_offset > -0.0001 and current_offset < 0.0001 then
current_offset = 0
end
bank[id][focused_pad].offset = math.pow(0.5, -current_offset / 12)
if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then
-- if params:get("preview_clip_change") == 1 then
-- cheat(id,bank[id].id)
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
-- end
end
-- if key1_hold then
for i = 1,16 do
if i ~= focused_pad then
bank[id][i].offset = bank[id][focused_pad].offset
end
end
-- end
elseif page.loops.top_option_set[page.loops.sel] == 2 then
bank[id][focused_pad].rate_slew = util.clamp(bank[id][focused_pad].rate_slew+d/10,0,4)
softcut.rate_slew_time(id+1,bank[id][focused_pad].rate_slew)
-- if key1_hold then
for i = 1,16 do
if i ~= focused_pad then
bank[id][i].rate_slew = bank[id][focused_pad].rate_slew
end
end
-- end
end
elseif page.loops.frame == 2 then
if key2_hold then
if page.loops.top_option_set[page.loops.sel] == 1 then
local current_offset = (math.log(bank[id][focused_pad].offset)/math.log(0.5))*-12
current_offset = util.clamp(current_offset+d/32,-36,24)
if current_offset > -0.0001 and current_offset < 0.0001 then
current_offset = 0
end
bank[id][focused_pad].offset = math.pow(0.5, -current_offset / 12)
if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then
-- if params:get("preview_clip_change") == 1 then
-- cheat(id,bank[id].id)
-- end
softcut.rate(id+1, bank[id][focused_pad].rate*bank[id][focused_pad].offset)
end
elseif page.loops.top_option_set[page.loops.sel] == 2 then
bank[id][focused_pad].rate_slew = util.clamp(bank[id][focused_pad].rate_slew+d/10,0,4)
softcut.rate_slew_time(id+1,bank[id][focused_pad].rate_slew)
end
else
local resolution = loop_enc_resolution[id] * (key1_hold and 10 or 1)
local rs = {1,2,4}
local rate_mod = rs[params:get("live_buff_rate")]
ea.move_end(bank[id][focused_pad],d/(resolution*rate_mod))
if bank[id].focus_hold == false then
ea.sc.move_end(id)
end
end
end
elseif id == 4 then
if page.loops.frame == 1 and page.loops.top_option_set[id] == 1 then
params:delta("random_rec_clock_prob_"..rec.focus,d)
elseif page.loops.frame == 1 and page.loops.top_option_set[id] == 2 then
params:delta("live_buff_rate",d)
elseif page.loops.frame == 2 then
ea.move_rec_end(d)
if key1_hold then
update_waveform(1,rec[rec.focus].start_point,rec[rec.focus].end_point,128)
end
end
elseif id == 5 then
adjust_loops(d,"move_end")
end
elseif menu == 6 then
local item = page.delay[page.delay.focus].menu_sel[page.delay[page.delay.focus].menu]
local delay_name = page.delay.focus == 1 and "L" or "R"
local focused_menu = page.delay[page.delay.focus].menu
if page.delay.section == 2 then
if focused_menu == 1 then
if item == 1 then
ea.delta_delay_param(delay_name,"mode",d)
-- params:delta("delay "..delay_name..": mode",d)
elseif item == 2 then
local divisor;
if delay[page.delay.focus].mode == "free" and key1_hold then
divisor = 3
elseif delay[page.delay.focus].mode == "free" and not key1_hold then
divisor = 1/(100/3)
else
divisor = 1
end
ea.delta_delay_param(delay_name,delay[page.delay.focus].mode == "clocked" and "div/mult" or "free length",d/divisor)
-- params:delta(delay[page.delay.focus].mode == "clocked" and "delay "..delay_name..": div/mult" or "delay "..delay_name..": free length",d/divisor)
elseif item == 3 then
local divisor = (delay[page.delay.focus].mode == "free" and key1_hold) and 10 or 0.2
ea.delta_delay_param(delay_name,"fade time",d/divisor)
-- params:delta("delay "..delay_name..": fade time",d/divisor)
elseif item == 4 then
if key1_hold then
ea.delta_delay_param(delay_name,"rate",d)
-- params:delta("delay "..delay_name..": rate",d)
else
if params:get("delay "..delay_name..": rate") < 1.0 then
if d > 0 then
if params:get("delay "..delay_name..": rate") * 2 < 1.0 then
ea.set_delay_param(delay_name,"rate",params:get("delay "..delay_name..": rate") * 2)
-- params:set("delay "..delay_name..": rate",params:get("delay "..delay_name..": rate") * 2)
else
ea.set_delay_param(delay_name,"rate",1)
-- params:set("delay "..delay_name..": rate",1)
end
else
if params:get("delay "..delay_name..": rate") / 2 >= 0.25 then
ea.set_delay_param(delay_name,"rate",params:get("delay "..delay_name..": rate") / 2)
-- params:set("delay "..delay_name..": rate",params:get("delay "..delay_name..": rate") / 2)
else
ea.set_delay_param(delay_name,"rate",1)
-- params:set("delay "..delay_name..": rate",1)
end
end
else
ea.delta_delay_param(delay_name,"rate",d*100)
-- params:delta("delay "..delay_name..": rate",d*100)
if params:get("delay "..delay_name..": rate") < 1.0 then
ea.set_delay_param(delay_name,"rate",1)
-- params:set("delay "..delay_name..": rate",1)
end
end
end
elseif item == 5 then
ea.delta_delay_param(delay_name,"feedback",d)
-- params:delta("delay "..delay_name..": feedback",d)
end
elseif focused_menu == 2 then
if item == 1 then
ea.delta_delay_param(delay_name,"filter cut",d/10)
-- params:delta("delay "..delay_name..": filter cut",d/10)
elseif item == 2 then
ea.delta_delay_param(delay_name,"filter q",d/10)
-- params:delta("delay "..delay_name..": filter q",d/10)
elseif item == 3 then
ea.delta_delay_param(delay_name,"filter lp",d)
-- params:delta("delay "..delay_name..": filter lp",d)
elseif item == 4 then
ea.delta_delay_param(delay_name,"filter hp",d)
-- params:delta("delay "..delay_name..": filter hp",d)
elseif item == 5 then
ea.delta_delay_param(delay_name,"filter bp",d)
-- params:delta("delay "..delay_name..": filter bp",d)
elseif item == 6 then
ea.delta_delay_param(delay_name,"filter dry",d)
-- params:delta("delay "..delay_name..": filter dry",d)
end
elseif focused_menu == 3 then
if item < 7 then
if item == 1 or item == 3 or item == 5 then
local k = page.delay[page.delay.focus].menu
local v = page.delay[page.delay.focus].menu_sel[page.delay[page.delay.focus].menu]
local target = bank[util.round(item/2)]
local prm = {"left_delay_level","right_delay_level"}
if key1_hold then
for i = 1,16 do
target[i][prm[page.delay.focus]] = util.clamp(target[i][prm[page.delay.focus]] + d/10,0,1)
if delay_links[del.lookup_prm(k,v)] then
target[i][prm[page.delay.focus == 1 and 2 or 1]] = target[i][prm[page.delay.focus]]
end
end
else
target[target.id][prm[page.delay.focus]] = util.clamp(target[target.id][prm[page.delay.focus]] + d/10,0,1)
if delay_links[del.lookup_prm(k,v)] then
target[target.id][prm[page.delay.focus == 1 and 2 or 1]] = target[target.id][prm[page.delay.focus]]
end
end
grid_dirty = true
if target[target.id].enveloped == false then
softcut.level_cut_cut(util.round(item/2)+1,page.delay.focus+4,(target[target.id][prm[page.delay.focus]]*target[target.id].level)*target.global_level)
if delay_links[del.lookup_prm(k,v)] then
local this_one = page.delay.focus == 1 and 2 or 1
softcut.level_cut_cut(util.round(item/2)+1,(this_one)+4,(target[target.id][prm[this_one]]*target[target.id].level)*target.global_level)
end
end
else
local target = bank[item/2]
local prm = {"left_delay_thru","right_delay_thru"}
local current_thru = target[target.id][prm[page.delay.focus]] == true and 1 or 0
current_thru = util.clamp(current_thru + d,0,1)
if key1_hold then
for i = 1,16 do
target[i][prm[page.delay.focus]] = current_thru == 1 and true or false
end
else
target[target.id][prm[page.delay.focus]] = current_thru == 1 and true or false
end
end
elseif item == 7 then
ea.delta_delay_param(delay_name,"global level",d)
end
end
end
elseif menu == 7 then
local page_line = page.time_page_sel
local pattern_page = page.time_sel
-- local pattern = g.device ~= nil and grid_pat[pattern_page] or midi_pat[pattern_page]
local pattern
if get_grid_connected() or osc_communication then
pattern = grid_pat[pattern_page]
else
pattern = midi_pat[pattern_page]
end
if pattern_page < 4 then
if page_line[pattern_page] == 7 then
bank[pattern_page].crow_execute = util.clamp(bank[pattern_page].crow_execute+d,0,1)
elseif page_line[pattern_page] == 1 then
if pattern.rec ~= 1 then
if not key1_hold then
if pattern.play == 1 then -- actually, we won't want to allow change...
-- local pre_adjust_mode = pattern.playmode
-- pattern.playmode = util.clamp(pattern.playmode+d,1,2)
-- if pattern.playmode ~= pre_adjust_mode then
-- stop_pattern(pattern)
-- start_pattern(pattern)
-- end
else
pattern.playmode = util.clamp(pattern.playmode+d,1,2)
end
elseif key1_hold and pattern.playmode == 2 then
key1_hold_and_modify = true
pattern.rec_clock_time = util.clamp(pattern.rec_clock_time+d,1,64)
end
end
elseif page_line[pattern_page] == 8 and bank[pattern_page].crow_execute ~= 1 then
_crow.count_execute[pattern_page] = util.clamp(_crow.count_execute[pattern_page]+d,1,16)
elseif page_line[pattern_page] == 3 then
params:delta("sync_clock_to_pattern_"..pattern_page,d)
elseif page_line[pattern_page] == 4 then
pattern.random_pitch_range = util.clamp(pattern.random_pitch_range+d,1,5)
elseif page_line[pattern_page] == 5 then
if pattern.rec ~= 1 and pattern.count > 0 then
pattern.start_point = util.clamp(pattern.start_point+d,1,pattern.end_point)
--pattern_length_to_bars(pattern, "non-destructive")
if quantized_grid_pat[pattern_page].current_step < pattern.start_point then
quantized_grid_pat[pattern_page].current_step = pattern.start_point
quantized_grid_pat[pattern_page].sub_step = 1
end
end
elseif page_line[pattern_page] == 6 then
if pattern.rec ~= 1 and pattern.count > 0 then
pattern.end_point = util.clamp(pattern.end_point+d,pattern.start_point,pattern.count)
--pattern_length_to_bars(pattern, "non-destructive")
if quantized_grid_pat[pattern_page].current_step > pattern.end_point then
quantized_grid_pat[pattern_page].current_step = pattern.start_point
quantized_grid_pat[pattern_page].sub_step = 1
end
end
end
else
if not key1_hold then
if page_line[pattern_page] == 1 then
page.time_arc_loop[pattern_page-3] = util.clamp(page.time_arc_loop[pattern_page-3]+d,1,3)
-- if g.device == nil then
arc_param[pattern_page-3] = page.time_arc_loop[pattern_page-3]
grid_dirty = true
-- end
end
else
if page.time_page_sel[page.time_sel] <= 4 then
local id = page.time_sel-3
local val = page.time_page_sel[page.time_sel]
arc_pat[id][val].time_factor = util.clamp(arc_pat[id][val].time_factor + d/10,0.1,10)
end
end
end
elseif menu == 8 then
if not key1_hold then
if rytm.screen_focus == "right" then
-- rytm.track[rytm.track_edit].pad_offset = util.clamp(rytm.track[rytm.track_edit].pad_offset+d,-15,15)
params:delta("euclid_pad_offset_"..rytm.track_edit,d)
else
-- rytm.track[rytm.track_edit].n = util.clamp(rytm.track[rytm.track_edit].n+d,1,16)
-- rytm.track[rytm.track_edit].k = util.clamp(rytm.track[rytm.track_edit].k,0,rytm.track[rytm.track_edit].n)
params:delta("euclid_duration_"..rytm.track_edit,d)
end
elseif key1_hold then
if rytm.screen_focus == "left" then
-- local deci = {"0.25","0.5","1","2","4"}
-- local lookup = string.format("%.4g",rytm.track[rytm.track_edit].clock_div)
-- local current = (tab.key(deci, lookup))
-- local new_value = util.clamp(current+d,1,#deci)
-- rytm.track[rytm.track_edit].clock_div = tonumber(deci[new_value])
params:delta("euclid_clock_div_"..rytm.track_edit,d)
else
-- rytm.track[rytm.track_edit].auto_pad_offset = util.clamp(rytm.track[rytm.track_edit].auto_pad_offset+d,-15,15)
params:delta("euclid_auto_offset_"..rytm.track_edit,d)
end
end
elseif menu == 9 then
local focus_arp = arp[page.arp_page_sel]
local id = page.arp_page_sel
if page.arp_param[id] == 1 then
local deci_to_int =
{ ["0.125"] = 1 --1/32
, ["0.1667"] = 2 --1/16T
, ["0.25"] = 3 -- 1/16
, ["0.3333"] = 4 -- 1/8T
, ["0.5"] = 5 -- 1/8
, ["0.6667"] = 6 -- 1/4T
, ["1.0"] = 7 -- 1/4
, ["1.3333"] = 8 -- 1/2T
, ["2.0"] = 9 -- 1/2
, ["2.6667"] = 10 -- 1T
, ["4.0"] = 11 -- 1
}
local rounded = arp[page.arp_page_sel].alt and util.round(bank[id][bank[id].id].arp_time,0.0001) or util.round(focus_arp.time,0.0001)
local working = deci_to_int[tostring(rounded)]
working = util.clamp(working+d,1,11)
local int_to_deci = {0.125,1/6,0.25,1/3,0.5,2/3,1,4/3,2,8/3,4}
if arp[page.arp_page_sel].alt then
bank[page.arp_page_sel][bank[page.arp_page_sel].id].arp_time = int_to_deci[working]
focus_arp.time = bank[page.arp_page_sel][bank[page.arp_page_sel].id].arp_time
else
-- focus_arp.time = int_to_deci[working]
-- for i = 1,16 do
-- bank[page.arp_page_sel][i].arp_time = focus_arp.time
-- end
params:delta("arp_"..page.arp_page_sel.."_rate",d)
end
elseif page.arp_param[id] == 2 then
local dir_to_int =
{ ["fwd"] = 1
, ["bkwd"] = 2
, ["pend"] = 3
, ["rnd"] = 4
}
local dir = dir_to_int[focus_arp.mode]
dir = util.clamp(dir+d,1,4)
local int_to_dir = {"fwd","bkwd","pend","rnd"}
focus_arp.mode = int_to_dir[dir]
elseif page.arp_param[id] == 3 then
focus_arp.start_point = util.clamp(focus_arp.start_point+d,1,focus_arp.end_point)
elseif page.arp_param[id] == 4 then
if #focus_arp.notes > 0 then
focus_arp.end_point = util.clamp(focus_arp.end_point+d,focus_arp.start_point,#focus_arp.notes)
end
elseif page.arp_param[id] == 5 then
local working = arp[page.arp_page_sel].retrigger and 0 or 1
working = util.clamp(working+d,0,1)
arp[page.arp_page_sel].retrigger = (working == 0 and true or false)
end
elseif menu == 10 then
local current = rnd[page.rnd_page][page.rnd_page_sel[page.rnd_page]]
if page.rnd_page_section == 2 then
if page.rnd_page_edit[page.rnd_page] == 1 then
if not current.playing then
current.param = rnd.targets[util.clamp(find_the_key(rnd.targets,current.param)+d,1,#rnd.targets)]
end
elseif page.rnd_page_edit[page.rnd_page] == 2 then
if d > 0 then
current.mode = "destructive"
elseif d < 0 then
current.mode = "non-destructive"
end
elseif page.rnd_page_edit[page.rnd_page] == 3 then
current.num = util.clamp(current.num+d,1,32)
-- current.time = current.num / current.denom
rnd.update_time(page.rnd_page,page.rnd_page_sel[page.rnd_page])
elseif page.rnd_page_edit[page.rnd_page] == 4 then
current.denom = util.clamp(current.denom+d,1,32)
-- current.time = current.num / current.denom
rnd.update_time(page.rnd_page,page.rnd_page_sel[page.rnd_page])
elseif page.rnd_page_edit[page.rnd_page] == 5 then
if current.param == "pan" then
current.pan_min = util.clamp(current.pan_min+d,-100,current.pan_max-1)
elseif current.param == "rate" then
local rates_to_mins =
{ [0.125] = 1
, [0.25] = 2
, [0.5] = 3
, [1] = 4
, [2] = 5
, [4] = 6
}
local working = util.clamp(rates_to_mins[current.rate_min]+d,1,rates_to_mins[current.rate_max])
local mins_to_rates = {0.125,0.25,0.5,1,2,4}
current.rate_min = mins_to_rates[working]
elseif current.param == "rate slew" then
current.rate_slew_min = util.clamp(current.rate_slew_min+d/10,0,current.rate_slew_max-0.1)
elseif current.param == "semitone offset" then
local which_scale = nil
for i = 1,#MusicUtil.SCALES do
if MusicUtil.SCALES[i].name == current.offset_scale then
which_scale = i
end
end
local working = util.clamp(which_scale+d,1,#MusicUtil.SCALES)
current.offset_scale = MusicUtil.SCALES[working].name
elseif current.param == "filter tilt" then
current.filter_min = util.clamp(current.filter_min+d/100,-1,current.filter_max-0.01)
end
elseif page.rnd_page_edit[page.rnd_page] == 6 then
if current.param == "pan" then
current.pan_max = util.clamp(current.pan_max+d,current.pan_min+1,100)
elseif current.param == "rate" then
local rates_to_mins =
{ [0.125] = 1
, [0.25] = 2
, [0.5] = 3
, [1] = 4
, [2] = 5
, [4] = 6
}
local working = util.clamp(rates_to_mins[current.rate_max]+d,rates_to_mins[current.rate_min],6)
local maxes_to_rates = {0.125,0.25,0.5,1,2,4}
current.rate_max = maxes_to_rates[working]
elseif current.param == "rate slew" then
current.rate_slew_max = util.clamp(current.rate_slew_max+d/10,current.rate_slew_min+0.1,20)
elseif current.param == "semitone offset" then
elseif current.param == "filter tilt" then
current.filter_max = util.clamp(current.filter_max+d/100,current.filter_min+0.01,1)
end
end
end
-- elseif menu == "MIDI_config" then
-- local i = page.midi_bank
-- if page.midi_focus == "notes" then
-- ea.delta_MIDI_values(mc.midi_notes_velocities[i],d)
-- elseif page.midi_focus == "ccs" then
-- ea.delta_MIDI_values(mc.midi_ccs_values[i],d)
-- elseif page.midi_focus == "alt" then
-- ea.delta_MIDI_values(mc.midi_ccs_channels[i],d)
-- elseif page.midi_focus == "header" then
-- params:delta(i.."_pad_to_midi_note_scale",d)
-- end
end
end
if menu == 8 then
rytm.reer(rytm.track_edit)
end
if menu == 3 then
local focused_pad = nil
if bank[n].focus_hold == true then
focused_pad = bank[n].focus_pad
else
focused_pad = bank[n].id
end
if page.levels.sel == 0 then
if key1_hold or grid_alt or bank[n].alt_lock then
bank[n].global_level = util.clamp(bank[n].global_level+d/10,0,2)
else
bank[n][focused_pad].level = util.clamp(bank[n][focused_pad].level+d/10,0,2)
if bank[n][focused_pad].enveloped and not bank[n][focused_pad].pause then
if bank[n][focused_pad].level > 0.05 then
-- if bank[n][focused_pad].envelope_time/(bank[n][focused_pad].level/0.05) ~= inf then
env_counter[n].time = (bank[n][focused_pad].envelope_time/(bank[n][focused_pad].level/0.05))
end
end
end
if bank[n][bank[n].id].envelope_mode == 2 or bank[n][bank[n].id].enveloped == false then
if bank[n].focus_hold == false then
softcut.level_slew_time(n+1,1.0)
softcut.level(n+1,bank[n][bank[n].id].level*bank[n].global_level)
softcut.level_cut_cut(n+1,5,(bank[n][bank[n].id].left_delay_level*bank[n][bank[n].id].level)*bank[n].global_level)
softcut.level_cut_cut(n+1,6,(bank[n][bank[n].id].right_delay_level*bank[n][bank[n].id].level)*bank[n].global_level)
end
end
elseif page.levels.sel == 1 then
local pre_enveloped = bank[n][focused_pad].enveloped
local pre_mode = bank[n][focused_pad].envelope_mode
bank[n][focused_pad].envelope_mode = util.clamp(bank[n][focused_pad].envelope_mode + d,0,3)
if bank[n][focused_pad].envelope_mode == 0 then
bank[n][focused_pad].enveloped = false
else
bank[n][focused_pad].enveloped = true
if pre_enveloped ~= bank[n][focused_pad].enveloped then
if bank[n].focus_hold == false then
cheat(n, bank[n].id)
end
elseif pre_mode ~= bank[n][focused_pad].envelope_mode then
if bank[n].focus_hold == false then
cheat(n, bank[n].id)
end
end
end
if key1_hold or grid_alt or bank[n].alt_lock then
for j = 1,16 do
if j ~= focused_pad then
bank[n][j].envelope_mode = bank[n][focused_pad].envelope_mode
bank[n][j].enveloped = bank[n][focused_pad].enveloped
end
end
end
elseif page.levels.sel == 2 then
if bank[n][focused_pad].enveloped then
local pre_loop = bank[n][focused_pad].envelope_loop
if d>0 then
bank[n][focused_pad].envelope_loop = true
if pre_loop ~= bank[n][focused_pad].envelope_loop then
if bank[n].focus_hold == false then
cheat(n, bank[n].id)
end
end
else
bank[n][focused_pad].envelope_loop = false
end
end
if key1_hold or grid_alt or bank[n].alt_lock then
for j = 1,16 do
if j ~= focused_pad then
bank[n][j].envelope_loop = bank[n][focused_pad].envelope_loop
end
end
end
elseif page.levels.sel == 3 then
if bank[n][focused_pad].enveloped then
bank[n][focused_pad].envelope_time = util.explin(0.05,60,0.05,60,bank[n][focused_pad].envelope_time)
bank[n][focused_pad].envelope_time = util.clamp(bank[n][focused_pad].envelope_time+d/10,0.05,60)
bank[n][focused_pad].envelope_time = util.linexp(0.05,60,0.05,60,bank[n][focused_pad].envelope_time)
end
if key1_hold or grid_alt or bank[n].alt_lock then
for j = 1,16 do
if j ~= focused_pad then
if bank[n][j].enveloped then
bank[n][j].envelope_time = bank[n][focused_pad].envelope_time
end
end
end
end
if bank[n][focused_pad].level > 0.05 then
env_counter[n].time = (bank[n][focused_pad].envelope_time/(bank[n][focused_pad].level/0.05))
end
end
end
if menu == 4 then
local focused_pad = nil
if key1_hold or grid_alt then
for i = 1,16 do
bank[n][i].pan = util.clamp(bank[n][i].pan+d/10,-1,1)
end
else
if bank[n].focus_hold == true then
focused_pad = bank[n].focus_pad
else
focused_pad = bank[n].id
end
bank[n][focused_pad].pan = util.clamp(bank[n][focused_pad].pan+d/10,-1,1)
end
softcut.pan(n+1, bank[n][bank[n].id].pan)
elseif menu == 5 then
local filt_page = page.filters.sel + 1
if filt_page == 1 then
if bank[n][bank[n].id].filter_type == 4 then
if key1_hold or grid_alt then
if slew_counter[n] ~= nil then
slew_counter[n].prev_tilt = bank[n][bank[n].id].tilt
end
bank[n][bank[n].id].tilt = util.clamp(bank[n][bank[n].id].tilt+(d/100),-1,1)
if d < 0 then
if util.round(bank[n][bank[n].id].tilt*100) < 0 and util.round(bank[n][bank[n].id].tilt*100) > -9 then
bank[n][bank[n].id].tilt = -0.10
elseif util.round(bank[n][bank[n].id].tilt*100) > 0 and util.round(bank[n][bank[n].id].tilt*100) < 32 then
bank[n][bank[n].id].tilt = 0.0
end
elseif d > 0 and util.round(bank[n][bank[n].id].tilt*100) > 0 and util.round(bank[n][bank[n].id].tilt*100) < 32 then
bank[n][bank[n].id].tilt = 0.32
end
slew_filter(n,slew_counter[n].prev_tilt,bank[n][bank[n].id].tilt,bank[n][bank[n].id].q,bank[n][bank[n].id].q,15)
else
ea.set_filter_cutoff(n,d)
end
end
elseif filt_page == 2 then
if key1_hold or grid_alt then
bank[n][bank[n].id].tilt_ease_time = util.clamp(bank[n][bank[n].id].tilt_ease_time+(d/1), 5, 15000)
else
for j = 1,16 do
bank[n][j].tilt_ease_time = util.clamp(bank[n][j].tilt_ease_time+(d/1), 5, 15000)
end
end
elseif filt_page == 3 then
params:delta("filter "..n.." q",d*-1)
elseif filt_page == 4 then
if key1_hold or grid_alt then
bank[n][bank[n].id].tilt_ease_type = util.clamp(bank[n][bank[n].id].tilt_ease_type+d, 1, 2)
else
for j = 1,16 do
bank[n][j].tilt_ease_type = util.clamp(bank[n][j].tilt_ease_type+d, 1, 2)
end
end
end
end
screen_dirty = true
end
function ea.move_play_window(target,delta)
local duration = target.mode == 1 and 8 or clip[target.clip].sample_length
local current_difference = (target.end_point - target.start_point)
local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min
local current_clip = duration*(target.clip-1)
local reasonable_max = target.mode == 1 and live[target.clip].max or clip[target.clip].max
if params:get("loop_enc_resolution_"..target.bank_id) > 2 then