-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelative_notes.py
More file actions
73 lines (52 loc) · 2.1 KB
/
relative_notes.py
File metadata and controls
73 lines (52 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#how do we know when downstep happens?
##find max val of phrase and go down
#take in notes of notes from the csv file
#use their locations to determine their relative position in the note phrase
#need data type of [[start, length, relnote1], [start, stop, relnote2]...]
#get to [start, length, relnote1], [start, stop, relnote2]...]
# two outcomes: one for individual notes, one for phrased notes. the individual notes need to come from the phrased notes, so do phrased notes first
# in phrases find max val, make 5 - curr val
def relative_notes(file_info):
info = []
count = 0
#goes through each phrase in file_info
for phrase in file_info[1]:
# print(phrase)
phrase_list = []
#checks for phrase_break
if 'phrase_break' in phrase:
info.append(phrase)
#can remove if desired
else:
high_note = 0
for note in phrase:
rel_note = note[2]
if '.' in rel_note or 'undefined' in note:
# info.append(note)
continue
else:
rel_note = int(rel_note)
if rel_note > high_note:
high_note = rel_note
# phrase_length += note[1]
for note in phrase:
#gets the note relative to others
if not '.' in note[2] and not 'undefined' in note[2]:
#the note is 5 minus (the highest note of the phrase minus the row number of the note)
new_note = [note[0], note[1], str(5 - (high_note-int(note[2])))]
#if this new note is 0, then it equals the high note and should be 5, if it less than 0, it is an octave below, and should have 5 added to it.
if int(new_note[2]) <= 0 :
new_note = str(int(new_note[2]) + 5) + 'a'
if new_note == '0a':
new_note = '5aa'
phrase_list.append(new_note)
new_note = [note[0], note[1], new_note]
phrase_list.append(new_note)
info.append(new_note)
else:
info.append(note)
info_outer = []
info_outer.append(info)
# for x in info:
# print(x)
return info