|
@@ -1,9 +1,6 @@
|
|
|
|
|
|
-""" helper functions """
|
|
|
|
-# temporary notation fix
|
|
|
|
|
|
|
|
-def fix_temp(note):
|
|
|
|
- return note[:4] + note[6:]
|
|
|
|
|
|
+""" helper functions """
|
|
|
|
|
|
# converts float duration to string in the form x.xx
|
|
# converts float duration to string in the form x.xx
|
|
def duration_to_string(input_float_duration):
|
|
def duration_to_string(input_float_duration):
|
|
@@ -20,28 +17,35 @@ def duration_to_string(input_float_duration):
|
|
|
|
|
|
# converts the weird notation like -#, ## or -- to nothing, one note higher or lower respectivly
|
|
# converts the weird notation like -#, ## or -- to nothing, one note higher or lower respectivly
|
|
def convert_multiple_key_signetures(note):
|
|
def convert_multiple_key_signetures(note):
|
|
- while len(note) > 7:
|
|
|
|
- if note[5:7] == "##":
|
|
|
|
- note = note[:5] + note[7:]
|
|
|
|
- note = highes_note(note, 2)
|
|
|
|
- if note[5:7] == "--":
|
|
|
|
- note = note[:5] + note[7:]
|
|
|
|
- note = highes_note(note, -2)
|
|
|
|
- if note[5:7] == "-#" or note[5:7] == "#-":
|
|
|
|
- note = note[:5] + note[7:]
|
|
|
|
- return note
|
|
|
|
|
|
+ conv_note = note
|
|
|
|
+ note = note.split(',')
|
|
|
|
+ while len(note[1]) > 3:
|
|
|
|
+ if note[1][1:3] == "##":
|
|
|
|
+ note[1] = note[1][:1] + note[1][-1:] #remove ##
|
|
|
|
+ conv_note = note[0] + ',' + note[1] #built new note
|
|
|
|
+ conv_note = highes_note(conv_note, 2) #highes note by 2
|
|
|
|
+ elif note[1][1:3] == "--":
|
|
|
|
+ note[1] = note[1][:1] + note[1][-1:] #remove --
|
|
|
|
+ conv_note = note[0] + ',' + note[1] #built new note
|
|
|
|
+ conv_note = highes_note(conv_note, -2) #highes note by 2
|
|
|
|
+ elif note[1][1:3] == "-#" or note[1][1:3] == "#-":
|
|
|
|
+ note[1] = note[1][:1] + note[1][-1:] #remove #- or -#
|
|
|
|
+ conv_note = note[0] + ',' + note[1] #built new note
|
|
|
|
+ return conv_note
|
|
|
|
|
|
# returns the pitch difference from two notes
|
|
# returns the pitch difference from two notes
|
|
-
|
|
|
|
|
|
+# assumes that last char is octave indicater
|
|
def interval(note_1, note_2):
|
|
def interval(note_1, note_2):
|
|
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']
|
|
- octave = int(note_2[-1:]) - int(note_1[-1:])
|
|
|
|
- pitch = notes_list.index(note_2[4:5]) - notes_list.index(note_1[4:5])
|
|
|
|
|
|
+ note_1 = note_1.split(',')
|
|
|
|
+ note_2 = note_2.split(',')
|
|
|
|
+ octave = int(note_2[1][-1:]) - int(note_1[1][-1:])
|
|
|
|
+ pitch = notes_list.index(note_2[1][:1]) - notes_list.index(note_1[1][:1])
|
|
pitch += 12 * octave
|
|
pitch += 12 * octave
|
|
- if note_1[5:6] == '#': pitch -= 1
|
|
|
|
- if note_2[5:6] == '-': pitch -= 1
|
|
|
|
- if note_1[5:6] == '-': pitch += 1
|
|
|
|
- if note_2[5:6] == '#': pitch += 1
|
|
|
|
|
|
+ if note_1[1][1:2] == '#': pitch -= 1
|
|
|
|
+ if note_2[1][1:2] == '-': pitch -= 1
|
|
|
|
+ if note_1[1][1:2] == '-': pitch += 1
|
|
|
|
+ if note_2[1][1:2] == '#': pitch += 1
|
|
return pitch
|
|
return pitch
|
|
|
|
|
|
""" actual functions """
|
|
""" actual functions """
|
|
@@ -50,7 +54,7 @@ def interval(note_1, note_2):
|
|
def tempo(input_list, temp):
|
|
def tempo(input_list, temp):
|
|
working_list = []
|
|
working_list = []
|
|
for note in input_list:
|
|
for note in input_list:
|
|
- duration = float (note[0:4]) * float(temp)
|
|
|
|
|
|
+ duration = float (note[0:4]) * temp
|
|
note = duration_to_string(duration) + note[4:]
|
|
note = duration_to_string(duration) + note[4:]
|
|
working_list.append(note)
|
|
working_list.append(note)
|
|
return working_list
|
|
return working_list
|
|
@@ -63,7 +67,7 @@ def verkleinerung(input_list):
|
|
def vergrösserung(input_list):
|
|
def vergrösserung(input_list):
|
|
return tempo(input_list, 2)
|
|
return tempo(input_list, 2)
|
|
|
|
|
|
- # return the note higher by a value (1 = half a step)
|
|
|
|
|
|
+# return the note higher by a value (1 = half a step)
|
|
def highes_note(note, value):
|
|
def highes_note(note, value):
|
|
note = note.split(',')
|
|
note = note.split(',')
|
|
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']
|
|
@@ -83,13 +87,13 @@ def highes_note(note, value):
|
|
octave -= 1
|
|
octave -= 1
|
|
ord_number = ord_number - 12
|
|
ord_number = ord_number - 12
|
|
if note[1][1:2] == '#': # 2nd char from 2nd list argument
|
|
if note[1][1:2] == '#': # 2nd char from 2nd list argument
|
|
- note = note[0] + notes_list[ord_number] + '#' + str(octave)
|
|
|
|
|
|
+ higher_note = note[0] + ',' + notes_list[ord_number] + '#' + str(octave)
|
|
elif note[1][1:2] == '-':
|
|
elif note[1][1:2] == '-':
|
|
- note = note[0] + notes_list[ord_number] + '-' + str(octave)
|
|
|
|
|
|
+ higher_note = note[0] + ',' + notes_list[ord_number] + '-' + str(octave)
|
|
else:
|
|
else:
|
|
- note = note[0] + notes_list[ord_number] + str(octave)
|
|
|
|
- note = convert_multiple_key_signetures(note)
|
|
|
|
- return note
|
|
|
|
|
|
+ higher_note = note[0] + ',' + notes_list[ord_number] + str(octave)
|
|
|
|
+ higher_note = convert_multiple_key_signetures(higher_note)
|
|
|
|
+ return higher_note
|
|
|
|
|
|
# returns a part higher by some value
|
|
# returns a part higher by some value
|
|
def sequenz(input_list, value):
|
|
def sequenz(input_list, value):
|
|
@@ -100,14 +104,28 @@ def sequenz(input_list, value):
|
|
return working_list
|
|
return working_list
|
|
|
|
|
|
# mirrors notes at the first note
|
|
# mirrors notes at the first note
|
|
-def mirror(input_list):
|
|
|
|
|
|
+def mirror_pitch(input_list):
|
|
working_list = []
|
|
working_list = []
|
|
mirror = input_list[0]
|
|
mirror = input_list[0]
|
|
for note in input_list:
|
|
for note in input_list:
|
|
- tmp_note = highes_note(mirror, - interval(mirror, note))
|
|
|
|
- working_list.append(tmp_note)
|
|
|
|
|
|
+ pitch = highes_note(mirror, - interval(mirror, note)) # change pitch
|
|
|
|
+ note = note.split(',')
|
|
|
|
+ pitch = pitch.split(',')
|
|
|
|
+ mir_note = note[0] + ',' + pitch[1] # take duration from "note"
|
|
|
|
+ working_list.append(mir_note)
|
|
return working_list
|
|
return working_list
|
|
|
|
|
|
|
|
+# mirrors the rythme from back to front
|
|
|
|
+def mirror_rythm(input_list):
|
|
|
|
+ r_input_list = input_list[::-1]
|
|
|
|
+ working_list = [] # revesed list
|
|
|
|
+ for i in range (0, len(input_list)):
|
|
|
|
+ r_note = r_input_list[i].split(',')
|
|
|
|
+ n_note = input_list[i].split(',')
|
|
|
|
+ working_list.append(r_note[0] + ',' + n_note[1])
|
|
|
|
+ return working_list
|
|
|
|
+
|
|
|
|
+
|
|
# reverses list of notes (krebs)
|
|
# reverses list of notes (krebs)
|
|
def krebs(input_list):
|
|
def krebs(input_list):
|
|
return input_list[::-1]
|
|
return input_list[::-1]
|