info@shuvit.org 2 years ago
parent
commit
07a358c1db
11 changed files with 180 additions and 73 deletions
  1. 1
    1
      config.txt
  2. 3
    1
      lib/StatesProg.py
  3. 87
    32
      lib/menus.py
  4. 10
    10
      lib/sEditSoundSequence.py
  5. 11
    7
      lib/sMain.py
  6. 37
    1
      lib/sSelectPattern.py
  7. 30
    11
      main.py
  8. 1
    2
      runner.sh
  9. 0
    4
      user/songs/EMU_SP-12.sng
  10. 0
    4
      user/songs/Linn_Linndrum.sng
  11. 0
    0
      user/songs/other/thing.nope

+ 1
- 1
config.txt View File

1
-default_song = 909
1
+default_song = Casio_SK-1
2
 theme = default
2
 theme = default
3
 title = default
3
 title = default
4
 bpm = 90
4
 bpm = 90

+ 3
- 1
lib/StatesProg.py View File

113
 		self.FSM.stateLife = 1
113
 		self.FSM.stateLife = 1
114
 		o = self.FSM.owner
114
 		o = self.FSM.owner
115
 		o.header_text = "Starting up..."
115
 		o.header_text = "Starting up..."
116
+
116
 		o.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
117
 		o.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
117
 		#u.draw_header(o)
118
 		#u.draw_header(o)
118
 		#o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)			
119
 		#o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)			
119
-		o.center_block("Starting up...", o.h2, [0, 0, o.width, o.height], o.light_grey)
120
+		o.center_block("zpc_ct", o.h4, [0, 0, o.width, o.height-40], o.light_grey)
121
+		o.center_block("Starting up...", o.h2, [0, 0, o.width, o.height+60], o.light_grey)
120
 		#o.display_thread.start()
122
 		#o.display_thread.start()
121
 		o.update_display(0)
123
 		o.update_display(0)
122
 		#o.update_display(0)
124
 		#o.update_display(0)

+ 87
- 32
lib/menus.py View File

1
 import utils as u
1
 import utils as u
2
 import pygame
2
 import pygame
3
+from itertools import cycle
3
 
4
 
4
 def draw_menu1(o):
5
 def draw_menu1(o):
5
 	bpm_inc = 4
6
 	bpm_inc = 4
63
 	text_padding = 6
64
 	text_padding = 6
64
 	_id = 0
65
 	_id = 0
65
 	while _id < 16:
66
 	while _id < 16:
66
-	   
67
 		o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
67
 		o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
68
-
69
 		
68
 		
70
 		if _id == 0:
69
 		if _id == 0:
71
 			o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
70
 			o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
