projectlosangeles commited on
Commit
ac1bc9c
1 Parent(s): 968d976

Upload 2 files

Browse files
Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb CHANGED
@@ -11,7 +11,7 @@
11
  "id": "SiTIpPjArIyr"
12
  },
13
  "source": [
14
- "# Los Angeles MIDI Dataset: Search and Explore (ver. 2.1)\n",
15
  "\n",
16
  "***\n",
17
  "\n",
@@ -87,6 +87,7 @@
87
  "import random\n",
88
  "import pickle\n",
89
  "from tqdm import tqdm\n",
 
90
  "\n",
91
  "from joblib import Parallel, delayed\n",
92
  "import multiprocessing\n",
@@ -523,14 +524,21 @@
523
  "\n",
524
  "for i in range(-6, 6):\n",
525
  "\n",
 
 
526
  " for e in events_matrix:\n",
527
- " if e[0] == 'note':\n",
528
- " if e[3] == 9:\n",
529
- " e[4] = ((e[4] % 128) + 128)\n",
530
- " else:\n",
531
- " e[4] = ((e[4] % 128) + i)\n",
532
  "\n",
533
- " pitches_counts = [[y[0],y[1]] for y in Counter([y[4] for y in events_matrix if y[0] == 'note']).most_common()]\n",
 
 
 
 
 
 
 
 
 
 
534
  " pitches_counts.sort(key=lambda x: x[0], reverse=True)\n",
535
  " \n",
536
  " mult_pitches_counts.append(pitches_counts)\n",
@@ -588,8 +596,8 @@
588
  "plt.show()"
589
  ],
590
  "metadata": {
591
- "cellView": "form",
592
- "id": "z7mm6WsDmuRi"
593
  },
594
  "execution_count": null,
595
  "outputs": []
@@ -902,7 +910,7 @@
902
  "for d in tqdm(meta_data):\n",
903
  "\n",
904
  " try:\n",
905
- " p_counts = d[1][3][1]\n",
906
  " p_counts.sort(reverse = True, key = lambda x: x[1])\n",
907
  " max_p_count = p_counts[1][0]\n",
908
  " trimmed_p_counts = [y for y in p_counts if y[1] >= (max_p_count * pitches_counts_cutoff_threshold_ratio)] \n",
@@ -948,7 +956,7 @@
948
  "print('Match ratio', max_ratio)\n",
949
  "print('MIDI file name', meta_data[max_ratio_index][0])\n",
950
  "print('=' * 70)\n",
951
- "print('First metadata MIDI event', meta_data[max_ratio_index][1][0])\n",
952
  "print('=' * 70)\n",
953
  "\n",
954
  "#============================================\n",
@@ -1030,7 +1038,7 @@
1030
  "\n",
1031
  " try:\n",
1032
  "\n",
1033
- " p_list= d[1][4][1]\n",
1034
  "\n",
1035
  " num_same_patches = len(set(p_list) & set(patches_list))\n",
1036
  " \n",
@@ -1062,7 +1070,7 @@
1062
  "print('Match ratio', max_ratio)\n",
1063
  "print('MIDI file name', meta_data[max_ratio_index][0])\n",
1064
  "print('=' * 70)\n",
1065
- "print('Found MIDI patches list', meta_data[max_ratio_index][1][4][1])\n",
1066
  "print('=' * 70)\n",
1067
  "\n",
1068
  "#============================================\n",
@@ -1163,7 +1171,8 @@
1163
  " print('=' * 70)\n",
1164
  " print('Metadata index:', meta_data.index(d))\n",
1165
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1166
- " print('Result:', d[1])\n",
 
1167
  " print('=' * 70)\n",
1168
  " break\n",
1169
  " \n",
@@ -1195,7 +1204,8 @@
1195
  " print('=' * 70)\n",
1196
  " print('Metadata index:', meta_data.index(d))\n",
1197
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1198
- " print('Result:', dd[2])\n",
 
