-
Notifications
You must be signed in to change notification settings - Fork 4
/
compass.lua
936 lines (840 loc) · 22 KB
/
compass.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
--
-- Compass (3.1)
-- Command-based looper
-- llllllll.co/t/compass/25192
-- @olivier w/ contributions
-- from @justmat + @gonecaving
--
--
-- see full manual @
-- compass-manual.glitch.me
g = grid.connect()
sc = softcut
pattern_time = require 'pattern_time'
local recLevel = 0
local pos = 1
local edit = 1
local clkSpd = 1
local division = 1
local loopLength = 64
local loopStart = 1
local sPoint = 1
local loopEnd = loopLength+1
local ePoint = loopLength+1
local loop_time = ePoint - sPoint
-- local fade = 0.05
local pageNum = 1
local rateSlew = 0.1
local down_time = 0
local KEYDOWN1 = 0
local KEYDOWN2 = 0
local key_mode = 0
local edit_lev = 0
local positions = {0,0}
local rate_pos = 5
local rates = {-2,-1,-0.5,0.5,1,2}
local STEPS = 16
local step = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
local led_lev = 1
local metro_state = 1
local Arcify = include("lib/arcify")
local arcify = Arcify.new()
local COMMANDS = 18
local act = {
label = {}
}
function update_positions(i,x)
grid_redraw()
positions[i] = util.clamp(x,0.1,loopEnd)
for i=1,2 do
sc.recpre_slew_time(i,2)
if recLevel == 0 then
sc.pre_level(i,1)
else
sc.pre_level(i,params:get("Overdub"))
end
-- sc.level(i,1)
sc.rate_slew_time(i,rateSlew)
sc.rec_level(i,recLevel)
sc.loop_start(i,loopStart)
sc.loop_end(i,loopEnd)
end
setn(step,STEPS)
COMMANDS = #act
redraw()
end
-- INPUT ROUTING
function stereo()
-- set sc to stereo inputs
sc.level_input_cut(1, 1, 1)
sc.level_input_cut(2, 1, 0)
sc.level_input_cut(1, 2, 0)
sc.level_input_cut(2, 2, 1)
end
function mono()
--set sc to mono input
sc.level_input_cut(1, 1, 0.5)
sc.level_input_cut(2, 1, 0)
sc.level_input_cut(1, 2, 0.5)
sc.level_input_cut(2, 2, 0)
end
function set_input(n)
if n == 1 then
stereo()
else
mono()
end
end
function scLevel(x)
x = util.clamp(x,0,5)
audio.level_cut((x*2)/10)
end
function scRate(x)
x = util.clamp(x,-4,4)
for i=1,2 do
sc.rate(i,x)
end
end
-- SEQUENCE LENGTH
function setn(t,n)
setmetatable(t,{__len=function() return n end})
end
-- COMMANDS
-- Sequence ommands
function metroSteady() division = 1 end
function metroDec() division = util.clamp(division / 2, 1, 16) end
function metroInc() division = util.clamp(division * 2, 1, 16) end
function metroTop() division = 16 end
function metroBottom() division = 1 end
function stepRnd() pos = math.random(1,#step) end
-- Softcut
function rateForward() for i=1,2 do sc.rate(i,rates[5]) end end
function rateReverse() for i=1,2 do sc.rate(i,rates[2]) end end
function rateInc() rate_pos = util.clamp(rate_pos+1,1,6) ; for i=1,2 do sc.rate(i,rates[rate_pos]) end end
function rateDec() rate_pos = util.clamp(rate_pos-1,1,6) ; for i=1,2 do sc.rate(i,rates[rate_pos]) end end
function rateRnd() for i=1,2 do sc.rate(i,rates[math.random(1,6)]) end end
function sPosStart() for i=1,2 do sc.position(i,loopStart) end end
function sPosRnd() for i=1,2 do sc.position(i,math.random(loopStart,loopEnd)) end end
function loopRnd() loopStart = math.random(sPoint,loopEnd-1) ; loopEnd = math.random(loopStart+1,ePoint) end
function rndPanL() params:set("Pan (L)",math.random(0,8)/-10) end
function rndPanR() params:set("Pan (R)",math.random(0,8)/10) end
function toggleRec() recLevel = 1 - recLevel end
-- Crow
function crowTrig() crow.output[1].execute() end
function crowRnd() crow.output[2].volts = math.random(10) end
local command_list = {
{metroBottom,1,"[", "Slowest clock speed"},
{metroTop,1,"]", "Fastest clock speed"},
{metroDec,1,"<", "Decrement clock speed"},
{metroInc,1,">", "Increment clock speed"},
{stepRnd,1,"?", "Random sequence position"},
{rateForward,1,"F", "Set SC rate to 1x"},
{rateReverse,1,"R", "Set SC rate to -1x"},
{rateInc,1,"+", "Set random forward rate"},
{rateDec,1,"-", "Set random reverse rate"},
{rateRnd,1,"!", "Set random rate"},
{sPosStart,1,"1", "Jump to start of buffers"},
{sPosRnd,1,"P", "Set random buffer positions"},
{loopRnd,1,"L", "Set random loop length"},
{rndPanL,1,"(", "Random pan position (L)"},
{rndPanR,1,")", "Random pan position (R)"},
{toggleRec,1,"::", "Toggle recording on/off"},
{crowTrig,1,"T", "Crow trig (out 1)"},
{crowRnd,1,"V", "Crow rnd voltage (out 2)"},
}
function build_command_list()
act = { label = {} }
for i=1,#command_list do
if command_list[i][2] == 1 then
table.insert(act,command_list[i][1])
table.insert(act.label,command_list[i][3])
end
end
end
local grid_pattern = {}
function init()
main_clk = clock.run(bang)
-- COMMAND SETUP
build_command_list()
-- GRID SETUP
for i=1,4 do
grid_pattern[i] = pattern_time.new()
grid_pattern[i].process = grid_pattern_execute
end
for i=13,16 do
grid_pattern[i] = pattern_time.new()
grid_pattern[i].process = grid_pattern_execute_comm
end
grid_redraw()
-- PARAMS
params:set("clock_tempo",80)
params:add_group("COMPASS",26)
params:add_separator("RECORDING")
params:add_option("Input", "Input", {"Stereo", "Mono (L)"}, 1)
params:set_action("Input", function(x) set_input(x) end)
params:add_control("Record Level","Record level",controlspec.new(0,1,'lin',0.01,1))
params:set_action("Record Level", function(x) for i=1,2 do sc.rec_level(i,x) end end)
params:add_control("Overdub","Overdub",controlspec.new(0,1,'lin',0.01,1))
params:set_action("Overdub", function(x) end) --pre = x
params:add_separator("BUFFERS")
params:add{id="Rate (coarse)", name="Rate (coarse)", type="control",
controlspec=controlspec.new(-4,4,'lin',0.50,1,""),
action=function(x)
sc.rate(1,x)
sc.rate(2,x)
end}
params:add_control("Rate (slew)", "Rate (slew)", controlspec.new(0,2,'lin',0.01,0.1))
params:set_action("Rate (slew)", function(x) rateSlew = x end)
params:add_control("Fade","Fade",controlspec.new(0,1,'lin',0.01,0.05))
params:set_action("Fade", function(x) for i=1,2 do sc.fade_time(i,x) end end)
params:add_control("Pan (R)", "Pan (R)", controlspec.new(-1,1,'lin',0.01,0.5))
params:set_action("Pan (R)", function(x) sc.pan(1,x) end) --panR = x
params:add_control("Pan (L)", "Pan (L)", controlspec.new(-1,1,'lin',0.01,-0.5))
params:set_action("Pan (L)", function(x) sc.pan(2,x) end) --panL = x
params:add_control("Pan slew", "Pan (slew)", controlspec.new(0,2,'lin', 0.01,0.25))
params:set_action("Pan slew", function(x) for i=1,2 do sc.pan_slew_time(i,x) end end)
-- params:add_control("Level slew", "Level (slew)", controlspec.new(0,10,'lin', 0.01,0.25))
-- params:set_action("Level slew", function(x) for i=1,2 do sc.level_slew_time(i,x) end end)
params:add_control("Start point","Start point",controlspec.new(1,ePoint-1,'lin',1,1))
params:set_action("Start point", function(x) sPoint = util.clamp(x,1,ePoint-1); loopStart = sPoint end)
params:add_control("End point","End point",controlspec.new(sPoint+1,65,'lin',1,65))
params:set_action("End point", function(x) ePoint = util.clamp(x,sPoint+1,65); loopEnd = ePoint end)
-- params:add_separator("CLOCKING")
-- params:add_option("Clock", "Clock", {"Internal", "crow in 1"},1)
-- params:set_action("Clock", function(x) set_clock(x) end)
params:add_separator("CROW")
params:add_option("Mode (input 2)", "Mode (input 2)", {"Off", "SC Level", "SC Rate"}, 1)
params:set_action("Mode (input 2)", function(x) set_crowIn2(x) end)
-- Arc control over loop start & end
params:add_separator("ARC")
arcify:register("Start point",1)
arcify:register("End point",1)
arcify:add_params()
-- send audio input to sc input + adjust cut volume
audio.level_cut(1)
audio.level_adc_cut(1)
audio.level_eng_cut(1)
-- CLOCK
-- METROS
-- m = metro.init(count,clkSpd,-1)
-- m:start()
e = metro.init(pulse,0.10,-1)
ledcounter = metro.init(ledclk, 0.10, -1)
ledcounter:start()
-- POSITION POLL
sc.event_phase(update_positions)
sc.poll_start_phase()
-- CROW
crow.input[1].change = count
crow.output[1].action = "pulse(0.01,7,1)"
crow.input[2].mode("none")
norns.enc.sens(1,5) -- set encoder 1 to sensitivity 4 (slower)
-- softcut
sc.buffer_clear()
for i=1,2 do
sc.enable(i,1)
sc.buffer(i,i)
sc.level(i,1.0)
sc.rec_level(i,recLevel)
sc.loop(i,1)
sc.loop_start(i,1)
sc.loop_end(i,loopEnd)
sc.position(i,1)
sc.play(i,1)
sc.fade_time(i,params:get("Fade"))
sc.pre_level(i,params:get("Overdub"))
sc.rec(i,1)
sc.pan(1,params:get("Pan (R)"))
sc.pan(2,params:get("Pan (L)"))
sc.rate(i,1)
sc.phase_quant(i,0.03)
sc.rate_slew_time(i,rateSlew)
sc.level_slew_time(i,0.10)
sc.pre_filter_dry(i, 1)
sc.pre_filter_lp(i, 0)
sc.pre_filter_hp(i, 0)
sc.pre_filter_bp(i, 0)
sc.pre_filter_br(i, 0)
end
stereo()
end
--------------------------------------------------
function bang()
while true do
clock.sync(1/division)
count()
end
end
function count()
pos = (pos % #step) + 1
if edit == pos and KEYDOWN2 == 1 then
print("Ignored")
else
act[step[pos]]()
end
redraw()
end
-- RESET FUNCTIONS
function commReset()
-- ratePos = 5
for i=1,#step do
step[i] = 1
end
end
function cutReset()
for i=1,2 do
sc.position(i,loopStart)
sc.rate(i,1)
end
sc.buffer_clear()
end
function randomize_steps()
for i=1,#step do
step[i] = math.random(COMMANDS)
end
end
-- ENCODERS & KEYS
function enc(n,d)
-- ENCODER 1
if n==1 then
if edit > #step then
edit = #step
end
if KEYDOWN1 == 0 then
-- increase max to 3 when third edit page is built
pageNum = util.clamp(pageNum+d,1,2)
else
if pageNum == 1 then
STEPS = util.clamp(STEPS+d,2,16)
end
end
-- ENCODER 2
elseif n==2 then
if pageNum == 1 then
if KEYDOWN1 == 0 then
edit = util.clamp(edit+d,1,#step)
else
params:delta("Start point",d)
loopStart = sPoint
loop_time = ePoint - sPoint
end
elseif pageNum == 2 then
edit = util.clamp(edit+d,1,#command_list)
end
-- ENCODER 3
elseif n==3 then
if pageNum == 1 then
if KEYDOWN1 == 0 then
step[edit] = util.clamp(step[edit]+d, 1, COMMANDS)
else
params:delta("End point",d)
loopEnd = ePoint
loop_time = ePoint - sPoint
end
end
end
redraw()
end
function key(n,z)
if n == 1 then
KEYDOWN1 = z
elseif n == 2 then
KEYDOWN2 = z
if KEYDOWN1 == 0 then
if z == 1 then
down_time = util.time()
else
hold_time = util.time() - down_time
if pageNum == 1 then
if hold_time < 1 then
randomize_steps()
else
commReset()
end
elseif pageNum == 2 then
command_list[edit][2] = 1 - command_list[edit][2]
build_command_list()
commReset()
-- for i=1,#command_list do
-- if act[step[i]] == command_list[i][1] then
-- if command_list[i][2] == 0 then
-- act[step[i]] = act[step[1]]
-- end
-- end
-- end
elseif pageNum == 3 then
end
end
else
if z == 1 then
if pageNum == 1 then
metro_state = 1 - metro_state
if metro_state == 1 then
main_clk = clock.run(bang)
else
clock.cancel(main_clk)
end
end
end
end
elseif n == 3 then
if KEYDOWN1 == 0 then
if z == 1 then
down_time = util.time()
else
hold_time = util.time() - down_time
if pageNum == 1 then
if hold_time < 1 then
recLevel = 1 - recLevel
else
cutReset()
end
elseif pageNum == 2 then
-- future saving/loading stuff
elseif pageNum == 3 then
-- nothing
end
end
end
end
redraw()
end
-- GRID ---------------------------------------------
-- local gridRate = 10
local gridALT = 0
local pattern_mode = 0
function ledclk()
led_lev = (led_lev % 15) + 1
end
function patternbank_a(x,y,z)
for i=1,4 do
if z == 1 and y == 1 and x == i then
led_lev = 1
if gridALT == 0 then
if grid_pattern[i].rec == 1 then
grid_pattern[i]:rec_stop()
grid_pattern[i]:start()
elseif grid_pattern[i].count == 0 then
grid_pattern[i]:rec_start()
elseif grid_pattern[i].play == 1 then
grid_pattern[i]:stop()
else
grid_pattern[i]:start()
end
elseif gridALT == 1 then
grid_pattern[i]:rec_stop()
grid_pattern[i]:stop()
grid_pattern[i]:clear()
g:all(0)
end
end
if pattern_mode == 0 then
if z == 1 and y == 1 and x ~= i and x < 5 then
if gridALT == 0 then
grid_pattern[i]:stop()
end
end
else
if z == 1 and y == 1 and x ~= i then
if gridALT == 0 then
grid_pattern[i]:stop()
end
end
end
end
for i=1,4 do
if z == 1 and y ~= 8 then
record_this = {}
record_this.x = x
record_this.y = y
grid_pattern[i]:watch(record_this)
g:all(0)
g:led(x,y,z*15)
end
end
end
function patternbank_b(x,y,z)
for i=13,16 do
if z == 1 and y == 1 and x == i then
led_lev = 1
if gridALT == 0 then
if grid_pattern[i].rec == 1 then
grid_pattern[i]:rec_stop()
grid_pattern[i]:start()
elseif grid_pattern[i].count == 0 then
grid_pattern[i]:rec_start()
elseif grid_pattern[i].play == 1 then
grid_pattern[i]:stop()
else
grid_pattern[i]:start()
end
elseif gridALT == 1 then
grid_pattern[i]:rec_stop()
grid_pattern[i]:stop()
grid_pattern[i]:clear()
g:all(0)
end
end
if pattern_mode == 0 then
if z == 1 and y == 1 and x ~= i and x > 12 then
if gridALT == 0 then
grid_pattern[i]:stop()
end
end
else
if z == 1 and y == 1 and x ~= i then
if gridALT == 0 then
grid_pattern[i]:stop()
end
end
end
end
for i=13,16 do
if z == 1 and y ~= 8 then
record_this = {}
record_this.x = x
record_this.y = y
grid_pattern[i]:watch(record_this)
g:all(0)
g:led(x,y,z*15)
end
end
end
g.key = function(x,y,z)
if x == 1 and y == 8 then
gridALT = z
end
if pageNum == 1 then
patternbank_a(x,y,z)
patternbank_b(x,y,z)
if z == 1 then
if x == 16 and y == 8 then
metro_state = 1 - metro_state
if metro_state == 1 then
main_clk = clock.run(bang)
else
clock.cancel(main_clk)
end
elseif x == 1 and y == 2 then
pattern_mode = 1 - pattern_mode
elseif x > 0 and y == 7 then
if gridALT == 1 then
STEPS = x
else
pos = x-1
count()
end
elseif y == 4 then
sc.position(1,math.floor((x*65)/16)-3)
elseif y == 5 then
sc.position(2,math.floor((x*65)/16)-3)
end
end
else
for i=1,9 do
if x == i and y == 4 and z == 1 then
if gridALT == 1 then
command_list[i][2] = 1 - command_list[i][2]
build_command_list()
commReset()
end
edit = x
end
end
for i=10,#command_list do
if x == (i-9) and y == 5 and z == 1 then
if gridALT == 1 then
command_list[i][2] = 1 - command_list[i][2]
build_command_list()
commReset()
end
edit = x+9
end
end
end
redraw()
end
function grid_pattern_execute(recorded)
g:all(0)
g:led(recorded.x,recorded.y,15)
grid_redraw()
g:refresh()
if recorded.y == 4 then
sc.position(1,math.floor((recorded.x*65)/16)-3)
elseif recorded.y == 5 then
sc.position(2,math.floor((recorded.x*65)/16)-3)
end
if pattern_mode == 1 then
if recorded.y == 7 then
pos = recorded.x-1
count()
end
end
end
function grid_pattern_execute_comm(recorded)
g:all(0)
g:led(recorded.x,recorded.y,15)
grid_redraw()
g:refresh()
if recorded.y == 7 then
pos = recorded.x-1
count()
end
if pattern_mode == 1 then
if recorded.y == 4 then
sc.position(1,math.floor((recorded.x*65)/16)-3)
elseif recorded.y == 5 then
sc.position(2,math.floor((recorded.x*65)/16)-3)
end
end
end
function grid_redraw()
g:all(0)
g:led(1,8,5)
if pageNum == 1 then
for i=1,4 do
if grid_pattern[i].rec == 1 then
g:led(i,1,led_lev)
elseif grid_pattern[i].play == 1 then
g:led(i,1,15)
elseif grid_pattern[i].play == 0 and grid_pattern[i].count > 0 then
g:led(i,1,5)
else
g:led(i,1,3)
end
end
for i=13,16 do
if grid_pattern[i].rec == 1 then
g:led(i,1,led_lev)
elseif grid_pattern[i].play == 1 then
g:led(i,1,15)
elseif grid_pattern[i].play == 0 and grid_pattern[i].count > 0 then
g:led(i,1,5)
else
g:led(i,1,3)
end
end
local gStart = util.clamp(math.abs(math.floor(sPoint*16/65)+1),1,16)
local gEnd = util.clamp(math.abs(math.floor(ePoint*16/65)+1),1,16)
-- clock led
g:led(16,8,metro_state*3+3)
-- pattern mode led
g:led(1,2,pattern_mode*7+3)
for i=1,16 do
g:led(i,7,2)
end
for i=1,STEPS do
g:led(i,7,i==pos and 15 or 5)
end
for i=gStart,gEnd do
g:led(i,4,i==util.clamp(math.abs(math.floor((positions[1]*16)/65)+1),1,16) and 15 or 5)
g:led(i,5,i==util.clamp(math.abs(math.floor((positions[2]*16)/65)+1),1,16) and 15 or 5)
end
elseif pageNum == 2 then
for i=1,9 do
g:led((i),4,(command_list[i][2]*5)+3)
end
for i=10,#command_list do
g:led(((i-9)),5,(command_list[i][2]*5)+3)
end
end
g:refresh()
end
-- SCREEN -------------------------------------------
function pulse()
edit_lev = (edit_lev % 10) + 1
end
function drawMenu()
screen.move(2,10)
if pageNum == 1 then
screen.level(10)
screen.text("Play")
else
screen.level(10)
screen.text("Edit")
screen.move(20,10)
screen.level(1)
-- if pageNum == 2 then
-- screen.text("| 1")
-- elseif pageNum == 3 then
-- screen.text("| 2")
-- elseif pageNum == 4 then
-- screen.text("| 3")
-- end
end
screen.move(124,10)
screen.level(3)
if KEYDOWN1 == 1 then
screen.move(22,10)
screen.level(2)
screen.text("| "..loop_time.."s.")
end
end
function drawEdit()
screen.move(2,20)
if key_mode == 0 then
if recLevel >= 0.01 then
screen.level(15)
screen.rect(121,6,4,4)
screen.fill()
else
screen.level(2)
end
screen.rect(121,6,4,4)
end
screen.stroke()
drawLoop()
drawCommands()
end
function drawCommands()
for i=1,#step do
screen.move(i*8-8+2,58)
if pageNum == 1 then
if i == edit then
screen.level(15)
elseif i == pos then
screen.level(3)
else
screen.level(1)
end
screen.text(act.label[step[i]])
elseif pageNum == 3 then
screen.level(10)
screen.text(act.label[step[i]])
end
end
end
function draw_ref()
for i=1,9 do
screen.level((command_list[i][2]*10)+1)
screen.move(i*10-8,27)
screen.text(command_list[i][3])
--
screen.move(i*10-8,32)
if i == edit then
screen.level(10)
else
screen.level(2)
end
screen.line_rel(5,0)
screen.stroke()
end
for i=10,#command_list do
screen.level((command_list[i][2]*10)+1)
screen.move((i-8)*10-18,42)
screen.text(command_list[i][3])
--
screen.move((i-8)*10-18,47)
if i == edit then
screen.level(10)
else
screen.level(2)
end
screen.line_rel(5,0)
screen.stroke()
end
screen.level(5)
screen.move(2,58)
screen.text(command_list[edit][4])
end
function drawLoop()
screen.level(2)
-- voice 1
screen.move(2,(1*9)+27)
screen.line(126,(1*9)+27)
screen.stroke()
screen.level(4)
screen.move((loopStart*124)/loopLength-(124/loopLength)+2,(1*9)+27)
screen.line((loopEnd*124)/loopLength-(124/loopLength)+2,(1*9)+27)
screen.stroke()
--
screen.level(15)
screen.move((sPoint*124)/loopLength-(124/loopLength)+2,(1*9)+26)
screen.line_rel(0,1)
screen.stroke()
screen.level(15)
screen.move((ePoint*124)/loopLength-(124/loopLength)+2,(1*9)+26)
screen.line_rel(0,1)
screen.stroke()
--
screen.level(15)
screen.move((positions[1]-1)*(124/(loopLength))+2,(1*9)+25)
screen.line_rel(0,3)
screen.stroke()
-- voice 2
screen.level(2)
screen.move(2,(2*9)+27)
screen.line(126,(2*9)+27)
screen.stroke()
screen.level(5)
screen.move((loopStart*124)/loopLength-(124/loopLength)+2,(2*9)+27)
screen.line((loopEnd*124)/loopLength-(124/loopLength)+2,(2*9)+27)
screen.stroke()
---
screen.level(15)
screen.move((sPoint*124)/loopLength-(124/loopLength)+2,(2*9)+26)
screen.line_rel(0,1)
screen.level(15)
screen.move((ePoint*124)/loopLength-(124/loopLength)+2,(2*9)+26)
screen.line_rel(0,1)
screen.stroke()
---
screen.level(15)
screen.move((positions[2]-1)*(124/(loopLength))+2,(2*9)+25)
screen.line_rel(0,3)
screen.stroke()
end
-- function set_clock(x)
-- if x == 1 then
-- m:start()
-- crow.input[1].mode("none")
-- for i=1,5 do
-- command_list[i][2] = 1
-- end
-- build_command_list()
-- commReset()
-- else
-- m:stop()
-- crow.input[1].mode("change", 2.0, 0.25, "rising")
-- for i=1,5 do
-- command_list[i][2] = 0
-- end
-- build_command_list()
-- commReset()
-- end
-- for i=1,#step do
-- step[i] = 1
-- end
-- count()
-- redraw()
-- end
function set_crowIn2(x)
if x == 1 then
audio.level_cut(1)
crow.input[2].mode("none")
print("^^ in 2: OFF")
else
crow.input[2].mode("stream", 0.05)
if x == 2 then
crow.input[2].stream = scLevel
print("^^ in 2: sc LEVEL")
elseif x == 3 then
crow.input[2].stream = scRate
print("^^ in 2: sc RATE")
end
end
end
function redraw()
screen.clear()
drawMenu()
if pageNum == 1 then
drawEdit()
elseif pageNum == 2 then
draw_ref()
elseif pageNum == 3 then
drawMenu()
drawCommands()
end
screen.stroke()
screen.update()
end