码迷,mamicode.com
首页 > 其他好文 > 详细

Music21 关联 MuseScore 和 Lilypond

时间:2019-01-07 23:32:06      阅读:407      评论:0      收藏:0      [点我收藏+]

标签:tps   warnings   user   ogr   div   env   guide   ges   使用   

在python安装 music21后,需要关联 musescore 或 lilypond 才能可以用图形化的形式看到 乐谱。

因此 在安装 music21后,需要配置环境变量

首先、 通过 导入music21:

from music21 import *

然后,查看环境变量有哪些。

>>>environment.keys()

[directoryScratch, lilypondPath, lilypondVersion, lilypondFormat, lilypondBackend, 
musicxmlPath, midiPath,
graphicsPath, vectorPath, pdfPath, braillePath, musescoreDirectPNGPath,
showFormat, writeFormat, ipythonShowFormat,
autoDownload, debug, warnings, localCorpusSettings,
localCorporaSettings, manualCoreCorpusPath, localCorpusPath]

或者是 

>>> us = environment.UserSettings()
>>> us.keys()
[directoryScratch, lilypondPath, lilypondVersion, lilypondFormat, lilypondBackend, musicxmlPath, 
midiPath, graphicsPath, vectorPath, pdfPath, braillePath, musescoreDirectPNGPath, showFormat,
writeFormat, ipythonShowFormat, autoDownload, debug, warnings, localCorpusSettings,
localCorporaSettings, manualCoreCorpusPath, localCorpusPath]

 

后续统一使用后者进行配置。

对于 lilypond的配置(路径请自行编写):

us[lilypondPath] = C:/Program Files (x86)/LilyPond/usr/bin/lilypond.exe

对于 musescore的配置: 

us[‘musescoreDirectPNGPath‘] = "C:/Program Files (x86)/MuseScore 2/bin/MuseScore.exe"
us[‘musicxmlPath‘] = "C:/Program Files (x86)/MuseScore 2/bin/MuseScore.exe"

 

如果 keys()里面没有 相关配置,可以先set出相关配置项。

environment.set("musescoreDirectPNGPath", "C:/Program Files (x86)/MuseScore 2/bin/MuseScore.exe")
environment.set("musicxmlPath", "C:/Program Files (x86)/MuseScore 2/bin/MuseScore.exe")

 

参考:

1、http://web.mit.edu/music21/doc/usersGuide/usersGuide_08_installingMusicXML.html

2、https://stackoverflow.com/questions/25879764/creating-images-of-notes-in-music21

Music21 关联 MuseScore 和 Lilypond

标签:tps   warnings   user   ogr   div   env   guide   ges   使用   

原文地址:https://www.cnblogs.com/yvivid/p/music21_setting.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!