1199
  " print('=' * 70)\n",
1200
  " \n",
1201
  " else:\n",
@@ -1204,7 +1214,8 @@
1204
  " print('=' * 70)\n",
1205
  " print('Metadata index:', meta_data.index(d))\n",
1206
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1207
- " print('Result:', dd[2])\n",
 
1208
  " print('=' * 70)\n",
1209
  " \n",
1210
  " except KeyboardInterrupt:\n",
 
11
  "id": "SiTIpPjArIyr"
12
  },
13
  "source": [
14
+ "# Los Angeles MIDI Dataset: Search and Explore (ver. 2.2)\n",
15
  "\n",
16
  "***\n",
17
  "\n",
 
87
  "import random\n",
88
  "import pickle\n",
89
  "from tqdm import tqdm\n",
90
+ "import pprint\n",
91
  "\n",
92
  "from joblib import Parallel, delayed\n",
93
  "import multiprocessing\n",
 
524
  "\n",
525
  "for i in range(-6, 6):\n",
526
  "\n",
527
+ " events_matrix1 = []\n",
528
+ "\n",
529
  " for e in events_matrix:\n",
 
 
 
 
 
530
  "\n",
531
+ " ev = copy.deepcopy(e)\n",
532
+ "\n",
533
+ " if e[0] == 'note':\n",
534
+ " if e[3] == 9:\n",
535
+ " ev[4] = ((e[4] % 128) + 128)\n",
536
+ " else:\n",
537
+ " ev[4] = ((e[4] % 128) + i)\n",
538
+ "\n",
539
+ " events_matrix1.append(ev)\n",
540
+ "\n",
541
+ " pitches_counts = [[y[0],y[1]] for y in Counter([y[4] for y in events_matrix1 if y[0] == 'note']).most_common()]\n",
542
  " pitches_counts.sort(key=lambda x: x[0], reverse=True)\n",
543
  " \n",
544
  " mult_pitches_counts.append(pitches_counts)\n",
 
596
  "plt.show()"
597
  ],
598
  "metadata": {
599
+ "id": "z7mm6WsDmuRi",
600
+ "cellView": "form"
601
  },
602
  "execution_count": null,
603
  "outputs": []
 
910
  "for d in tqdm(meta_data):\n",
911
  "\n",
912
  " try:\n",
913
+ " p_counts = d[1][10][1]\n",
914
  " p_counts.sort(reverse = True, key = lambda x: x[1])\n",
915
  " max_p_count = p_counts[1][0]\n",
916
  " trimmed_p_counts = [y for y in p_counts if y[1] >= (max_p_count * pitches_counts_cutoff_threshold_ratio)] \n",
 
956
  "print('Match ratio', max_ratio)\n",
957
  "print('MIDI file name', meta_data[max_ratio_index][0])\n",
958
  "print('=' * 70)\n",
959
+ "pprint.pprint(['Sample metadata entries', meta_data[max_ratio_index][1][:8]], compact = True)\n",
960
  "print('=' * 70)\n",
961
  "\n",
962
  "#============================================\n",
 
1038
  "\n",
1039
  " try:\n",
1040
  "\n",
1041
+ " p_list= d[1][12][1]\n",
1042
  "\n",
1043
  " num_same_patches = len(set(p_list) & set(patches_list))\n",
1044
  " \n",
 
1070
  "print('Match ratio', max_ratio)\n",
1071
  "print('MIDI file name', meta_data[max_ratio_index][0])\n",
1072
  "print('=' * 70)\n",
1073
+ "print('Found MIDI patches list', meta_data[max_ratio_index][1][12][1])\n",
1074
  "print('=' * 70)\n",
1075
  "\n",
1076
  "#============================================\n",
 
1171
  " print('=' * 70)\n",
1172
  " print('Metadata index:', meta_data.index(d))\n",
1173
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1174
+ " print('-' * 70)\n",
1175
+ " pprint.pprint(['Result:', d[1][:16]], compact = True)\n",
1176
  " print('=' * 70)\n",
