在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的更多相关文章

  1. 个人使用的lilypond第一个模板

    手残非要用lilypond打谱真是…… 可是lilypond又能满足各种细节标记和谱文混排,这是musescore达不到的 所以还是开这个坑,希望能逐渐自己有能力编写自己的音乐教材 个人用Fresco ...

  2. Hibernatel框架关联映射

    Hibernatel框架关联映射 Hibernate程序执行流程: 1.集合映射 需求:网络购物时,用户购买商品,填写地址 每个用户会有不确定的地址数目,或者只有一个或者有很多.这个时候不能把每条地址 ...

  3. hibernate多对多关联映射

    关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...

  4. hibernate多对一双向关联

    关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...

  5. JDBC MySQL 多表关联查询查询

    public static void main(String[] args) throws Exception{ Class.forName("com.mysql.jdbc.Driver&q ...

  6. UML类图(下):关联、聚合、组合、依赖

    前言 上一篇文章UML类图(上):类.继承.实现,讲了UML类图中类.继承.实现三种关系及其在UML类图中的画法,本文将接着上文的内容,继续讲讲对象之间的其他几种关系,主要就是关联.聚合.组合.依赖, ...

  7. Entity Framework 6 Recipes 2nd Edition(12-5)译 -> 自动删除相关联实体

    12-5. 自动删除相关联实体 问题 当一个实体被删除时,你想自动删除它相关联的实体 解决方案 假设你有一个表结构由一个course (科目), course 的classes (课程),以及enro ...

  8. hibernate多对一单向关联

    关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...

  9. hibernate一对一外键双向关联

    关联是类(类的实例)之间的关系,表示有意义和值得关注的连接. 本系列将介绍Hibernate中主要的几种关联映射 Hibernate一对一主键单向关联Hibernate一对一主键双向关联Hiberna ...

随机推荐

  1. Hadoop完全分布式环境下,DataNode进程正常启动,但是网页上不显示DataNode节点

    Hadoop完全分布式环境下,上传文件到hdfs上时报错: // :: WARN hdfs.DFSClient: DataStreamer Exception org.apache.hadoop.ip ...

  2. shell 文件测试 蛮全的

    文件状态测试 -b filename : 当filename 存在并且是块文件时返回真(返回0)-c filename : 当filename 存在并且是字符文件时返回真-d pathname : 当 ...

  3. 性能测试学习第九天_脚本编写以及controller场景

    创建java脚本 环境配置: 安装jdk(lr11最高支持java1.6) 配置环境变量 在lr选择java Vuser协议 脚本结构: 一般在init中编写初始化脚本,在action中编写业务流程, ...

  4. MySQL三种存储引擎总结

    MySQL三种存储引擎 MyISAM.InnoDB.MEMORY 1.MyISAM MyISAM,3.23.34a前的默认存储引擎. 优缺点 优点 在于占用空间小,处理速度快. 缺点 不支持事务的完整 ...

  5. c#写word文档基础操作(自己控制样式)

    下面一个函数,建立一个Word 文档,添加页眉.页脚,在内容中两个不同字体的Hello!!!   来自 <http://bbs.csdn.net/topics/340041961> pub ...

  6. jQuery学习笔记(四)

    动画效果 显示和隐藏效果 无动画效果 显示:show() 隐藏:hide() <!DOCTYPE html> <html lang="en"> <he ...

  7. win10 asp+access

    今天是灰色的一天. 大清早来到单位,告知:单位主页访问不了! 我远程看了下.所有的文件后缀都变成了.crab 赶紧上网查下,哎呀我的妈呀,这是中了勒索病毒啊. 还用查?打开服务器,有个打开的文本文件写 ...

  8. grunt配置sass项目自动编译

    1.安装Ruby和SASS 首先我们需要在电脑上安装Ruby和SASS.如果您使用的是Mac,您就没必要安装Ruby.如果您使用的是Window系统,你需要安装Ruby. 2.安装Nodejs 由于使 ...

  9. echarts折线图相关

    optionJKDLine = { title: { text: '告警数量趋势图', textStyle:{ //标题样式 fontStyle:'normal', fontFamily:'sans- ...

  10. C#启动或停止 计算机中“服务”

    第一.要添加一个引用System.ServiceProcess 第二.要在程序中使用命名空间ServiceProcess 代码片段: using System.ServiceProcess; Serv ...