raspberry pi zero based drum machine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menus.py 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. import utils as u
  2. import pygame
  3. def draw_menu1(o):
  4. bpm_inc = 4
  5. x_size = o.width / 4
  6. y_size = o.height / 4
  7. og_x = 0
  8. o_x = og_x
  9. o_y = o.height
  10. text_padding = 6
  11. _id = 0
  12. while _id < 16:
  13. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
  14. if _id == 0:
  15. o.center_block("Main", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  16. if _id == 1:
  17. o.center_block("Note", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  18. if _id == 2:
  19. o.center_block("Patt", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  20. if _id == 3:
  21. o.center_block("Song", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  22. if _id == 4:
  23. o.center_block("File", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  24. if _id == 5:
  25. o.center_block("Util", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  26. # if _id == 6:
  27. # o.center_block("Bank-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  28. # if _id == 7:
  29. # o.center_block("Bank+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  30. if _id == 8:
  31. o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  32. if _id == 9:
  33. o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  34. #if _id == 11:
  35. #o.center_block("", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  36. if _id == 12:
  37. o.center_block("Play", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  38. if _id == 13:
  39. o.center_block("Stop", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  40. if _id == 10:
  41. o.center_block("BPM-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  42. if _id == 11:
  43. o.center_block("BPM+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  44. o_x = o_x + x_size
  45. _id += 1
  46. if _id % 4 == 0:
  47. o_y -= y_size
  48. o_x = og_x
  49. def draw_menu2_sample(o):
  50. bpm_inc = 4
  51. x_size = o.width / 4
  52. y_size = o.height / 4
  53. og_x = 0
  54. o_x = og_x
  55. o_y = o.height
  56. text_padding = 6
  57. _id = 0
  58. while _id < 16:
  59. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
  60. if _id == 0:
  61. o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  62. if _id == 1:
  63. o.center_block("Paste", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  64. if _id == 2:
  65. o.center_block("Del", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  66. if _id == 3:
  67. o.center_block("Load", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  68. if _id == 8:
  69. o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  70. if _id == 9:
  71. o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  72. if _id == 6:
  73. o.center_block("Bank-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  74. if _id == 7:
  75. o.center_block("Bank+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  76. if _id == 10:
  77. o.center_block("Pitch-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  78. if _id == 11:
  79. o.center_block("Pitch+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  80. if _id == 12:
  81. if o.odub == True:
  82. o.center_block("Odub", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
  83. else:
  84. o.center_block("Odub", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  85. if _id == 13:
  86. o.center_block("Undo", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  87. if _id == 14:
  88. if o.erase == True:
  89. o.center_block("Erase", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
  90. else:
  91. o.center_block("Erase", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  92. if _id == 15:
  93. if o.mute == True:
  94. o.center_block("Mute", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
  95. else:
  96. o.center_block("Mute", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  97. o_x = o_x + x_size
  98. _id += 1
  99. if _id % 4 == 0:
  100. o_y -= y_size
  101. o_x = og_x
  102. def draw_menu2_pattern(o):
  103. bpm_inc = 4
  104. x_size = o.width / 4
  105. y_size = o.height / 4
  106. og_x = 0
  107. o_x = og_x
  108. o_y = o.height
  109. text_padding = 6
  110. _id = 0
  111. while _id < 16:
  112. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
  113. if _id == 0:
  114. o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  115. if _id == 1:
  116. o.center_block("Paste", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  117. if _id == 2:
  118. o.center_block("Clear", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  119. if _id == 6:
  120. o.center_block("Bank -", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  121. if _id == 7:
  122. o.center_block("Bank +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  123. o_x = o_x + x_size
  124. _id += 1
  125. if _id % 4 == 0:
  126. o_y -= y_size
  127. o_x = og_x
  128. def draw_menu2_note(o):
  129. bpm_inc = 4
  130. x_size = o.width / 4
  131. y_size = o.height / 4
  132. og_x = 0
  133. o_x = og_x
  134. o_y = o.height
  135. text_padding = 6
  136. _id = 0
  137. while _id < 16:
  138. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
  139. if _id == 8:
  140. o.center_block("Vol -", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  141. elif _id == 9:
  142. o.center_block("Vol +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  143. elif _id == 12:
  144. if o.patternFollow:
  145. o.center_block("Follow", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.pink)
  146. else:
  147. o.center_block("Follow", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  148. o_x = o_x + x_size
  149. _id += 1
  150. if _id % 4 == 0:
  151. o_y -= y_size
  152. o_x = og_x
  153. def draw_menu2_song(o):
  154. bpm_inc = 4
  155. x_size = o.width / 4
  156. y_size = o.height / 4
  157. og_x = 0
  158. o_x = og_x
  159. o_y = o.height
  160. text_padding = 6
  161. _id = 0
  162. while _id < 16:
  163. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
  164. if _id == 6:
  165. o.center_block("Bank -", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  166. if _id == 7:
  167. o.center_block("Bank +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  168. o_x = o_x + x_size
  169. _id += 1
  170. if _id % 4 == 0:
  171. o_y -= y_size
  172. o_x = og_x
  173. def draw_menu_saveas(o):
  174. bpm_inc = 4
  175. x_size = o.width / 2
  176. y_size = o.height / 4
  177. og_x = 0
  178. o_x = og_x
  179. o_y = o.height
  180. text_padding = 6
  181. _id = 0
  182. while _id < 8:
  183. o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
  184. if _id == 6:
  185. o.center_block("Select Folder", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  186. if _id == 7:
  187. o.center_block("New Folder", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
  188. o_x = o_x + x_size
  189. _id += 1
  190. if _id % 2 == 0:
  191. o_y -= y_size
  192. o_x = og_x
  193. def menu1_actions(self, o):
  194. if o.keyState[8] == 4 or o.keyState[8] == 3:
  195. print('reset repeat from menu')
  196. o.button_repeater(1,[])
  197. if o.keyState[9] == 4 or o.keyState[9] == 3:
  198. print('reset repeat from menu')
  199. o.button_repeater(1,[])
  200. if o.keyState[16] == 2:
  201. #print('key 8 ', o.keyState[8])
  202. #o.button_repeater(0, [8,9,14,15])
  203. if o.keyState[0] == 1:
  204. self.FSM.ToTransition('toMain')
  205. elif o.keyState[1] == 1:
  206. self.FSM.ToTransition('toEditSoundSequence')
  207. elif o.keyState[2] == 1:
  208. self.FSM.ToTransition('toSelectPattern')
  209. elif o.keyState[3] == 1:
  210. self.FSM.ToTransition('toEditSong')
  211. elif o.keyState[4] == 1:
  212. self.FSM.ToTransition('toFile')
  213. elif o.keyState[5] == 1:
  214. self.FSM.ToTransition('toUtil')
  215. if o.keyState[12] == 1:
  216. o.start_playback()
  217. u.play_seq(o, [o.curPattern, 0])
  218. if o.keyState[13] == 1:
  219. o.stop_playback()
  220. if o.keyState[8] == 2:
  221. if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
  222. if o.volume > 0:
  223. o.volume -= 1
  224. u.text_center(o, "Master Volume", str(o.volume))
  225. o.update_display(0)
  226. o.repeater_states[8] = pygame.time.get_ticks()
  227. if o.keyState[8] == 1:
  228. o.repeater_states[8] = pygame.time.get_ticks()
  229. if o.volume > 0:
  230. o.volume -= 1
  231. u.text_center(o, "Master Volume", str(o.volume))
  232. o.update_display(0)
  233. if o.keyState[9] == 2:
  234. if (o.repeater_states[9] != None and ((pygame.time.get_ticks() - o.repeater_states[9]) > 500)):
  235. if o.volume < 16:
  236. o.volume += 1
  237. u.text_center(o, "Master Volume", str(o.volume))
  238. o.update_display(0)
  239. o.repeater_states[9] = pygame.time.get_ticks()
  240. if o.keyState[9] == 1:
  241. o.repeater_states[9] = pygame.time.get_ticks()
  242. if o.volume < 16:
  243. o.volume += 1
  244. u.text_center(o, "Master Volume", str(o.volume))
  245. o.update_display(0)
  246. if o.keyState[11] == 1:
  247. #o.save_song()
  248. pass
  249. if o.keyState[10] == 2:
  250. if (o.repeater_states[10] != None and ((pygame.time.get_ticks() - o.repeater_states[10]) > 500)):
  251. if o.bpm > 60:
  252. o.bpm = o.bpm - o.bpm_inc
  253. o.update_bpm()
  254. u.text_center(o, "Master BPM", str(o.bpm))
  255. o.update_display(0)
  256. o.repeater_states[10] = pygame.time.get_ticks()
  257. if o.keyState[10] == 1:
  258. o.repeater_states[10] = pygame.time.get_ticks()
  259. if o.bpm > 60:
  260. o.bpm = o.bpm - o.bpm_inc
  261. o.update_bpm()
  262. u.text_center(o, "Master BPM", str(o.bpm))
  263. o.update_display(0)
  264. if o.keyState[11] == 2:
  265. if (o.repeater_states[11] != None and ((pygame.time.get_ticks() - o.repeater_states[11]) > 500)):
  266. if o.bpm < 240:
  267. o.bpm = o.bpm + o.bpm_inc
  268. o.update_bpm()
  269. u.text_center(o, "Master BPM", str(o.bpm))
  270. o.update_display(0)
  271. o.repeater_states[11] = pygame.time.get_ticks()
  272. if o.keyState[11] == 1:
  273. o.repeater_states[11] = pygame.time.get_ticks()
  274. if o.bpm < 240:
  275. o.bpm = o.bpm + o.bpm_inc
  276. o.update_bpm()
  277. u.text_center(o, "Master BPM", str(o.bpm))
  278. o.update_display(0)
  279. def menu2_actions_sample(self, o):
  280. if o.keyState[6] == 4 or o.keyState[6] == 3:
  281. print('reset repeat from menu')
  282. o.button_repeater(1,[])
  283. if o.keyState[7] == 4 or o.keyState[7] == 3:
  284. print('reset repeat from menu')
  285. o.button_repeater(1,[])
  286. if o.keyState[8] == 4 or o.keyState[8] == 3:
  287. print('reset repeat from menu')
  288. o.button_repeater(1,[])
  289. if o.keyState[9] == 4 or o.keyState[9] == 3:
  290. print('reset repeat from menu')
  291. o.button_repeater(1,[])
  292. if o.keyState[10] == 4 or o.keyState[10] == 3:
  293. print('reset repeat from menu')
  294. o.button_repeater(1,[])
  295. if o.keyState[11] == 4 or o.keyState[11] == 3:
  296. print('reset repeat from menu')
  297. o.button_repeater(1,[])
  298. if o.keyState[17] == 2:
  299. if o.keyState[0] == 1:
  300. if o.soundSlots[o.eSound].volume > 0:
  301. print('copy')
  302. o.soundClipboard = [o.soundSlots[o.eSound].file, o.soundSlots[o.eSound].volume, o.soundSlots[o.eSound].pitch]
  303. print(o.soundClipboard)
  304. if o.keyState[1] == 1:
  305. if o.soundClipboard != []:
  306. print('pasting ', o.soundClipboard)
  307. o.soundSlots[o.eSound].file = o.soundClipboard[0]
  308. o.soundSlots[o.eSound].volume = o.soundClipboard[1]
  309. o.soundSlots[o.eSound].pitch = o.soundClipboard[2]
  310. o.soundSlots[o.eSound].create_sound()
  311. o.soundSlots[o.eSound].set_pitch()
  312. if o.keyState[2] == 1:
  313. print('delete sound ', o.eSound)
  314. o.soundSlots[o.eSound].file = None
  315. o.soundSlots[o.eSound].volume = 16
  316. o.soundSlots[o.eSound].pitch = 0
  317. if o.keyState[3] == 1:
  318. print('load')
  319. o.FSM.FSM.ToTransition("toLoadSound")
  320. if o.keyState[8] == 2:
  321. if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
  322. if o.soundSlots[o.eSound].volume > 0:
  323. o.soundSlots[o.eSound].volume -= 1
  324. u.text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
  325. o.update_display(0)
  326. o.repeater_states[8] = pygame.time.get_ticks()
  327. if o.keyState[8] == 1:
  328. if o.soundSlots[o.eSound].volume > 0:
  329. o.soundSlots[o.eSound].volume -= 1
  330. u.text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
  331. o.update_display(0)
  332. o.repeater_states[8] = pygame.time.get_ticks()
  333. if o.keyState[9] == 2:
  334. if (o.repeater_states[9] != None and ((pygame.time.get_ticks() - o.repeater_states[9]) > 500)):
  335. if o.soundSlots[o.eSound].volume < 16:
  336. o.soundSlots[o.eSound].volume += 1
  337. u.text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
  338. o.update_display(0)
  339. o.repeater_states[9] = pygame.time.get_ticks()
  340. if o.keyState[9] == 1:
  341. if o.soundSlots[o.eSound].volume < 16:
  342. o.soundSlots[o.eSound].volume += 1
  343. u.text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
  344. o.update_display(0)
  345. o.repeater_states[9] = pygame.time.get_ticks()
  346. if o.keyState[6] == 2:
  347. if (o.repeater_states[6] != None and ((pygame.time.get_ticks() - o.repeater_states[6]) > 500)):
  348. if o.note_bank > 0:
  349. o.note_bank -= 1
  350. u.text_center(o, "Sound Bank", str(o.note_bank))
  351. o.update_display(0)
  352. o.repeater_states[6] = pygame.time.get_ticks()
  353. if o.keyState[6] == 1:
  354. if o.note_bank > 0:
  355. o.note_bank -= 1
  356. u.text_center(o, "Sound Bank", str(o.note_bank))
  357. o.repeater_states[6] = pygame.time.get_ticks()
  358. o.update_display(0)
  359. if o.keyState[7] == 2:
  360. if (o.repeater_states[7] != None and ((pygame.time.get_ticks() - o.repeater_states[7]) > 500)):
  361. if o.note_bank < 3:
  362. o.note_bank += 1
  363. u.text_center(o, "Sound Bank", str(o.note_bank))
  364. o.update_display(0)
  365. o.repeater_states[7] = pygame.time.get_ticks()
  366. if o.keyState[7] == 1:
  367. if o.note_bank < 3:
  368. o.note_bank += 1
  369. u.text_center(o, "Sound Bank", str(o.note_bank))
  370. o.repeater_states[7] = pygame.time.get_ticks()
  371. o.update_display(0)
  372. if o.keyState[10] == 2:
  373. if (o.repeater_states[10] != None and ((pygame.time.get_ticks() - o.repeater_states[10]) > 500)):
  374. if o.soundSlots[o.eSound].pitch > -10:
  375. o.soundSlots[o.eSound].pitch -= 1
  376. u.text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
  377. o.soundSlots[o.eSound].set_pitch()
  378. o.update_display(0)
  379. o.repeater_states[10] = pygame.time.get_ticks()
  380. if o.keyState[10] == 1:
  381. if o.soundSlots[o.eSound].pitch > -10:
  382. o.soundSlots[o.eSound].pitch -= 1
  383. u.text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
  384. o.soundSlots[o.eSound].set_pitch()
  385. o.repeater_states[10] = pygame.time.get_ticks()
  386. o.update_display(0)
  387. if o.keyState[11] == 2:
  388. if (o.repeater_states[11] != None and ((pygame.time.get_ticks() - o.repeater_states[11]) > 500)):
  389. if o.soundSlots[o.eSound].pitch < 10:
  390. o.soundSlots[o.eSound].pitch += 1
  391. u.text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
  392. o.soundSlots[o.eSound].set_pitch()
  393. o.update_display(0)
  394. o.repeater_states[11] = pygame.time.get_ticks()
  395. if o.keyState[11] == 1:
  396. if o.soundSlots[o.eSound].pitch < 10:
  397. o.soundSlots[o.eSound].pitch += 1
  398. u.text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
  399. o.soundSlots[o.eSound].set_pitch()
  400. o.repeater_states[11] = pygame.time.get_ticks()
  401. o.update_display(0)
  402. if o.keyState[12] == 1:
  403. o.odub = not o.odub
  404. o.undo_buf = []
  405. print('odub now is ', o.odub)
  406. draw_menu2_sample(o)
  407. o.update_display(0)
  408. if o.keyState[13] == 1:
  409. print('undo something')
  410. for i in o.undo_buf:
  411. o.soundSlots[i[0]].notes[i[1]][i[2]][0] = 0
  412. o.soundSlots[i[0]].notes[i[1]][i[2]][1] = 0
  413. o.undo_buf = []
  414. if o.keyState[14] == 1:
  415. o.erase = not o.erase
  416. o.erase_buf = []
  417. print('erase now is ', o.erase)
  418. if o.erase:
  419. o.mute = False
  420. o.mute_buf = []
  421. draw_menu2_sample(o)
  422. o.update_display(0)
  423. if o.keyState[15] == 1:
  424. o.mute = not o.mute
  425. o.mute_buf = []
  426. print('mute now is ', o.mute)
  427. if o.mute:
  428. o.erase = False
  429. o.erase_buf = []
  430. draw_menu2_sample(o)
  431. o.update_display(0)
  432. def menu2_actions_pattern(self, o):
  433. if o.keyState[17] == 2:
  434. if o.keyState[0] == 1:
  435. print('copy')
  436. o.patternClipboard = []
  437. for s in o.soundSlots:
  438. notes = []
  439. for i in s.notes[o.ePattern]:
  440. notes.append([i[0], i[1]])
  441. o.patternClipboard.append(notes)
  442. print('adding to clip ', notes)
  443. elif o.keyState[1] == 1:
  444. print('paste')
  445. if o.patternClipboard != []:
  446. p = 0
  447. for s in o.soundSlots:
  448. n = 0
  449. for i in s.notes[o.ePattern]:
  450. i[0] = o.patternClipboard[p][n][0]
  451. i[1] = o.patternClipboard[p][n][1]
  452. n += 1
  453. print('added ', o.patternClipboard[p])
  454. p += 1
  455. else:
  456. print('nothing to paste')
  457. elif o.keyState[2] == 1:
  458. print('clear')
  459. print(o.soundSlots[o.eSound].notes[o.ePattern])
  460. for s in o.soundSlots:
  461. for i in s.notes[o.ePattern]:
  462. i[0] = 0
  463. i[1] = 0
  464. elif o.keyState[6] == 1:
  465. if o.pat_bank > 0:
  466. o.pat_bank -= 1
  467. u.text_center(o, "Pattern Bank", str(o.pat_bank))
  468. o.update_display(0)
  469. elif o.keyState[7] == 1:
  470. if o.pat_bank < 3:
  471. o.pat_bank += 1
  472. u.text_center(o, "Pattern Bank", str(o.pat_bank))
  473. o.update_display(0)
  474. def menu2_actions_song(self, o):
  475. if o.keyState[17] == 2:
  476. if o.keyState[6] == 1:
  477. if o.pat_bank > 0:
  478. o.pat_bank -= 1
  479. u.text_center(o, "Pattern Bank", str(o.pat_bank))
  480. o.update_display(0)
  481. elif o.keyState[7] == 1:
  482. if o.pat_bank < 3:
  483. o.pat_bank += 1
  484. u.text_center(o, "Pattern Bank", str(o.pat_bank))
  485. o.update_display(0)
  486. def menu2_actions_note(self, o):
  487. if o.keyState[8] == 4 or o.keyState[8] == 3:
  488. print('reset repeat from menu')
  489. o.button_repeater(1,[])
  490. if o.keyState[9] == 4 or o.keyState[9] == 3:
  491. print('reset repeat from menu')
  492. o.button_repeater(1,[])
  493. if o.keyState[17] == 2:
  494. if o.keyState[8] == 2:
  495. if (o.repeater_states[8] != None and ((pygame.time.get_ticks() - o.repeater_states[8]) > 500)):
  496. if o.note_vol > 0:
  497. o.note_vol -= 1
  498. u.text_center(o, "Note Volume", str(o.note_vol))
  499. o.update_display(0)
  500. o.repeater_states[8] = pygame.time.get_ticks()
  501. if o.keyState[8] == 1:
  502. if o.note_vol > 0:
  503. o.note_vol -= 1
  504. u.text_center(o, "Note Volume", str(o.note_vol))
  505. o.repeater_states[8] = pygame.time.get_ticks()
  506. o.update_display(0)
  507. if o.keyState[9] == 2:
  508. if (o.repeater_states[9] != None and ((pygame.time.get_ticks() - o.repeater_states[9]) > 500)):
  509. if o.note_vol < 16:
  510. o.note_vol += 1
  511. u.text_center(o, "Note Volume", str(o.note_vol))
  512. o.update_display(0)
  513. o.repeater_states[9] = pygame.time.get_ticks()
  514. if o.keyState[9] == 1:
  515. if o.note_vol < 16:
  516. o.note_vol += 1
  517. u.text_center(o, "Note Volume", str(o.note_vol))
  518. o.repeater_states[9] = pygame.time.get_ticks()
  519. o.update_display(0)
  520. if o.keyState[12] == 1:
  521. if o.patternFollow:
  522. o.patternFollow = False
  523. else:
  524. o.patternFollow = True
  525. print('pattern follow is ', o.patternFollow)
  526. draw_menu2_note(o)
  527. o.update_display(0)
  528. def menu2_actions_saveas(self, o):
  529. if o.keyState[17] == 2:
  530. if o.keyState[12] == 1:
  531. print('select folder')
  532. self.FSM.ToTransition('toSelectFolder')
  533. elif o.keyState[14] == 1:
  534. print('new folder')
  535. #o.song_dir
  536. #os.mkdir(path)
  537. self.FSM.ToTransition('toNewDir')
  538. def util_command(self, o, command):
  539. if command == "Clock":
  540. self.FSM.ToTransition('toClock')
  541. elif command == "Balls":
  542. self.FSM.ToTransition('toBall')
  543. elif command == "Defender":
  544. self.FSM.ToTransition('toDefender')
  545. elif command == "Calculator":
  546. self.FSM.ToTransition('toCalculator')
  547. elif command == "Exit":
  548. self.FSM.ToTransition('toExit')
  549. elif command == "Theme":
  550. self.FSM.ToTransition('toSelTheme')
  551. elif command == "Reboot":
  552. self.FSM.ToTransition('toReboot')
  553. elif command == "Update":
  554. self.FSM.ToTransition('toUpdate')
  555. #os.system("sudo reboot")
  556. elif command == "Shutdown":
  557. self.FSM.ToTransition('toShutdown')
  558. elif command == "Ping":
  559. self.FSM.ToTransition('toPing')
  560. elif command == "Wifi":
  561. self.FSM.ToTransition('toWifi')
  562. elif command == "About":
  563. self.FSM.ToTransition('toAbout')
  564. def file_command(self, o, command):
  565. if command == "Save":
  566. if o.sconf['title'] != "blank":
  567. o.save_song()
  568. else:
  569. print('cant save over blank')
  570. elif command == "Open":
  571. self.FSM.ToTransition('toOpenSong')
  572. elif command == "Save As":
  573. self.FSM.ToTransition('toEnterText')
  574. elif command == "New":
  575. #self.FSM.ToTransition('toEnterText')
  576. #o.title = '_blank'
  577. o.mconf['default_song'] = '_blank'
  578. o.load_song()