info@shuvit.org 9 months 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,4 +1,4 @@
1
-default_song = 909
1
+default_song = Casio_SK-1
2 2
 theme = default
3 3
 title = default
4 4
 bpm = 90

+ 3
- 1
lib/StatesProg.py View File

@@ -113,10 +113,12 @@ class Intro(State):
113 113
 		self.FSM.stateLife = 1
114 114
 		o = self.FSM.owner
115 115
 		o.header_text = "Starting up..."
116
+
116 117
 		o.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
117 118
 		#u.draw_header(o)
118 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 122
 		#o.display_thread.start()
121 123
 		o.update_display(0)
122 124
 		#o.update_display(0)

+ 87
- 32
lib/menus.py View File

@@ -1,5 +1,6 @@
1 1
 import utils as u
2 2
 import pygame
3
+from itertools import cycle
3 4
 
4 5
 def draw_menu1(o):
5 6
 	bpm_inc = 4
@@ -63,9 +64,7 @@ def draw_menu2_sample(o):
63 64
 	text_padding = 6
64 65
 	_id = 0
65 66
 	while _id < 16:
66
-	   
67 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 69
 		if _id == 0:
71 70
 			o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
@@ -75,6 +74,12 @@ def draw_menu2_sample(o):
75 74
 			o.center_block("Del", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
76 75
 		if _id == 3:
77 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 84
 		if _id == 8:
80 85
 			o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
@@ -141,6 +146,17 @@ def draw_menu2_pattern(o):
141 146
 		if _id == 7:
142 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 160
 		o_x = o_x + x_size
145 161
 		_id += 1
146 162
 		if _id % 4 == 0:
@@ -229,11 +245,11 @@ def draw_menu_saveas(o):
229 245
 
230 246
 def menu1_actions(self, o):
231 247
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
232
-		print('reset repeat from menu')
248
+		#print('reset repeat from menu')
233 249
 		o.button_repeater(1,[])
234 250
 
235 251
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
236
-		print('reset repeat from menu')
252
+		#print('reset repeat from menu')
237 253
 		o.button_repeater(1,[])
238 254
 
239 255
 	if o.keyState[16] == 2:
@@ -329,39 +345,39 @@ def menu1_actions(self, o):
329 345
 
330 346
 def menu2_actions_sample(self, o):
331 347
 	if o.keyState[6] == 4 or o.keyState[6] == 3:
332
-		print('reset repeat from menu')
348
+		#print('reset repeat from menu')
333 349
 		o.button_repeater(1,[])
334 350
 
335 351
 	if o.keyState[7] == 4 or o.keyState[7] == 3:
336
-		print('reset repeat from menu')
352
+		#print('reset repeat from menu')
337 353
 		o.button_repeater(1,[])
338 354
 
339 355
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
340
-		print('reset repeat from menu')
356
+		#print('reset repeat from menu')
341 357
 		o.button_repeater(1,[])
342 358
 
343 359
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
344
-		print('reset repeat from menu')
360
+		#print('reset repeat from menu')
345 361
 		o.button_repeater(1,[])
346 362
 
347 363
 	if o.keyState[10] == 4 or o.keyState[10] == 3:
348
-		print('reset repeat from menu')
364
+		#print('reset repeat from menu')
349 365
 		o.button_repeater(1,[])
350 366
 
351 367
 	if o.keyState[11] == 4 or o.keyState[11] == 3:
352
-		print('reset repeat from menu')
368
+		#print('reset repeat from menu')
353 369
 		o.button_repeater(1,[])
354 370
 
355 371
 	if o.keyState[17] == 2:
356 372
 		if o.keyState[0] == 1:
357 373
 			if o.soundSlots[o.eSound].volume > 0:
358
-				print('copy')
374
+				#print('copy')
359 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 378
 		if o.keyState[1] == 1:
363 379
 			if o.soundClipboard != []:
364
-				print('pasting ', o.soundClipboard)				
380
+				#print('pasting ', o.soundClipboard)				
365 381
 				o.soundSlots[o.eSound].file = o.soundClipboard[0]
366 382
 				o.soundSlots[o.eSound].volume = o.soundClipboard[1]
367 383
 				o.soundSlots[o.eSound].pitch = o.soundClipboard[2]
@@ -369,14 +385,20 @@ def menu2_actions_sample(self, o):
369 385
 				o.soundSlots[o.eSound].set_pitch()
370 386
 			
371 387
 		if o.keyState[2] == 1:
372
-			print('delete sound ', o.eSound)
388
+			#print('delete sound ', o.eSound)
373 389
 			o.soundSlots[o.eSound].file = None
374 390
 			o.soundSlots[o.eSound].volume = 16
375 391
 			o.soundSlots[o.eSound].pitch = 0
376 392
 		if o.keyState[3] == 1:
377
-			print('load')
393
+			#print('load')
378 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 402
 		if o.keyState[8] == 2:
381 403
 			if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
382 404
 				if o.soundSlots[o.eSound].volume > 0:
@@ -476,12 +498,12 @@ def menu2_actions_sample(self, o):
476 498
 		if o.keyState[12] == 1:
477 499
 			o.odub = not o.odub
478 500
 			o.undo_buf = []
479
-			print('odub now is ', o.odub)
501
+			#print('odub now is ', o.odub)
480 502
 			draw_menu2_sample(o)
481 503
 			o.update_display(0)
482 504
 
483 505
 		if o.keyState[13] == 1:
484
-			print('undo something')
506
+			#print('undo something')
485 507
 			for i in o.undo_buf:
486 508
 				o.soundSlots[i[0]].notes[i[1]][i[2]][0] = 0
487 509
 				o.soundSlots[i[0]].notes[i[1]][i[2]][1] = 0
@@ -490,7 +512,7 @@ def menu2_actions_sample(self, o):
490 512
 		if o.keyState[14] == 1:
491 513
 			o.erase = not o.erase
492 514
 			o.erase_buf = []
493
-			print('erase now is ', o.erase)
515
+			#print('erase now is ', o.erase)
494 516
 			if o.erase:
495 517
 				o.mute = False
496 518
 				o.mute_buf = []
@@ -500,7 +522,7 @@ def menu2_actions_sample(self, o):
500 522
 		if o.keyState[15] == 1:
501 523
 			o.mute = not o.mute
502 524
 			o.mute_buf = []
503
-			print('mute now is ', o.mute)
525
+			#print('mute now is ', o.mute)
504 526
 			if o.mute:
505 527
 				o.erase = False
506 528
 				o.erase_buf = []
@@ -554,6 +576,42 @@ def menu2_actions_pattern(self, o):
554 576
 				u.text_center(o, "Pattern Bank", str(o.pat_bank))
555 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 615
 def menu2_actions_song(self, o):
558 616
 	if o.keyState[17] == 2:
559 617
 		
@@ -573,11 +631,11 @@ def menu2_actions_song(self, o):
573 631
 
574 632
 def menu2_actions_note(self, o):
575 633
 	if o.keyState[8] == 4 or o.keyState[8] == 3:
576
-		print('reset repeat from menu')
634
+		#print('reset repeat from menu')
577 635
 		o.button_repeater(1,[])
578 636
 
579 637
 	if o.keyState[9] == 4 or o.keyState[9] == 3:
580
-		print('reset repeat from menu')
638
+		#print('reset repeat from menu')
581 639
 		o.button_repeater(1,[])
582 640
 
583 641
 	if o.keyState[17] == 2:
@@ -619,7 +677,7 @@ def menu2_actions_note(self, o):
619 677
 			else:
620 678
 				o.patternFollow = True
621 679
 
622
-			print('pattern follow is ', o.patternFollow)
680
+			#print('pattern follow is ', o.patternFollow)
623 681
 			draw_menu2_note(o)
624 682
 			o.update_display(0)			
625 683
 					
@@ -627,12 +685,10 @@ def menu2_actions_note(self, o):
627 685
 def menu2_actions_saveas(self, o):
628 686
 	if o.keyState[17] == 2:
629 687
 		if o.keyState[12] == 1:
630
-			print('select folder')
688
+			#print('select folder')
631 689
 			self.FSM.ToTransition('toSelectFolder')	
632 690
 		elif o.keyState[14] == 1:
633
-			print('new folder')
634
-			#o.song_dir
635
-			#os.mkdir(path)
691
+			#print('new folder')
636 692
 			self.FSM.ToTransition('toNewDir')	
637 693
 
638 694
 
@@ -645,7 +701,6 @@ def util_command(self, o, command):
645 701
 		self.FSM.ToTransition('toDefender')	
646 702
 	elif command == "Calculator":
647 703
 		self.FSM.ToTransition('toCalculator')	
648
-
649 704
 	elif command == "Exit":
650 705
 		self.FSM.ToTransition('toExit')		
651 706
 	elif command == "Theme":
@@ -654,7 +709,6 @@ def util_command(self, o, command):
654 709
 		self.FSM.ToTransition('toReboot')		
655 710
 	elif command == "Update":
656 711
 		self.FSM.ToTransition('toUpdate')	
657
-		#os.system("sudo reboot")
658 712
 	elif command == "Shutdown":
659 713
 		self.FSM.ToTransition('toShutdown')		
660 714
 	elif command == "Ping":
@@ -669,14 +723,15 @@ def file_command(self, o, command):
669 723
 		if o.sconf['title'] != "blank":
670 724
 			o.save_song()
671 725
 		else:
672
-			print('cant save over blank')
726
+			pass
727
+			#print('cant save over blank')
673 728
 	
674 729
 	elif command == "Open":
675 730
 		self.FSM.ToTransition('toOpenSong')	
676 731
 	elif command == "Save As":
677 732
 		self.FSM.ToTransition('toEnterText')	
678 733
 	elif command == "New":
679
-		#self.FSM.ToTransition('toEnterText')
680
-		#o.title = '_blank'
734
+		o.song_dir = o.base_song_dir
681 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,8 +31,8 @@ class EditSoundSequence(State):
31 31
 		else:
32 32
 			u.draw_header(o)
33 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 36
 			o.update_display(0)
37 37
 		super(EditSoundSequence, self).Enter()        
38 38
 		
@@ -46,8 +46,8 @@ class EditSoundSequence(State):
46 46
 		elif o.keyState[16] == 4:
47 47
 			u.draw_header(o)
48 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 51
 			o.update_display(0)
52 52
 
53 53
 		if o.keyState[17] == 1:
@@ -56,8 +56,8 @@ class EditSoundSequence(State):
56 56
 		elif o.keyState[17] == 4:
57 57
 			u.draw_header(o)
58 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 61
 			o.update_display(0)
62 62
 
63 63
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
@@ -75,8 +75,8 @@ class EditSoundSequence(State):
75 75
 						o.soundSlots[o.eSound].notes[self.curPattern][_id][1] = o.note_vol
76 76
 					u.draw_header(o)
77 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 80
 					o.update_display(0)
81 81
 				_id += 1
82 82
 		
@@ -112,8 +112,8 @@ class EditSoundSequence(State):
112 112
 		else:
113 113
 			u.draw_header(o)            
114 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 117
 		if o.patternFollow:
118 118
 			self.curPattern = message[0]
119 119
 		else:

+ 11
- 7
lib/sMain.py View File

@@ -32,8 +32,8 @@ class Main(State):
32 32
 		else:
33 33
 			u.draw_header(o)
34 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 37
 			u.text_box2(o, "BPM", str(o.bpm))
38 38
 			u.text_box4(o, "Bank", str(o.note_bank))
39 39
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
@@ -60,7 +60,8 @@ class Main(State):
60 60
 		elif o.keyState[16] == 4:
61 61
 			u.draw_header(o)
62 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 65
 			u.text_box2(o, "BPM", str(o.bpm))
65 66
 			u.text_box4(o, "Bank", str(o.note_bank))
66 67
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
@@ -73,7 +74,8 @@ class Main(State):
73 74
 		elif o.keyState[17] == 4:
74 75
 			u.draw_header(o)
75 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 79
 			u.text_box2(o, "BPM", str(o.bpm))
78 80
 			u.text_box4(o, "Bank", str(o.note_bank))
79 81
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
@@ -90,11 +92,12 @@ class Main(State):
90 92
 					note = _id + o.note_bank * 16
91 93
 					if k == 1:						
92 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 96
 							o.soundSlots[note].play(o.note_vol)
95 97
 						o.eSound = note
96 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 101
 						u.text_box2(o, "BPM", str(o.bpm))
99 102
 						u.text_box4(o, "Bank", str(o.note_bank))
100 103
 						u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
@@ -123,7 +126,8 @@ class Main(State):
123 126
 		else:
124 127
 			u.draw_header(o)            
125 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 131
 			u.text_box2(o, "BPM", str(o.bpm))
128 132
 			u.text_box4(o, "Bank", str(o.note_bank))
129 133
 			u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))			         

