music21 关联 MuseScore 和 Lilypond
在python安装 music21后,需要关联 musescore 或 lilypond 才能可以用图形化的形式看到 乐谱。
因此 在安装 music21后,需要配置环境变量,yvivid 在 music21的官方 doc 没找到简单的指引,后来搜到相关信息,整理如下。
首先、在 python 中导入music21(安装可以 pip install 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")
最后,yvivid做个验证测试:
from music21 import *
littleMelody = converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#")
littleMelody.show()

作者:www.cnblogs.com/yvivid
参考文献:
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的更多相关文章
- 个人使用的lilypond第一个模板
手残非要用lilypond打谱真是…… 可是lilypond又能满足各种细节标记和谱文混排,这是musescore达不到的 所以还是开这个坑,希望能逐渐自己有能力编写自己的音乐教材 个人用Fresco ...
- Hibernatel框架关联映射
Hibernatel框架关联映射 Hibernate程序执行流程: 1.集合映射 需求:网络购物时,用户购买商品,填写地址 每个用户会有不确定的地址数目,或者只有一个或者有很多.这个时候不能把每条地址 ...
- hibernate多对多关联映射
关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...
- hibernate多对一双向关联
关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...
- JDBC MySQL 多表关联查询查询
public static void main(String[] args) throws Exception{ Class.forName("com.mysql.jdbc.Driver&q ...
- UML类图(下):关联、聚合、组合、依赖
前言 上一篇文章UML类图(上):类.继承.实现,讲了UML类图中类.继承.实现三种关系及其在UML类图中的画法,本文将接着上文的内容,继续讲讲对象之间的其他几种关系,主要就是关联.聚合.组合.依赖, ...
- Entity Framework 6 Recipes 2nd Edition(12-5)译 -> 自动删除相关联实体
12-5. 自动删除相关联实体 问题 当一个实体被删除时,你想自动删除它相关联的实体 解决方案 假设你有一个表结构由一个course (科目), course 的classes (课程),以及enro ...
- hibernate多对一单向关联
关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...
- hibernate一对一外键双向关联
关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...
随机推荐
- svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupte...
今天在svn提交的时候它卡顿了一下,我以为已经提交完了,就按了一下,结果就再也恢复不了,也继续不了了... 报错 cleanup failed–previous operation has not f ...
- NLog学习笔记一
一.NLog是什么? NLog是一个基于.NET的免费的开源的日志记录类库.(官网:http://nlog-project.org/) NLog特点如下: 配置简单方便.可以将配置信息写的应用程序的配 ...
- JavaSE_2_关键字
1.介绍一下Syncronized锁,如果用这个关键字修饰一个静态方法,锁住了什么?如果修饰成员方法,锁住了什么? synchronized是Java中的关键字,是一种同步锁.它修饰的对象有以下四种: ...
- Int与String之间相互转换
1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([ ...
- Android list加载图片工具类
总体思路 Handler + looper + message 核心类 package com.base.imagechoose.util; import android.graphics.Bitma ...
- Visual Studio 更改护眼颜色
- 关于调用百度地图api在自己写的网页中实现和解决在https中正常显示
百度地图开发者:http://lbsyun.baidu.com/index.php?title=jspopular 我们打开百度地图开发者网站,注册一个百度账号,然后打开控制台,开始创建应用:(如果你 ...
- win10蓝牙添加设备无法连接
解决方法: 打开运行窗口,输入services.msc. 找到蓝牙支持服务(或者Bluetooth Support Service),右键,属性,启动类型选择手动,启动服务. 还不行的话,此电脑右键, ...
- linux 命令——39 grep (转)
Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...
- IOS 绘制条纹背景
@interface NJViewController () @property (weak, nonatomic) IBOutlet UITextView *contentView; - (IBAc ...