Browse Source

added vergrösserung and verkleinerung

Paola Fontana Gasio 4 years ago
parent
commit
507220fe3c
2 changed files with 72 additions and 0 deletions
  1. 34 0
      src/gizmo_transforming_functions.py
  2. 38 0
      tests/test.py

+ 34 - 0
src/gizmo_transforming_functions.py

@@ -0,0 +1,34 @@
+
+# doubles duration
+def vergrösserung(input_list):
+    working_list = []
+    for n in input_list:
+        note = n
+        duration = float (note[0:4]) * 2
+        note = duration_to_string(duration) + note[4:]
+        working_list.append(note)
+    return working_list
+
+# halfs duration
+def verkleinerung(input_list):
+    working_list = []
+    for n in input_list:
+        note = n
+        duration = float(note[:4]) / 2
+        note = duration_to_string(duration) + note[4:]
+        working_list.append(note)
+    return working_list
+
+# converts float duration to string in the form x.xx
+def duration_to_string(input_float_duration):
+    input_float_duration *= 100
+    input_int_duration = int(input_float_duration)
+    duration = ""
+    for i in range (0, 3):
+        x = input_int_duration % 10
+        duration = duration + str(x)
+        input_int_duration = input_int_duration // 10
+    duration = duration[::-1]
+    duration = duration[:1] + '.' + duration[1:]
+    return duration
+

+ 38 - 0
tests/test.py

@@ -0,0 +1,38 @@
+# 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):
+    notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+    working_list = []
+    for n in input_list:
+        note = n[:4]
+        pitch = n[4:5]
+        ord_number = notes_list.index(pitch)
+        octave = int(n[-1:])
+        ord_number += value
+        while ord_number >= 12:
+            octave += 1
+            ord_number = ord_number - 12
+        if n[5:6] == '#':
+            note = note + notes_list[ord_number] + '#' + str(octave)
+            working_list.append(note)
+        elif n[5:6] == '-':
+            note = note + notes_list[ord_number] + '-' + str(octave)
+            working_list.append(note)
+        else:
+            note = note + notes_list[ord_number] + str(octave)
+            working_list.append(note)
+    return working_list
+
+# work in progress ...
+def convert_multiple_key_signetures(note):
+    notes_list = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+    while len(note) > 7:
+        if note[5:7] == "##":
+            note[4:5]
+        if note[5:7] == "--":
+        if note[5:7] == "-#" or note[4:6] == "#-":
+            note = note[:5] + note[7:]
+    return note
+l = ['1.00D#5', '0.25F-4', '0.50C5']
+print (l)
+print(sequenz(l, 3))