projectlosangeles
commited on
Commit
·
80ecbdb
1
Parent(s):
ac1bc9c
Upload 2 files
Browse files
Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb
CHANGED
@@ -312,7 +312,7 @@
|
|
312 |
{
|
313 |
"cell_type": "code",
|
314 |
"source": [
|
315 |
-
"#@title Plot
|
316 |
"\n",
|
317 |
"cos_sim = pairwise.cosine_similarity(\n",
|
318 |
" totals[0][0][4] \n",
|
@@ -399,6 +399,127 @@
|
|
399 |
"execution_count": null,
|
400 |
"outputs": []
|
401 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
{
|
403 |
"cell_type": "markdown",
|
404 |
"source": [
|
@@ -622,6 +743,7 @@
|
|
622 |
"stop_search_on_exact_match = True #@param {type:\"boolean\"}\n",
|
623 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
624 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
|
|
625 |
"\n",
|
626 |
"#=================================================================================\n",
|
627 |
"\n",
|
@@ -863,7 +985,14 @@
|
|
863 |
"\n",
|
864 |
"except:\n",
|
865 |
" pass\n",
|
|
|
866 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
"#============================================\n",
|
868 |
"\n",
|
869 |
"print('Top 100 matches')\n",
|
@@ -896,10 +1025,11 @@
|
|
896 |
"#@markdown NOTE: You can stop the search at any time to render partial results\n",
|
897 |
"\n",
|
898 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.01}\n",
|
899 |
-
"pitches_counts_cutoff_threshold_ratio = 0
|
900 |
"search_transposed_pitches = False #@param {type:\"boolean\"}\n",
|
901 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
902 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
|
|
903 |
"\n",
|
904 |
"print('=' * 70)\n",
|
905 |
"print('MIDI Pitches Search')\n",
|
@@ -1008,7 +1138,15 @@
|
|
1008 |
"plt.scatter(x,y, c=c)\n",
|
1009 |
"plt.xlabel(\"Time\")\n",
|
1010 |
"plt.ylabel(\"Pitch\")\n",
|
1011 |
-
"plt.show()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
],
|
1013 |
"metadata": {
|
1014 |
"cellView": "form",
|
@@ -1027,6 +1165,7 @@
|
|
1027 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.01}\n",
|
1028 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
1029 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
|
|
1030 |
"\n",
|
1031 |
"print('=' * 70)\n",
|
1032 |
"print('MIDI Patches Search')\n",
|
@@ -1122,7 +1261,15 @@
|
|
1122 |
"plt.scatter(x,y, c=c)\n",
|
1123 |
"plt.xlabel(\"Time\")\n",
|
1124 |
"plt.ylabel(\"Pitch\")\n",
|
1125 |
-
"plt.show()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1126 |
],
|
1127 |
"metadata": {
|
1128 |
"cellView": "form",
|
@@ -1254,6 +1401,7 @@
|
|
1254 |
"md5_hash_MIDI_file_name = \"d9a7e1c6a375b8e560155a5977fc10f8\" #@param {type:\"string\"}\n",
|
1255 |
"full_path_to_MIDI = \"/content/Los-Angeles-MIDI-Dataset/Come-To-My-Window-Modified-Sample-MIDI.mid\" #@param {type:\"string\"}\n",
|
1256 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
|
|
1257 |
"\n",
|
1258 |
"#============================================\n",
|
1259 |
"# MIDI rendering code\n",
|
@@ -1319,6 +1467,14 @@
|
|
1319 |
" plt.ylabel(\"Pitch\")\n",
|
1320 |
" plt.show()\n",
|
1321 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1322 |
"except:\n",
|
1323 |
" print('File not found!!!')\n",
|
1324 |
" print('Check the filename!')\n",
|
|
|
312 |
{
|
313 |
"cell_type": "code",
|
314 |
"source": [
|
315 |
+
"#@title Plot totals from MIDI matrixes (legacy)\n",
|
316 |
"\n",
|
317 |
"cos_sim = pairwise.cosine_similarity(\n",
|
318 |
" totals[0][0][4] \n",
|
|
|
399 |
"execution_count": null,
|
400 |
"outputs": []
|
401 |
},
|
402 |
+
{
|
403 |
+
"cell_type": "code",
|
404 |
+
"source": [
|
405 |
+
"#@title Plot totals from MIDI metadata\n",
|
406 |
+
"\n",
|
407 |
+
"#===============================================================================\n",
|
408 |
+
"\n",
|
409 |
+
"pitches_counts_totals = [0] * 128\n",
|
410 |
+
"\n",
|
411 |
+
"for m in tqdm(meta_data):\n",
|
412 |
+
" for mm in m[1][10][1]:\n",
|
413 |
+
" if mm[0] < 128:\n",
|
414 |
+
" pitches_counts_totals[mm[0]] += mm[1]\n",
|
415 |
+
"\n",
|
416 |
+
"y = range(128)\n",
|
417 |
+
"plt.figure(figsize=(8, 8))\n",
|
418 |
+
"plt.plot(y, pitches_counts_totals)\n",
|
419 |
+
"\n",
|
420 |
+
"plt.title('MIDI Instruments Pitches')\n",
|
421 |
+
"plt.xlabel(\"Ratio\")\n",
|
422 |
+
"plt.ylabel(\"Pitch\")\n",
|
423 |
+
"plt.tight_layout()\n",
|
424 |
+
"plt.plot()\n",
|
425 |
+
"\n",
|
426 |
+
"sim_mat = [ [0]*128 for i in range(128)]\n",
|
427 |
+
"x = 0\n",
|
428 |
+
"\n",
|
429 |
+
"for p in pitches_counts_totals:\n",
|
430 |
+
" y = 0\n",
|
431 |
+
" for pp in pitches_counts_totals:\n",
|
432 |
+
"\n",
|
433 |
+
" sim_mat[x][y] = min(10, (p / pp))\n",
|
434 |
+
" y += 1\n",
|
435 |
+
"\n",
|
436 |
+
" x += 1\n",
|
437 |
+
"\n",
|
438 |
+
"cos_sim = pairwise.cosine_similarity(\n",
|
439 |
+
" sim_mat \n",
|
440 |
+
" )\n",
|
441 |
+
"plt.figure(figsize=(8, 8))\n",
|
442 |
+
"plt.imshow(sim_mat, cmap=\"inferno\", interpolation=\"none\")\n",
|
443 |
+
"im_ratio = 1\n",
|
444 |
+
"plt.colorbar(fraction=0.046 * im_ratio, pad=0.04)\n",
|
445 |
+
"plt.title('MIDI Instruments Pitches')\n",
|
446 |
+
"plt.xlabel(\"Ratio\")\n",
|
447 |
+
"plt.ylabel(\"Pitch\")\n",
|
448 |
+
"plt.tight_layout()\n",
|
449 |
+
"plt.plot()\n",
|
450 |
+
"\n",
|
451 |
+
"#===============================================================================\n",
|
452 |
+
"\n",
|
453 |
+
"pitches_counts_totals = [1] * 128\n",
|
454 |
+
"\n",
|
455 |
+
"\n",
|
456 |
+
"for m in tqdm(meta_data):\n",
|
457 |
+
" for mm in m[1][10][1]:\n",
|
458 |
+
" if mm[0] > 128:\n",
|
459 |
+
" pitches_counts_totals[mm[0] % 128] += mm[1]\n",
|
460 |
+
"\n",
|
461 |
+
"y = range(128)\n",
|
462 |
+
"plt.figure(figsize=(8, 8))\n",
|
463 |
+
"plt.plot(y, pitches_counts_totals)\n",
|
464 |
+
"\n",
|
465 |
+
"plt.title('MIDI Drums Pitches')\n",
|
466 |
+
"plt.xlabel(\"Ratio\")\n",
|
467 |
+
"plt.ylabel(\"Pitch\")\n",
|
468 |
+
"plt.tight_layout()\n",
|
469 |
+
"plt.plot()\n",
|
470 |
+
"\n",
|
471 |
+
"sim_mat = [ [0]*128 for i in range(128)]\n",
|
472 |
+
"x = 0\n",
|
473 |
+
"\n",
|
474 |
+
"for p in pitches_counts_totals:\n",
|
475 |
+
" y = 0\n",
|
476 |
+
" for pp in pitches_counts_totals:\n",
|
477 |
+
"\n",
|
478 |
+
" sim_mat[x][y] = min(10, (p / pp))\n",
|
479 |
+
" y += 1\n",
|
480 |
+
"\n",
|
481 |
+
" x += 1\n",
|
482 |
+
"\n",
|
483 |
+
"cos_sim = pairwise.cosine_similarity(\n",
|
484 |
+
" sim_mat \n",
|
485 |
+
" )\n",
|
486 |
+
"plt.figure(figsize=(8, 8))\n",
|
487 |
+
"plt.imshow(sim_mat, cmap=\"inferno\", interpolation=\"none\")\n",
|
488 |
+
"im_ratio = 1\n",
|
489 |
+
"plt.colorbar(fraction=0.046 * im_ratio, pad=0.04)\n",
|
490 |
+
"plt.title('MIDI Drums Pitches')\n",
|
491 |
+
"plt.xlabel(\"Ratio\")\n",
|
492 |
+
"plt.ylabel(\"Pitch\")\n",
|
493 |
+
"plt.tight_layout()\n",
|
494 |
+
"plt.plot()\n",
|
495 |
+
"\n",
|
496 |
+
"#===============================================================================\n",
|
497 |
+
"\n",
|
498 |
+
"patches_counts_totals = [0] * 256\n",
|
499 |
+
"\n",
|
500 |
+
"\n",
|
501 |
+
"for m in tqdm(meta_data):\n",
|
502 |
+
" for mm in m[1][11][1]:\n",
|
503 |
+
" patches_counts_totals[mm[0]] += mm[1]\n",
|
504 |
+
"\n",
|
505 |
+
"\n",
|
506 |
+
"y = range(128)\n",
|
507 |
+
"plt.figure(figsize=(8, 8))\n",
|
508 |
+
"plt.plot(y, patches_counts_totals[:128])\n",
|
509 |
+
"\n",
|
510 |
+
"plt.title('MIDI Patches')\n",
|
511 |
+
"plt.xlabel(\"Ratio\")\n",
|
512 |
+
"plt.ylabel('Patch')\n",
|
513 |
+
"plt.tight_layout()\n",
|
514 |
+
"plt.plot()"
|
515 |
+
],
|
516 |
+
"metadata": {
|
517 |
+
"cellView": "form",
|
518 |
+
"id": "NLo2pUSQjpgg"
|
519 |
+
},
|
520 |
+
"execution_count": null,
|
521 |
+
"outputs": []
|
522 |
+
},
|
523 |
{
|
524 |
"cell_type": "markdown",
|
525 |
"source": [
|
|
|
743 |
"stop_search_on_exact_match = True #@param {type:\"boolean\"}\n",
|
744 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
745 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
746 |
+
"download_MIDI = False #@param {type:\"boolean\"}\n",
|
747 |
"\n",
|
748 |
"#=================================================================================\n",
|
749 |
"\n",
|
|
|
985 |
"\n",
|
986 |
"except:\n",
|
987 |
" pass\n",
|
988 |
+
"#==============================================\n",
|
989 |
"\n",
|
990 |
+
"if download_MIDI:\n",
|
991 |
+
" print('=' * 70)\n",
|
992 |
+
" print('Downloading MIDI file', str(fn) + '.mid')\n",
|
993 |
+
" files.download(f)\n",
|
994 |
+
" print('=' * 70)\n",
|
995 |
+
" \n",
|
996 |
"#============================================\n",
|
997 |
"\n",
|
998 |
"print('Top 100 matches')\n",
|
|
|
1025 |
"#@markdown NOTE: You can stop the search at any time to render partial results\n",
|
1026 |
"\n",
|
1027 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.01}\n",
|
1028 |
+
"pitches_counts_cutoff_threshold_ratio = 0 #@param {type:\"slider\", min:0, max:1, step:0.05}\n",
|
1029 |
"search_transposed_pitches = False #@param {type:\"boolean\"}\n",
|
1030 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
1031 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
1032 |
+
"download_MIDI = False #@param {type:\"boolean\"}\n",
|
1033 |
"\n",
|
1034 |
"print('=' * 70)\n",
|
1035 |
"print('MIDI Pitches Search')\n",
|
|
|
1138 |
"plt.scatter(x,y, c=c)\n",
|
1139 |
"plt.xlabel(\"Time\")\n",
|
1140 |
"plt.ylabel(\"Pitch\")\n",
|
1141 |
+
"plt.show()\n",
|
1142 |
+
"\n",
|
1143 |
+
"#==============================================\n",
|
1144 |
+
"\n",
|
1145 |
+
"if download_MIDI:\n",
|
1146 |
+
" print('=' * 70)\n",
|
1147 |
+
" print('Downloading MIDI file', str(fn) + '.mid')\n",
|
1148 |
+
" files.download(f)\n",
|
1149 |
+
" print('=' * 70)"
|
1150 |
],
|
1151 |
"metadata": {
|
1152 |
"cellView": "form",
|
|
|
1165 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.01}\n",
|
1166 |
"skip_exact_matches = False #@param {type:\"boolean\"}\n",
|
1167 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
1168 |
+
"download_MIDI = False #@param {type:\"boolean\"}\n",
|
1169 |
"\n",
|
1170 |
"print('=' * 70)\n",
|
1171 |
"print('MIDI Patches Search')\n",
|
|
|
1261 |
"plt.scatter(x,y, c=c)\n",
|
1262 |
"plt.xlabel(\"Time\")\n",
|
1263 |
"plt.ylabel(\"Pitch\")\n",
|
1264 |
+
"plt.show()\n",
|
1265 |
+
"\n",
|
1266 |
+
"#==============================================\n",
|
1267 |
+
"\n",
|
1268 |
+
"if download_MIDI:\n",
|
1269 |
+
" print('=' * 70)\n",
|
1270 |
+
" print('Downloading MIDI file', str(fn) + '.mid')\n",
|
1271 |
+
" files.download(f)\n",
|
1272 |
+
" print('=' * 70)"
|
1273 |
],
|
1274 |
"metadata": {
|
1275 |
"cellView": "form",
|
|
|
1401 |
"md5_hash_MIDI_file_name = \"d9a7e1c6a375b8e560155a5977fc10f8\" #@param {type:\"string\"}\n",
|
1402 |
"full_path_to_MIDI = \"/content/Los-Angeles-MIDI-Dataset/Come-To-My-Window-Modified-Sample-MIDI.mid\" #@param {type:\"string\"}\n",
|
1403 |
"render_MIDI_to_audio = False #@param {type:\"boolean\"}\n",
|
1404 |
+
"download_MIDI = False #@param {type:\"boolean\"}\n",
|
1405 |
"\n",
|
1406 |
"#============================================\n",
|
1407 |
"# MIDI rendering code\n",
|
|
|
1467 |
" plt.ylabel(\"Pitch\")\n",
|
1468 |
" plt.show()\n",
|
1469 |
"\n",
|
1470 |
+
" #==============================================\n",
|
1471 |
+
"\n",
|
1472 |
+
" if download_MIDI:\n",
|
1473 |
+
" print('=' * 70)\n",
|
1474 |
+
" print('Downloading MIDI file', str(fn) + '.mid')\n",
|
1475 |
+
" files.download(f)\n",
|
1476 |
+
" print('=' * 70)\n",
|
1477 |
+
"\n",
|
1478 |
"except:\n",
|
1479 |
" print('File not found!!!')\n",
|
1480 |
" print('Check the filename!')\n",
|
los_angeles_midi_dataset_search_and_explore.py
CHANGED
@@ -193,7 +193,7 @@ print('=' * 70)
|
|
193 |
|
194 |
"""# (PLOT TOTALS)"""
|
195 |
|
196 |
-
#@title Plot
|
197 |
|
198 |
cos_sim = pairwise.cosine_similarity(
|
199 |
totals[0][0][4]
|
@@ -273,6 +273,117 @@ plt.ylabel("Position")
|
|
273 |
plt.tight_layout()
|
274 |
plt.plot()
|
275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
"""# (LOAD SOURCE MIDI)"""
|
277 |
|
278 |
#@title Load source MIDI
|
@@ -469,6 +580,7 @@ minimum_match_ratio_to_search_for = 0 #@param {type:"slider", min:0, max:500, st
|
|
469 |
stop_search_on_exact_match = True #@param {type:"boolean"}
|
470 |
skip_exact_matches = False #@param {type:"boolean"}
|
471 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
|
|
472 |
|
473 |
#=================================================================================
|
474 |
|
@@ -710,7 +822,14 @@ try:
|
|
710 |
|
711 |
except:
|
712 |
pass
|
|
|
713 |
|
|
|
|
|
|
|
|
|
|
|
|
|
714 |
#============================================
|
715 |
|
716 |
print('Top 100 matches')
|
@@ -733,10 +852,11 @@ print('=' * 70)
|
|
733 |
#@markdown NOTE: You can stop the search at any time to render partial results
|
734 |
|
735 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.01}
|
736 |
-
pitches_counts_cutoff_threshold_ratio = 0
|
737 |
search_transposed_pitches = False #@param {type:"boolean"}
|
738 |
skip_exact_matches = False #@param {type:"boolean"}
|
739 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
|
|
740 |
|
741 |
print('=' * 70)
|
742 |
print('MIDI Pitches Search')
|
@@ -847,6 +967,14 @@ plt.xlabel("Time")
|
|
847 |
plt.ylabel("Pitch")
|
848 |
plt.show()
|
849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
850 |
#@title MIDI Patches Search (Fast)
|
851 |
|
852 |
#@markdown NOTE: You can stop the search at any time to render partial results
|
@@ -854,6 +982,7 @@ plt.show()
|
|
854 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.01}
|
855 |
skip_exact_matches = False #@param {type:"boolean"}
|
856 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
|
|
857 |
|
858 |
print('=' * 70)
|
859 |
print('MIDI Patches Search')
|
@@ -951,6 +1080,14 @@ plt.xlabel("Time")
|
|
951 |
plt.ylabel("Pitch")
|
952 |
plt.show()
|
953 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
954 |
#@title Metadata Search
|
955 |
|
956 |
#@markdown You can search the metadata by search query or by MIDI md5 hash file name
|
@@ -1054,6 +1191,7 @@ else:
|
|
1054 |
md5_hash_MIDI_file_name = "d9a7e1c6a375b8e560155a5977fc10f8" #@param {type:"string"}
|
1055 |
full_path_to_MIDI = "/content/Los-Angeles-MIDI-Dataset/Come-To-My-Window-Modified-Sample-MIDI.mid" #@param {type:"string"}
|
1056 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
|
|
1057 |
|
1058 |
#============================================
|
1059 |
# MIDI rendering code
|
@@ -1119,6 +1257,14 @@ try:
|
|
1119 |
plt.ylabel("Pitch")
|
1120 |
plt.show()
|
1121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1122 |
except:
|
1123 |
print('File not found!!!')
|
1124 |
print('Check the filename!')
|
|
|
193 |
|
194 |
"""# (PLOT TOTALS)"""
|
195 |
|
196 |
+
#@title Plot totals from MIDI matrixes (legacy)
|
197 |
|
198 |
cos_sim = pairwise.cosine_similarity(
|
199 |
totals[0][0][4]
|
|
|
273 |
plt.tight_layout()
|
274 |
plt.plot()
|
275 |
|
276 |
+
#@title Plot totals from MIDI metadata
|
277 |
+
|
278 |
+
#===============================================================================
|
279 |
+
|
280 |
+
pitches_counts_totals = [0] * 128
|
281 |
+
|
282 |
+
for m in tqdm(meta_data):
|
283 |
+
for mm in m[1][10][1]:
|
284 |
+
if mm[0] < 128:
|
285 |
+
pitches_counts_totals[mm[0]] += mm[1]
|
286 |
+
|
287 |
+
y = range(128)
|
288 |
+
plt.figure(figsize=(8, 8))
|
289 |
+
plt.plot(y, pitches_counts_totals)
|
290 |
+
|
291 |
+
plt.title('MIDI Instruments Pitches')
|
292 |
+
plt.xlabel("Ratio")
|
293 |
+
plt.ylabel("Pitch")
|
294 |
+
plt.tight_layout()
|
295 |
+
plt.plot()
|
296 |
+
|
297 |
+
sim_mat = [ [0]*128 for i in range(128)]
|
298 |
+
x = 0
|
299 |
+
|
300 |
+
for p in pitches_counts_totals:
|
301 |
+
y = 0
|
302 |
+
for pp in pitches_counts_totals:
|
303 |
+
|
304 |
+
sim_mat[x][y] = min(10, (p / pp))
|
305 |
+
y += 1
|
306 |
+
|
307 |
+
x += 1
|
308 |
+
|
309 |
+
cos_sim = pairwise.cosine_similarity(
|
310 |
+
sim_mat
|
311 |
+
)
|
312 |
+
plt.figure(figsize=(8, 8))
|
313 |
+
plt.imshow(sim_mat, cmap="inferno", interpolation="none")
|
314 |
+
im_ratio = 1
|
315 |
+
plt.colorbar(fraction=0.046 * im_ratio, pad=0.04)
|
316 |
+
plt.title('MIDI Instruments Pitches')
|
317 |
+
plt.xlabel("Ratio")
|
318 |
+
plt.ylabel("Pitch")
|
319 |
+
plt.tight_layout()
|
320 |
+
plt.plot()
|
321 |
+
|
322 |
+
#===============================================================================
|
323 |
+
|
324 |
+
pitches_counts_totals = [1] * 128
|
325 |
+
|
326 |
+
|
327 |
+
for m in tqdm(meta_data):
|
328 |
+
for mm in m[1][10][1]:
|
329 |
+
if mm[0] > 128:
|
330 |
+
pitches_counts_totals[mm[0] % 128] += mm[1]
|
331 |
+
|
332 |
+
y = range(128)
|
333 |
+
plt.figure(figsize=(8, 8))
|
334 |
+
plt.plot(y, pitches_counts_totals)
|
335 |
+
|
336 |
+
plt.title('MIDI Drums Pitches')
|
337 |
+
plt.xlabel("Ratio")
|
338 |
+
plt.ylabel("Pitch")
|
339 |
+
plt.tight_layout()
|
340 |
+
plt.plot()
|
341 |
+
|
342 |
+
sim_mat = [ [0]*128 for i in range(128)]
|
343 |
+
x = 0
|
344 |
+
|
345 |
+
for p in pitches_counts_totals:
|
346 |
+
y = 0
|
347 |
+
for pp in pitches_counts_totals:
|
348 |
+
|
349 |
+
sim_mat[x][y] = min(10, (p / pp))
|
350 |
+
y += 1
|
351 |
+
|
352 |
+
x += 1
|
353 |
+
|
354 |
+
cos_sim = pairwise.cosine_similarity(
|
355 |
+
sim_mat
|
356 |
+
)
|
357 |
+
plt.figure(figsize=(8, 8))
|
358 |
+
plt.imshow(sim_mat, cmap="inferno", interpolation="none")
|
359 |
+
im_ratio = 1
|
360 |
+
plt.colorbar(fraction=0.046 * im_ratio, pad=0.04)
|
361 |
+
plt.title('MIDI Drums Pitches')
|
362 |
+
plt.xlabel("Ratio")
|
363 |
+
plt.ylabel("Pitch")
|
364 |
+
plt.tight_layout()
|
365 |
+
plt.plot()
|
366 |
+
|
367 |
+
#===============================================================================
|
368 |
+
|
369 |
+
patches_counts_totals = [0] * 256
|
370 |
+
|
371 |
+
|
372 |
+
for m in tqdm(meta_data):
|
373 |
+
for mm in m[1][11][1]:
|
374 |
+
patches_counts_totals[mm[0]] += mm[1]
|
375 |
+
|
376 |
+
|
377 |
+
y = range(128)
|
378 |
+
plt.figure(figsize=(8, 8))
|
379 |
+
plt.plot(y, patches_counts_totals[:128])
|
380 |
+
|
381 |
+
plt.title('MIDI Patches')
|
382 |
+
plt.xlabel("Ratio")
|
383 |
+
plt.ylabel('Patch')
|
384 |
+
plt.tight_layout()
|
385 |
+
plt.plot()
|
386 |
+
|
387 |
"""# (LOAD SOURCE MIDI)"""
|
388 |
|
389 |
#@title Load source MIDI
|
|
|
580 |
stop_search_on_exact_match = True #@param {type:"boolean"}
|
581 |
skip_exact_matches = False #@param {type:"boolean"}
|
582 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
583 |
+
download_MIDI = False #@param {type:"boolean"}
|
584 |
|
585 |
#=================================================================================
|
586 |
|
|
|
822 |
|
823 |
except:
|
824 |
pass
|
825 |
+
#==============================================
|
826 |
|
827 |
+
if download_MIDI:
|
828 |
+
print('=' * 70)
|
829 |
+
print('Downloading MIDI file', str(fn) + '.mid')
|
830 |
+
files.download(f)
|
831 |
+
print('=' * 70)
|
832 |
+
|
833 |
#============================================
|
834 |
|
835 |
print('Top 100 matches')
|
|
|
852 |
#@markdown NOTE: You can stop the search at any time to render partial results
|
853 |
|
854 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.01}
|
855 |
+
pitches_counts_cutoff_threshold_ratio = 0 #@param {type:"slider", min:0, max:1, step:0.05}
|
856 |
search_transposed_pitches = False #@param {type:"boolean"}
|
857 |
skip_exact_matches = False #@param {type:"boolean"}
|
858 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
859 |
+
download_MIDI = False #@param {type:"boolean"}
|
860 |
|
861 |
print('=' * 70)
|
862 |
print('MIDI Pitches Search')
|
|
|
967 |
plt.ylabel("Pitch")
|
968 |
plt.show()
|
969 |
|
970 |
+
#==============================================
|
971 |
+
|
972 |
+
if download_MIDI:
|
973 |
+
print('=' * 70)
|
974 |
+
print('Downloading MIDI file', str(fn) + '.mid')
|
975 |
+
files.download(f)
|
976 |
+
print('=' * 70)
|
977 |
+
|
978 |
#@title MIDI Patches Search (Fast)
|
979 |
|
980 |
#@markdown NOTE: You can stop the search at any time to render partial results
|
|
|
982 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.01}
|
983 |
skip_exact_matches = False #@param {type:"boolean"}
|
984 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
985 |
+
download_MIDI = False #@param {type:"boolean"}
|
986 |
|
987 |
print('=' * 70)
|
988 |
print('MIDI Patches Search')
|
|
|
1080 |
plt.ylabel("Pitch")
|
1081 |
plt.show()
|
1082 |
|
1083 |
+
#==============================================
|
1084 |
+
|
1085 |
+
if download_MIDI:
|
1086 |
+
print('=' * 70)
|
1087 |
+
print('Downloading MIDI file', str(fn) + '.mid')
|
1088 |
+
files.download(f)
|
1089 |
+
print('=' * 70)
|
1090 |
+
|
1091 |
#@title Metadata Search
|
1092 |
|
1093 |
#@markdown You can search the metadata by search query or by MIDI md5 hash file name
|
|
|
1191 |
md5_hash_MIDI_file_name = "d9a7e1c6a375b8e560155a5977fc10f8" #@param {type:"string"}
|
1192 |
full_path_to_MIDI = "/content/Los-Angeles-MIDI-Dataset/Come-To-My-Window-Modified-Sample-MIDI.mid" #@param {type:"string"}
|
1193 |
render_MIDI_to_audio = False #@param {type:"boolean"}
|
1194 |
+
download_MIDI = False #@param {type:"boolean"}
|
1195 |
|
1196 |
#============================================
|
1197 |
# MIDI rendering code
|
|
|
1257 |
plt.ylabel("Pitch")
|
1258 |
plt.show()
|
1259 |
|
1260 |
+
#==============================================
|
1261 |
+
|
1262 |
+
if download_MIDI:
|
1263 |
+
print('=' * 70)
|
1264 |
+
print('Downloading MIDI file', str(fn) + '.mid')
|
1265 |
+
files.download(f)
|
1266 |
+
print('=' * 70)
|
1267 |
+
|
1268 |
except:
|
1269 |
print('File not found!!!')
|
1270 |
print('Check the filename!')
|