LilyPond

LilyPond 是什么?(https://lilypond.org/)

LilyPond (荷花池) 是一个音乐雕版软件,致力产生最高质量的乐谱。它把传统音乐雕版印刷的美学,呈现在计算机打印的乐谱上。LilyPond 是自由软件,也是 GNU Project 的一部分。

计算机软件的内核是将接收到的数据进行计算并输出,LilyPond 也不例外。我们需要按照 LilyPond 开发者制定的规则编写乐谱源码,然后使用 LilyPond 将源代码转换为 PNG、PDF、SVG、MIDI 等格式的文件。

荷花池(线谱)的运作流程如下:

  1. 按照 lilypond 开发者制定的规则编写「LilyPond 乐谱源码」。
  2. 使用 lilypond 程序将「LilyPond 乐谱源码」转换为我们期望的「乐谱」文件。

这里的 lilypond.exe 程序与我们日常使用的软件有所不同,需要通过命令行的方式来调用执行。

不过 LilyPond 主要用于生成五线谱,若想生成简谱我们还需要借助另外一个工具:

与上面不同,我们不再按照 LilyPond 的规则编写「LilyPond 乐谱源码」而是按照 jianpuly 开发者制定的规则编写「Jianpuly 简谱源码」。

荷花池(简谱)的运作流程如下:

  1. 按照 jianpuly 开发者制定的规则编写「Jianpuly 简谱源码」。
  2. 使用 jianpuly 脚本将「Jianpuly 简谱源码」转换为「LilyPond 乐谱源码」。
  3. 使用 lilypond 程序将「LilyPond 乐谱源码」转换为我们期望的「乐谱」文件。

与 lilypond 类似,jianpu-ly.py 需要通过命令行的方式经 python 调用执行。

软件下载

1. 下载 lilypond 压缩包

下载链接

2. 下载 jianpu-ly.py 脚本文件

下载链接

软件安装

1. 将下载好的 lilypond 压缩包解压至任意位置

2. 将下载好的 jianpu-ly.py 剪切至 lilypond 解压目录下的 bin 文件夹中

3. 将 lilypond 安装目录下的 bin 文件夹添加至系统环境变量 PATH 中

第一步:搜索「环境变量」然后点击「编辑系统环境变量」

第二步:点击「环境变量」按钮

第三步:选中系统变量中的「PATH」然后点击下方的「编辑」按钮

第四步:点击「新建」按钮然后输入之前解压的 lilypond 的完整路径

4. 验证 lilypond 是否正常安装

第一步:按下「Win+R」键打开运行对话框然后输入 cmd 并运行

第二步:输入「lilypond –help」然后按下回车键

如果你能看到上图中的信息,那么恭喜,安装完成!下面可以尝试制作一个简单的乐谱了!


线谱制作

写到这里时发现了一篇非常不错的 lilypond 中文入门教程,既然如此,那我索性就偷个懒,各位看官请移步这里:

《LilyPond 入门教程》 by 兔子不咬人

简谱制作

1. 新建一个文件夹作为工作空间

2. 将 jianpu-ly.py 脚本文件拷贝至工作空间

3. 在工作空间中创建一个文本文档(例如:简谱代码.txt)然后写入以下内容

%% tempo: 4=60
title=标题
1=C
2/4

1 2 3 4 5 6 7 1'

4. 在工作空间中单击右键选择「在终端中打开」然后会弹出一个黑框框

5. 输入以下命令并然后按回车键执行

python jianpu-ly.py 简谱代码.txt > 乐谱代码.ly

6. 输入以下命令并然后按回车键执行

lilypond -o 乐谱文件 --format=pdf,png 乐谱代码.ly

7. 嫌麻烦的话也可以在工作空间中新建一个「自动脚本.bat」批处理文件并填入以下内容

chcp 65001

set jianpuly="D:\develop.r.1\lilypond-2.24.1\bin\jianpu-ly.py"

set source="简谱"
set output="曲谱"

set middle="荷花"

python %jianpuly% %source%.txt > %middle%.ly
lilypond -o %output% --format=pdf,png %middle%.ly
lilypond -o %output% --format=svg %middle%.ly

md %source%

move .\%output%.* .\%source%
move .\%middle%.* .\%source%

8. 以后只要双击该脚本即可自动生成

使用这种方式时,文件名就不能随便起了,必须与「source」字段保持一致。

简谱规则

Scale going up                                              1 2 3 4 5 6 7 1'
Accidentals 1 #1 2 b2 1
Octaves 1,, 1, 1 1' 1''
Shortcuts for 1’ and 2’ 8 9
Semiquaver, quaver, crotchet (16/8/4th notes) s1 q1 1
Dotted versions of the above (50% longer) s1. q1. 1.
Demisemiquaver, hemidemisemiquaver (32/64th notes) d1 h1
Minims (half notes) use dashes 1 -
Dotted minim 1 - -
Semibreve (whole note) 1 - - -
Time signature 4/4
Time signature with quaver anacrusis (8th-note pickup) 4/4,8
Key signature (major) 1=Bb
Key signature (minor) 6=F#
Tempo 4=85
Lyrics L: here are the syl- la- bles (all on one line)
Lyrics (verse 1) L: 1. Here is verse one
Lyrics (verse 2) L: 2. Here is verse two
Hanzi lyrics (auto space) H: hanzi (with or without spaces)
Lilypond headers title=the title (on a line of its own)
Multiple parts NextPart
Instrument of current part instrument=Flute (on a line of its own)
Multiple movements NextScore
Prohibit page breaks until end of this movement OnePage
Suppress bar numbers NoBarNums
Old-style time signature SeparateTimesig 1=C 4/4
Indonesian ‘not angka’ style angka
Add a Western staff doubling the tune WithStaff
Tuplets 3[ q1 q1 q1 ]
Grace notes before g[#45] 1
Grace notes after 1 ['1]g
Simple chords 135 1 13 1
Da capo 1 1 Fine 1 1 1 1 1 1 DC
Repeat (with alternate endings) R{ 1 1 1 } A{ 2 | 3 }
Short repeats (percent) R4{ 1 2 }
Ties (like Lilypond’s, if you don’t want dashes) 1 ~ 1
Slurs (like Lilypond’s) 1 ( 2 )
Erhu fingering (applies to previous note) Fr=0 Fr=4
Erhu symbol (applies to previous note) souyin harmonic up down bend tilde
Tremolo 1/// - 1///5 -
Rehearsal letters letterA letterB
Multibar rest R*8
Dynamics (applies to previous note) \p \mp \f
Other 1-word Lilypond \ commands \fermata \> \! \( \) etc
Text ^"above note" _"below note"
Other Lilypond code LP: (block of code) :LP (each delimeter at start of its line)
Ignored % a comment