1177
  " break\n",
1178
  " \n",
 
1204
  " print('=' * 70)\n",
1205
  " print('Metadata index:', meta_data.index(d))\n",
1206
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1207
+ " print('-' * 70)\n",
1208
+ " pprint.pprint(['Result:', dd[2][:16]], compact = True)\n",
1209
  " print('=' * 70)\n",
1210
  " \n",
1211
  " else:\n",
 
1214
  " print('=' * 70)\n",
1215
  " print('Metadata index:', meta_data.index(d))\n",
1216
  " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1217
+ " print('-' * 70)\n",
1218
+ " pprint.pprint(['Result:', dd[2][:16]], compact = True)\n",
1219
  " print('=' * 70)\n",
1220
  " \n",
1221
  " except KeyboardInterrupt:\n",
los_angeles_midi_dataset_search_and_explore.py CHANGED
@@ -6,7 +6,7 @@ Automatically generated by Colaboratory.
6
  Original file is located at
7
  https://colab.research.google.com/github/asigalov61/Los-Angeles-MIDI-Dataset/blob/main/Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb
8
 
9
- # Los Angeles MIDI Dataset: Search and Explore (ver. 2.1)
10
 
11
  ***
12
 
@@ -41,6 +41,7 @@ from collections import Counter
41
  import random
42
  import pickle
43
  from tqdm import tqdm
 
44
 
45
  from joblib import Parallel, delayed
46
  import multiprocessing
@@ -387,14 +388,21 @@ mult_pitches_counts = []
387
 
388
  for i in range(-6, 6):
389
 
 
 
390
  for e in events_matrix:
391
- if e[0] == 'note':
392
- if e[3] == 9:
393
- e[4] = ((e[4] % 128) + 128)
394
- else:
395
- e[4] = ((e[4] % 128) + i)
396
 
397
- pitches_counts = [[y[0],y[1]] for y in Counter([y[4] for y in events_matrix if y[0] == 'note']).most_common()]
 
 
 
 
 
 
 
 
 
 
398
  pitches_counts.sort(key=lambda x: x[0], reverse=True)
399
 
400
  mult_pitches_counts.append(pitches_counts)
@@ -739,7 +747,7 @@ ratios = []
739
  for d in tqdm(meta_data):
740
 
741
  try:
742
- p_counts = d[1][3][1]
743
  p_counts.sort(reverse = True, key = lambda x: x[1])
744
  max_p_count = p_counts[1][0]
745
  trimmed_p_counts = [y for y in p_counts if y[1] >= (max_p_count * pitches_counts_cutoff_threshold_ratio)]
@@ -785,7 +793,7 @@ print('=' * 70)
785
  print('Match ratio', max_ratio)
786
  print('MIDI file name', meta_data[max_ratio_index][0])
787
  print('=' * 70)
788
- print('First metadata MIDI event', meta_data[max_ratio_index][1][0])
789
  print('=' * 70)
790
 
791
  #============================================
@@ -857,7 +865,7 @@ for d in tqdm(meta_data):
857
 
858
  try:
859
 
860
- p_list= d[1][4][1]
861
 
862
  num_same_patches = len(set(p_list) & set(patches_list))
863
 
@@ -889,7 +897,7 @@ print('=' * 70)
889
  print('Match ratio', max_ratio)
890
  print('MIDI file name', meta_data[max_ratio_index][0])
891
  print('=' * 70)
892
- print('Found MIDI patches list', meta_data[max_ratio_index][1][4][1])
893
  print('=' * 70)
894
 
895
  #============================================
@@ -980,7 +988,8 @@ if md5_hash_MIDI_file_name != '':
980
  print('=' * 70)
981
  print('Metadata index:', meta_data.index(d))
982
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
983
- print('Result:', d[1])
 
984
  print('=' * 70)
985
  break
986
 
@@ -1012,7 +1021,8 @@ else:
1012
  print('=' * 70)
