19 lines
584 B
Python
19 lines
584 B
Python
|
import pypianoroll as roll
|
||
|
import matplotlib.pyplot as plt
|
||
|
import numpy as np
|
||
|
import os
|
||
|
import settings
|
||
|
|
||
|
instruments = np.load(settings.generated_sample_path)['arr_0'][0]
|
||
|
|
||
|
instruments = instruments.reshape(96,128)
|
||
|
# instruments = instruments>0.5
|
||
|
instruments = instruments*255
|
||
|
|
||
|
i = roll.Track(instruments, program=0)
|
||
|
generated_midi = roll.Multitrack(tracks=[i], tempo=120.0, downbeat=[0, 96, 192, 288], beat_resolution=24)
|
||
|
roll.write(generated_midi, settings.generated_midi_path)
|
||
|
|
||
|
plt.imshow(instruments.T, cmap='gray')
|
||
|
plt.savefig(settings.generated_pianoroll_path)
|