File size: 938 Bytes
a03c9b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from utils.mirdata_dev.datasets import slakh16k


def check_drum_channel_slakh(data_home: str):
    ds = slakh16k.Dataset(data_home, version='default')
    for track_id in ds.track_ids:
        is_drum = ds.track(track_id).is_drum
        midi = MidiFile(ds.track(track_id).midi_path)
        cnt = 0
        for msg in midi:
            if 'note' in msg.type:
                if is_drum and (msg.channel != 9):
                    print('found drum track with channel != 9 in track_id: ',
                          track_id)
                if not is_drum and (msg.channel == 9):
                    print(
                        'found non-drum track with channel == 9 in track_id: ',
                        track_id)
                if is_drum and (msg.channel == 9):
                    cnt += 1
        if cnt > 0:
            print(f'found {cnt} notes in drum track with ch 9 in track_id: ',
                  track_id)
    return