Enable Musescore with Music21 in Collab
enables music21 to render images of musical notes
print('installing lilypond...')
!apt-get install lilypond > /dev/null
print('installing musescore...')
!sudo apt-get install musescore
converts midi files to wav files into order to play them
print('installing fluidsynth...')
!apt-get install fluidsynth > /dev/null
!cp /usr/share/sounds/sf2/FluidR3_GM.sf2 ./font.sf2
print('done!')
import music21
from IPython.display import Image, Audio
def show(music):
display(Image(str(music.write('lily.png'))))
def play(music):
filename = music.write('mid')
!fluidsynth -ni font.sf2 $filename -F $filename.wav -r 44100 > /dev/null
display(Audio(filename + '.wav'))
n = music21.note.Note('D#3')
n.duration.type = 'half'
play(n)
show(n)
Comments
The question is what do you want musescore to do?