1013
  print('Metadata index:', meta_data.index(d))
1014
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
1015
- print('Result:', dd[2])
 
1016
  print('=' * 70)
1017
 
1018
  else:
@@ -1021,7 +1031,8 @@ else:
1021
  print('=' * 70)
1022
  print('Metadata index:', meta_data.index(d))
1023
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
1024
- print('Result:', dd[2])
 
1025
  print('=' * 70)
1026
 
1027
  except KeyboardInterrupt:
 
6
  Original file is located at
7
  https://colab.research.google.com/github/asigalov61/Los-Angeles-MIDI-Dataset/blob/main/Los_Angeles_MIDI_Dataset_Search_and_Explore.ipynb
8
 
9
+ # Los Angeles MIDI Dataset: Search and Explore (ver. 2.2)
10
 
11
  ***
12
 
 
41
  import random
42
  import pickle
43
  from tqdm import tqdm
44
+ import pprint
45
 
46
  from joblib import Parallel, delayed
47
  import multiprocessing
 
388
 
389
  for i in range(-6, 6):
390
 
391
+ events_matrix1 = []
392
+
393
  for e in events_matrix:
 
 
 
 
 
394
 
395
+ ev = copy.deepcopy(e)
396
+
397
+ if e[0] == 'note':
398
+ if e[3] == 9:
399
+ ev[4] = ((e[4] % 128) + 128)
400
+ else:
401
+ ev[4] = ((e[4] % 128) + i)
402
+
403
+ events_matrix1.append(ev)
404
+
405
+ pitches_counts = [[y[0],y[1]] for y in Counter([y[4] for y in events_matrix1 if y[0] == 'note']).most_common()]
406
  pitches_counts.sort(key=lambda x: x[0], reverse=True)
407
 
408
  mult_pitches_counts.append(pitches_counts)
 
747
  for d in tqdm(meta_data):
748
 
749
  try:
750
+ p_counts = d[1][10][1]
751
  p_counts.sort(reverse = True, key = lambda x: x[1])
752
  max_p_count = p_counts[1][0]
753
  trimmed_p_counts = [y for y in p_counts if y[1] >= (max_p_count * pitches_counts_cutoff_threshold_ratio)]
 
793
  print('Match ratio', max_ratio)
794
  print('MIDI file name', meta_data[max_ratio_index][0])
795
  print('=' * 70)
796
+ pprint.pprint(['Sample metadata entries', meta_data[max_ratio_index][1][:8]], compact = True)
797
  print('=' * 70)
798
 
799
  #============================================
 
865
 
866
  try:
867
 
868
+ p_list= d[1][12][1]
869
 
870
  num_same_patches = len(set(p_list) & set(patches_list))
871
 
 
897
  print('Match ratio', max_ratio)
898
  print('MIDI file name', meta_data[max_ratio_index][0])
899
  print('=' * 70)
900
+ print('Found MIDI patches list', meta_data[max_ratio_index][1][12][1])
901
  print('=' * 70)
902
 
903
  #============================================
 
988
  print('=' * 70)
989
  print('Metadata index:', meta_data.index(d))
990
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
991
+ print('-' * 70)
992
+ pprint.pprint(['Result:', d[1][:16]], compact = True)
993
  print('=' * 70)
994
  break
995
 
 
1021
  print('=' * 70)
1022
  print('Metadata index:', meta_data.index(d))
1023
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
1024
+ print('-' * 70)
1025
+ pprint.pprint(['Result:', dd[2][:16]], compact = True)
1026
  print('=' * 70)
1027
 
1028
  else:
 
1031
  print('=' * 70)
1032
  print('Metadata index:', meta_data.index(d))
1033
  print('MIDI file name:', meta_data[meta_data.index(d)][0])
1034
+ print('-' * 70)
1035
+ pprint.pprint(['Result:', dd[2][:16]], compact = True)
1036
  print('=' * 70)
1037
 
1038
  except KeyboardInterrupt: