asigalov61 commited on
Commit
c3563d1
1 Parent(s): 09fc820

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -9
app.py CHANGED
@@ -43,9 +43,6 @@ def Generate_Chords_Progression(total_song_length_in_chords_chunks,
43
  print('Base MIDI patch number:', base_MIDI_patch_number)
44
  print('=' * 70)
45
 
46
- chords_progression_summary_string = '=' * 70
47
- chords_progression_summary_string += '\n'
48
-
49
  #==================================================================
50
 
51
  print('=' * 70)
@@ -140,10 +137,49 @@ def Generate_Chords_Progression(total_song_length_in_chords_chunks,
140
  print('Rendering results...')
141
  print('=' * 70)
142
 
143
- fn1 = "Melody2Song-Seq2Seq-Music-Transformer-Composition"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
- detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
146
- output_signature = 'Melody2Song Seq2Seq Music Transformer',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  output_file_name = fn1,
148
  track_name='Project Los Angeles',
149
  list_of_MIDI_patches=patches
@@ -165,11 +201,15 @@ def Generate_Chords_Progression(total_song_length_in_chords_chunks,
165
  #========================================================
166
 
167
  output_midi_title = str(fn1)
168
- output_midi_summary = str(song_f[:3])
169
  output_midi = str(new_fn)
170
  output_audio = (16000, audio)
171
 
172
- output_plot = TMIDIX.plot_ms_SONG(song_f, plot_title=output_midi, return_plt=True)
 
 
 
 
 
173
 
174
  #========================================================
175
 
@@ -178,7 +218,7 @@ def Generate_Chords_Progression(total_song_length_in_chords_chunks,
178
  print('-' * 70)
179
  print('Req execution time:', (reqtime.time() - start_time), 'sec')
180
 
181
- return output_audio, output_plot, output_midi, output_cp_summary
182
 
183
  # =================================================================================================
184
 
 
43
  print('Base MIDI patch number:', base_MIDI_patch_number)
44
  print('=' * 70)
45
 
 
 
 
46
  #==================================================================
47
 
48
  print('=' * 70)
 
137
  print('Rendering results...')
138
  print('=' * 70)
139
 
140
+ output_score = []
141
+
142
+ time = 0
143
+
144
+ patches = [0] * 16
145
+ patches[0] = chords_progression_MIDI_patch
146
+
147
+ if base_MIDI_patch_number > -1:
148
+ patches[2] = base_MIDI_patch_number
149
+
150
+ if melody_MIDI_patch_number > -1:
151
+ patches[3] = melody_MIDI_patch_number
152
+
153
+ chords_labels = []
154
+
155
+ for i, s in enumerate(f_song):
156
+
157
+ time += chord_time_step
158
+
159
+ dur = chord_time_step
160
+
161
+ chord_str = str(i+1)
162
 
163
+ for t in sorted(set([t % 12 for t in s])):
164
+ chord_str += '-' + str(t)
165
+
166
+ chords_labels.append(['text_event', time, chord_str])
167
+
168
+ for p in s:
169
+ output_score.append(['note', time, dur, 0, p, max(40, p), chords_progression_MIDI_patch])
170
+
171
+ if base_MIDI_patch_number > -1:
172
+ output_score.append(['note', time, dur, 2, (s[-1] % 12)+24, 120-(s[-1] % 12), base_MIDI_patch_number])
173
+
174
+ if melody_MIDI_patch_number > -1:
175
+ output_score = TMIDIX.add_melody_to_enhanced_score_notes(output_score, melody_patch=melody_MIDI_patch_number)
176
+
177
+ midi_score = sorted(chords_labels + output_score, key=lambda x: x[1])
178
+
179
+ fn1 = "Pitches-Chords-Progression-Composition"
180
+
181
+ detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(midi_score,
182
+ output_signature = 'Pitches Chords Progression',
183
  output_file_name = fn1,
184
  track_name='Project Los Angeles',
185
  list_of_MIDI_patches=patches
 
201
  #========================================================
202
 
203
  output_midi_title = str(fn1)
 
204
  output_midi = str(new_fn)
205
  output_audio = (16000, audio)
206
 
207
+ output_plot = TMIDIX.plot_ms_SONG(output_score, plot_title=output_midi, return_plt=True)
208
+
209
+ #========================================================
210
+
211
+ chords_progression_summary_string = '=' * 70
212
+ chords_progression_summary_string += '\n'
213
 
214
  #========================================================
215
 
 
218
  print('-' * 70)
219
  print('Req execution time:', (reqtime.time() - start_time), 'sec')
220
 
221
+ return output_audio, output_plot, output_midi, chords_progression_summary_string
222
 
223
  # =================================================================================================
224