Guest User

Untitled

a guest
Nov 21st, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.67 KB | None | 0 0
  1. ...
  2. tracks_array = { "PART DRUMS" : 999,
  3. "PART GUITAR" : 999,
  4. "PART BASS" : 999,
  5. "PART VOCALS" : 999,
  6. "PART KEYS" : 999,
  7. "PART REAL_KEYS_X": 999,
  8. "PART REAL_KEYS_H": 999,
  9. "PART REAL_KEYS_M": 999,
  10. "PART REAL_KEYS_E": 999,
  11. "PART KEYS_ANIM_LH": 999,
  12. "PART KEYS_ANIM_RH": 999,
  13. "HARM1": 999,
  14. "HARM2": 999,
  15. "HARM3": 999,
  16. "EVENTS": 999,
  17. "BEAT": 999,
  18. "PART DRUMS 2X": 999,
  19. "VENUE": 999,
  20. "PART RHYTHM": 999,
  21. "PART REAL_GUITAR": 999,
  22. "PART REAL_GUITAR_22": 999,
  23. "PART REAL_BASS": 999,
  24. "PART REAL_BASS_22": 999
  25. }
  26. array_instruments = {
  27. "Drums" : "PART DRUMS",
  28. "2x Drums" : "PART DRUMS 2X",
  29. "Rhythm" : "PART RHYTHM",
  30. "Guitar" : "PART GUITAR",
  31. "Bass" : "PART BASS",
  32. "Keys" : "PART KEYS",
  33. "Pro Keys" : "PART REAL_KEYS",
  34. "Vocals" : "PART VOCALS",
  35. "Harmony 1" : "HARM1",
  36. "Harmony 2" : "HARM2",
  37. "Harmony 3" : "HARM3",
  38. "Pro Guitar" : "PART REAL_GUITAR",
  39. "Pro Guitar 22" : "PART REAL_GUITAR_22",
  40. "Pro Bass" : "PART REAL_BASS",
  41. "Pro Bass 22" : "PART REAL_BASS_22"
  42. }
  43. array_dropdownid = { "PART DRUMS" : 0,
  44. "PART GUITAR" : 1,
  45. "PART BASS" : 2,
  46. "PART KEYS" : 3,
  47. "PART REAL_KEYS_X": 4,
  48. "PART REAL_KEYS_H": 4,
  49. "PART REAL _KEYS_H": 4,
  50. "PART REAL_KEYS_M": 4,
  51. "PART REAL_KEYS_E": 4,
  52. "PART DRUMS 2X": 5,
  53. "PART RHYTHM": 6,
  54. "PART VOCALS": 7,
  55. "PART REAL_GUITAR": 8,
  56. "PART REAL_GUITAR_22": 8,
  57. "PART REAL_BASS": 9,
  58. "PART REAL_BASS_22": 9
  59. }
  60. ...
  61. def prep_tracks():
  62. global maxlen
  63. global tracks_array
  64. num_mi = RPR_CountMediaItems(0)
  65.  
  66. for i in range(0, num_mi):
  67. mi = RPR_GetMediaItem(0,i)
  68. trackID = RPR_GetMediaItem_Track(mi)
  69. trackname = RPR_GetSetMediaTrackInfo_String(trackID, "P_NAME", "", 0)[3]
  70. chunk = ""
  71. instrument = ""
  72. (boolvar, mi, chunk, maxlen) = RPR_GetSetItemState(mi, chunk, maxlen)
  73. #CYCLING THROUGH ALL TRACKS TO FIND THOSE RELEVANT
  74. #This check needs to go off everytime a command is issued because if the user changes position of the tracks the IDs change
  75. if "PART BASS" == trackname:
  76. tracks_array["PART BASS"] = i
  77. elif "PART DRUMS 2X" == trackname or "PART DRUMS 2x" == trackname or "PART DRUMS_2x" == trackname or "PART DRUMS_2X" == trackname:
  78. tracks_array["PART DRUMS 2X"] = i
  79. elif "PART DRUMS" == trackname:
  80. tracks_array["PART DRUMS"] = i
  81. elif "PART GUITAR" == trackname:
  82. tracks_array["PART GUITAR"] = i
  83. elif "PART VOCALS" == trackname:
  84. tracks_array["PART VOCALS"] = i
  85. elif "PART KEYS" == trackname:
  86. tracks_array["PART KEYS"] = i
  87. elif "KEYS_X" in trackname:
  88. tracks_array["PART REAL_KEYS_X"] = i
  89. elif "KEYS_H" in trackname:
  90. tracks_array["PART REAL_KEYS_H"] = i
  91. elif "KEYS_M" in trackname:
  92. tracks_array["PART REAL_KEYS_M"] = i
  93. elif "KEYS_E" in trackname:
  94. tracks_array["PART REAL_KEYS_E"] = i
  95. elif "PART KEYS_ANIM_RH" == trackname:
  96. tracks_array["PART KEYS_ANIM_RH"] = i
  97. elif "PART KEYS_ANIM_LH" == trackname:
  98. tracks_array["PART KEYS_ANIM_LH"] = i
  99. elif "HARM1" == trackname:
  100. tracks_array["HARM1"] = i
  101. elif "HARM2" == trackname:
  102. tracks_array["HARM2"] = i
  103. elif "HARM3" == trackname:
  104. tracks_array["HARM3"] = i
  105. elif "EVENTS" == trackname:
  106. tracks_array["EVENTS"] = i
  107. elif "BEAT" == trackname:
  108. tracks_array["BEAT"] = i
  109. elif "VENUE" == trackname:
  110. tracks_array["VENUE"] = i
  111. elif "PART REAL_GUITAR" == trackname:
  112. tracks_array["PART REAL_GUITAR"] = i
  113. elif "PART REAL_GUITAR_22" == trackname:
  114. tracks_array["PART REAL_GUITAR_22"] = i
  115. elif "PART REAL_BASS" == trackname:
  116. tracks_array["PART REAL_BASS"] = i
  117. elif "PART REAL_BASS_22" == trackname:
  118. tracks_array["PART REAL_BASS_22"] = i
  119. else:
  120. instrument = "???"
  121. #PM("\ntracks_array:\n")
  122. #PM(tracks_array)
  123. ...
  124. def pg_root_notes(instrument, estringlow, astring, dstring, gstring, bstring, estringhigh):
  125.  
  126. #instrument (PART REAL_GUITAR, PART REAL_GUITAR_22, PART REAL_BASS, PART REAL_BASS_22)
  127. #all strings : tuning
  128.  
  129. global maxlen
  130.  
  131. instrument_track = tracks_array[instrument]
  132. notes_dict = notesname_array[notesname_instruments_array[instrument]]
  133.  
  134. array_instrument_data = process_instrument(instrument_track)
  135. array_instrument_notes = array_instrument_data[1]
  136. end_part = array_instrument_data[2]
  137. start_part = array_instrument_data[3]
  138. array_notesevents = create_notes_array(array_instrument_notes)
  139. array_notes = array_notesevents[0]
  140. array_events = array_notesevents[1]
  141. notes_found = 0
  142. result = 0
  143.  
  144. string1 = 0 + estringlow
  145. string2 = 0 + astring
  146. string3 = 0 + dstring
  147. string4 = 0 + gstring
  148. string5 = 0 + bstring
  149. string6 = 0 + estringhigh
  150.  
  151. for x in range(0, len(array_notes)):
  152. note = array_notes[x]
  153. if notes_dict[note[2]][1] == "root_notes":
  154. notes_found = 1
  155. result = RPR_MB( "Root notes found. Do you want to delete them and proceed?", "Root notes found", 1 )
  156. break
  157.  
  158. if result == 1 or notes_found == 0:
  159. array_temp = list(array_notes)
  160. array_notes = []
  161. for x in range(0, len(array_temp)):
  162. note = array_temp[x]
  163. if notes_dict[note[2]][1] != "root_notes":
  164. array_notes.append(note)
  165. else:
  166. return
  167.  
  168. for x in range(0, len(array_notes)):
  169. note = array_notes[x]
  170. if notes_dict[note[2]][1] == "notes_x":
  171. #It's an expert note, let's add it as a root note
  172. pitch = note[2]
  173. velocity = int(str(note[3]), 16)
  174. new_note = list(note)
  175. openstring = 0
  176. if(pitch == 96): #Which string? Which note?
  177. openstring = 16 + string1
  178. elif(pitch == 97):
  179. openstring = 9 + string2
  180. elif(pitch == 98):
  181. openstring = 14 + string3
  182. elif(pitch == 99):
  183. openstring = 7 + string4
  184. elif(pitch == 100):
  185. openstring = 11 + string5
  186. elif(pitch == 101):
  187. openstring = 16 + string6
  188. root = openstring + velocity - 100
  189. roothigh = 15
  190. rootlow = 4
  191. while (root > roothigh):
  192. root = root - 12
  193. if(root < rootlow):
  194. break
  195. while (root < rootlow):
  196. root = root + 12
  197. if(root > roothigh):
  198. break
  199. new_note[2] = root
  200. array_notes.append(new_note)
  201.  
  202. write_midi(instrument_track, [array_notes, array_events], end_part, start_part)
Advertisement
Add Comment
Please, Sign In to add comment