Browse Source

added sequenz (not working properly yet)

Paola Fontana Gasio 4 years ago
parent
commit
1cf9032425
1 changed files with 67 additions and 8 deletions
  1. 67 8
      tests/test.py

+ 67 - 8
tests/test.py

@@ -1,7 +1,12 @@
-# plays inputed higher by a value. By now only works upwards (positiv values) and can 
-# cause weird notation like G#- with F- and 2 
-def sequenz(input_list, value):
+# plays inputed higher by a value. By now can 
+# cause weird notation like G#- with F- and 2
+
+"""
+def sequenz_old(input_list, value):
     notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+    if value < 0:
+        notes_list.reverse()
+        value = -value
     working_list = []
     working_list = []
     for n in input_list:
     for n in input_list:
         note = n[:4]
         note = n[:4]
@@ -22,17 +27,71 @@ def sequenz(input_list, value):
             note = note + notes_list[ord_number] + str(octave)
             note = note + notes_list[ord_number] + str(octave)
             working_list.append(note)
             working_list.append(note)
     return working_list
     return working_list
+"""
+
+def sequenz(input_list, value):
+    working_list = []
+    for n in input_list:
+        note = highes_note(n, value)
+        working_list.append(note)
+    return working_list
 
 
-# work in progress ...
+# return the note higher by a value (1 = half a step)
+def highes_note(note, value):
+    notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+    is_up = True
+    if value < 0:
+        notes_list.reverse()
+        value = -value
+        is_up = False
+    tmp_note = note[:4]
+    pitch = note[4:5]
+    ord_number = notes_list.index(pitch)
+    octave = int(note[-1:])
+    ord_number += value
+    while ord_number >= 12: #bug to fix (octave down)
+        if is_up:
+            octave += 1
+        else:
+            octave -= 1
+        ord_number = ord_number - 12
+    if note[5:6] == '#':
+        note = tmp_note + notes_list[ord_number] + '#' + str(octave)
+    elif note[5:6] == '-':
+        note = tmp_note + notes_list[ord_number] + '-' + str(octave)
+    else:
+        note = tmp_note + notes_list[ord_number] + str(octave)
+    note = convert_multiple_key_signetures(note)
+    return note
+
+# converts the weird notation like -# to something more common
 def convert_multiple_key_signetures(note):
 def convert_multiple_key_signetures(note):
     notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     while len(note) > 7:
     while len(note) > 7:
         if note[5:7] == "##":
         if note[5:7] == "##":
-            note[4:5]
+            note = note[:5] + note[7:]
+            note = highes_note(note, 2)
         if note[5:7] == "--":
         if note[5:7] == "--":
-        if note[5:7] == "-#" or note[4:6] == "#-":
             note = note[:5] + note[7:]
             note = note[:5] + note[7:]
-    return note
+            note = highes_note(note, -2)
+        if note[5:7] == "-#" or note[5:7] == "#-":
+            note = note[:5] + note[7:]
+    return note 
+
 l = ['1.00D#5', '0.25F-4', '0.50C5']
 l = ['1.00D#5', '0.25F-4', '0.50C5']
 print (l)
 print (l)
-print(sequenz(l, 3))
+print(sequenz(l, 3))
+print(sequenz(l, -3))
+
+"""
+print(highes_note('1.00D5', 2))
+print(highes_note('1.00D5', -2))
+print(highes_note('1.00D5', 13))
+print(highes_note('1.00D5', -13))
+
+
+print(convert_multiple_key_signetures('1.00D##5'))
+print(convert_multiple_key_signetures('1.00D#-5'))
+print(convert_multiple_key_signetures('1.00D--5'))
+print(convert_multiple_key_signetures('1.00D5'))
+"""