asigalov61
commited on
Commit
•
b2482f9
1
Parent(s):
0e91e80
Update app.py
Browse files
app.py
CHANGED
@@ -77,15 +77,97 @@ def GenerateBridge(input_midi, input_start_note):
|
|
77 |
|
78 |
print('Done!')
|
79 |
print('=' * 70)
|
80 |
-
seed_melody = seed_melodies_data[input_melody_seed_number]
|
81 |
-
print('Input melody seed number:', input_melody_seed_number)
|
82 |
-
print('-' * 70)
|
83 |
-
|
84 |
-
#==================================================================
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
print('=' * 70)
|
87 |
|
88 |
-
print('
|
|
|
|
|
89 |
print('=' * 70)
|
90 |
print('Generating...')
|
91 |
|
|
|
77 |
|
78 |
print('Done!')
|
79 |
print('=' * 70)
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
print('Loading MIDI...')
|
82 |
+
|
83 |
+
#===============================================================================
|
84 |
+
# Raw single-track ms score
|
85 |
+
|
86 |
+
raw_score = TMIDIX.midi2single_track_ms_score(input_midi.name)
|
87 |
+
|
88 |
+
#===============================================================================
|
89 |
+
# Enhanced score notes
|
90 |
+
|
91 |
+
escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True)[0]
|
92 |
+
|
93 |
+
#===============================================================================
|
94 |
+
# Augmented enhanced score notes
|
95 |
+
|
96 |
+
escore_notes = TMIDIX.recalculate_score_timings(TMIDIX.augment_enhanced_score_notes(escore_notes, timings_divider=32))
|
97 |
+
|
98 |
+
#=======================================================
|
99 |
+
# FINAL PROCESSING
|
100 |
+
|
101 |
+
melody_chords = []
|
102 |
+
|
103 |
+
#=======================================================
|
104 |
+
# MAIN PROCESSING CYCLE
|
105 |
+
#=======================================================
|
106 |
+
|
107 |
+
pe = escore_notes[0]
|
108 |
+
|
109 |
+
for e in escore_notes:
|
110 |
+
|
111 |
+
#=======================================================
|
112 |
+
# Timings...
|
113 |
+
|
114 |
+
delta_time = max(0, min(127, e[1]-pe[1]))
|
115 |
+
|
116 |
+
# Durations and channels
|
117 |
+
|
118 |
+
dur = max(0, min(127, e[2]))
|
119 |
+
|
120 |
+
cha = max(0, min(15, e[3]))
|
121 |
+
|
122 |
+
# Patches
|
123 |
+
pat = max(0, min(128, e[6]))
|
124 |
+
|
125 |
+
# Pitches
|
126 |
+
if cha != 9:
|
127 |
+
ptc = max(1, min(127, e[4]))
|
128 |
+
else:
|
129 |
+
ptc = max(1, min(127, e[4]))+128
|
130 |
+
|
131 |
+
# Velocities
|
132 |
+
# Calculating octo-velocity
|
133 |
+
velocity = max(8, min(127, e[5]))
|
134 |
+
vel = round(velocity / 15)-1
|
135 |
+
|
136 |
+
#=======================================================
|
137 |
+
# FINAL NOTE SEQ
|
138 |
+
|
139 |
+
# Writing final note synchronously
|
140 |
+
|
141 |
+
melody_chords.extend([delta_time, dur+128, pat+256, ptc+384, vel+640])
|
142 |
+
|
143 |
+
pe = e
|
144 |
+
|
145 |
+
#=======================================================
|
146 |
+
|
147 |
+
SEQ_L = 3060
|
148 |
+
STEP = SEQ_L // 3
|
149 |
+
|
150 |
+
score_chunk = melody_chords[:SEQ_L]
|
151 |
+
|
152 |
+
td = [649]
|
153 |
+
|
154 |
+
td.extend(score_chunk[:STEP])
|
155 |
+
|
156 |
+
td += [650]
|
157 |
+
|
158 |
+
td.extend(score_chunk[-STEP:])
|
159 |
+
|
160 |
+
td += [651]
|
161 |
+
|
162 |
+
start_note = score_chunk[:STEP][-5:]
|
163 |
+
end_note = score_chunk[-STEP:][:5]
|
164 |
+
|
165 |
+
print('Done!')
|
166 |
print('=' * 70)
|
167 |
|
168 |
+
print('Start note', start_note)
|
169 |
+
print('Etart note', end_note)
|
170 |
+
|
171 |
print('=' * 70)
|
172 |
print('Generating...')
|
173 |
|