test.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # plays inputed higher by a value. By now can
  2. # cause weird notation like G#- with F- and 2
  3. """
  4. def sequenz_old(input_list, value):
  5. notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
  6. if value < 0:
  7. notes_list.reverse()
  8. value = -value
  9. working_list = []
  10. for n in input_list:
  11. note = n[:4]
  12. pitch = n[4:5]
  13. ord_number = notes_list.index(pitch)
  14. octave = int(n[-1:])
  15. ord_number += value
  16. while ord_number >= 12:
  17. octave += 1
  18. ord_number = ord_number - 12
  19. if n[5:6] == '#':
  20. note = note + notes_list[ord_number] + '#' + str(octave)
  21. working_list.append(note)
  22. elif n[5:6] == '-':
  23. note = note + notes_list[ord_number] + '-' + str(octave)
  24. working_list.append(note)
  25. else:
  26. note = note + notes_list[ord_number] + str(octave)
  27. working_list.append(note)
  28. return working_list
  29. """
  30. def sequenz(input_list, value):
  31. working_list = []
  32. for n in input_list:
  33. note = highes_note(n, value)
  34. working_list.append(note)
  35. return working_list
  36. # return the note higher by a value (1 = half a step)
  37. def highes_note(note, value):
  38. notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
  39. is_up = True
  40. if value < 0:
  41. notes_list.reverse()
  42. value = -value
  43. is_up = False
  44. tmp_note = note[:4]
  45. pitch = note[4:5]
  46. ord_number = notes_list.index(pitch)
  47. octave = int(note[-1:])
  48. ord_number += value
  49. while ord_number >= 12: #bug to fix (octave down)
  50. if is_up:
  51. octave += 1
  52. else:
  53. octave -= 1
  54. ord_number = ord_number - 12
  55. if note[5:6] == '#':
  56. note = tmp_note + notes_list[ord_number] + '#' + str(octave)
  57. elif note[5:6] == '-':
  58. note = tmp_note + notes_list[ord_number] + '-' + str(octave)
  59. else:
  60. note = tmp_note + notes_list[ord_number] + str(octave)
  61. note = convert_multiple_key_signetures(note)
  62. return note
  63. # converts the weird notation like -# to something more common
  64. def convert_multiple_key_signetures(note):
  65. notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
  66. while len(note) > 7:
  67. if note[5:7] == "##":
  68. note = note[:5] + note[7:]
  69. note = highes_note(note, 2)
  70. if note[5:7] == "--":
  71. note = note[:5] + note[7:]
  72. note = highes_note(note, -2)
  73. if note[5:7] == "-#" or note[5:7] == "#-":
  74. note = note[:5] + note[7:]
  75. return note
  76. l = ['1.00D#5', '0.25F-4', '0.50C5']
  77. print (l)
  78. print(sequenz(l, 3))
  79. print(sequenz(l, -3))
  80. """
  81. print(highes_note('1.00D5', 2))
  82. print(highes_note('1.00D5', -2))
  83. print(highes_note('1.00D5', 13))
  84. print(highes_note('1.00D5', -13))
  85. print(convert_multiple_key_signetures('1.00D##5'))
  86. print(convert_multiple_key_signetures('1.00D#-5'))
  87. print(convert_multiple_key_signetures('1.00D--5'))
  88. print(convert_multiple_key_signetures('1.00D5'))
  89. """