fork download
  1. import sys, ntpath, pygame, pygame.mixer, launchpad
  2. from PyQt4 import QtCore, QtGui
  3.  
  4. class Sampler():
  5. def __init__(self):
  6. self.changeLabel("Edit")
  7. #Poll for MIDI input
  8. while True:
  9. pad = LP.ButtonStateRaw()
  10. if pad != []:
  11. self.padnumber = pad[0]
  12. self.velocity = pad[1]
  13. if self.padnumber == 200:
  14. self.Trigger(ex.btn_a1.samplePath, 0, ex.btn_a1)
  15. if self.padnumber == 201:
  16. self.Trigger(ex.btn_a2.samplePath, 1, ex.btn_a2)
  17. if self.padnumber == 202:
  18. self.Trigger(ex.btn_a3.samplePath, 2, ex.btn_a3)
  19. if self.padnumber == 203:
  20. self.Trigger(ex.btn_a4.samplePath, 3, ex.btn_a4)
  21. if self.padnumber == 204:
  22. self.Trigger(ex.btn_a5.samplePath, 4, ex.btn_a5)
  23. if self.padnumber == 205:
  24. self.Trigger(ex.btn_a6.samplePath, 5, ex.btn_a6)
  25. if self.padnumber == 206:
  26. self.Trigger(ex.btn_a7.samplePath, 6, ex.btn_a7)
  27. if self.padnumber == 207:
  28. self.Trigger(ex.btn_a8.samplePath, 7, ex.btn_a8)
  29. if self.padnumber == 0:
  30. self.Trigger(ex.btn_b1.samplePath, 0, ex.btn_b1)
  31. if self.padnumber == 1:
  32. self.Trigger(ex.btn_b2.samplePath, 1, ex.btn_b2)
  33. if self.padnumber == 2:
  34. self.Trigger(ex.btn_b3.samplePath, 2, ex.btn_b3)
  35. if self.padnumber == 3:
  36. self.Trigger(ex.btn_b4.samplePath, 3, ex.btn_b4)
  37. if self.padnumber == 4:
  38. self.Trigger(ex.btn_b5.samplePath, 4, ex.btn_b5)
  39. if self.padnumber == 5:
  40. self.Trigger(ex.btn_b6.samplePath, 5, ex.btn_b6)
  41. if self.padnumber == 6:
  42. self.Trigger(ex.btn_b7.samplePath, 6, ex.btn_b7)
  43. if self.padnumber == 7:
  44. self.Trigger(ex.btn_b8.samplePath, 7, ex.btn_b8)
  45. if self.padnumber == 8:
  46. self.Trigger(ex.btn_b9.samplePath, 8, ex.btn_b9)
  47. if self.padnumber == 16:
  48. self.Trigger(ex.btn_c1.samplePath, 16, ex.btn_c1)
  49. if self.padnumber == 17:
  50. self.Trigger(ex.btn_c2.samplePath, 17, ex.btn_c2)
  51. if self.padnumber == 18:
  52. self.Trigger(ex.btn_c3.samplePath, 18, ex.btn_c3)
  53. if self.padnumber == 19:
  54. self.Trigger(ex.btn_c4.samplePath, 19, ex.btn_c4)
  55. if self.padnumber == 20:
  56. self.Trigger(ex.btn_c5.samplePath, 20, ex.btn_c5)
  57. if self.padnumber == 21:
  58. self.Trigger(ex.btn_c6.samplePath, 21, ex.btn_c6)
  59. if self.padnumber == 22:
  60. self.Trigger(ex.btn_c7.samplePath, 22, ex.btn_c7)
  61. if self.padnumber == 23:
  62. self.Trigger(ex.btn_c8.samplePath, 23, ex.btn_c8)
  63. if self.padnumber == 24:
  64. self.Trigger(ex.btn_c9.samplePath, 24, ex.btn_c9)
  65. if self.padnumber == 32:
  66. self.Trigger(ex.btn_d1.samplePath, 32, ex.btn_d1)
  67. if self.padnumber == 33:
  68. self.Trigger(ex.btn_d2.samplePath, 33, ex.btn_d2)
  69. if self.padnumber == 34:
  70. self.Trigger(ex.btn_d3.samplePath, 34, ex.btn_d3)
  71. if self.padnumber == 35:
  72. self.Trigger(ex.btn_d4.samplePath, 35, ex.btn_d4)
  73. if self.padnumber == 36:
  74. self.Trigger(ex.btn_d5.samplePath, 36, ex.btn_d5)
  75. if self.padnumber == 37:
  76. self.Trigger(ex.btn_d6.samplePath, 37, ex.btn_d6)
  77. if self.padnumber == 38:
  78. self.Trigger(ex.btn_d7.samplePath, 38, ex.btn_d7)
  79. if self.padnumber == 39:
  80. self.Trigger(ex.btn_d8.samplePath, 39, ex.btn_d8)
  81. if self.padnumber == 40:
  82. self.Trigger(ex.btn_d9.samplePath, 40, ex.btn_d9)
  83. if self.padnumber == 48:
  84. self.Trigger(ex.btn_e1.samplePath, 48, ex.btn_e1)
  85. if self.padnumber == 49:
  86. self.Trigger(ex.btn_e2.samplePath, 49, ex.btn_e2)
  87. if self.padnumber == 50:
  88. self.Trigger(ex.btn_e3.samplePath, 50, ex.btn_e3)
  89. if self.padnumber == 51:
  90. self.Trigger(ex.btn_e4.samplePath, 51, ex.btn_e4)
  91. if self.padnumber == 52:
  92. self.Trigger(ex.btn_e5.samplePath, 52, ex.btn_e5)
  93. if self.padnumber == 53:
  94. self.Trigger(ex.btn_e6.samplePath, 53, ex.btn_e6)
  95. if self.padnumber == 54:
  96. self.Trigger(ex.btn_e7.samplePath, 54, ex.btn_e7)
  97. if self.padnumber == 55:
  98. self.Trigger(ex.btn_e8.samplePath, 55, ex.btn_e8)
  99. if self.padnumber == 56:
  100. self.Trigger(ex.btn_e9.samplePath, 56, ex.btn_e9)
  101. if self.padnumber == 64:
  102. self.Trigger(ex.btn_f1.samplePath, 64, ex.btn_f1)
  103. if self.padnumber == 65:
  104. self.Trigger(ex.btn_f2.samplePath, 65, ex.btn_f2)
  105. if self.padnumber == 66:
  106. self.Trigger(ex.btn_f3.samplePath, 66, ex.btn_f3)
  107. if self.padnumber == 67:
  108. self.Trigger(ex.btn_f4.samplePath, 67, ex.btn_f4)
  109. if self.padnumber == 68:
  110. self.Trigger(ex.btn_f5.samplePath, 68, ex.btn_f5)
  111. if self.padnumber == 69:
  112. self.Trigger(ex.btn_f6.samplePath, 69, ex.btn_f6)
  113. if self.padnumber == 70:
  114. self.Trigger(ex.btn_f7.samplePath, 70, ex.btn_f7)
  115. if self.padnumber == 71:
  116. self.Trigger(ex.btn_f8.samplePath, 71, ex.btn_f8)
  117. if self.padnumber == 72:
  118. self.Trigger(ex.btn_f9.samplePath, 72, ex.btn_f9)
  119. if self.padnumber == 80:
  120. self.Trigger(ex.btn_g1.samplePath, 80, ex.btn_g1)
  121. if self.padnumber == 81:
  122. self.Trigger(ex.btn_g2.samplePath, 81, ex.btn_g2)
  123. if self.padnumber == 82:
  124. self.Trigger(ex.btn_g3.samplePath, 82, ex.btn_g3)
  125. if self.padnumber == 83:
  126. self.Trigger(ex.btn_g4.samplePath, 83, ex.btn_g4)
  127. if self.padnumber == 84:
  128. self.Trigger(ex.btn_g5.samplePath, 84, ex.btn_g5)
  129. if self.padnumber == 85:
  130. self.Trigger(ex.btn_g6.samplePath, 85, ex.btn_g6)
  131. if self.padnumber == 86:
  132. self.Trigger(ex.btn_g7.samplePath, 86, ex.btn_g7)
  133. if self.padnumber == 87:
  134. self.Trigger(ex.btn_g8.samplePath, 87, ex.btn_g8)
  135. if self.padnumber == 88:
  136. self.Trigger(ex.btn_g9.samplePath, 88, ex.btn_g9)
  137. if self.padnumber == 96:
  138. self.Trigger(ex.btn_h1.samplePath, 96, ex.btn_h1)
  139. if self.padnumber == 97:
  140. self.Trigger(ex.btn_h2.samplePath, 97, ex.btn_h2)
  141. if self.padnumber == 98:
  142. self.Trigger(ex.btn_h3.samplePath, 98, ex.btn_h3)
  143. if self.padnumber == 99:
  144. self.Trigger(ex.btn_h4.samplePath, 99, ex.btn_h4)
  145. if self.padnumber == 100:
  146. self.Trigger(ex.btn_h5.samplePath, 100, ex.btn_h5)
  147. if self.padnumber == 101:
  148. self.Trigger(ex.btn_h6.samplePath, 101, ex.btn_h6)
  149. if self.padnumber == 102:
  150. self.Trigger(ex.btn_h7.samplePath, 102, ex.btn_h7)
  151. if self.padnumber == 103:
  152. self.Trigger(ex.btn_h8.samplePath, 103, ex.btn_h8)
  153. if self.padnumber == 104:
  154. self.Trigger(ex.btn_h9.samplePath, 104, ex.btn_h9)
  155. if self.padnumber == 112:
  156. self.Trigger(ex.btn_i1.samplePath, 112, ex.btn_i1)
  157. if self.padnumber == 113:
  158. self.Trigger(ex.btn_i2.samplePath, 113, ex.btn_i2)
  159. if self.padnumber == 114:
  160. self.Trigger(ex.btn_i3.samplePath, 114, ex.btn_i3)
  161. if self.padnumber == 115:
  162. self.Trigger(ex.btn_i4.samplePath, 115, ex.btn_i4)
  163. if self.padnumber == 116:
  164. self.Trigger(ex.btn_i5.samplePath, 116, ex.btn_i5)
  165. if self.padnumber == 117:
  166. self.Trigger(ex.btn_i6.samplePath, 117, ex.btn_i6)
  167. if self.padnumber == 118:
  168. self.Trigger(ex.btn_i7.samplePath, 118, ex.btn_i7)
  169. if self.padnumber == 119:
  170. self.Trigger(ex.btn_i8.samplePath, 119, ex.btn_i8)
  171. if self.padnumber == 120:
  172. self.changeLabel("Play")
  173. break
  174.  
  175. #Change text for the mode button and colour of corresponding Launchpad Pad
  176. def changeLabel(self, currentMode):
  177. if currentMode == "Play":
  178. ex.lab_i9.setText(QtGui.QApplication.translate("Form", "<html><head/><body><p align=\"center\"><span style=\" color:#ffffff;\">Edit</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
  179. QtGui.QApplication.processEvents()
  180. LP.LedCtrlRaw(120, 0, 3)
  181. return
  182. if currentMode == "Edit":
  183. ex.lab_i9.setText(QtGui.QApplication.translate("Form", "<html><head/><body><p align=\"center\"><span style=\" color:#ffffff;\">Play</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
  184. QtGui.QApplication.processEvents()
  185. LP.LedCtrlRaw(120, 3, 0)
  186. return
  187.  
  188. #Determine if pad has a sample assigned. If so then play it, if not then ignore. Change pad LEDs and GUI icons for visual feedback.
  189. def Trigger(self, sample, padnumber, button):
  190. self.samplePath = sample
  191. if self.samplePath == None:
  192. pass
  193. else:
  194. if self.velocity < 1:
  195. LP.LedCtrlRaw(padnumber, 0, 3)
  196. button.icon.addPixmap(QtGui.QPixmap(button.iconPathAssigned), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  197. button.setIcon(button.icon)
  198. QtGui.QApplication.processEvents()
  199. else:
  200. LP.LedCtrlRaw(padnumber, 3, 0)
  201. button.icon.addPixmap(QtGui.QPixmap(button.iconPathPlaying), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  202. button.setIcon(button.icon)
  203. QtGui.QApplication.processEvents()
  204. sample = pygame.mixer.Sound(self.samplePath)
  205. pygame.mixer.Sound.play(sample)
  206.  
  207. #Create the GUI. Inherits from the QT QWidget class.
  208. class Ui_Form(QtGui.QWidget):
  209. def __init__(self):
  210. QtGui.QWidget.__init__(self)
  211. self.setupUi(self)
  212.  
  213. #Properly shut the Launchpad process and turn off all LEDs.
  214. def closeEvent(self, event):
  215. LP.Reset()
  216. LP.Close()
  217.  
  218. #Create the buttons, labels and background. Define properties.
  219. def setupUi(self, Form):
  220. Form.setObjectName("Form")
  221. Form.resize(591, 591)
  222.  
  223. self.Background = QtGui.QLabel(Form)
  224. self.Background.setGeometry(QtCore.QRect(0, 0, 631, 591))
  225. self.Background.setPixmap(QtGui.QPixmap("Python/LP_Proj/LP_Background.png"))
  226. self.Background.setObjectName("Background")
  227.  
  228. self.lab_a1 = Label("Unassigned", 20, 76, 61, 16, "lab_a1", self)
  229. self.lab_a2 = Label("Unassigned", 80, 76, 61, 16, "lab_a2", self)
  230. self.lab_a3 = Label("Unassigned", 140, 76, 61, 16, "lab_a3", self)
  231. self.lab_a4 = Label("Unassigned", 200, 76, 61, 16, "lab_a4", self)
  232. self.lab_a5 = Label("Unassigned", 260, 76, 61, 16, "lab_a5", self)
  233. self.lab_a6 = Label("Unassigned", 320, 76, 61, 16, "lab_a6", self)
  234. self.lab_a7 = Label("Unassigned", 380, 76, 61, 16, "lab_a7", self)
  235. self.lab_a8 = Label("Unassigned", 440, 76, 61, 16, "lab_a8", self)
  236.  
  237. self.lab_b1 = Label("Unassigned", 20, 136, 61, 16, "lab_b1", self)
  238. self.lab_b2 = Label("Unassigned", 80, 136, 61, 16, "lab_b2", self)
  239. self.lab_b3 = Label("Unassigned", 140, 136, 61, 16, "lab_b3", self)
  240. self.lab_b4 = Label("Unassigned", 200, 136, 61, 16, "lab_b4", self)
  241. self.lab_b5 = Label("Unassigned", 260, 136, 61, 16, "lab_b5", self)
  242. self.lab_b6 = Label("Unassigned", 320, 136, 61, 16, "lab_b6", self)
  243. self.lab_b7 = Label("Unassigned", 380, 136, 61, 16, "lab_b7", self)
  244. self.lab_b8 = Label("Unassigned", 440, 136, 61, 16, "lab_b8", self)
  245. self.lab_b9 = Label("Unassigned", 500, 136, 61, 16, "lab_b9", self)
  246.  
  247. self.lab_c1 = Label("Unassigned", 20, 196, 61, 16, "lab_c1", self)
  248. self.lab_c2 = Label("Unassigned", 80, 196, 61, 16, "lab_c2", self)
  249. self.lab_c3 = Label("Unassigned", 140, 196, 61, 16, "lab_c3", self)
  250. self.lab_c4 = Label("Unassigned", 200, 196, 61, 16, "lab_c4", self)
  251. self.lab_c5 = Label("Unassigned", 260, 196, 61, 16, "lab_c5", self)
  252. self.lab_c6 = Label("Unassigned", 320, 196, 61, 16, "lab_c6", self)
  253. self.lab_c7 = Label("Unassigned", 380, 196, 61, 16, "lab_c7", self)
  254. self.lab_c8 = Label("Unassigned", 440, 196, 61, 16, "lab_c8", self)
  255. self.lab_c9 = Label("Unassigned", 500, 196, 61, 16, "lab_c9", self)
  256.  
  257. self.lab_d1 = Label("Unassigned", 20, 256, 61, 16, "lab_d1", self)
  258. self.lab_d2 = Label("Unassigned", 80, 256, 61, 16, "lab_d2", self)
  259. self.lab_d3 = Label("Unassigned", 140, 256, 61, 16, "lab_d3", self)
  260. self.lab_d4 = Label("Unassigned", 200, 256, 61, 16, "lab_d4", self)
  261. self.lab_d5 = Label("Unassigned", 260, 256, 61, 16, "lab_d5", self)
  262. self.lab_d6 = Label("Unassigned", 320, 256, 61, 16, "lab_d6", self)
  263. self.lab_d7 = Label("Unassigned", 380, 256, 61, 16, "lab_d7", self)
  264. self.lab_d8 = Label("Unassigned", 440, 256, 61, 16, "lab_d8", self)
  265. self.lab_d9 = Label("Unassigned", 500, 256, 61, 16, "lab_d9", self)
  266.  
  267. self.lab_e1 = Label("Unassigned", 20, 316, 61, 16, "lab_e1", self)
  268. self.lab_e2 = Label("Unassigned", 80, 316, 61, 16, "lab_e2", self)
  269. self.lab_e3 = Label("Unassigned", 140, 316, 61, 16, "lab_e3", self)
  270. self.lab_e4 = Label("Unassigned", 200, 316, 61, 16, "lab_e4", self)
  271. self.lab_e5 = Label("Unassigned", 260, 316, 61, 16, "lab_e5", self)
  272. self.lab_e6 = Label("Unassigned", 320, 316, 61, 16, "lab_e6", self)
  273. self.lab_e7 = Label("Unassigned", 380, 316, 61, 16, "lab_e7", self)
  274. self.lab_e8 = Label("Unassigned", 440, 316, 61, 16, "lab_e8", self)
  275. self.lab_e9 = Label("Unassigned", 500, 316, 61, 16, "lab_e9", self)
  276.  
  277. self.lab_f1 = Label("Unassigned", 20, 376, 61, 16, "lab_f1", self)
  278. self.lab_f2 = Label("Unassigned", 80, 376, 61, 16, "lab_f2", self)
  279. self.lab_f3 = Label("Unassigned", 140, 376, 61, 16, "lab_f3", self)
  280. self.lab_f4 = Label("Unassigned", 200, 376, 61, 16, "lab_f4", self)
  281. self.lab_f5 = Label("Unassigned", 260, 376, 61, 16, "lab_f5", self)
  282. self.lab_f6 = Label("Unassigned", 320, 376, 61, 16, "lab_f6", self)
  283. self.lab_f7 = Label("Unassigned", 380, 376, 61, 16, "lab_f7", self)
  284. self.lab_f8 = Label("Unassigned", 440, 376, 61, 16, "lab_f8", self)
  285. self.lab_f9 = Label("Unassigned", 500, 376, 61, 16, "lab_f9", self)
  286.  
  287. self.lab_g1 = Label("Unassigned", 20, 436, 61, 16, "lab_g1", self)
  288. self.lab_g2 = Label("Unassigned", 80, 436, 61, 16, "lab_g2", self)
  289. self.lab_g3 = Label("Unassigned", 140, 436, 61, 16, "lab_g3", self)
  290. self.lab_g4 = Label("Unassigned", 200, 436, 61, 16, "lab_g4", self)
  291. self.lab_g5 = Label("Unassigned", 260, 436, 61, 16, "lab_g5", self)
  292. self.lab_g6 = Label("Unassigned", 320, 436, 61, 16, "lab_g6", self)
  293. self.lab_g7 = Label("Unassigned", 380, 436, 61, 16, "lab_g7", self)
  294. self.lab_g8 = Label("Unassigned", 440, 436, 61, 16, "lab_g8", self)
  295. self.lab_g9 = Label("Unassigned", 500, 436, 61, 16, "lab_g9", self)
  296.  
  297. self.lab_h1 = Label("Unassigned", 20, 496, 61, 16, "lab_h1", self)
  298. self.lab_h2 = Label("Unassigned", 80, 496, 61, 16, "lab_h2", self)
  299. self.lab_h3 = Label("Unassigned", 140, 496, 61, 16, "lab_h3", self)
  300. self.lab_h4 = Label("Unassigned", 200, 496, 61, 16, "lab_h4", self)
  301. self.lab_h5 = Label("Unassigned", 260, 496, 61, 16, "lab_h5", self)
  302. self.lab_h6 = Label("Unassigned", 320, 496, 61, 16, "lab_h6", self)
  303. self.lab_h7 = Label("Unassigned", 380, 496, 61, 16, "lab_h7", self)
  304. self.lab_h8 = Label("Unassigned", 440, 496, 61, 16, "lab_h8", self)
  305. self.lab_h9 = Label("Unassigned", 500, 496, 61, 16, "lab_h9", self)
  306.  
  307. self.lab_i1 = Label("Unassigned", 20, 556, 61, 16, "lab_i1", self)
  308. self.lab_i2 = Label("Unassigned", 80, 556, 61, 16, "lab_i2", self)
  309. self.lab_i3 = Label("Unassigned", 140, 556, 61, 16, "lab_i3", self)
  310. self.lab_i4 = Label("Unassigned", 200, 556, 61, 16, "lab_i4", self)
  311. self.lab_i5 = Label("Unassigned", 260, 556, 61, 16, "lab_i5", self)
  312. self.lab_i6 = Label("Unassigned", 320, 556, 61, 16, "lab_i6", self)
  313. self.lab_i7 = Label("Unassigned", 380, 556, 61, 16, "lab_i7", self)
  314. self.lab_i8 = Label("Unassigned", 440, 556, 61, 16, "lab_i8", self)
  315. self.lab_i9 = Label("Edit", 500, 556, 61, 16, "lab_i9", self)
  316.  
  317. self.btn_a1 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 30, 38, 41, 41, "btn_a1", self.lab_a1, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 200, self)
  318. self.btn_a2 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 90, 38, 41, 41, "btn_a2", self.lab_a2, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 201, self)
  319. self.btn_a3 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 150, 38, 41, 41, "btn_a3", self.lab_a3, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 202, self)
  320. self.btn_a4 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 210, 38, 41, 41, "btn_a4", self.lab_a4, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 203, self)
  321. self.btn_a5 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 270, 38, 41, 41, "btn_a5", self.lab_a5, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 204, self)
  322. self.btn_a6 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 330, 38, 41, 41, "btn_a6", self.lab_a6, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 205, self)
  323. self.btn_a7 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 390, 38, 41, 41, "btn_a7", self.lab_a7, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 206, self)
  324. self.btn_a8 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 450, 38, 41, 41, "btn_a8", self.lab_a8, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 207, self)
  325.  
  326. self.btn_b1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 90, 61, 51, "btn_b1", self.lab_b1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 0, self)
  327. self.btn_b2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 90, 61, 51, "btn_b2", self.lab_b2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 1, self)
  328. self.btn_b3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 90, 61, 51, "btn_b3", self.lab_b3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 2, self)
  329. self.btn_b4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 90, 61, 51, "btn_b4", self.lab_b4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 3, self)
  330. self.btn_b5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 90, 61, 51, "btn_b5", self.lab_b5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 4, self)
  331. self.btn_b6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 90, 61, 51, "btn_b6", self.lab_b6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 5, self)
  332. self.btn_b7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 90, 61, 51, "btn_b7", self.lab_b7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 6, self)
  333. self.btn_b8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 90, 61, 51, "btn_b8", self.lab_b8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 7, self)
  334. self.btn_b9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 95, 41, 41, "btn_b9", self.lab_b9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 8, self)
  335.  
  336. self.btn_c1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 150, 61, 51, "btn_c1", self.lab_c1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 16, self)
  337. self.btn_c2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 150, 61, 51, "btn_c2", self.lab_c2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 17, self)
  338. self.btn_c3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 150, 61, 51, "btn_c3", self.lab_c3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 18, self)
  339. self.btn_c4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 150, 61, 51, "btn_c4", self.lab_c4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 19, self)
  340. self.btn_c5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 150, 61, 51, "btn_c5", self.lab_c5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 20, self)
  341. self.btn_c6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 150, 61, 51, "btn_c6", self.lab_c6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 21, self)
  342. self.btn_c7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 150, 61, 51, "btn_c7", self.lab_c7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 22, self)
  343. self.btn_c8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 150, 61, 51, "btn_c8", self.lab_c8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 23, self)
  344. self.btn_c9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 155, 41, 41, "btn_c9", self.lab_c9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 24, self)
  345.  
  346. self.btn_d1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 210, 61, 51, "btn_d1", self.lab_d1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 32, self)
  347. self.btn_d2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 210, 61, 51, "btn_d2", self.lab_d2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 33, self)
  348. self.btn_d3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 210, 61, 51, "btn_d3", self.lab_d3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 34, self)
  349. self.btn_d4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 210, 61, 51, "btn_d4", self.lab_d4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 35, self)
  350. self.btn_d5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 210, 61, 51, "btn_d5", self.lab_d5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 36, self)
  351. self.btn_d6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 210, 61, 51, "btn_d6", self.lab_d6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 37, self)
  352. self.btn_d7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 210, 61, 51, "btn_d7", self.lab_d7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 38, self)
  353. self.btn_d8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 210, 61, 51, "btn_d8", self.lab_d8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 39, self)
  354. self.btn_d9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 215, 41, 41, "btn_d9", self.lab_d9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 40, self)
  355.  
  356. self.btn_e1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 270, 61, 51, "btn_e1", self.lab_e1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 48, self)
  357. self.btn_e2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 270, 61, 51, "btn_e2", self.lab_e2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 49, self)
  358. self.btn_e3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 270, 61, 51, "btn_e3", self.lab_e3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 50, self)
  359. self.btn_e4 = Button("Python/LP_Proj/LP_MidTL_Off.png", 55, 55, 200, 270, 61, 51, "btn_e4", self.lab_e4, "Python/LP_Proj/LP_MidTL_Green.png", "Python/LP_Proj/LP_MidTL_Red.png", 51, self)
  360. self.btn_e5 = Button("Python/LP_Proj/LP_MidTR_Off.png", 55, 55, 260, 270, 61, 51, "btn_e5", self.lab_e5, "Python/LP_Proj/LP_MidTR_Green.png", "Python/LP_Proj/LP_MidTR_Red.png", 52, self)
  361. self.btn_e6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 270, 61, 51, "btn_e6", self.lab_e6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 53, self)
  362. self.btn_e7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 270, 61, 51, "btn_e7", self.lab_e7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 54, self)
  363. self.btn_e8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 270, 61, 51, "btn_e8", self.lab_e8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 55, self)
  364. self.btn_e9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 275, 41, 41, "btn_e9", self.lab_e9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 56, self)
  365.  
  366. self.btn_f1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 330, 61, 51, "btn_f1", self.lab_f1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 64, self)
  367. self.btn_f2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 330, 61, 51, "btn_f2", self.lab_f2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 65, self)
  368. self.btn_f3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 330, 61, 51, "btn_f3", self.lab_f3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 66, self)
  369. self.btn_f4 = Button("Python/LP_Proj/LP_MidBL_Off.png", 55, 55, 200, 330, 61, 51, "btn_f4", self.lab_f4, "Python/LP_Proj/LP_MidBL_Green.png", "Python/LP_Proj/LP_MidBL_Red.png", 67, self)
  370. self.btn_f5 = Button("Python/LP_Proj/LP_MidBR_Off.png", 55, 55, 260, 330, 61, 51, "btn_f5", self.lab_f5, "Python/LP_Proj/LP_MidBR_Green.png", "Python/LP_Proj/LP_MidBR_Red.png", 68, self)
  371. self.btn_f6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 330, 61, 51, "btn_f6", self.lab_f6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 69, self)
  372. self.btn_f7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 330, 61, 51, "btn_f7", self.lab_f7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 70, self)
  373. self.btn_f8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 330, 61, 51, "btn_f8", self.lab_f8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 71, self)
  374. self.btn_f9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 335, 41, 41, "btn_f9", self.lab_f9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 72, self)
  375.  
  376. self.btn_g1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 390, 61, 51, "btn_g1", self.lab_g1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 80, self)
  377. self.btn_g2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 390, 61, 51, "btn_g2", self.lab_g2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 81, self)
  378. self.btn_g3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 390, 61, 51, "btn_g3", self.lab_g3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 82, self)
  379. self.btn_g4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 390, 61, 51, "btn_g4", self.lab_g4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 83, self)
  380. self.btn_g5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 390, 61, 51, "btn_g5", self.lab_g5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 84, self)
  381. self.btn_g6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 390, 61, 51, "btn_g6", self.lab_g6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 85, self)
  382. self.btn_g7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 390, 61, 51, "btn_g7", self.lab_g7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 86, self)
  383. self.btn_g8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 390, 61, 51, "btn_g8", self.lab_g8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 87, self)
  384. self.btn_g9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 395, 41, 41, "btn_g9", self.lab_g9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 88, self)
  385.  
  386. self.btn_h1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 450, 61, 51, "btn_h1", self.lab_h1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 96, self)
  387. self.btn_h2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 450, 61, 51, "btn_h2", self.lab_h2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 97, self)
  388. self.btn_h3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 450, 61, 51, "btn_h3", self.lab_h3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 98, self)
  389. self.btn_h4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 450, 61, 51, "btn_h4", self.lab_h4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 99, self)
  390. self.btn_h5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 450, 61, 51, "btn_h5", self.lab_h5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 100, self)
  391. self.btn_h6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 450, 61, 51, "btn_h6", self.lab_h6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 101, self)
  392. self.btn_h7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 450, 61, 51, "btn_h7", self.lab_h7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 102, self)
  393. self.btn_h8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 450, 61, 51, "btn_h8", self.lab_h8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 103, self)
  394. self.btn_h9 = Button("Python/LP_Proj/LP_Circle_Off.png", 49, 49, 510, 455, 41, 41, "btn_h9", self.lab_h9, "Python/LP_Proj/LP_Circle_Green.png", "Python/LP_Proj/LP_Circle_Red.png", 104, self)
  395.  
  396. self.btn_i1 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 20, 510, 61, 51, "btn_i1", self.lab_i1, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 112, self)
  397. self.btn_i2 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 80, 510, 61, 51, "btn_i2", self.lab_i2, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 113, self)
  398. self.btn_i3 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 140, 510, 61, 51, "btn_i3", self.lab_i3, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 114, self)
  399. self.btn_i4 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 200, 510, 61, 51, "btn_i4", self.lab_i4, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 115, self)
  400. self.btn_i5 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 260, 510, 61, 51, "btn_i5", self.lab_i5, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 116, self)
  401. self.btn_i6 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 320, 510, 61, 51, "btn_i6", self.lab_i6, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 117, self)
  402. self.btn_i7 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 380, 510, 61, 51, "btn_i7", self.lab_i7, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 118, self)
  403. self.btn_i8 = Button("Python/LP_Proj/LP_Square_Off.png", 55, 55, 440, 510, 61, 51, "btn_i8", self.lab_i8, "Python/LP_Proj/LP_Square_Green.png", "Python/LP_Proj/LP_Square_Red.png", 119, self)
  404. self.btn_i9 = ModeButton("Python/LP_Proj/LP_Circle_Mode.png", 49, 49, 510, 515, 41, 41, "btn_i9", self)
  405.  
  406. self.retranslateUi(Form)
  407. QtCore.QMetaObject.connectSlotsByName(Form)
  408.  
  409. #Allow buttons to function upon being clicked.
  410. def retranslateUi(self, Form):
  411. Form.setWindowTitle(QtGui.QApplication.translate("Form", "Launchpad Control", None, QtGui.QApplication.UnicodeUTF8))
  412.  
  413. self.btn_a1.clicked.connect(self.btn_a1.playSample)
  414. self.btn_a2.clicked.connect(self.btn_a2.playSample)
  415. self.btn_a3.clicked.connect(self.btn_a1.playSample)
  416. self.btn_a4.clicked.connect(self.btn_a2.playSample)
  417. self.btn_a5.clicked.connect(self.btn_a1.playSample)
  418. self.btn_a6.clicked.connect(self.btn_a2.playSample)
  419. self.btn_a7.clicked.connect(self.btn_a1.playSample)
  420. self.btn_a8.clicked.connect(self.btn_a2.playSample)
  421.  
  422. self.btn_b1.clicked.connect(self.btn_b1.playSample)
  423. self.btn_b2.clicked.connect(self.btn_b2.playSample)
  424. self.btn_b3.clicked.connect(self.btn_b3.playSample)
  425. self.btn_b4.clicked.connect(self.btn_b4.playSample)
  426. self.btn_b5.clicked.connect(self.btn_b5.playSample)
  427. self.btn_b6.clicked.connect(self.btn_b6.playSample)
  428. self.btn_b7.clicked.connect(self.btn_b7.playSample)
  429. self.btn_b8.clicked.connect(self.btn_b8.playSample)
  430. self.btn_b9.clicked.connect(self.btn_b9.playSample)
  431.  
  432. self.btn_c1.clicked.connect(self.btn_c1.playSample)
  433. self.btn_c2.clicked.connect(self.btn_c2.playSample)
  434. self.btn_c3.clicked.connect(self.btn_c3.playSample)
  435. self.btn_c4.clicked.connect(self.btn_c4.playSample)
  436. self.btn_c5.clicked.connect(self.btn_c5.playSample)
  437. self.btn_c6.clicked.connect(self.btn_c6.playSample)
  438. self.btn_c7.clicked.connect(self.btn_c7.playSample)
  439. self.btn_c8.clicked.connect(self.btn_c8.playSample)
  440. self.btn_c9.clicked.connect(self.btn_c9.playSample)
  441.  
  442. self.btn_d1.clicked.connect(self.btn_d1.playSample)
  443. self.btn_d2.clicked.connect(self.btn_d2.playSample)
  444. self.btn_d3.clicked.connect(self.btn_d3.playSample)
  445. self.btn_d4.clicked.connect(self.btn_d4.playSample)
  446. self.btn_d5.clicked.connect(self.btn_d5.playSample)
  447. self.btn_d6.clicked.connect(self.btn_d6.playSample)
  448. self.btn_d7.clicked.connect(self.btn_d7.playSample)
  449. self.btn_d8.clicked.connect(self.btn_d8.playSample)
  450. self.btn_d9.clicked.connect(self.btn_d9.playSample)
  451.  
  452. self.btn_e1.clicked.connect(self.btn_e1.playSample)
  453. self.btn_e2.clicked.connect(self.btn_e2.playSample)
  454. self.btn_e3.clicked.connect(self.btn_e3.playSample)
  455. self.btn_e4.clicked.connect(self.btn_e4.playSample)
  456. self.btn_e5.clicked.connect(self.btn_e5.playSample)
  457. self.btn_e6.clicked.connect(self.btn_e6.playSample)
  458. self.btn_e7.clicked.connect(self.btn_e7.playSample)
  459. self.btn_e8.clicked.connect(self.btn_e8.playSample)
  460. self.btn_e9.clicked.connect(self.btn_e9.playSample)
  461.  
  462. self.btn_f1.clicked.connect(self.btn_f1.playSample)
  463. self.btn_f2.clicked.connect(self.btn_f2.playSample)
  464. self.btn_f3.clicked.connect(self.btn_f3.playSample)
  465. self.btn_f4.clicked.connect(self.btn_f4.playSample)
  466. self.btn_f5.clicked.connect(self.btn_f5.playSample)
  467. self.btn_f6.clicked.connect(self.btn_f6.playSample)
  468. self.btn_f7.clicked.connect(self.btn_f7.playSample)
  469. self.btn_f8.clicked.connect(self.btn_f8.playSample)
  470. self.btn_f9.clicked.connect(self.btn_f9.playSample)
  471.  
  472. self.btn_g1.clicked.connect(self.btn_g1.playSample)
  473. self.btn_g2.clicked.connect(self.btn_g2.playSample)
  474. self.btn_g3.clicked.connect(self.btn_g3.playSample)
  475. self.btn_g4.clicked.connect(self.btn_g4.playSample)
  476. self.btn_g5.clicked.connect(self.btn_g5.playSample)
  477. self.btn_g6.clicked.connect(self.btn_g6.playSample)
  478. self.btn_g7.clicked.connect(self.btn_g7.playSample)
  479. self.btn_g8.clicked.connect(self.btn_g8.playSample)
  480. self.btn_g9.clicked.connect(self.btn_g9.playSample)
  481.  
  482. self.btn_h1.clicked.connect(self.btn_h1.playSample)
  483. self.btn_h2.clicked.connect(self.btn_h2.playSample)
  484. self.btn_h3.clicked.connect(self.btn_h3.playSample)
  485. self.btn_h4.clicked.connect(self.btn_h4.playSample)
  486. self.btn_h5.clicked.connect(self.btn_h5.playSample)
  487. self.btn_h6.clicked.connect(self.btn_h6.playSample)
  488. self.btn_h7.clicked.connect(self.btn_h7.playSample)
  489. self.btn_h8.clicked.connect(self.btn_h8.playSample)
  490. self.btn_h9.clicked.connect(self.btn_h9.playSample)
  491.  
  492. self.btn_i1.clicked.connect(self.btn_i1.playSample)
  493. self.btn_i2.clicked.connect(self.btn_i2.playSample)
  494. self.btn_i3.clicked.connect(self.btn_i3.playSample)
  495. self.btn_i4.clicked.connect(self.btn_i4.playSample)
  496. self.btn_i5.clicked.connect(self.btn_i5.playSample)
  497. self.btn_i6.clicked.connect(self.btn_i6.playSample)
  498. self.btn_i7.clicked.connect(self.btn_i7.playSample)
  499. self.btn_i8.clicked.connect(self.btn_i8.playSample)
  500. self.btn_i9.clicked.connect(launchSampler)
  501.  
  502. #Custom label class, inheriting from QT QLabel.
  503. class Label(QtGui.QLabel):
  504. def __init__(self, text, posX, posY, posA, posB, objName, parent=None):
  505. super(Label, self).__init__(parent=parent)
  506.  
  507. self.setGeometry(QtCore.QRect(posX, posY, posA, posB))
  508. self.font = QtGui.QFont()
  509. self.font.setPointSize(10)
  510. self.setFont(self.font)
  511. self.setObjectName(objName)
  512. self.text = text
  513. self.setText(QtGui.QApplication.translate("Form", "<html><head/><body><p align=\"center\"><span style=\" color:#ffffff;\">"+ self.text +"</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
  514.  
  515. #Custom button class without drag and drop functionality.
  516. class ModeButton(QtGui.QPushButton):
  517. def __init__(self, iconPathUnassigned, iconX, iconY, posX, posY, posA, posB, objName, parent=None):
  518. super(ModeButton, self).__init__(parent=parent)
  519.  
  520. self.icon = QtGui.QIcon()
  521. self.icon.addPixmap(QtGui.QPixmap(iconPathUnassigned), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  522. self.setIcon(self.icon)
  523. self.setIconSize(QtCore.QSize(iconX, iconY))
  524. self.setGeometry(QtCore.QRect(posX, posY, posA, posB))
  525. self.setObjectName(objName)
  526. LP.LedCtrlRaw(120, 0, 3)
  527.  
  528. #Custom button class with drag and drop functionality.
  529. class Button(QtGui.QPushButton):
  530. def __init__(self, iconPathUnassigned, iconX, iconY, posX, posY, posA, posB, objName, labEdit, iconPathAssigned, iconPathPlaying, padnumber, parent=None):
  531. super(Button, self).__init__(parent=parent)
  532.  
  533. self.setAcceptDrops(True)
  534.  
  535. self.iconPathAssigned = iconPathAssigned
  536. self.iconPathPlaying = iconPathPlaying
  537. self.icon = QtGui.QIcon()
  538. self.icon.addPixmap(QtGui.QPixmap(iconPathUnassigned), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  539. self.setIcon(self.icon)
  540. self.setIconSize(QtCore.QSize(iconX, iconY))
  541. self.setGeometry(QtCore.QRect(posX, posY, posA, posB))
  542. self.setObjectName(objName)
  543. self.samplePath = None
  544. self.label = labEdit
  545. self.padnumber = padnumber
  546.  
  547. #If dragged item has a filepath then accept it, otherwise do not (i.e if it were text that had been dragged straight onto the button)
  548. def dragEnterEvent(self, event):
  549. if event.mimeData().hasUrls():
  550. event.acceptProposedAction()
  551. else:
  552. super(Button, self).dragEnterEvent(event)
  553.  
  554. def dragMoveEvent(self, event):
  555. super(Button, self).dragMoveEvent(event)
  556.  
  557. #If dragged item has a filepath then accept it, otherwise do not (i.e if it were text that had been dragged straight onto the button)
  558. def dropEvent(self, event):
  559. if event.mimeData().hasUrls():
  560. for url in event.mimeData().urls():
  561. self.samplePath = str(url.toLocalFile())
  562. self.editLabel()
  563. self.iconAssigned()
  564. event.acceptProposedAction()
  565. else:
  566. super(Button,self).dropEvent(event)
  567.  
  568. def iconAssigned(self):
  569. self.icon.addPixmap(QtGui.QPixmap(self.iconPathAssigned), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  570. self.setIcon(self.icon)
  571. LP.LedCtrlRaw(self.padnumber, 0, 3)
  572.  
  573. def iconPlaying(self):
  574. self.icon.addPixmap(QtGui.QPixmap(self.iconPathPlaying), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  575. self.setIcon(self.icon)
  576.  
  577. def playSample(self):
  578. if self.samplePath == None:
  579. self.sample = None
  580. else:
  581. self.sample = pygame.mixer.Sound(self.samplePath)
  582. pygame.mixer.Sound.play(self.sample)
  583.  
  584. def editLabel(self):
  585. self.fileName = ntpath.basename(self.samplePath)
  586. self.label.setText(QtGui.QApplication.translate("Form", "<html><head/><body><p align=\"center\"><span style=\" color:#ffffff;\">"+ self.fileName +"</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
  587.  
  588. def launchSampler():
  589. playmode = Sampler()
  590.  
  591. if __name__=='__main__':
  592. pygame.mixer.init(frequency=44100, size=-16, buffer=1024)
  593. pygame.init()
  594. app = QtGui.QApplication(sys.argv)
  595. LP = launchpad.Launchpad()
  596. LP.Open()
  597. LP.Reset()
  598. ex = Ui_Form()
  599. ex.show()
  600. sys.exit(app.exec_())
Runtime error #stdin #stdout #stderr 0.01s 9112KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 1, in <module>
ImportError: No module named pygame