asigalov61
commited on
Commit
•
2967e03
1
Parent(s):
1d137aa
Update app.py
Browse files
app.py
CHANGED
@@ -57,22 +57,12 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
57 |
#=======================================================
|
58 |
# START PROCESSING
|
59 |
|
60 |
-
raw_score = TMIDIX.midi2single_track_ms_score(fdata
|
61 |
-
|
62 |
-
escore = TMIDIX.advanced_score_processor(raw_score,
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
for e in escore:
|
67 |
-
e[1] = int(e[1] / 16)
|
68 |
-
e[2] = int(e[2] / 16)
|
69 |
-
|
70 |
-
# Sorting by patch, pitch, then by start-time
|
71 |
-
|
72 |
-
escore.sort(key=lambda x: x[6])
|
73 |
-
escore.sort(key=lambda x: x[4], reverse=True)
|
74 |
-
escore.sort(key=lambda x: x[1])
|
75 |
-
|
76 |
cscore = TMIDIX.chordify_score([1000, escore])
|
77 |
|
78 |
meta_data = raw_score[1][:first_note_index] + [escore[0]] + [escore[-1]] + [raw_score[1][-1]]
|
@@ -87,31 +77,15 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
87 |
output_score = copy.deepcopy(escore)
|
88 |
|
89 |
elif render_type == "Extract melody":
|
90 |
-
|
91 |
|
92 |
-
for e in
|
93 |
e[3] = 0
|
94 |
|
95 |
if e[4] < 60:
|
96 |
e[4] = (e[4] % 12) + 60
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
for i in range(len(output_score)-1):
|
101 |
-
note = output_score[i]
|
102 |
-
|
103 |
-
nmt = output_score[i+1][1]
|
104 |
-
|
105 |
-
if note[1]+note[2] >= nmt:
|
106 |
-
note_dur = nmt-note[1]-1
|
107 |
-
else:
|
108 |
-
note_dur = note[2]
|
109 |
-
|
110 |
-
fixed_score.append([note[0], note[1], note_dur, note[3], note[4], note[5], note[6]])
|
111 |
-
|
112 |
-
fixed_score.append(output_score[-1])
|
113 |
-
|
114 |
-
output_score = copy.deepcopy(fixed_score)
|
115 |
|
116 |
elif render_type == "Transform":
|
117 |
|
|
|
57 |
#=======================================================
|
58 |
# START PROCESSING
|
59 |
|
60 |
+
raw_score = TMIDIX.midi2single_track_ms_score(fdata)
|
61 |
+
|
62 |
+
escore = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True)[0]
|
63 |
+
|
64 |
+
escore= TMIDIX.augment_enhanced_score_notes(escore)
|
65 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
cscore = TMIDIX.chordify_score([1000, escore])
|
67 |
|
68 |
meta_data = raw_score[1][:first_note_index] + [escore[0]] + [escore[-1]] + [raw_score[1][-1]]
|
|
|
77 |
output_score = copy.deepcopy(escore)
|
78 |
|
79 |
elif render_type == "Extract melody":
|
80 |
+
melody_score = copy.deepcopy([c[0] for c in cscore if c[0][3] != 9])
|
81 |
|
82 |
+
for e in melody_score:
|
83 |
e[3] = 0
|
84 |
|
85 |
if e[4] < 60:
|
86 |
e[4] = (e[4] % 12) + 60
|
87 |
|
88 |
+
output_score = TMIDIX.fix_monophonic_score_durations(melody_score)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
elif render_type == "Transform":
|
91 |
|