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

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