ProjectMu 是一个用于通过简谱生成 .wav 格式音频文件的工具。
ProjectMu is a tool for generating audio files in .wav format from numbered musical notations.
git clone https://github.com/Jemtaly/ProjectMu
cd ProjectMu
# 安装(推荐:可编辑安装,安装后会有 mu 命令)
python -m pip install -e .
# 你也可以安装可选依赖(播放功能)
python -m pip install -e ".[play]"
# 查看帮助
mu -h注意:在部分 Linux 环境下安装 pyaudio 可能需要系统层面的 PortAudio 开发库(具体以你的发行版/包管理器为准)。
安装完成后,你可以直接使用 mu 命令:
mu -h或者
python -m mu -h如果你不想安装(保持仓库原样运行),需要在 src 目录下执行:
cd src && python -m mu -h输出:
usage: python -m mu [-h] [-o OUTPUT] [-t {sn,pl,sq,tr,st}]
[-r SAMPLE_RATE] [-w {1,2}] [-a ATTACK] [-d DECAY]
[-v VOLUME]
filename
ProjectMu - A Numbered Notation Score Compiler
positional arguments:
filename path to the input numbered notation score file
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
output wav file path
-t {sn,pl,sq,tr,st}, --timbre {sn,pl,sq,tr,st}
timbre of the output sound
-r SAMPLE_RATE, --sample-rate SAMPLE_RATE
sample rate of the output sound
-w {1,2}, --sample-width {1,2}
sample width of the output sound
-a ATTACK, --attack ATTACK
attack time of the output sound
-d DECAY, --decay DECAY
decay time of the output sound
-v VOLUME, --volume VOLUME
volume of the output sound
你可以通过以下命令将简谱文件 examples/Bad Apple!!.μ 转换为音频文件 Bad Apple!!.wav:
mu -o 'Bad Apple!!.wav' -t sn 'examples/Bad Apple!!.μ'如果安装了 pyaudio,你也可以直接播放音频:
mu -t sn 'examples/Bad Apple!!.μ'- Amazing Grace
1=G 3/4 88
0 0 <5,1> |
1 - [3]<321> | 3 - <32> | 1 - 6, |
5, - <5,1> | 1 - [3]<321> | 3 - <23> | 5 - - |
- - <35> | 5 - [3]<321> | 3 - <32> | 1 - 6, |
5, - <5,1> | 1 - [3]<321> | 3 - 2 | 1 - - | - - ||
- Bad Apple!! - nomico
1=F# 4/4 137
6,, <<06,,5,,6,,>> 6,, <<06,,5,,6,,>> | 6,, <<06,,5,,6,,>> <6,,<6,,1,>> <2,<1,2,>> |
6,, <<06,,5,,6,,>> 6,, <<06,,5,,6,,>> | 6,, <<06,,5,,6,,>> <2,<1,2,>> <1,<6,,1,>> |,
<6,7,> <12> 3 <65> | 3 6, <32> <17,> | <6,7,> <12> 3 <21> | <7,6,> <7,1> <7,6,> <#5,7,> |
<6,7,> <12> 3 <65> | 3 6, <32> <17,> | <6,7,> <12> 3 <21> | 7, 1 2 3 |,
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <67> | <1'7> <65> 3 <23> | <21> <7,5,> 6, |,
<35> |,
0 |;
G 4/4 137
<35> |
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <23> | <21> <7,5,> 6, <5,6,> | <7,1> <23> 6, <35> |
<56> <32> 3 <23> | <56> <32> 3 <67> | <1'7> <65> 3 <23> | <21> <7,5,> 6, 0 |
<6,.6,/> <-6,> <6,.6,/> <-6,> | <6,.6,/> <-6,> <6,.6,/> <-6,> |
<6,.6,/> <-6,> <6,.6,/> <-6,> | <6,.6,/> <-6,> <6,.6,/> <-0> |:
1 1 2 2 3 4 3 5 1 1 2 2 3 6
| 符号 | 说明 |
|---|---|
1=F# |
调式。1=F# 表示升 F 大调,又如,降 C 小调表示为 6=Cb。 |
4/4 |
节奏型。如 4/4, 6/8, 1/2 ... |
174 |
每分钟节拍数(BPM) |
| |
小节线 |
|, |
用于表示该段乐谱结束,且下一段的调号、节奏型、速度和当前段相同。(通常用于当乐曲中存在反复记号时) |
|; |
用于表示该段乐谱结束,下一段需要重新设置调号、节奏型和速度。(用于当乐曲的调号、节奏型与速度中途改变时) |
|| |
用于表示乐谱结束。 |
|: |
当乐谱中存在反复记号(各段的演奏顺序需要手动排列)时,用此符号表示乐谱结束。并在后面输入乐谱各段在整首乐曲中的排列顺序。 |
| 符号 | 说明 |
|---|---|
1 ~ 7 |
音符 |
0 |
休止符 |
# |
升号(加在数字前) |
b |
降号(同上) |
@ |
还原号(同上) |
' |
将当前音符升高八度 |
, |
将当前音符降低八度 |
- |
延长线,每加一条横线相当于延长一个四分音符的长度,也可用于替代延音线第一个以后的音符(表示延续前一个音符) |
. |
附点 |
/ |
用于表示下加线 |
<...> |
表示为 < 和 > 之间的所有音符添加下加线。例如,<<1/2/>2/> 等同于 1///2///2//. |
[3]{...} |
三连音,同理, [5]{...} 表示五连音。由四拍分拆而来的七连音可写作 [7]{...} 或 [7:4]{...},而由六拍分拆而来或由八拍结合合而来的七连音则分别需表示为 [7:6]{...} 和 [7:8]{...},依此类推。此外,[x]{<...>} 可略写为 [x]<...>。 |
更多乐谱示例见此处。