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 ...
随机推荐
- c/c++技巧总结
1.bzero().memset()初始化结构体. 2.求结构体分量在结构体中地址偏移量 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) ...
- 【Unity3D/C#】利用IEnumerable<>和yield产生斐波那契数列
using UnityEngine; using System.Collections; using System.Collections.Generic; public class YieldTes ...
- Hadoop源生实用工具之distcp
1 概览 DistCp(Distributed Copy)是用于大规模集群内部或者集群之间的高性能拷贝工具. 它使用Map/Reduce实现文件分发,错误处理和恢复,以及报告生成. 它把文件和目录的列 ...
- OAuth相关知识
什么是OAuth认证 1.一种安全认证的协议;2.协议为用户资源的授权提供了一个安全的.开放又简易的标准;3.OAuth的授权不会使第三方触及到用户的账户信息(例如用户名和密码) 网址:www.oau ...
- JQuery notepad
ready:在文档加载后执行,在文档对象加载完毕后,页面完全显示后执行,把所有事件函数放在ready中加载是一种非常好的方法,ready() 函数不应与 <body onload="& ...
- JavaScript随机生成颜色以及十六进制颜色 与RGB颜色值的相互转换
/** * 随机生成颜色 * @return 随机生成的十六进制颜色 */ function randomColor(){ var colorStr=Math.floor(Math.random()* ...
- RING0到RING3
在前一篇文章里面,我们将了CPU保护模式中的几种特权RING0,RING1,RING2,RING3!操作系统通常运行在RING0,应用程序通常运行在RING3. CPU如何从RING0到RING3 先 ...
- .gitignore梳理
参考来源: https://www.cnblogs.com/kevingrace/p/5690241.html 对于经常使用Git的朋友来说,.gitignore配置一定不会陌生.废话不说多了,接下来 ...
- 大数四则运算java(转)
// 大数的四则运算 #include <iostream> #include <string> #include <algorithm> using namesp ...
- MVC文件下载和webform也能使用的下载方法
public ActionResult Index() { DownloadMethod("text/plain", "C:/Users/sunny/Pictures/S ...