projectlosangeles commited on
Commit
a2fcb8c
1 Parent(s): a928126

Upload 5 files

Browse files
Monster_MIDI_Dataset_GPU_Search_and_Filter.ipynb CHANGED
@@ -11,7 +11,7 @@
11
  "id": "SiTIpPjArIyr"
12
  },
13
  "source": [
14
- "# Monster MIDI Dataset GPU Search and Filter (ver. 2.0)\n",
15
  "\n",
16
  "***\n",
17
  "\n",
@@ -387,7 +387,7 @@
387
  " e[1] = int(e[1] / 16)\n",
388
  " e[2] = int(e[2] / 16)\n",
389
  "\n",
390
- " drums_offset = len(TMIDIX.ALL_CHORDS) + 128\n",
391
  "\n",
392
  " src_sigs = []\n",
393
  "\n",
@@ -411,12 +411,15 @@
411
  " if pitches:\n",
412
  " if len(pitches) > 1:\n",
413
  " tones_chord = sorted(set([p % 12 for p in pitches]))\n",
414
- " checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)\n",
415
  "\n",
416
- " sig_token = TMIDIX.ALL_CHORDS.index(checked_tones_chord) + 128\n",
 
 
 
 
417
  "\n",
418
- " elif len(pitches) == 1:\n",
419
- " sig_token = pitches[0]\n",
420
  "\n",
421
  " sig.append(sig_token)\n",
422
  "\n",
@@ -791,9 +794,12 @@
791
  " if pitches:\n",
792
  " if len(pitches) > 1:\n",
793
  " tones_chord = sorted(set([p % 12 for p in pitches]))\n",
794
- " checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)\n",
795
  "\n",
796
- " chord_token = TMIDIX.ALL_CHORDS.index(checked_tones_chord) + 128\n",
 
 
 
 
797
  "\n",
798
  " elif len(pitches) == 1:\n",
799
  " chord_token = pitches[0]\n",
@@ -956,7 +962,7 @@
956
  {
957
  "cell_type": "markdown",
958
  "source": [
959
- "# (DOWNLOAD RESULTS)"
960
  ],
961
  "metadata": {
962
  "id": "7Lyy0vjV0dlI"
@@ -1022,6 +1028,140 @@
1022
  "execution_count": null,
1023
  "outputs": []
1024
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
  {
1026
  "cell_type": "markdown",
1027
  "metadata": {
 
11
  "id": "SiTIpPjArIyr"
12
  },
13
  "source": [
14
+ "# Monster MIDI Dataset GPU Search and Filter (ver. 3.0)\n",
15
  "\n",
16
  "***\n",
17
  "\n",
 
387
  " e[1] = int(e[1] / 16)\n",
388
  " e[2] = int(e[2] / 16)\n",
389
  "\n",
390
+ " drums_offset = len(TMIDIX.ALL_CHORDS_SORTED) + 128\n",
391
  "\n",
392
  " src_sigs = []\n",
393
  "\n",
 
411
  " if pitches:\n",
412
  " if len(pitches) > 1:\n",
413
  " tones_chord = sorted(set([p % 12 for p in pitches]))\n",
 
414
  "\n",
415
+ " try:\n",
416
+ " sig_token = TMIDIX.ALL_CHORDS_SORTED.index(tones_chord) + 128\n",
417
+ " except:\n",
418
+ " checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)\n",
419
+ " sig_token = TMIDIX.ALL_CHORDS_SORTED.index(checked_tones_chord) + 128\n",
420
  "\n",
421
+ " elif len(pitches) == 1:\n",
422
+ " sig_token = pitches[0]\n",
423
  "\n",
424
  " sig.append(sig_token)\n",
425
  "\n",
 
794
  " if pitches:\n",
795
  " if len(pitches) > 1:\n",
796
  " tones_chord = sorted(set([p % 12 for p in pitches]))\n",
 
797
  "\n",
798
+ " try:\n",
799
+ " chord_token = TMIDIX.ALL_CHORDS_SORTED.index(tones_chord) + 128\n",
800
+ " except:\n",
801
+ " checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)\n",
802
+ " chord_token = TMIDIX.ALL_CHORDS_SORTED.index(checked_tones_chord) + 128\n",
803
  "\n",
804
  " elif len(pitches) == 1:\n",
805
  " chord_token = pitches[0]\n",
 
962
  {
963
  "cell_type": "markdown",
964
  "source": [
965
+ "# (DOWNLOAD SEARCH RESULTS)"
966
  ],
967
  "metadata": {
968
  "id": "7Lyy0vjV0dlI"
 
1028
  "execution_count": null,
1029
  "outputs": []
1030
  },
1031
+ {
1032
+ "cell_type": "markdown",
1033
+ "source": [
1034
+ "# (META DATA SEARCH)"
1035
+ ],
1036
+ "metadata": {
1037
+ "id": "kawXUInwyh2X"
1038
+ }
1039
+ },
1040
+ {
1041
+ "cell_type": "code",
1042
+ "source": [
1043
+ "#@title Load Monster MIDI Dataset Metadata\n",
1044
+ "print('=' * 70)\n",
1045
+ "print('Loading Monster MIDI Dataset Metadata...')\n",
1046
+ "meta_data = pickle.load(open('/content/Main-MIDI-Dataset/META_DATA/MONSTER_META_DATA.pickle', 'rb'))\n",
1047
+ "print('Done!')\n",
1048
+ "print('=' * 70)\n",
1049
+ "print('Enjoy!')\n",
1050
+ "print('=' * 70)"
1051
+ ],
1052
+ "metadata": {
1053
+ "cellView": "form",
1054
+ "id": "l72wnOFAy9Ly"
1055
+ },
1056
+ "execution_count": null,
1057
+ "outputs": []
1058
+ },
1059
+ {
1060
+ "cell_type": "code",
1061
+ "source": [
1062
+ "#@title Monster MIDI Dataset Metadata Search\n",
1063
+ "\n",
1064
+ "#@markdown You can search the metadata by search query or by MIDI md5 hash file name\n",
1065
+ "\n",
1066
+ "search_query = \"Come To My Window\" #@param {type:\"string\"}\n",
1067
+ "md5_hash_MIDI_file_name = \"68dfb00f24f5ebd9bb52823fa9a04c3e\" #@param {type:\"string\"}\n",
1068
+ "case_sensitive_search = False #@param {type:\"boolean\"}\n",
1069
+ "\n",
1070
+ "fields_to_search = ['track_name',\n",
1071
+ " 'text_event',\n",
1072
+ " 'lyric',\n",
1073
+ " 'copyright_text_event',\n",
1074
+ " 'marker',\n",
1075
+ " 'text_event_08',\n",
1076
+ " 'text_event_09',\n",
1077
+ " 'text_event_0a',\n",
1078
+ " 'text_event_0b',\n",
1079
+ " 'text_event_0c',\n",
1080
+ " 'text_event_0d',\n",
1081
+ " 'text_event_0e',\n",
1082
+ " 'text_event_0f',\n",
1083
+ " ]\n",
1084
+ "\n",
1085
+ "print('=' * 70)\n",
1086
+ "print('Los Angeles MIDI Dataset Metadata Search')\n",
1087
+ "print('=' * 70)\n",
1088
+ "print('Searching...')\n",
1089
+ "print('=' * 70)\n",
1090
+ "\n",
1091
+ "if md5_hash_MIDI_file_name != '':\n",
1092
+ " for d in tqdm(meta_data):\n",
1093
+ " try:\n",
1094
+ " if d[0] == md5_hash_MIDI_file_name:\n",
1095
+ " print('Found!')\n",
1096
+ " print('=' * 70)\n",
1097
+ " print('Metadata index:', meta_data.index(d))\n",
1098
+ " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1099
+ " print('-' * 70)\n",
1100
+ " pprint.pprint(['Result:', d[1][:16]], compact = True)\n",
1101
+ " print('=' * 70)\n",
1102
+ " break\n",
1103
+ "\n",
1104
+ " except KeyboardInterrupt:\n",
1105
+ " print('Ending search...')\n",
1106
+ " print('=' * 70)\n",
1107
+ " break\n",
1108
+ "\n",
1109
+ " except Exception as e:\n",
1110
+ " print('WARNING !!!')\n",
1111
+ " print('=' * 70)\n",
1112
+ " print('Error detected:', e)\n",
1113
+ " print('=' * 70)\n",
1114
+ " continue\n",
1115
+ "\n",
1116
+ " if d[0] != md5_hash_MIDI_file_name:\n",
1117
+ " print('Not found!')\n",
1118
+ " print('=' * 70)\n",
1119
+ " print('md5 hash was not found!')\n",
1120
+ " print('Ending search...')\n",
1121
+ " print('=' * 70)\n",
1122
+ "\n",
1123
+ "else:\n",
1124
+ " for d in tqdm(meta_data):\n",
1125
+ " try:\n",
1126
+ " for dd in d[1]:\n",
1127
+ " if dd[0] in fields_to_search:\n",
1128
+ " if case_sensitive_search:\n",
1129
+ " if str(search_query) in str(dd[2]):\n",
1130
+ " print('Found!')\n",
1131
+ " print('=' * 70)\n",
1132
+ " print('Metadata index:', meta_data.index(d))\n",
1133
+ " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1134
+ " print('-' * 70)\n",
1135
+ " pprint.pprint(['Result:', dd[2][:16]], compact = True)\n",
1136
+ " print('=' * 70)\n",
1137
+ "\n",
1138
+ " else:\n",
1139
+ " if str(search_query).lower() in str(dd[2]).lower():\n",
1140
+ " print('Found!')\n",
1141
+ " print('=' * 70)\n",
1142
+ " print('Metadata index:', meta_data.index(d))\n",
1143
+ " print('MIDI file name:', meta_data[meta_data.index(d)][0])\n",
1144
+ " print('-' * 70)\n",
1145
+ " pprint.pprint(['Result:', dd[2][:16]], compact = True)\n",
1146
+ " print('=' * 70)\n",
1147
+ "\n",
1148
+ " except KeyboardInterrupt:\n",
1149
+ " print('Ending search...')\n",
1150
+ " print('=' * 70)\n",
1151
+ " break\n",
1152
+ "\n",
1153
+ " except:\n",
1154
+ " print('Ending search...')\n",
1155
+ " print('=' * 70)\n",
1156
+ " break"
1157
+ ],
1158
+ "metadata": {
1159
+ "cellView": "form",
1160
+ "id": "2iC3oMnZyksz"
1161
+ },
1162
+ "execution_count": null,
1163
+ "outputs": []
1164
+ },
1165
  {
1166
  "cell_type": "markdown",
1167
  "metadata": {
TMIDIX.py CHANGED
@@ -4707,23 +4707,62 @@ def augment_enhanced_score_notes(enhanced_score_notes,
4707
 
4708
  ###################################################################################
4709
 
 
 
 
 
 
 
 
 
 
 
 
 
4710
  def extract_melody(chordified_enhanced_score,
4711
- melody_range=[60, 84],
4712
  melody_channel=0,
4713
- melody_patch=0
 
 
 
4714
  ):
4715
 
4716
- melody_score = copy.deepcopy([c[0] for c in chordified_enhanced_score if c[0][3] != 9])
4717
-
4718
- for e in melody_score:
4719
- e[3] = melody_channel
4720
- e[6] = melody_patch
4721
 
4722
- if e[4] < melody_range[0]:
4723
- e[4] = (e[4] % 12) + melody_range[0]
4724
-
4725
- if e[4] >= melody_range[1]:
4726
- e[4] = (e[4] % 12) + (melody_range[1]-12)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4727
 
4728
  return fix_monophonic_score_durations(melody_score)
4729
 
@@ -4960,6 +4999,57 @@ def patch_enhanced_score_notes(enhanced_score_notes,
4960
 
4961
  ###################################################################################
4962
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4963
  # This is the end of the TMIDI X Python module
4964
 
4965
  ###################################################################################
 
4707
 
4708
  ###################################################################################
4709
 
4710
+ def stack_list(lst, base=12):
4711
+ return sum(j * base**i for i, j in enumerate(lst[::-1]))
4712
+
4713
+ def destack_list(num, base=12):
4714
+ lst = []
4715
+ while num:
4716
+ lst.append(num % base)
4717
+ num //= base
4718
+ return lst[::-1]
4719
+
4720
+ ###################################################################################
4721
+
4722
  def extract_melody(chordified_enhanced_score,
4723
+ melody_range=[48, 84],
4724
  melody_channel=0,
4725
+ melody_patch=0,
4726
+ melody_velocity=0,
4727
+ stacked_melody=False,
4728
+ stacked_melody_base_pitch=60
4729
  ):
4730
 
4731
+ if stacked_melody:
 
 
 
 
4732
 
4733
+
4734
+ all_pitches_chords = []
4735
+ for e in chordified_enhanced_score:
4736
+ all_pitches_chords.append(sorted(set([p[4] for p in e]), reverse=True))
4737
+
4738
+ melody_score = []
4739
+ for i, chord in enumerate(chordified_enhanced_score):
4740
+
4741
+ if melody_velocity > 0:
4742
+ vel = melody_velocity
4743
+ else:
4744
+ vel = chord[0][5]
4745
+
4746
+ melody_score.append(['note', chord[0][1], chord[0][2], melody_channel, stacked_melody_base_pitch+(stack_list([p % 12 for p in all_pitches_chords[i]]) % 12), vel, melody_patch])
4747
+
4748
+ else:
4749
+
4750
+ melody_score = copy.deepcopy([c[0] for c in chordified_enhanced_score if c[0][3] != 9])
4751
+
4752
+ for e in melody_score:
4753
+
4754
+ e[3] = melody_channel
4755
+
4756
+ if melody_velocity > 0:
4757
+ e[5] = melody_velocity
4758
+
4759
+ e[6] = melody_patch
4760
+
4761
+ if e[4] < melody_range[0]:
4762
+ e[4] = (e[4] % 12) + melody_range[0]
4763
+
4764
+ if e[4] >= melody_range[1]:
4765
+ e[4] = (e[4] % 12) + (melody_range[1]-12)
4766
 
4767
  return fix_monophonic_score_durations(melody_score)
4768
 
 
4999
 
5000
  ###################################################################################
5001
 
5002
+ def create_enhanced_monophonic_melody(monophonic_melody):
5003
+
5004
+ enhanced_monophonic_melody = []
5005
+
5006
+ for i, note in enumerate(monophonic_melody[:-1]):
5007
+
5008
+ enhanced_monophonic_melody.append(note)
5009
+
5010
+ if note[1]+note[2] < monophonic_melody[i+1][1]:
5011
+
5012
+ delta_time = monophonic_melody[i+1][1] - (note[1]+note[2])
5013
+ enhanced_monophonic_melody.append(['silence', note[1]+note[2], delta_time, note[3], 0, 0, note[6]])
5014
+
5015
+ enhanced_monophonic_melody.append(monophonic_melody[-1])
5016
+
5017
+ return enhanced_monophonic_melody
5018
+
5019
+ ###################################################################################
5020
+
5021
+ def frame_monophonic_melody(monophonic_melody, min_frame_time_threshold=10):
5022
+
5023
+ mzip = list(zip(monophonic_melody[:-1], monophonic_melody[1:]))
5024
+
5025
+ times_counts = Counter([(b[1]-a[1]) for a, b in mzip]).most_common()
5026
+
5027
+ mc_time = next((item for item, count in times_counts if item >= min_frame_time_threshold), min_frame_time_threshold)
5028
+
5029
+ times = [(b[1]-a[1]) // mc_time for a, b in mzip] + [monophonic_melody[-1][2] // mc_time]
5030
+
5031
+ framed_melody = []
5032
+
5033
+ for i, note in enumerate(monophonic_melody):
5034
+
5035
+ stime = note[1]
5036
+ count = times[i]
5037
+
5038
+ if count != 0:
5039
+ for j in range(count):
5040
+
5041
+ new_note = copy.deepcopy(note)
5042
+ new_note[1] = stime + (j * mc_time)
5043
+ new_note[2] = mc_time
5044
+ framed_melody.append(new_note)
5045
+
5046
+ else:
5047
+ framed_melody.append(note)
5048
+
5049
+ return [framed_melody, mc_time]
5050
+
5051
+ ###################################################################################
5052
+
5053
  # This is the end of the TMIDI X Python module
5054
 
5055
  ###################################################################################
monster_midi_dataset_gpu_search_and_filter.py CHANGED
@@ -6,7 +6,7 @@ Automatically generated by Colaboratory.
6
  Original file is located at
7
  https://colab.research.google.com/github/asigalov61/Monster-MIDI-Dataset/blob/main/Monster_MIDI_Dataset_GPU_Search_and_Filter.ipynb
8
 
9
- # Monster MIDI Dataset GPU Search and Filter (ver. 2.0)
10
 
11
  ***
12
 
@@ -260,7 +260,7 @@ if filez:
260
  e[1] = int(e[1] / 16)
261
  e[2] = int(e[2] / 16)
262
 
263
- drums_offset = len(TMIDIX.ALL_CHORDS) + 128
264
 
265
  src_sigs = []
266
 
@@ -284,12 +284,15 @@ if filez:
284
  if pitches:
285
  if len(pitches) > 1:
286
  tones_chord = sorted(set([p % 12 for p in pitches]))
287
- checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)
288
 
289
- sig_token = TMIDIX.ALL_CHORDS.index(checked_tones_chord) + 128
 
 
 
 
290
 
291
- elif len(pitches) == 1:
292
- sig_token = pitches[0]
293
 
294
  sig.append(sig_token)
295
 
@@ -637,9 +640,12 @@ if filez:
637
  if pitches:
638
  if len(pitches) > 1:
639
  tones_chord = sorted(set([p % 12 for p in pitches]))
640
- checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)
641
 
642
- chord_token = TMIDIX.ALL_CHORDS.index(checked_tones_chord) + 128
 
 
 
 
643
 
644
  elif len(pitches) == 1:
645
  chord_token = pitches[0]
@@ -792,7 +798,7 @@ else:
792
  print('Could not find any MIDI files. Please check Dataset dir...')
793
  print('=' * 70)
794
 
795
- """# (DOWNLOAD RESULTS)"""
796
 
797
  # Commented out IPython magic to ensure Python compatibility.
798
  #@title Zip and download all search results
@@ -835,4 +841,111 @@ print('=' * 70)
835
  print('Done!')
836
  print('=' * 70)
837
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  """# Congrats! You did it! :)"""
 
6
  Original file is located at
7
  https://colab.research.google.com/github/asigalov61/Monster-MIDI-Dataset/blob/main/Monster_MIDI_Dataset_GPU_Search_and_Filter.ipynb
8
 
9
+ # Monster MIDI Dataset GPU Search and Filter (ver. 3.0)
10
 
11
  ***
12
 
 
260
  e[1] = int(e[1] / 16)
261
  e[2] = int(e[2] / 16)
262
 
263
+ drums_offset = len(TMIDIX.ALL_CHORDS_SORTED) + 128
264
 
265
  src_sigs = []
266
 
 
284
  if pitches:
285
  if len(pitches) > 1:
286
  tones_chord = sorted(set([p % 12 for p in pitches]))
 
287
 
288
+ try:
289
+ sig_token = TMIDIX.ALL_CHORDS_SORTED.index(tones_chord) + 128
290
+ except:
291
+ checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)
292
+ sig_token = TMIDIX.ALL_CHORDS_SORTED.index(checked_tones_chord) + 128
293
 
294
+ elif len(pitches) == 1:
295
+ sig_token = pitches[0]
296
 
297
  sig.append(sig_token)
298
 
 
640
  if pitches:
641
  if len(pitches) > 1:
642
  tones_chord = sorted(set([p % 12 for p in pitches]))
 
643
 
644
+ try:
645
+ chord_token = TMIDIX.ALL_CHORDS_SORTED.index(tones_chord) + 128
646
+ except:
647
+ checked_tones_chord = TMIDIX.check_and_fix_tones_chord(tones_chord)
648
+ chord_token = TMIDIX.ALL_CHORDS_SORTED.index(checked_tones_chord) + 128
649
 
650
  elif len(pitches) == 1:
651
  chord_token = pitches[0]
 
798
  print('Could not find any MIDI files. Please check Dataset dir...')
799
  print('=' * 70)
800
 
801
+ """# (DOWNLOAD SEARCH RESULTS)"""
802
 
803
  # Commented out IPython magic to ensure Python compatibility.
804
  #@title Zip and download all search results
 
841
  print('Done!')
842
  print('=' * 70)
843
 
844
+ """# (META DATA SEARCH)"""
845
+
846
+ #@title Load Monster MIDI Dataset Metadata
847
+ print('=' * 70)
848
+ print('Loading Monster MIDI Dataset Metadata...')
849
+ meta_data = pickle.load(open('/content/Main-MIDI-Dataset/META_DATA/MONSTER_META_DATA.pickle', 'rb'))
850
+ print('Done!')
851
+ print('=' * 70)
852
+ print('Enjoy!')
853
+ print('=' * 70)
854
+
855
+ #@title Monster MIDI Dataset Metadata Search
856
+
857
+ #@markdown You can search the metadata by search query or by MIDI md5 hash file name
858
+
859
+ search_query = "Come To My Window" #@param {type:"string"}
860
+ md5_hash_MIDI_file_name = "68dfb00f24f5ebd9bb52823fa9a04c3e" #@param {type:"string"}
861
+ case_sensitive_search = False #@param {type:"boolean"}
862
+
863
+ fields_to_search = ['track_name',
864
+ 'text_event',
865
+ 'lyric',
866
+ 'copyright_text_event',
867
+ 'marker',
868
+ 'text_event_08',
869
+ 'text_event_09',
870
+ 'text_event_0a',
871
+ 'text_event_0b',
872
+ 'text_event_0c',
873
+ 'text_event_0d',
874
+ 'text_event_0e',
875
+ 'text_event_0f',
876
+ ]
877
+
878
+ print('=' * 70)
879
+ print('Los Angeles MIDI Dataset Metadata Search')
880
+ print('=' * 70)
881
+ print('Searching...')
882
+ print('=' * 70)
883
+
884
+ if md5_hash_MIDI_file_name != '':
885
+ for d in tqdm(meta_data):
886
+ try:
887
+ if d[0] == md5_hash_MIDI_file_name:
888
+ print('Found!')
889
+ print('=' * 70)
890
+ print('Metadata index:', meta_data.index(d))
891
+ print('MIDI file name:', meta_data[meta_data.index(d)][0])
892
+ print('-' * 70)
893
+ pprint.pprint(['Result:', d[1][:16]], compact = True)
894
+ print('=' * 70)
895
+ break
896
+
897
+ except KeyboardInterrupt:
898
+ print('Ending search...')
899
+ print('=' * 70)
900
+ break
901
+
902
+ except Exception as e:
903
+ print('WARNING !!!')
904
+ print('=' * 70)
905
+ print('Error detected:', e)
906
+ print('=' * 70)
907
+ continue
908
+
909
+ if d[0] != md5_hash_MIDI_file_name:
910
+ print('Not found!')
911
+ print('=' * 70)
912
+ print('md5 hash was not found!')
913
+ print('Ending search...')
914
+ print('=' * 70)
915
+
916
+ else:
917
+ for d in tqdm(meta_data):
918
+ try:
919
+ for dd in d[1]:
920
+ if dd[0] in fields_to_search:
921
+ if case_sensitive_search:
922
+ if str(search_query) in str(dd[2]):
923
+ print('Found!')
924
+ print('=' * 70)
925
+ print('Metadata index:', meta_data.index(d))
926
+ print('MIDI file name:', meta_data[meta_data.index(d)][0])
927
+ print('-' * 70)
928
+ pprint.pprint(['Result:', dd[2][:16]], compact = True)
929
+ print('=' * 70)
930
+
931
+ else:
932
+ if str(search_query).lower() in str(dd[2]).lower():
933
+ print('Found!')
934
+ print('=' * 70)
935
+ print('Metadata index:', meta_data.index(d))
936
+ print('MIDI file name:', meta_data[meta_data.index(d)][0])
937
+ print('-' * 70)
938
+ pprint.pprint(['Result:', dd[2][:16]], compact = True)
939
+ print('=' * 70)
940
+
941
+ except KeyboardInterrupt:
942
+ print('Ending search...')
943
+ print('=' * 70)
944
+ break
945
+
946
+ except:
947
+ print('Ending search...')
948
+ print('=' * 70)
949
+ break
950
+
951
  """# Congrats! You did it! :)"""