+ 37
- 1
lib/sSelectPattern.py View File

@@ -1,6 +1,7 @@
1 1
 import FSM
2 2
 import utils as u
3 3
 import menus as m
4
+from itertools import cycle
4 5
 #====================================     
5 6
 
6 7
 State = type("State", (object,), {})
@@ -29,6 +30,8 @@ class SelectPattern(State):
29 30
 		self.cur_playing = 0
30 31
 		self.active_patterns = []
31 32
 		self.get_active_patterns(o)
33
+		o.pat_buf = o.song
34
+		self.new_song = []
32 35
 
33 36
 		if o.keyState[16] > 0 or o.keyState[17] > 0:
34 37
 			pass
@@ -75,6 +78,17 @@ class SelectPattern(State):
75 78
 					pass
76 79
 				else:
77 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 92
 						o.ePattern = (o.pat_bank * 16) +_id 
79 93
 
80 94
 						u.draw_header(o)
@@ -99,6 +113,17 @@ class SelectPattern(State):
99 113
 				u.text_box1(o, "Pat", str(o.ePattern))
100 114
 				u.text_box4(o, "Bank", str(o.pat_bank))
101 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 128
 	def draw_square(self):
104 129
 		o = self.FSM.owner 
@@ -139,4 +164,15 @@ class SelectPattern(State):
139 164
 			_iter += 1
140 165
 	
141 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,6 +76,7 @@ class Prog:
76 76
 		self.h1 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 30)
77 77
 		self.h2 = ImageFont.truetype("/home/pi/zpc_ct/fonts/Pixellari.ttf", 20)
78 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 81
 		self.disp = st7789.ST7789(
81 82
 			spi,
@@ -139,6 +140,11 @@ class Prog:
139 140
 		self.olive = "#80D52A"
140 141
 		self.notes_on = []
141 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 149
 		self.press_ticks_up = None
144 150
 		self.press_ticks_down = None
@@ -289,26 +295,39 @@ class Prog:
289 295
 			pygame.time.set_timer(TIMER, int(bpm))
290 296
 
291 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 311
 	def stop_playback(self):
305 312
 		self.playing = False
306 313
 		self.playhead = -1
307 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 319
 		pygame.time.set_timer(TIMER, 0)
310 320
 		GPIO.setup(29, GPIO.OUT)
311 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 332
 	def center_text(self, text, font, width, y, color):
314 333
 		w,h = font.getsize(text)

+ 1
- 2
runner.sh View File

@@ -1,5 +1,4 @@
1
-#until "python3 /home/pi/zpc_ct/main.py"; do
2 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 3
     sleep 2
5 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