-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplesynth.py
executable file
·1374 lines (1282 loc) · 46.7 KB
/
simplesynth.py
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
#!/usr/bin/env python
import pygame.event
import pygame.key
import pygame.display
import pygame.image
import pygame.mixer
import pygame
from pygame.locals import *
import time
import os
import array
import math
import copy
import fssynthlib
from fssynthlib import ewchunk
from threading import Thread
pygame.display.init()
windowicon=pygame.image.load("icon32.png")
pygame.display.set_icon(windowicon)
screensurf=pygame.display.set_mode((800, 600))
print (pygame.display.list_modes()[0])
pygame.display.set_caption("Floored Square Simple Synth", "Floored Square Simple Synth")
pygame.font.init()
simplefont = pygame.font.SysFont(None, 22)
bgimg=pygame.image.load("simplesynth.jpg").convert()
#controls the frequency of the synthesizer logic and pygame mixer.
#lower frequencies are faster, but are lower quality.
#synthfreq=44100
synthfreq=22050
#synthfreq=16000
#synthfreq=11025
#synthfreq=8000
synthfreqmain=synthfreq
STACKRANGE=int(synthfreqmain/1)
araylimit=1
#pygame.mixer.init()
pygame.mixer.init(frequency=synthfreq , size=-16)
pygame.mixer.set_num_channels(24)
print ("mixer frequency:" + str(synthfreq))
#pygame.mixer.set_num_channels(6)
print ("number of channels: "+ str(pygame.mixer.get_num_channels()))
def foobsin1(num):
return (strex(math.sin(num)) * 12500)
#def foobsin1(num):
# return strex((num) * 240)
def foobsin2(num):
return (strex(math.tan(num)) * 12500)
def foobsin3(num):
return (strex(math.cos(num) + math.sin(num)) * 5500)
def foobsin4(num):
return (strex(math.tan(num) + math.sin(num)) * 5500)
foobsin=foobsin1
def foobsin5(num):
return (strex(math.sin(num)+math.sin(num*2)-math.cos(num)) * 3000)
def foobsin6(num):
return (strex(math.sin(num)+math.cos(num*2)-math.cos(num)) * 3000)
def foobsin7(num):
return (strex(math.sin(num)-math.sin(num*2)-math.cos(num)) * 3000)
def foobsin8(num):
return (strex(math.sin(num)-math.cos(num*2)-math.cos(num)) * 3000)
def foobsin9(num):
return (strex(math.sin(num)*7) * 700)
def foobsin10(num):
return (strex(math.tan(num)*4) * 300)
#foobsin=foobsin10
def vstroke(num):
if num<0.5:
return math.ceil(num)
else:
return math.floor(num)
def jstroke(num):
if num>0.5:
return math.ceil(abs(num) - abs(num) - abs(num))
else:
return math.floor(abs(num))
def cstroke(num):
if num>0.5:
return math.floor(abs(num) - abs(num) - abs(num))
else:
return math.floor(abs(num))
def wstroke(num):
if num>0.7:
return math.ceil(num)
elif num<0.3:
return math.floor(num)
else:
return float(0.5)
def wstroke(num):
if num>0.5:
return math.ceil(num)
elif num<(-0.5):
return math.floor(num)
else:
return float(0.0)
def three_way(num):
if num>0.5:
return float(0.9)
elif num<(-0.5):
return float(-0.9)
else:
return float(0.0)
def two_way(num):
if num>=0:
return float(1)
else:
return float(0)
def floorceil(num):
num=num/2.0
return math.ceil(num)+math.floor(num)
strex=math.floor
#strex=floorceil
#strex=two_way
#def dummyfunct(arg):
# return arg
strexmd=1
wavemode=1
retrigtime=0.1
stackit=1
octshift=1
stackmod=1
def autosquare(freq, lenth):
global STACKRANGE
if octshift==0:
freq=(freq/2.0)
elif octshift==-1:
freq=(freq/3.0)
else:
freq=(freq*octshift)
#print freq
#STACKRANGE=(1)*int((synthfreqmain / araylimit) // (freq / float(stacksub)))
STACKRANGE=(1)*int((synthfreqmain / araylimit) / (freq /float((stackit) / (stacksub))))
#print stackmod
if stackmod==1:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stack(freq, lenth)
elif stackit==3:
retarray=autosquare3stack(freq, lenth)
elif stackit==4:
retarray=autosquare4stack(freq, lenth)
elif stackit==5:
retarray=autosquare5stack(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
elif stackmod==3:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stackne(freq, lenth)
elif stackit==3:
retarray=autosquare3stacknexq(freq, lenth)
elif stackit==4:
retarray=autosquare4stacknexq(freq, lenth)
elif stackit==5:
retarray=autosquare5stacknexq(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
elif stackmod==4:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stack(freq, lenth)
elif stackit==3:
retarray=autosquare3stackaddmean(freq, lenth)
elif stackit==4:
retarray=autosquare4stackaddmean(freq, lenth)
elif stackit==5:
retarray=autosquare5stackaddmean(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
elif stackmod==5:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stackne(freq, lenth)
elif stackit==3:
retarray=autosquare3stacksubmean(freq, lenth)
elif stackit==4:
retarray=autosquare4stacksubmean(freq, lenth)
elif stackit==5:
retarray=autosquare5stacksubmean(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
elif stackmod==6:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stackmean(freq, lenth)
elif stackit==3:
retarray=autosquare3stackmean(freq, lenth)
elif stackit==4:
retarray=autosquare4stackmean(freq, lenth)
elif stackit==5:
retarray=autosquare5stackmean(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
else:
if stackit==1:
retarray=autosquare1stack(freq, lenth)
elif stackit==2:
retarray=autosquare2stackne(freq, lenth)
elif stackit==3:
retarray=autosquare3stackne(freq, lenth)
elif stackit==4:
retarray=autosquare4stackne(freq, lenth)
elif stackit==5:
retarray=autosquare5stackne(freq, lenth)
else:
retarray=autosquare1stack(freq, lenth)
#return ( + retarray)
#return arrayduplicate(retarray)
#sys.exit()
return retarray
pival=math.pi
stacksub=1
#add
def autosquare1stack(freq, lenth):
temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq)) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#def autosquare1stack(freq, lenth):
# #temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq)) for t in xrange(0, STACKRANGE)])
# #temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
# rangeq=int(synthfreq/float(freq * stacksub))
# temparray=array.array('f', [math.floor((1000.0/rangeq) * t) for t in xrange(0, rangeq)])
# return temparray
def autosquare2stack(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare3stack(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stack(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stack(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#subtract
def autosquare2stackne(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare3stackne(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stackne(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stackne(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#adsub1
def autosquare2stacknexq(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - (foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq)))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare3stacknexq(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - (foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq)))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stacknexq(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - (foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq)))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stacknexq(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - (foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq) - foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq) + foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq)))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#SUB ABS
def autosquare3stackaddmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stackaddmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stackaddmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) + mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#sub mean
def autosquare3stacksubmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stacksubmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stacksubmean(freq, lenth):
temparray=array.array('i', [ewchunk((foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq) - mean([foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq)]))) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
#mean
def autosquare2stackmean(freq, lenth):
temparray=array.array('i', [ewchunk(mean([foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq)])) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare3stackmean(freq, lenth):
temparray=array.array('i', [ewchunk(mean([foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq)])) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare4stackmean(freq, lenth):
temparray=array.array('i', [ewchunk(mean([foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq)])) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
def autosquare5stackmean(freq, lenth):
temparray=array.array('i', [ewchunk(mean([foobsin(2.0 * pival * (freq * stacksub) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 2)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 3)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 4)) * t / synthfreq), foobsin(2.0 * pival * (freq *(stacksub * 5)) * t / synthfreq)])) for t in xrange(0, STACKRANGE)])
#temparray=array.array('i', [ewchunk(foobsin(2.0 * pival * freq * t / synthfreq)) for t in xrange(0, int(lenth * synthfreq))])
return temparray
fadex=600
fadetime=fadex
notetime=(0.1)
def keycheckoff():
keypressed=pygame.key.get_pressed()
if fadetime!=0:
if not keypressed[K_z]:
snf0.fadeout(fadetime)
if not keypressed[K_s]:
snf1.fadeout(fadetime)
if not keypressed[K_x]:
snf2.fadeout(fadetime)
if not keypressed[K_d]:
snf3.fadeout(fadetime)
if not keypressed[K_c]:
snf4.fadeout(fadetime)
if not keypressed[K_v]:
snf5.fadeout(fadetime)
if not keypressed[K_g]:
snf5b.fadeout(fadetime)
if not keypressed[K_b]:
snf6.fadeout(fadetime)
if not keypressed[K_h]:
snf7.fadeout(fadetime)
if not keypressed[K_n]:
snf8.fadeout(fadetime)
if not keypressed[K_j]:
snf9.fadeout(fadetime)
if not keypressed[K_m]:
snf10.fadeout(fadetime)
if not (keypressed[K_q] or keypressed[K_LESS] or keypressed[K_COMMA]):
snf11.fadeout(fadetime)
if not (keypressed[K_2] or keypressed[K_l]):
snf12.fadeout(fadetime)
if not (keypressed[K_w] or keypressed[K_GREATER] or keypressed[K_PERIOD]):
snf13.fadeout(fadetime)
if not (keypressed[K_3] or keypressed[K_COLON] or keypressed[K_SEMICOLON]):
snf14.fadeout(fadetime)
if not (keypressed[K_e] or keypressed[K_SLASH] or keypressed[K_QUESTION]):
snf15.fadeout(fadetime)
if not keypressed[K_r]:
snf16.fadeout(fadetime)
if not keypressed[K_5]:
snf17.fadeout(fadetime)
if not keypressed[K_t]:
snf18.fadeout(fadetime)
if not keypressed[K_6]:
snf19.fadeout(fadetime)
if not keypressed[K_y]:
snf.fadeout(fadetime)
if not keypressed[K_7]:
snf20.fadeout(fadetime)
if not keypressed[K_u]:
snf21.fadeout(fadetime)
if not keypressed[K_i]:
snf22.fadeout(fadetime)
if not keypressed[K_9]:
snf23.fadeout(fadetime)
if not keypressed[K_o]:
snf24.fadeout(fadetime)
if not keypressed[K_0]:
snf25.fadeout(fadetime)
if not keypressed[K_p]:
snf26.fadeout(fadetime)
if not keypressed[K_LEFTBRACKET]:
snf27.fadeout(fadetime)
if not (keypressed[K_EQUALS] or keypressed[K_PLUS]):
snf28.fadeout(fadetime)
if not keypressed[K_RIGHTBRACKET]:
snf29.fadeout(fadetime)
else:
if not keypressed[K_z]:
snf0.stop()
if not keypressed[K_s]:
snf1.stop()
if not keypressed[K_x]:
snf2.stop()
if not keypressed[K_d]:
snf3.stop()
if not keypressed[K_c]:
snf4.stop()
if not keypressed[K_v]:
snf5.stop()
if not keypressed[K_g]:
snf5b.stop()
if not keypressed[K_b]:
snf6.stop()
if not keypressed[K_h]:
snf7.stop()
if not keypressed[K_n]:
snf8.stop()
if not keypressed[K_j]:
snf9.stop()
if not keypressed[K_m]:
snf10.stop()
if not (keypressed[K_q] or keypressed[K_LESS] or keypressed[K_COMMA]):
snf11.stop()
if not (keypressed[K_2] or keypressed[K_l]):
snf12.stop()
if not (keypressed[K_w] or keypressed[K_GREATER] or keypressed[K_PERIOD]):
snf13.stop()
if not (keypressed[K_3] or keypressed[K_COLON] or keypressed[K_SEMICOLON]):
snf14.stop()
if not (keypressed[K_e] or keypressed[K_SLASH] or keypressed[K_QUESTION]):
snf15.stop()
if not (keypressed[K_r]):
snf16.stop()
if not (keypressed[K_5]):
snf17.stop()
if not (keypressed[K_t]):
snf18.stop()
if not (keypressed[K_6]):
snf19.stop()
if not (keypressed[K_y]):
snf.stop()
if not (keypressed[K_7]):
snf20.stop()
if not (keypressed[K_u]):
snf21.stop()
if not (keypressed[K_i]):
snf22.stop()
if not (keypressed[K_9]):
snf23.stop()
if not (keypressed[K_o]):
snf24.stop()
if not (keypressed[K_0]):
snf25.stop()
if not (keypressed[K_p]):
snf26.stop()
if not keypressed[K_LEFTBRACKET]:
snf27.stop()
if not (keypressed[K_EQUALS] or keypressed[K_PLUS]):
snf28.stop()
if not keypressed[K_RIGHTBRACKET]:
snf29.stop()
pleasewaittx=simplefont.render("Please wait... Generating samples... ", True, (0, 0, 0), (255, 127, 127))
perc0tx=simplefont.render("0%", True, (0, 0, 0), (255, 127, 127))
perc25tx=simplefont.render("25%", True, (0, 0, 0), (255, 127, 127))
perc50tx=simplefont.render("50%", True, (0, 0, 0), (255, 127, 127))
perc75tx=simplefont.render("75%", True, (0, 0, 0), (255, 127, 127))
perc12tx=simplefont.render("12%", True, (0, 0, 0), (255, 127, 127))
perc37tx=simplefont.render("37%", True, (0, 0, 0), (255, 127, 127))
perc62tx=simplefont.render("62%", True, (0, 0, 0), (255, 127, 127))
perc87tx=simplefont.render("87%", True, (0, 0, 0), (255, 127, 127))
#Define sounds
def redefsounds():
global WAVDRAW
WAVDRAW=autosquare(110, notetime)
dispupdate()
screensurf.blit(pleasewaittx, (200, 580))
screensurf.blit(perc0tx, (460, 580))
pygame.display.update()
global snf
global snf0
global snf1
global snf2
global snf3
global snf4
global snf5
global snf5b
global snf6
global snf7
global snf8
global snf9
global snf10
global snf11
global snf12
global snf13
global snf14
global snf15
global snf16
global snf17
global snf18
global snf19
global snf20
global snf21
global snf22
global snf23
global snf24
global snf25
global snf26
global snf27
global snf28
global snf29
snf0=pygame.mixer.Sound(autosquare(65, notetime))
snf1=pygame.mixer.Sound(autosquare(69, notetime))
snf2=pygame.mixer.Sound(autosquare(74, notetime))
snf3=pygame.mixer.Sound(autosquare(78, notetime))
screensurf.blit(perc12tx, (460, 580))
pygame.display.update()
snf4=pygame.mixer.Sound(autosquare(82, notetime))
snf5=pygame.mixer.Sound(autosquare(87, notetime))
snf5b=pygame.mixer.Sound(autosquare(92, notetime))
snf6=pygame.mixer.Sound(autosquare(98, notetime))
screensurf.blit(perc25tx, (460, 580))
pygame.display.update()
snf7=pygame.mixer.Sound(autosquare(104, notetime))
snf8=pygame.mixer.Sound(autosquare(110, notetime))
snf9=pygame.mixer.Sound(autosquare(116, notetime))
snf9=pygame.mixer.Sound(autosquare(116, notetime))
snf10=pygame.mixer.Sound(autosquare(123, notetime))
screensurf.blit(perc37tx, (460, 580))
pygame.display.update()
snf11=pygame.mixer.Sound(autosquare(131, notetime))
snf12=pygame.mixer.Sound(autosquare(139, notetime))
snf13=pygame.mixer.Sound(autosquare(147, notetime))
snf14=pygame.mixer.Sound(autosquare(156, notetime))
snf15=pygame.mixer.Sound(autosquare(165, notetime))
screensurf.blit(perc50tx, (460, 580))
pygame.display.update()
snf16=pygame.mixer.Sound(autosquare(175, notetime))
snf17=pygame.mixer.Sound(autosquare(185, notetime))
snf18=pygame.mixer.Sound(autosquare(196, notetime))
snf19=pygame.mixer.Sound(autosquare(208, notetime))
screensurf.blit(perc62tx, (460, 580))
pygame.display.update()
snf19=pygame.mixer.Sound(autosquare(208, notetime))
snf=pygame.mixer.Sound(autosquare(220, notetime))
snf20=pygame.mixer.Sound(autosquare(233, notetime))
snf21=pygame.mixer.Sound(autosquare(247, notetime))
snf22=pygame.mixer.Sound(autosquare(262, notetime))
screensurf.blit(perc75tx, (460, 580))
pygame.display.update()
snf23=pygame.mixer.Sound(autosquare(277, notetime))
snf24=pygame.mixer.Sound(autosquare(294, notetime))
snf25=pygame.mixer.Sound(autosquare(311, notetime))
screensurf.blit(perc87tx, (460, 580))
pygame.display.update()
snf26=pygame.mixer.Sound(autosquare(330, notetime))
snf27=pygame.mixer.Sound(autosquare(349, notetime))
snf28=pygame.mixer.Sound(autosquare(370, notetime))
snf29=pygame.mixer.Sound(autosquare(392, notetime))
pygame.event.clear()
def setnotevols():
if wavemode==10:
notevolx=notevol*0.7
elif wavemode==9:
notevolx=notevol*1.1
else:
notevolx=notevol
for snd in [snf, snf0, snf1, snf2, snf3, snf4, snf5, snf5b, snf6, snf7, snf8, snf9, snf10, snf11, snf12, snf13, snf14, snf15, snf16, snf17, snf18, snf19, snf20, snf21, snf22, snf23, snf24, snf25, snf26, snf27, snf28, snf29]:
if stackit==1:
snd.set_volume((notevolx))
if stackit==2:
snd.set_volume((notevolx/1.3))
if stackit==3:
snd.set_volume((notevolx/1.5))
if stackit==4:
snd.set_volume((notevolx/1.6))
if stackit==5:
snd.set_volume((notevolx/1.7))
notevol=0.5
notestack=1
def meanx(numbers):
return float(sum(numbers)) / max(len(numbers), 1)
def absx(numbers):
return abs(sum(numbers))
def abssubx(numbers):
return abs(numbers[0] - sum(numbers[1:]))
mean=meanx
meanflg=0
def noteplay(notesnd):
if notestack==1:
notesnd.play(-1, fade_ms=fadeintime)
if notestack==2:
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
if notestack==3:
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
if notestack==4:
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
if notestack==5:
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
if notestack==6:
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
time.sleep(retrigtime)
notesnd.play(-1, fade_ms=fadeintime)
def notepop(notesnd):
if notestack==1:
noteplay(notesnd)
else:
notethread = Thread(target = noteplay, args = [notesnd])
notethread.start()
evhappenflg2=0
cpytx=simplefont.render("Copyright (c) 2016-2018 Thomas Leathers and contributors, See readme.md for details.", True, (0, 0, 0))
verstx=simplefont.render("v2.10", True, (0, 0, 0))
bgimg.blit(verstx, (2, 2))
bgimg.blit(cpytx, (2, 22))
txtx1=simplefont.render("Use keys q-],2,3, 5-7, 9,0, + and z-?/, s,d,g-k, l,: to play.", True, (0, 0, 0))
txtx2=simplefont.render("shift+1,2,3,4, or 5 controls octave stacking.", True, (0, 0, 0))
txtx2b=simplefont.render("CTRL+(-),0,1,2,3, or 4 controls octave shift.", True, (0, 0, 0))
txtx2c=simplefont.render("Shift + A,S,D,F,G,H controls Stack Synth ", True, (0, 0, 0))
txtx2bc=simplefont.render("ALT+shift+1,2,3 controls multi-trigger", True, (0, 0, 0))
txtx6=simplefont.render("shift+z,x,c,v,b,n,m controls square method", True, (0, 0, 0))
txtx7=simplefont.render("shift+q,w,e,r,t,y,u,i,o,p controls basewave", True, (0, 0, 0))
txtx1c=simplefont.render("Escape Quits", True, (0, 0, 0))
txtx3b=simplefont.render("(hold shift for fine control)", True, (0, 0, 0))
txtx3=simplefont.render("Use up and down arrow keys to control fade-out.", True, (0, 0, 0))
txtx4=simplefont.render("Use pageup and pagedown to control note volume.", True, (0, 0, 0))
txtx5=simplefont.render("Use left and right arrow keys to control fade-in.", True, (0, 0, 0))
txtx6=simplefont.render("Use Home and End keys to control multi-trigger delay", True, (0, 0, 0))
txtx8=simplefont.render("Use CTRL + PgUp and PgDn to control stack multi. mod.", True, (0, 0, 0))
txtx9=simplefont.render("Use alt+shift + z,x,c,v,b to control aux function.", True, (0, 0, 0))
bgimg.blit(txtx1, (2, 62))
bgimg.blit(txtx2, (2, 82))
bgimg.blit(txtx2b, (2, 102))
bgimg.blit(txtx1c, (400, 62))
bgimg.blit(txtx2c, (400, 82))
bgimg.blit(txtx2bc, (400, 102))
#bgimg.blit(txtx6, (400, 122))
bgimg.blit(txtx7, (400, 122))
bgimg.blit(txtx8, (400, 142))
bgimg.blit(txtx9, (400, 162))
bgimg.blit(txtx3b, (2, 122))
bgimg.blit(txtx4, (2, 142))
bgimg.blit(txtx3, (2, 162))
bgimg.blit(txtx5, (2, 182))
bgimg.blit(txtx6, (2, 202))
fadeintime=0
stm1=simplefont.render(("Stack Synth: Additive"), True, (255, 255, 255))
stm2=simplefont.render(("Stack Synth: Subtractive"), True, (255, 255, 255))
stm3=simplefont.render(("Stack Synth: adsub1"), True, (255, 255, 255))
stm4=simplefont.render(("Stack Synth: Add function"), True, (255, 255, 255))
stm5=simplefont.render(("Stack Synth: Sub function"), True, (255, 255, 255))
stm6=simplefont.render(("Stack Synth: function"), True, (255, 255, 255))
ws1=simplefont.render(("square method: floor"), True, (255, 255, 255))
ws2=simplefont.render(("square method: ceiling"), True, (255, 255, 255))
ws3=simplefont.render(("square method: vstroke"), True, (255, 255, 255))
ws4=simplefont.render(("square method: Two Way"), True, (255, 255, 255))
ws5=simplefont.render(("square method: cstroke"), True, (255, 255, 255))
ws6=simplefont.render(("square method: wstroke"), True, (255, 255, 255))
ws7=simplefont.render(("square method: Three Way"), True, (255, 255, 255))
wm1=simplefont.render(("Wave basetype: sin"), True, (255, 255, 255))
wm2=simplefont.render(("Wave basetype: tan"), True, (255, 255, 255))
wm3=simplefont.render(("Wave basetype: cos+sin"), True, (255, 255, 255))
wm4=simplefont.render(("Wave basetype: tan+sin"), True, (255, 255, 255))
wm5=simplefont.render(("Wave basetype: SC+S2"), True, (255, 255, 255))
wm6=simplefont.render(("Wave basetype: SC+C2"), True, (255, 255, 255))
wm7=simplefont.render(("Wave basetype: SC-S2"), True, (255, 255, 255))
wm8=simplefont.render(("Wave basetype: SC-C2"), True, (255, 255, 255))
wm9=simplefont.render(("Wave basetype: ap. sine"), True, (255, 255, 255))
wm10=simplefont.render(("Wave basetype: ap. tan"), True, (255, 255, 255))
af0=simplefont.render(("aux function: mean"), True, (255, 255, 255))
af1=simplefont.render(("aux function: max"), True, (255, 255, 255))
af2=simplefont.render(("aux function: min"), True, (255, 255, 255))
af3=simplefont.render(("aux function: abs sum"), True, (255, 255, 255))
af4=simplefont.render(("aux function: abs subtract"), True, (255, 255, 255))
sam1=simplefont.render(("Press enter/return to update samples!"), True, (0, 0, 0), (255, 127, 127))
sam2=simplefont.render(("Samples are updated."), True, (255, 255, 255))
def dispupdate():
notevtx=simplefont.render(("Note Vol: " + str(notevol)), True, (255, 255, 255))
fadetx=simplefont.render(("Note fadeout time: " + str(fadex)), True, (255, 255, 255))
fadeintx=simplefont.render(("Note fadein time: " + str(fadeintime)), True, (255, 255, 255))
stackintx=simplefont.render(("Octave Stacking: " + str(stackit)), True, (255, 255, 255))
octshifttx=simplefont.render(("Octave Shift: " + str(octshift)), True, (255, 255, 255))
multrigtx=simplefont.render(("Key multi-trigger: " + str(notestack)), True, (255, 255, 255))
arlimtx=simplefont.render(("multi-trigger delay: " + str(retrigtime)), True, (255, 255, 255))
stacksubtx=simplefont.render(("Stack Multiplier mod: " + str(stacksub)), True, (255, 255, 255))
if stackmod==1:
stacksyntx=stm1
elif stackmod==3:
stacksyntx=stm3
elif stackmod==4:
stacksyntx=stm4
elif stackmod==5:
stacksyntx=stm5
elif stackmod==6:
stacksyntx=stm6
else:
stacksyntx=stm2
if sampup==1:
syntx=sam1
else:
syntx=sam2
if strexmd==1:
wstx=ws1
elif strexmd==3:
wstx=ws3
elif strexmd==4:
wstx=ws4
elif strexmd==5:
wstx=ws5
elif strexmd==6:
wstx=ws6
elif strexmd==7:
wstx=ws7
else:
wstx=ws2
if wavemode==1:
wmtx=wm1
elif wavemode==3:
wmtx=wm3
elif wavemode==4:
wmtx=wm4
elif wavemode==5:
wmtx=wm5
elif wavemode==6:
wmtx=wm6
elif wavemode==7:
wmtx=wm7
elif wavemode==8:
wmtx=wm8
elif wavemode==9:
wmtx=wm9
elif wavemode==10:
wmtx=wm10
else:
wmtx=wm2
if meanflg==0:
auxfx=af0
elif meanflg==1:
auxfx=af1
elif meanflg==3:
auxfx=af3
elif meanflg==4:
auxfx=af4
else:
auxfx=af2
screensurf.blit(bgimg, (0, 0))
screensurf.blit(stacksyntx, (2, 480))
screensurf.blit(stackintx, (2, 500))
screensurf.blit(octshifttx, (2, 520))
screensurf.blit(wstx, (2, 540))
screensurf.blit(wmtx, (2, 560))
screensurf.blit(arlimtx, (2, 580))
screensurf.blit(multrigtx, (200, 480))
screensurf.blit(fadetx, (200, 520))
screensurf.blit(fadeintx, (200, 540))
screensurf.blit(notevtx, (200, 500))
screensurf.blit(syntx, (200, 580))
screensurf.blit(auxfx, (400, 500))
screensurf.blit(stacksubtx, (400, 480))
drawwave()
pygame.display.update()
#waveform drawing function.
def drawwave():
xpos=2
xjump=400.0/len(WAVDRAW)
yposbase=400
yposmag=0.00000002
oldxpos=0
oldypos=0
vlinecnt=0
vlineinterv=60
pygame.draw.rect(screensurf, (0, 0, 0), pygame.Rect(0, yposbase-60, 401, 121))
for x in WAVDRAW:
if vlinecnt<vlineinterv:
vlinecnt+=1
else:
vlinecnt=0
pygame.draw.line(screensurf, (0, 0, 150), (xpos, yposbase-60), (xpos, yposbase+60))
xpos+=xjump
xpos=2
pygame.draw.line(screensurf, (0, 255, 0), (0, yposbase), (400, yposbase))
for x in WAVDRAW:
xmag=x*yposmag
if xmag>60:
xmag=60
if xmag<-60:
xmag=-60
pygame.draw.line(screensurf, (255, 0, 0), (oldxpos, (oldypos+yposbase)), (xpos, (xmag+yposbase)))
pygame.draw.line(screensurf, (255, 255, 255), (xpos, (xmag+3+yposbase)), (xpos, (xmag+4+yposbase)))
oldypos=xmag
oldxpos=xpos
xpos+=xjump
sampup=0
redefsounds()
setnotevols()
dispupdate()
fscreen=0
while evhappenflg2==0:
time.sleep(.001)
keycheckoff()
for event in pygame.event.get():
if event.type == KEYDOWN and event.key == K_RETURN:
if sampup==1:
redefsounds()
setnotevols()
sampup=0
dispupdate()
if event.type == KEYDOWN and event.key == K_SPACE:
pygame.mixer.stop()
if event.type == KEYDOWN and event.key == K_F1:
if fscreen==0:
screensurf=pygame.display.set_mode((800, 600), pygame.FULLSCREEN)
fscreen=1
dispupdate()
else:
screensurf=pygame.display.set_mode((800, 600))
fscreen=0
dispupdate()
if (pygame.key.get_mods() & pygame.KMOD_ALT) and (pygame.key.get_mods() & pygame.KMOD_SHIFT):
if event.type == KEYDOWN and event.key == K_z:
if meanflg!=0:
mean=meanx
meanflg=0
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_x:
if meanflg!=1:
meanflg=1
mean=max
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_c:
if meanflg!=2:
meanflg=2
mean=min
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_v:
if meanflg!=3:
meanflg=3
mean=absx
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_b:
if meanflg!=4:
meanflg=4
mean=abssubx
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_1:
if notestack!=1:
notestack=1
dispupdate()
if event.type == KEYDOWN and event.key == K_2:
if notestack!=2:
notestack=2
dispupdate()
if event.type == KEYDOWN and event.key == K_3:
if notestack!=3:
notestack=3
dispupdate()
if event.type == KEYDOWN and event.key == K_4:
if notestack!=4:
notestack=4
dispupdate()
if event.type == KEYDOWN and event.key == K_5:
if notestack!=5:
notestack=5
dispupdate()
if event.type == KEYDOWN and event.key == K_6:
if notestack!=6:
notestack=6
dispupdate()
elif pygame.key.get_mods() & pygame.KMOD_SHIFT:
if event.type == KEYDOWN and event.key == K_1:
if stackit!=1:
stackit=1
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_2:
if stackit!=2:
stackit=2
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_3:
if stackit!=3:
stackit=3
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_4:
if stackit!=4:
stackit=4
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_5:
if stackit!=5:
stackit=5
sampup=1
dispupdate()
#wavemode
if event.type == KEYDOWN and event.key == K_q:
if wavemode!=1:
wavemode=1
foobsin=foobsin1
sampup=1
dispupdate()
if event.type == KEYDOWN and event.key == K_w:
if wavemode!=2:
wavemode=2