asigalov61 commited on
Commit
25992bf
·
verified ·
1 Parent(s): a56e703

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -23
app.py CHANGED
@@ -146,7 +146,7 @@ def Match_Cores(input_midi,
146
 
147
  match_idx = find_max_exact_match(src_core_chords, all_core_chords)
148
 
149
- print('MATCH IDX', match_idx)
150
 
151
  #==================================================================
152
 
@@ -158,26 +158,9 @@ def Match_Cores(input_midi,
158
 
159
  print('Creating final MIDI score...')
160
 
161
- all_matches_dscores = []
162
 
163
- for match in matched_chunks:
164
 
165
- start, end = kmp_search(tones_chords, match)
166
-
167
- sidx = tones_chords_idxs[start]
168
- eidx = tones_chords_idxs[end]
169
-
170
- all_matches_dscores.append(TMIDIX.delta_score_notes(TMIDIX.flatten(cscore[sidx:eidx+1])))
171
-
172
- #===============================================================================
173
-
174
- new_dscore = all_matches_dscores[0]
175
-
176
- for score in all_matches_dscores[1:]:
177
- score[0][1] = statistics.mode([e[1] for e in new_dscore[-75:] if e[1] != 0 and e[3] != 9])
178
- new_dscore.extend(score)
179
-
180
- new_escore = TMIDIX.delta_score_to_abs_score(new_dscore)
181
 
182
  #===============================================================================
183
 
@@ -189,15 +172,45 @@ def Match_Cores(input_midi,
189
  print('Rendering results...')
190
 
191
  print('=' * 70)
192
- print('Sample MIDI events:', new_escore[:3])
193
  print('=' * 70)
194
 
195
- output_score, patches, overflow_patches = TMIDIX.patch_enhanced_score_notes(new_escore)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
- fn1 = "MIDI-Remixer-Composition"
198
 
199
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
200
- output_signature = 'MIDI Remixer',
201
  output_file_name = fn1,
202
  track_name='Project Los Angeles',
203
  list_of_MIDI_patches=patches,
 
146
 
147
  match_idx = find_max_exact_match(src_core_chords, all_core_chords)
148
 
149
+ print('MAX MATCH IDX', match_idx)
150
 
151
  #==================================================================
152
 
 
158
 
159
  print('Creating final MIDI score...')
160
 
161
+ final_core_score = midi_cores_dataset['train'][match_idx]['core_score']
162
 
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  #===============================================================================
166
 
 
172
  print('Rendering results...')
173
 
174
  print('=' * 70)
175
+ print('Sample INTs', final_core_score[:15])
176
  print('=' * 70)
177
 
178
+ song_f = []
179
+
180
+ if len(final_core_score) != 0:
181
+
182
+ time = 0
183
+ dur = 0
184
+ vel = 90
185
+ pitch = 0
186
+ channel = 0
187
+ patch = 0
188
+
189
+ for m in final_core_score:
190
+
191
+ if 0 <= m < 256:
192
+ time += m * 16
193
+
194
+ elif 256 < m < 512:
195
+ dur = (m-256) * 16
196
+
197
+ elif 512 <= m <= 640:
198
+ pat = (m-512)
199
+
200
+ elif 640 < m < 768:
201
+ ptc = (m-640)
202
+
203
+ elif 768 <= m <= 896:
204
+ vel = (m-768)
205
+
206
+ song_f.append(['note', time, dur, min(15, pat // 8), ptc, vel, pat])
207
+
208
+ output_score, patches, overflow_patches = TMIDIX.patch_enhanced_score_notes(song_f)
209
 
210
+ fn1 = "MIDI-Cores-Match-Composition"
211
 
212
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
213
+ output_signature = 'MIDI Cores Match',
214
  output_file_name = fn1,
215
  track_name='Project Los Angeles',
216
  list_of_MIDI_patches=patches,