forked from salu133445/musegan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_is_drum.py
64 lines (41 loc) · 1.65 KB
/
check_is_drum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import json
import os
import sys
def check_is_drum_of_Grand_Piano(midi_folder):
invalid_files_counter = 0
song_count = 0
one_is_drum = 0
not_one_is_drum = []
for path, subdirs, files in os.walk(midi_folder):
for name in files:
_path = path.replace('\\', '/') + '/'
_name = name.replace('\\', '/')
try:
if _name == 'instruments.json':
song_count += 1
print _path
with open(_path + _name) as inst:
dict = json.load(inst)
is_drum_count = 0
for key, dic in zip(dict.keys(), dict.values()):
if dic['is_drum'] == True:
#print '0: ', dict['0']
#print 'key: ', key
#print dic
is_drum_count += 1
print 'is_drum count = ', is_drum_count
if is_drum_count == 1:
one_is_drum += 1
else:
not_one_is_drum.append(_path)
except:
exception_str = 'Unexpected error in ' + name, sys.exc_info()[0]
print(exception_str)
invalid_files_counter += 1
print '-----------------------------------------------'
print 'song count: ', song_count
print 'one_is_drum count: ', one_is_drum
print 'not one is_drum: ', not_one_is_drum[0:10]
if __name__ == '__main__':
path = '/data1/lakh/lmd_matched_processed_with_one_chord_per_bar'
check_is_drum_of_Grand_Piano(path)