Convert between music21 and musicpy objects
Project description
music21py
Github | Gitee | Gitlab | Bitbucket | Coding
安装
pip install music21py
使用说明
music21py.m21_to_mpy
:music21转musicpy
支持的类型:
转换前的类型 | 转换后的类型 | 说明 |
---|---|---|
music21.pitch.Pitch | musicpy.note | |
music21.note.Note | musicpy.note | musicpy不支持歌词 |
music21.tempo.MetronomeMark | musicpy.tempo | |
music21.stream.Stream | musicpy.track | |
music21.stream.Measure | musicpy.track | |
music21.stream.Part | musicpy.track | |
music21.stream.Score | musicpy.piece | musicpy不支持节拍 |
music21py.mpy_to_m21
:musicpy转music21
支持的类型:
转换前的类型 | 转换后的类型 | 说明 |
---|---|---|
musicpy.note | music21.note.Note | |
musicpy.tempo | music21.tempo.MetronomeMark | |
musicpy.chord | music21.stream.Stream | |
musicpy.track | music21.stream.Part | |
musicpy.piece | music21.stream.Score |
示例
import music21py
import musicpy
crd=musicpy.chord(['C5', 'E5', 'G5', 'B5'],interval=[0.25,0.5,0.75,1])
strm=music21py.mpy_to_m21(crd)
strm.show()
为什么要开发这个库
在我看来,musicpy和music21是两个口味不同的Python乐理分析库。
music21偏“学院派”,它的数据结构对标五线谱显示。音高可以用德语、意大利语、盲文等方式显示与输入,时值也支持eighth、16th等字符串形式,支持以基本时值+附点的方式展示与输入。music21严格区分等音,例如C#
、D-
、E---
。music21“大而全”,支持musicxml、abc等多种文件输入输出。在编写与music21集成的程序时,容易陷入困惑:我不知道隐藏在我所操作的变量下面有多少信息量。
而musicpy更符合现代电子音乐人的口味,其基本数据结构“小而精”。例如,用同一种数据结构来表示和弦与旋律段落。musicpy支持常用的运算符号,常用的函数都有简称,使代码大大缩短,开发效率更高(但可维护性变差,如同shell脚本)。
在使用music21时,我绝大多数时间都在与最基本的数据结构打交道,但偶尔也需要使用高级功能。因此,可以用musicpy完成绝大多数操作,在用到高级功能时再使用本库转换为music21对象
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file music21py-0.0.2.tar.gz
.
File metadata
- Download URL: music21py-0.0.2.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f402b7fbbb71305c07290e7087c1c1d2c2fc61b6e29796838371871f8725668 |
|
MD5 | dcb8cba75324e4d82f720169703e1c99 |
|
BLAKE2b-256 | 1bf85660cefac193b28e369ab7e446b2c7dba04bfdcce7a2ca580081f846e68a |
File details
Details for the file music21py-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: music21py-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6a8fb854ea29aed9966ac4e8e15a6190e08027a17a5a131f47290f29d4f0039 |
|
MD5 | a0c4c29136b331b78f24cfecc4e059c1 |
|
BLAKE2b-256 | 226f0c5d9f345206a91db3f816e5da12ae4a7edac3001ee7440be7d19fd0f863 |