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 ...
随机推荐
- Python3.5 调用Ansible 执行命令
ansible.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import tempfile from collections ...
- springboot 学习笔记(九)
springboot整合activemq,实现broker集群部署(cluster) 1.为实现jms高并发操作,需要对activemq进行集群部署,broker cluster就是activemq自 ...
- hibernate课程 初探单表映射3-1 hibernate单表操作简介
本章简介: 1 单一主键 2 基本类型 3 对象类型 4 组件属性 5 单表操作CRUD实例
- Java调用webservice接口方法(SOAP message、xfire、axis)
webservice的 发布一般都是使用WSDL(web service descriptive language)文件的样式来发布的,在WSDL文件里面,包含这个webservice暴露在外面可供使 ...
- 洛谷 P1281 书的复制
书的复制 Code: #include <iostream> #include <cstdio> #include <cstring> using namespac ...
- 前端Json数据模拟神器mockJs使用教程
一般项目做法: <html> <head> <script src="http://requirejs.org/docs/release/2.1.16/comm ...
- keil 系列问题
1.为了让keil支持stm32f0系列,安装了keil4更高级的版本,但是发现编译时弹出异常提示框,经过一番折腾后找到解决办法,首先把电脑登陆账户名改为非中文的,然后卸载了keil重装就可以了. ...
- 360 so动态脱壳
环境及工具 手机 : 中兴 U887 系统版本: Android 2.3.5 工具 : IDA pro 6.6 .0101Editor 版权声明:未经许可,随便转载 目前so加壳有 ...
- MobaXterm连接远程Linux服务器
MobaXterm是一个X服务器和一组的Unix命令(GNU/ Cygwin的)封装在一个单一的便携式exe文件的增强终端. MobaXterm包括一个巨大的multitab原生的Windows终端. ...
- DB2数据库备份还原
恢复及备份NC DB2数据库步 一. 安装DB2数据库 解压db2v9.5ins.rar安装,在写此文档时客户一般用的是9.5: 注意不要将db2安装到系统盘: 二. Windows版本 1.数据库备 ...