75
 			o.center_block("Del", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
74
 			o.center_block("Del", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
76
 		if _id == 3:
75
 		if _id == 3:
77
 			o.center_block("Load", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
76
 			o.center_block("Load", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
77
+		
78
+		if _id == 4:
79
+			if o.prev == True:
80
+				o.center_block("Prev", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
81
+			else:
82
+				o.center_block("Prev", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
78
 
83
 
79
 		if _id == 8:
84
 		if _id == 8:
80
 			o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
85
 			o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
141
 		if _id == 7:
146
 		if _id == 7:
142
 			o.center_block("Bank +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
147
 			o.center_block("Bank +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
143
 
148
 
149
+		if _id == 12:
150
+			if o.pat_odub:
151
+				o.center_block("Odub", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
152
+			else:
153
+				o.center_block("Odub", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
154
+		if _id == 13:
155
+			if o.pat_perf:
156
+				o.center_block("Perf", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
157
+			else:
158
+				o.center_block("Perf", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
159
+
144
 		o_x = o_x + x_size
160
 		o_x = o_x + x_size
145
 		_id += 1
161
 		_id += 1
146
 		if _id % 4 == 0:
162
 		if _id % 4 == 0:
229
 
245
 
230
 def menu1_actions(self, o):
246
 def menu1_actions(self, o):
231
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
247
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
232
-		print('reset repeat from menu')
248
+		#print('reset repeat from menu')
233
 		o.button_repeater(1,[])
249
 		o.button_repeater(1,[])
234
 
250
 
235
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
251
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
236
-		print('reset repeat from menu')
252
+		#print('reset repeat from menu')
237
 		o.button_repeater(1,[])
253
 		o.button_repeater(1,[])
238
 
254
 
239
 	if o.keyState[16] == 2:
255
 	if o.keyState[16] == 2:
329
 
345
 
330
 def menu2_actions_sample(self, o):
346
 def menu2_actions_sample(self, o):
331
 	if o.keyState[6] == 4 or o.keyState[6] == 3:
347
 	if o.keyState[6] == 4 or o.keyState[6] == 3:
332
-		print('reset repeat from menu')
348
+		#print('reset repeat from menu')
333
 		o.button_repeater(1,[])
349
 		o.button_repeater(1,[])
334
 
350
 
335
 	if o.keyState[7] == 4 or o.keyState[7] == 3:
351
 	if o.keyState[7] == 4 or o.keyState[7] == 3:
336
-		print('reset repeat from menu')
352
+		#print('reset repeat from menu')
337
 		o.button_repeater(1,[])
353
 		o.button_repeater(1,[])
338
 
354
 
339
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
355
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
340
-		print('reset repeat from menu')
356
+		#print('reset repeat from menu')
341
 		o.button_repeater(1,[])
357
 		o.button_repeater(1,[])
342
 
358
 
343
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
359
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
344
-		print('reset repeat from menu')
360
+		#print('reset repeat from menu')
345
 		o.button_repeater(1,[])
361
 		o.button_repeater(1,[])
346
 
362
 
347
 	if o.keyState[10] == 4 or o.keyState[10] == 3:
363
 	if o.keyState[10] == 4 or o.keyState[10] == 3:
348
-		print('reset repeat from menu')
364
+		#print('reset repeat from menu')
349
 		o.button_repeater(1,[])
365
 		o.button_repeater(1,[])
350
 
366
 
351
 	if o.keyState[11] == 4 or o.keyState[11] == 3:
367
 	if o.keyState[11] == 4 or o.keyState[11] == 3:
352
-		print('reset repeat from menu')
368
+		#print('reset repeat from menu')
353
 		o.button_repeater(1,[])
369
 		o.button_repeater(1,[])
354
 
370
 
355
 	if o.keyState[17] == 2:
371
 	if o.keyState[17] == 2:
356
 		if o.keyState[0] == 1:
372
 		if o.keyState[0] == 1:
357
 			if o.soundSlots[o.eSound].volume > 0:
373
 			if o.soundSlots[o.eSound].volume > 0:
358
-				print('copy')
374
+				#print('copy')
359
 				o.soundClipboard = [o.soundSlots[o.eSound].file, o.soundSlots[o.eSound].volume, o.soundSlots[o.eSound].pitch]
375
 				o.soundClipboard = [o.soundSlots[o.eSound].file, o.soundSlots[o.eSound].volume, o.soundSlots[o.eSound].pitch]
360
-				print(o.soundClipboard)
376
+				#print(o.soundClipboard)
361
 
377
 
362
 		if o.keyState[1] == 1:
378
 		if o.keyState[1] == 1:
363
 			if o.soundClipboard != []:
379
 			if o.soundClipboard != []:
364
-				print('pasting ', o.soundClipboard)				
380
+				#print('pasting ', o.soundClipboard)				
365
 				o.soundSlots[o.eSound].file = o.soundClipboard[0]
381
 				o.soundSlots[o.eSound].file = o.soundClipboard[0]
366
 				o.soundSlots[o.eSound].volume = o.soundClipboard[1]
382
 				o.soundSlots[o.eSound].volume = o.soundClipboard[1]
367
 				o.soundSlots[o.eSound].pitch = o.soundClipboard[2]
383
 				o.soundSlots[o.eSound].pitch = o.soundClipboard[2]
369
 				o.soundSlots[o.eSound].set_pitch()
385
 				o.soundSlots[o.eSound].set_pitch()
370
 			
386
 			
371
 		if o.keyState[2] == 1:
387
 		if o.keyState[2] == 1:
372
-			print('delete sound ', o.eSound)
388
+			#print('delete sound ', o.eSound)
373
 			o.soundSlots[o.eSound].file = None
389
 			o.soundSlots[o.eSound].file = None
374
 			o.soundSlots[o.eSound].volume = 16
390
 			o.soundSlots[o.eSound].volume = 16
375
 			o.soundSlots[o.eSound].pitch = 0
391
 			o.soundSlots[o.eSound].pitch = 0
376
 		if o.keyState[3] == 1:
392
 		if o.keyState[3] == 1:
377
-			print('load')
393
+			#print('load')
378
 			o.FSM.FSM.ToTransition("toLoadSound")
394
 			o.FSM.FSM.ToTransition("toLoadSound")
379
 
395
 
396
+
397
+		if o.keyState[4] == 1:
398
+			o.prev = not o.prev
399
+			draw_menu2_sample(o)
400
+			o.update_display(0)
401
+
380
 		if o.keyState[8] == 2:
402
 		if o.keyState[8] == 2:
381
 			if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
403
 			if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
382
 				if o.soundSlots[o.eSound].volume > 0:
404
 				if o.soundSlots[o.eSound].volume > 0:
476
 		if o.keyState[12] == 1:
498
 		if o.keyState[12] == 1:
477
 			o.odub = not o.odub
499
 			o.odub = not o.odub
478
 			o.undo_buf = []
500
 			o.undo_buf = []
479
-			print('odub now is ', o.odub)
501
+			#print('odub now is ', o.odub)
480
 			draw_menu2_sample(o)
502
 			draw_menu2_sample(o)
481
 			o.update_display(0)
503
 			o.update_display(0)
482
 
504
 
483
 		if o.keyState[13] == 1:
505
 		if o.keyState[13] == 1:
484
-			print('undo something')
506
+			#print('undo something')
485
 			for i in o.undo_buf:
507
 			for i in o.undo_buf:
486
 				o.soundSlots[i[0]].notes[i[1]][i[2]][0] = 0
508
 				o.soundSlots[i[0]].notes[i[1]][i[2]][0] = 0
487
 				o.soundSlots[i[0]].notes[i[1]][i[2]][1] = 0
509
 				o.soundSlots[i[0]].notes[i[1]][i[2]][1] = 0
490
 		if o.keyState[14] == 1:
512
 		if o.keyState[14] == 1:
491
 			o.erase = not o.erase
513
 			o.erase = not o.erase
492
 			o.erase_buf = []
514
 			o.erase_buf = []
493
-			print('erase now is ', o.erase)
515
+			#print('erase now is ', o.erase)
494
 			if o.erase:
516
 			if o.erase:
495
 				o.mute = False
517
 				o.mute = False
496
 				o.mute_buf = []
518
 				o.mute_buf = []
500
 		if o.keyState[15] == 1:
522
 		if o.keyState[15] == 1:
501
 			o.mute = not o.mute
523
 			o.mute = not o.mute
502
 			o.mute_buf = []
524
 			o.mute_buf = []
503
-			print('mute now is ', o.mute)
525
+			#print('mute now is ', o.mute)
504
 			if o.mute:
526
 			if o.mute:
505
 				o.erase = False
527
 				o.erase = False
506
 				o.erase_buf = []
528
 				o.erase_buf = []
554
 				u.text_center(o, "Pattern Bank", str(o.pat_bank))
576
 				u.text_center(o, "Pattern Bank", str(o.pat_bank))
555
 				o.update_display(0)		
577
 				o.update_display(0)		
556
 				
578
 				
579
+#--------------------------------------------
580
+		elif o.keyState[12] == 1:
581
+			o.pat_odub = not o.pat_odub
582
+			if o.pat_odub:
583
+				if o.playing:
584
+					o.stop_playback()
585
+				o.song_in = [o.curPattern]
586
+				if o.pat_perf:
587
+					pass
588
+				else:
589
+					o.pat_perf = True
590
+			else:
591
+				o.pat_perf = False
592
+				o.song = o.song_in
593
+				o.pat_buf = o.song_in
594
+				o.song_in = []
595
+				o.songCycle = cycle(o.song)
596
+				o.songStart = o.song[0]
597
+
598
+			draw_menu2_pattern(o)
599
+			o.update_display(0)		
600
+				
601
+
602
+		elif o.keyState[13] == 1:
603
+			o.pat_perf = not o.pat_perf
604
+			if o.pat_perf:
605
+				o.pat_buf = o.song
606
+				o.song = []
607
+				print('song is now ', o.song)
608
+			else:
609
+				o.song = o.pat_buf
610
+				print('song is now ', o.song)
611
+
612
+			draw_menu2_pattern(o)
613
+			o.update_display(0)		
614
+
557
 def menu2_actions_song(self, o):
615
 def menu2_actions_song(self, o):
558
 	if o.keyState[17] == 2:
616
 	if o.keyState[17] == 2:
559
 		
617
 		
573
 
631
 
574
 def menu2_actions_note(self, o):
632
 def menu2_actions_note(self, o):
575
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
633
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
576
-		print('reset repeat from menu')
634
+		#print('reset repeat from menu')
577
 		o.button_repeater(1,[])
635
 		o.button_repeater(1,[])
578
 
636
 
579
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
637
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
580
-		print('reset repeat from menu')
638
+		#print('reset repeat from menu')
581
 		o.button_repeater(1,[])
639
 		o.button_repeater(1,[])
582
 
640
 
583
 	if o.keyState[17] == 2:
641
 	if o.keyState[17] == 2:
619
 			else:
677
 			else:
620
 				o.patternFollow = True
678
 				o.patternFollow = True
621
 
679
 
622
-			print('pattern follow is ', o.patternFollow)
680
+			#print('pattern follow is ', o.patternFollow)
623
 			draw_menu2_note(o)
681
 			draw_menu2_note(o)
624
 			o.update_display(0)			
682
 			o.update_display(0)			
625
 					
683
 					
627
 def menu2_actions_saveas(self, o):
685
 def menu2_actions_saveas(self, o):
628
 	if o.keyState[17] == 2:
686
 	if o.keyState[17] == 2:
629
 		if o.keyState[12] == 1:
687
 		if o.keyState[12] == 1:
630
-			print('select folder')
688
+			#print('select folder')
631
 			self.FSM.ToTransition('toSelectFolder')	
689
 			self.FSM.ToTransition('toSelectFolder')	
632
 		elif o.keyState[14] == 1:
690
 		elif o.keyState[14] == 1:
633
-			print('new folder')
634
-			#o.song_dir
635
-			#os.mkdir(path)
691
+			#print('new folder')
636
 			self.FSM.ToTransition('toNewDir')	
692
 			self.FSM.ToTransition('toNewDir')	
637
 
693
 
638
 
694
 
645
 		self.FSM.ToTransition('toDefender')	
701
 		self.FSM.ToTransition('toDefender')	
646
 	elif command == "Calculator":
702
 	elif command == "Calculator":
647
 		self.FSM.ToTransition('toCalculator')	
703
 		self.FSM.ToTransition('toCalculator')	
648
-
649
 	elif command == "Exit":
704
 	elif command == "Exit":
650
 		self.FSM.ToTransition('toExit')		
705
 		self.FSM.ToTransition('toExit')		
651
 	elif command == "Theme":
706
 	elif command == "Theme":
654
 		self.FSM.ToTransition('toReboot')		
709
 		self.FSM.ToTransition('toReboot')		
655
 	elif command == "Update":
710
 	elif command == "Update":
656
 		self.FSM.ToTransition('toUpdate')	
711
 		self.FSM.ToTransition('toUpdate')	
657
-		#os.system("sudo reboot")
658
 	elif command == "Shutdown":
712
 	elif command == "Shutdown":
659
 		self.FSM.ToTransition('toShutdown')		
713
 		self.FSM.ToTransition('toShutdown')		
660
 	elif command == "Ping":
714
 	elif command == "Ping":
669
 		if o.sconf['title'] != "blank":
723
 		if o.sconf['title'] != "blank":
670
 			o.save_song()
724
 			o.save_song()
671
 		else:
725
 		else:
672
-			print('cant save over blank')
726
+			pass
727
+			#print('cant save over blank')
673
 	
728
 	
674
 	elif command == "Open":
729
 	elif command == "Open":
675
 		self.FSM.ToTransition('toOpenSong')	
730
 		self.FSM.ToTransition('toOpenSong')	
676
 	elif command == "Save As":
731
 	elif command == "Save As":
677
 		self.FSM.ToTransition('toEnterText')	
732
 		self.FSM.ToTransition('toEnterText')	
678
 	elif command == "New":
733
 	elif command == "New":
679
-		#self.FSM.ToTransition('toEnterText')
680
-		#o.title = '_blank'
734
+		o.song_dir = o.base_song_dir
681
 		o.mconf['default_song'] = '_blank'
735
 		o.mconf['default_song'] = '_blank'
682
-		o.load_song()
736
+		o.load_song()
737
+		self.FSM.ToTransition('toMain')	

+ 10
- 10
lib/sEditSoundSequence.py View File

31
 		else:
31
 		else:
32
 			u.draw_header(o)
32
 			u.draw_header(o)
33
 			self.draw_square()
33
 			self.draw_square()
34
-			u.text_box1(o, "Note Vol", str(o.note_vol))
35
-			u.text_box3(o, "Pat", str(self.curPattern))
34
+			u.text_box3(o, "Vol", str(o.note_vol))
35
+			u.text_box1(o, "Pat", str(self.curPattern))
36
 			o.update_display(0)
36
 			o.update_display(0)
37
 		super(EditSoundSequence, self).Enter()        
37
 		super(EditSoundSequence, self).Enter()        
38
 		
38
 		
46
 		elif o.keyState[16] == 4:
46
 		elif o.keyState[16] == 4:
47
 			u.draw_header(o)
47
 			u.draw_header(o)
48
 			self.draw_square()
48
 			self.draw_square()
49
-			u.text_box1(o, "Note Vol", str(o.note_vol))
50
-			u.text_box3(o, "Pat", str(self.curPattern))
49
+			u.text_box3(o, "Vol", str(o.note_vol))
50
+			u.text_box1(o, "Pat", str(self.curPattern))
51
 			o.update_display(0)
51
 			o.update_display(0)
52
 
52
 
53
 		if o.keyState[17] == 1:
53
 		if o.keyState[17] == 1:
56
 		elif o.keyState[17] == 4:
56
 		elif o.keyState[17] == 4:
57
 			u.draw_header(o)
57
 			u.draw_header(o)
58
 			self.draw_square()
58
 			self.draw_square()
59
-			u.text_box1(o, "Note Vol", str(o.note_vol))
60
-			u.text_box3(o, "Pat", str(self.curPattern))
59
+			u.text_box3(o, "Vol", str(o.note_vol))
60
+			u.text_box1(o, "Pat", str(self.curPattern))
61
 			o.update_display(0)
61
 			o.update_display(0)
62
 
62
 
63
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
63
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
75
 						o.soundSlots[o.eSound].notes[self.curPattern][_id][1] = o.note_vol
75
 						o.soundSlots[o.eSound].notes[self.curPattern][_id][1] = o.note_vol
76
 					u.draw_header(o)
76
 					u.draw_header(o)
77
 					self.draw_square()
77
 					self.draw_square()
78
-					u.text_box1(o, "Note Vol", str(o.note_vol))			
79
-					u.text_box3(o, "Pat", str(self.curPattern))
78
+					u.text_box3(o, "Vol", str(o.note_vol))			
79
+					u.text_box1(o, "Pat", str(self.curPattern))
80
 					o.update_display(0)
80
 					o.update_display(0)
81
 				_id += 1
81
 				_id += 1
82
 		
82
 		
112
 		else:
112
 		else:
113
 			u.draw_header(o)            
113
 			u.draw_header(o)            
114
 			self.draw_square()  
114
 			self.draw_square()  
115
-			u.text_box1(o, "Note Vol", str(o.note_vol))
116
-			u.text_box3(o, "Pat", str(self.curPattern))
115
+			u.text_box3(o, "Vol", str(o.note_vol))
116
+			u.text_box1(o, "Pat", str(self.curPattern))
117
 		if o.patternFollow:
117
 		if o.patternFollow:
118
 			self.curPattern = message[0]
118
 			self.curPattern = message[0]
119
 		else:
119
 		else:

+ 11
- 7
lib/sMain.py View File

32
 		else:
32
 		else:
33
 			u.draw_header(o)
33
 			u.draw_header(o)
34
 			self.draw_square()
34
 			self.draw_square()
35
-
36
-			u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
35
+			u.text_box1(o, "Pat", str(o.curPattern))
36
+			#u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
37
 			u.text_box2(o, "BPM", str(o.bpm))
37
 			u.text_box2(o, "BPM", str(o.bpm))
38
 			u.text_box4(o, "Bank", str(o.note_bank))
38
 			u.text_box4(o, "Bank", str(o.note_bank))
39
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
39
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
60
 		elif o.keyState[16] == 4:
60
 		elif o.keyState[16] == 4:
61
 			u.draw_header(o)
61
 			u.draw_header(o)
62
 			self.draw_square()
62
 			self.draw_square()
63
-			u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
63
+			#u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
64
+			u.text_box1(o, "Pat", str(o.curPattern))
64
 			u.text_box2(o, "BPM", str(o.bpm))
65
 			u.text_box2(o, "BPM", str(o.bpm))
65
 			u.text_box4(o, "Bank", str(o.note_bank))
66
 			u.text_box4(o, "Bank", str(o.note_bank))
66
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
67
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
73
 		elif o.keyState[17] == 4:
74
 		elif o.keyState[17] == 4:
74
 			u.draw_header(o)
75
 			u.draw_header(o)
75
 			self.draw_square()
76
 			self.draw_square()
76
-			u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
77
+			#u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
78
+			u.text_box1(o, "Pat", str(o.curPattern))
77
 			u.text_box2(o, "BPM", str(o.bpm))
79
 			u.text_box2(o, "BPM", str(o.bpm))
78
 			u.text_box4(o, "Bank", str(o.note_bank))
80
 			u.text_box4(o, "Bank", str(o.note_bank))
79
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
81
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
90
 					note = _id + o.note_bank * 16
92
 					note = _id + o.note_bank * 16
91
 					if k == 1:						
93
 					if k == 1:						
92
 						self.record_queue = pygame.time.get_ticks()
94
 						self.record_queue = pygame.time.get_ticks()
93
-						if not o.erase and not o.mute:
95
+						if not o.erase and not o.mute and o.prev:
94
 							o.soundSlots[note].play(o.note_vol)
96
 							o.soundSlots[note].play(o.note_vol)
95
 						o.eSound = note
97
 						o.eSound = note
96
 						u.draw_header(o)
98
 						u.draw_header(o)
97
-						u.text_box1(o, "SVol", str(o.slots[o.eSound].volume))
99
+						#u.text_box1(o, "SVol", str(o.slots[o.eSound].volume))
100
+						u.text_box1(o, "Pat", str(o.curPattern))
98
 						u.text_box2(o, "BPM", str(o.bpm))
101
 						u.text_box2(o, "BPM", str(o.bpm))
99
 						u.text_box4(o, "Bank", str(o.note_bank))
102
 						u.text_box4(o, "Bank", str(o.note_bank))
100
 						u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
103
 						u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
123
 		else:
126
 		else:
124
 			u.draw_header(o)            
127
 			u.draw_header(o)            
125
 			self.draw_square()   
128
 			self.draw_square()   
126
-			u.text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
129
+			u.text_box1(o, "Pat", str(o.curPattern))
130
+			#u.text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
127
 			u.text_box2(o, "BPM", str(o.bpm))
131
 			u.text_box2(o, "BPM", str(o.bpm))
128
 			u.text_box4(o, "Bank", str(o.note_bank))
132
 			u.text_box4(o, "Bank", str(o.note_bank))
129
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))			         
133
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))			         

+ 37
- 1
lib/sSelectPattern.py View File

1
 import FSM
1
 import FSM
2
 import utils as u
2
 import utils as u
3
 import menus as m
3
 import menus as m
4
+from itertools import cycle
4
 #====================================     
5
 #====================================     
5
 
6
 
6
 State = type("State", (object,), {})
7
 State = type("State", (object,), {})
29
 		self.cur_playing = 0
30
 		self.cur_playing = 0
30
 		self.active_patterns = []
31
 		self.active_patterns = []
31
 		self.get_active_patterns(o)
32
 		self.get_active_patterns(o)
33
+		o.pat_buf = o.song
34
+		self.new_song = []
32
 
35
 
33
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
36
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
34
 			pass
37
 			pass
75
 					pass
78
 					pass
76
 				else:
79
 				else:
77
 					if k == 1:
80
 					if k == 1:
81
+						if o.pat_perf:
82
+							this = o.ePattern = (o.pat_bank * 16) +_id 
83
+							#print('we should play ', this)	
84
+							o.song = [this]
85
+							o.songCycle = cycle(o.song)
86
+							o.songStart = this
87
+							if not o.playing:
88
+								
89
+								
90
+								o.start_playback()
91
+								u.play_seq(o, [o.curPattern, 0])
78
 						o.ePattern = (o.pat_bank * 16) +_id 
92
 						o.ePattern = (o.pat_bank * 16) +_id 
79
 
93
 
80
 						u.draw_header(o)
94
 						u.draw_header(o)
99
 				u.text_box1(o, "Pat", str(o.ePattern))
113
 				u.text_box1(o, "Pat", str(o.ePattern))
100
 				u.text_box4(o, "Bank", str(o.pat_bank))
114
 				u.text_box4(o, "Bank", str(o.pat_bank))
101
 				o.update_display(0)
115
 				o.update_display(0)
116
+			# if o.pat_odub:
117
+			# 	print('add to record queue ', o.song[0])
118
+			# else:
119
+			# 	print('not recording')
120
+		#print(message)
121
+		if o.pat_odub:
122
+			if message[1] == 0:
123
+				if len(o.song) > 0:
124
+					#print('adding to rec', o.song[0])
125
+					o.song_in.append(o.song[0])
126
+					#print('adding to song_in ', o.song_in)
102
 
127
 
103
 	def draw_square(self):
128
 	def draw_square(self):
104
 		o = self.FSM.owner 
129
 		o = self.FSM.owner 
139
 			_iter += 1
164
 			_iter += 1
140
 	
165
 	
141
 	def Exit(self):
166
 	def Exit(self):
142
-		self.FSM.owner.pub.unregister("beat", self)
167
+		o = self.FSM.owner 
168
+		o.pub.unregister("beat", self)
169
+		# if len(o.song) < 1 and len(o.pat_buf) > 0:
170
+		# 	o.song = o.pat_buf
171
+		# 	o.pat_buf = []
172
+		o.pat_perf = False
173
+		
174
+		o.song = o.pat_buf
175
+		o.pat_buf = []
176
+		o.songCycle = cycle(o.song)
177
+		o.songStart = o.song[0]
178
+		#print('song is ', o.song)

+ 30
- 11
main.py View File

76
 		self.h1 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 30)
76
 		self.h1 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 30)
77
 		self.h2 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 20)
77
 		self.h2 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 20)
78
 		self.h3 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 54)
78
 		self.h3 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 54)
79
+		self.h4 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 72)
79
 		
80
 		
80
 		self.disp = st7789.ST7789(
81
 		self.disp = st7789.ST7789(
81
 			spi,
82
 			spi,
139
 		self.olive = "#80D52A"
140
 		self.olive = "#80D52A"
140
 		self.notes_on = []
141
 		self.notes_on = []
141
 		self.clear_notes_on()
142
 		self.clear_notes_on()
143
+		self.prev = True
144
+		self.pat_odub = False
145
+		self.pat_perf = False
146
+		self.pat_buf = None
147
+		self.song_in = []
142
 
148
 
143
 		self.press_ticks_up = None
149
 		self.press_ticks_up = None
144
 		self.press_ticks_down = None
150
 		self.press_ticks_down = None
289
 			pygame.time.set_timer(TIMER, int(bpm))
295
 			pygame.time.set_timer(TIMER, int(bpm))
290
 
296
 
291
 	def start_playback(self):
297
 	def start_playback(self):
292
-		self.playing = True
293
-		self.playhead = -1
294
-		self.playhead = 0
295
-		self.songCycle = cycle(self.song)
296
-		self.curPattern = next(self.songCycle)
297
-		self.songStart = self.curPattern
298
-		bpm = (60000 / self.bpm) / 4
299
-		pygame.time.set_timer(TIMER, int(bpm))
300
-		GPIO.setup(29, GPIO.OUT)
301
-		GPIO.output(29, GPIO.LOW)
298
+		if len(self.song) > 0:
299
+			self.playing = True
300
+			self.playhead = -1
301
+			self.playhead = 0
302
+			self.songCycle = cycle(self.song)
303
+			self.curPattern = next(self.songCycle)
304
+			self.songStart = self.curPattern
305
+			bpm = (60000 / self.bpm) / 4
306
+			pygame.time.set_timer(TIMER, int(bpm))
307
+			GPIO.setup(29, GPIO.OUT)
308
+			GPIO.output(29, GPIO.LOW)
302
 		
309
 		
303
 
310
 
304
 	def stop_playback(self):
311
 	def stop_playback(self):
305
 		self.playing = False
312
 		self.playing = False
306
 		self.playhead = -1
313
 		self.playhead = -1
307
 		self.playhead = 0
314
 		self.playhead = 0
308
-		self.curPattern = self.song[0]
315
+		if len(self.song) > 0:
316
+			self.curPattern = self.song[0]
317
+		else:
318
+			self.curPattern = 0
309
 		pygame.time.set_timer(TIMER, 0)
319
 		pygame.time.set_timer(TIMER, 0)
310
 		GPIO.setup(29, GPIO.OUT)
320
 		GPIO.setup(29, GPIO.OUT)
311
 		GPIO.output(29, GPIO.HIGH)
321
 		GPIO.output(29, GPIO.HIGH)
322
+		if self.pat_odub:
323
+			print('stopping with odub')
324
+			self.pat_perf = False
325
+			self.pat_odub = False
326
+			self.song = self.song_in
327
+			self.pat_buf = self.song_in
328
+			self.song_in = []
329
+			self.songCycle = cycle(self.song)
330
+			self.songStart = self.song[0]
312
 
331
 
313
 	def center_text(self, text, font, width, y, color):
332
 	def center_text(self, text, font, width, y, color):
314
 		w,h = font.getsize(text)
333
 		w,h = font.getsize(text)

+ 1
- 2
runner.sh View File

1
-#until "python3 /home/pi/zpc_ct/main.py"; do
2
 until python3 ./main.py; do
1
 until python3 ./main.py; do
3
-    echo "App 'zpc_ct' crashed with exit code $?.  Respawning.." >&2
2
+    echo "zpc_ct crashed with exit code $?.  Respawning.." >&2
4
     sleep 2
3
     sleep 2
5
 done
4
 done

+ 0
- 4
user/songs/EMU_SP-12.sng
File diff suppressed because it is too large
View File


+ 0
- 4
user/songs/Linn_Linndrum.sng
File diff suppressed because it is too large
View File


+ 0
- 0
user/songs/other/thing.nope View File


Loading…
Cancel
Save