-
Notifications
You must be signed in to change notification settings - Fork 2
/
seperate_midi.py
49 lines (39 loc) · 1.5 KB
/
seperate_midi.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
import numpy as np
import glob
import datetime
import math
import random
import os
import shutil
ROOT_PATH = './my_datasets/'
#music_gerne_selected = ['rock','R&B','funk','bossanova','Medium_swing']
music_gerne_selected = ['bossanova','country','funk','rock','shuffle']
for music_gerne in music_gerne_selected:
# seperate the train npy
if not os.path.exists(os.path.join(ROOT_PATH, music_gerne + '/train')):
os.makedirs(os.path.join(ROOT_PATH, music_gerne + '/train'))
x = np.load(os.path.join(ROOT_PATH,
music_gerne+'_train.npy'))
print(x.shape)
count = 0
for i in range(x.shape[0]):
if np.max(x[i]):
count += 1
np.save(os.path.join(ROOT_PATH,
music_gerne +'/train/' + music_gerne + '_train_{}.npy'.format(
i + 1)), x[i])
print(x[i].shape)
#seperate the test npy
if not os.path.exists(os.path.join(ROOT_PATH, music_gerne + '/test')):
os.makedirs(os.path.join(ROOT_PATH, music_gerne + '/test'))
x = np.load(os.path.join(ROOT_PATH,
music_gerne+'_test.npy'))
print(x.shape)
count = 0
for i in range(x.shape[0]):
if np.max(x[i]):
count += 1
np.save(os.path.join(ROOT_PATH,
music_gerne + '/test/' + music_gerne + '_test_{}.npy'.format(
i + 1)), x[i])
print(x[i].shape)