summaryrefslogtreecommitdiffstats
path: root/2020/info/04.md
blob: e80e75181900d7d143804df0abc1ca226709cfd5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Music in Plain Text
Jonathan Gregory

[[!template id=vid vidid=mainVideo  src="https://mirror.csclub.uwaterloo.ca/emacsconf/2020/emacsconf-2020--04-music-in-plain-text--jonathan-gregory.webm" subtitles="/2020/subtitles/emacsconf-2020--04-music-in-plain-text--jonathan-gregory.vtt"]]  
[Download compressed .webm video (13.8M)](https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--04-music-in-plain-text--jonathan-gregory--vp9-q56-video-original-audio.webm)  
[View transcript](#transcript)

LilyPond is an extensible program for producing high-quality sheet
music engraved with traditional layout rules. Similar to LaTeX and
other typesetting programs, its input format describes the visual
layout of the score using commands to define musical expressions. This
makes collaboration easier, prevents users from having to adjust
layout settings manually, and facilitates digital archiving and
distribution of musical scores. In this talk, I begin with an overview
of the LilyPond syntax and move on to showcase ways for producing
algorithmic compositions and music books using Make, Org and
LilyPond-mode.

Source files and other materials can be found at
<https://gitlab.com/jagrg/emacsconf-2020> and
<https://gitlab.com/drumbook>.

<!-- from the pad --->

# Questions

## Do you have any thoughts on generating scores in chant notation (neumes)?
I'm not familiar with typesetting chant notation, so I suggest reading
this specific section of the manual for information.

## Do you use this to compose or to write up compositions&#x2026;?
No and yes. I use pencil and paper to compose the first draft. Then I
move to Emacs to input the notes. Either way it's certainly possible
to compose from Emacs directly, especially if you're doing this
programatically, so I guess it depends on what you're trying to do.

## Can one use MIDI/USB instruments (like keyboards) to input LilyPond? For example for note heights?

[Don't know about Emacs, but Frescobaldi supports MIDI input.]

There is a package called `midi-kbd` which creates keyboard events
from MIDI input, so I believe the answer is yes, but I don't own a
MIDI device, so I haven't tried it.

## Did you ever write huge scores (BigBand/Orchestra) in Emacs?
Never, but that's certainly possible.

## Is there a decent OCR for handwritten music→LilyPond?
I'm not sure, but if the OCR works with MusicXML, then you can use the
`musicxml2ly` command to convert the XML file to a LilyPond file.

## What shell are you using with the fancy autocomplete?
Zsh with fzf.

## Do you use any kind of Emacs to MIDI interface besides exporting MIDI from LilyPond?
No.

# Notes
- Emacs + LilyPond.
- Similar to LaTeX — has its own file format and syntax, can also export to MIDI.
- `(info "(lilypond-learning) Top")`
- The contrast between background and foreground is a little too weak.
- Uses LilyPond-mode, flycheck.
- <https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html>


<!-- transcript: 2020/subtitles/emacsconf-2020--04-music-in-plain-text--jonathan-gregory.vtt -->
<a name="transcript"></a>
# Transcript

[[!template new="1" text="Hello, everyone, and welcome to the EmacsConf." start="00:00:02.000" video="mainVideo" id=subtitle]]
[[!template text="I am Jonathan. In this talk," start="00:00:04.799" video="mainVideo" id=subtitle]]
[[!template text="I'm going to demonstrate ways of producing sheet music in Emacs" start="00:00:06.631" video="mainVideo" id=subtitle]]
[[!template text="using Lilypond, and maybe also convince you" start="00:00:10.880" video="mainVideo" id=subtitle]]
[[!template text="to use Emacs for writing your scores." start="00:00:14.636" video="mainVideo" id=subtitle]]
[[!template text="I'll start with an overview of the syntax" start="00:00:18.640" video="mainVideo" id=subtitle]]
[[!template text="for those who are new to using" start="00:00:20.698" video="mainVideo" id=subtitle]]
[[!template text="text-based notation" start="00:00:22.240" video="mainVideo" id=subtitle]]
[[!template text="as a shallow dive into the deep pond" start="00:00:24.400" video="mainVideo" id=subtitle]]
[[!template text="of lilies and Lilypond," start="00:00:26.615" video="mainVideo" id=subtitle]]
[[!template text="and move on to showcase" start="00:00:28.800" video="mainVideo" id=subtitle]]
[[!template text="some of its functionalities using Org Mode and lilypond-mode." start="00:00:30.171" video="mainVideo" id=subtitle]]
[[!template text="One disclaimer, however:" start="00:00:34.723" video="mainVideo" id=subtitle]]
[[!template text="I am not a Lilypond developer." start="00:00:37.173" video="mainVideo" id=subtitle]]
[[!template new="1" text="So what is Lilypond?" start="00:00:40.480" video="mainVideo" id=subtitle]]
[[!template text="Lilypond is a file format and music engraving system" start="00:00:42.841" video="mainVideo" id=subtitle]]
[[!template text="for producing high-quality sheet music." start="00:00:46.800" video="mainVideo" id=subtitle]]
[[!template text="It translates textual representations" start="00:00:50.000" video="mainVideo" id=subtitle]]
[[!template text="of music to graphical objects." start="00:00:52.442" video="mainVideo" id=subtitle]]
[[!template text="It's similar to LaTeX in that" start="00:00:55.120" video="mainVideo" id=subtitle]]
[[!template text="its input format describes" start="00:00:57.520" video="mainVideo" id=subtitle]]
[[!template text="the visual layouts of the score," start="00:00:59.329" video="mainVideo" id=subtitle]]
[[!template text="using commands to define musical expressions." start="00:01:01.600" video="mainVideo" id=subtitle]]
[[!template text="Commands begin with a backslash." start="00:01:05.119" video="mainVideo" id=subtitle]]
[[!template text="For example, the formatter command, as shown on the left," start="00:01:07.760" video="mainVideo" id=subtitle]]
[[!template text="yields its graphical equivalents on the right," start="00:01:10.791" video="mainVideo" id=subtitle]]
[[!template text="the fermata symbol over the low B" start="00:01:13.920" video="mainVideo" id=subtitle]]
[[!template text="and so on and so forth." start="00:01:16.345" video="mainVideo" id=subtitle]]
[[!template text="It's also fully extensible, like Emacs," start="00:01:19.119" video="mainVideo" id=subtitle]]
[[!template text="allowing users to extend" start="00:01:21.600" video="mainVideo" id=subtitle]]
[[!template text="and override Lilypond's functionalities" start="00:01:23.119" video="mainVideo" id=subtitle]]
[[!template text="using the Scheme scripting language." start="00:01:25.600" video="mainVideo" id=subtitle]]
[[!template text="It can be used for early and contemporary music tablature," start="00:01:28.452" video="mainVideo" id=subtitle]]
[[!template text="vocal music lead sheets, and so on." start="00:01:32.422" video="mainVideo" id=subtitle]]
[[!template text="Above all, it works with Emacs." start="00:01:35.200" video="mainVideo" id=subtitle]]
[[!template text="In fact, Lilypond ships with Emacs Lisp libraries," start="00:01:38.000" video="mainVideo" id=subtitle]]
[[!template text="including a major mode for editing Lilypond files." start="00:01:41.040" video="mainVideo" id=subtitle]]
[[!template new="1" text="So the input files are similar to source files." start="00:01:47.360" video="mainVideo" id=subtitle]]
[[!template text="They contain expressions formed with curly braces," start="00:01:50.560" video="mainVideo" id=subtitle]]
[[!template text="comments that start with the percent sign," start="00:01:54.079" video="mainVideo" id=subtitle]]
[[!template text="and the code is indented." start="00:01:56.549" video="mainVideo" id=subtitle]]
[[!template text="Notes are entered using lowercase letters," start="00:02:00.240" video="mainVideo" id=subtitle]]
[[!template text="and rests with the letter r." start="00:02:02.903" video="mainVideo" id=subtitle]]
[[!template text="In this case, the lowercase r or r4" start="00:02:05.600" video="mainVideo" id=subtitle]]
[[!template text="is the equivalence of a crotchet or" start="00:02:08.800" video="mainVideo" id=subtitle]]
[[!template text="quarter note rest." start="00:02:11.039" video="mainVideo" id=subtitle]]
[[!template text="Durations are entered using numbers" start="00:02:14.000" video="mainVideo" id=subtitle]]
[[!template text="and dots after the note name." start="00:02:15.938" video="mainVideo" id=subtitle]]
[[!template text="If you do not specify one," start="00:02:18.480" video="mainVideo" id=subtitle]]
[[!template text="the previous duration is used." start="00:02:20.196" video="mainVideo" id=subtitle]]
[[!template text="You can also tie notes together using the tilde symbol (~)." start="00:02:22.640" video="mainVideo" id=subtitle]]
[[!template text="In fact, you can input chords, lyrics," start="00:02:27.360" video="mainVideo" id=subtitle]]
[[!template text="embellishments, and a lot more." start="00:02:30.000" video="mainVideo" id=subtitle]]
[[!template text="I encourage you to read the manual for more information." start="00:02:32.080" video="mainVideo" id=subtitle]]
[[!template text="Now let's switch to a terminal window." start="00:02:36.160" video="mainVideo" id=subtitle]]
[[!template text="With Lilypond installed," start="00:02:39.680" video="mainVideo" id=subtitle]]
[[!template text="let's create a test file with the extension .ly and open it in Emacs." start="00:02:41.247" video="mainVideo" id=subtitle]]
[[!template new="1" text="At the top of the file is the version statement," start="00:02:50.560" video="mainVideo" id=subtitle]]
[[!template text="which tells Lilypond" start="00:02:53.048" video="mainVideo" id=subtitle]]
[[!template text="which version to use when compiling the file." start="00:02:54.395" video="mainVideo" id=subtitle]]
[[!template text="Here I'm using version 2.20.0." start="00:02:57.440" video="mainVideo" id=subtitle]]
[[!template text="I've added the clef and time signature." start="00:03:00.959" video="mainVideo" id=subtitle]]
[[!template text="Let's add some notes." start="00:03:04.159" video="mainVideo" id=subtitle]]
[[!template text="I'm going to close this now" start="00:03:09.280" video="mainVideo" id=subtitle]]
[[!template text="and compile the file" start="00:03:12.098" video="mainVideo" id=subtitle]]
[[!template text="by running lilypond followed by the file name." start="00:03:13.765" video="mainVideo" id=subtitle]]
[[!template text="So now let's view the output." start="00:03:19.760" video="mainVideo" id=subtitle]]
[[!template new="1" text="Okay. So here's a more complex example" start="00:03:27.360" video="mainVideo" id=subtitle]]
[[!template text="for randomizing note sequences." start="00:03:29.760" video="mainVideo" id=subtitle]]
[[!template text="The idea is to create" start="00:03:32.239" video="mainVideo" id=subtitle]]
[[!template text="new reading materials each time the code blocks are evaluated." start="00:03:33.410" video="mainVideo" id=subtitle]]
[[!template text="As usual, we begin with a header." start="00:03:37.760" video="mainVideo" id=subtitle]]
[[!template text="I've added the title and composer." start="00:03:40.640" video="mainVideo" id=subtitle]]
[[!template text="Then we add the note sequences to use in the composition." start="00:03:43.541" video="mainVideo" id=subtitle]]
[[!template text="In this case, sn is a note name just like" start="00:03:47.920" video="mainVideo" id=subtitle]]
[[!template text="a b c d and so on, and stands for snare drum," start="00:03:51.200" video="mainVideo" id=subtitle]]
[[!template text="the percussion instruments." start="00:03:54.959" video="mainVideo" id=subtitle]]
[[!template text="Now here's a function that's going to" start="00:03:58.879" video="mainVideo" id=subtitle]]
[[!template text="shuffle the notes in the table." start="00:04:00.720" video="mainVideo" id=subtitle]]
[[!template text="Finally, we expand the notes inside" start="00:04:04.080" video="mainVideo" id=subtitle]]
[[!template text="the Lilypond source block." start="00:04:06.560" video="mainVideo" id=subtitle]]
[[!template text="So whatever the function returns" start="00:04:08.799" video="mainVideo" id=subtitle]]
[[!template text="is expanded inside the drums block." start="00:04:10.684" video="mainVideo" id=subtitle]]
[[!template text="Now let's press C-c C-c to view the results." start="00:04:13.680" video="mainVideo" id=subtitle]]
[[!template text="Okay. And if I run this again, it should create a new composition." start="00:04:20.079" video="mainVideo" id=subtitle]]
[[!template text="Great. You can also audition a piece using the midi command," start="00:04:26.840" video="mainVideo" id=subtitle]]
[[!template text="which creates a midi file of the score." start="00:04:31.360" video="mainVideo" id=subtitle]]
[[!template new="1" text="Note also that the ob library--" start="00:04:34.320" video="mainVideo" id=subtitle]]
[[!template text="sorry, the ob-lilypond library comes" start="00:04:36.560" video="mainVideo" id=subtitle]]
[[!template text="with two modes." start="00:04:39.040" video="mainVideo" id=subtitle]]
[[!template text="The one I'm using now is called arrange mode" start="00:04:40.400" video="mainVideo" id=subtitle]]
[[!template text="and is useful for assembling complete scores." start="00:04:43.440" video="mainVideo" id=subtitle]]
[[!template text="The basic mode, on the other hand," start="00:04:47.120" video="mainVideo" id=subtitle]]
[[!template text="allows you to mix text and music" start="00:04:49.015" video="mainVideo" id=subtitle]]
[[!template text="by embedding Lilypond snippets and" start="00:04:51.199" video="mainVideo" id=subtitle]]
[[!template text="export them using typical Org Mode commands." start="00:04:53.360" video="mainVideo" id=subtitle]]
[[!template new="1" text="Now to demonstrate the basic mode in action." start="00:05:00.240" video="mainVideo" id=subtitle]]
[[!template text="I'm going to export this document" start="00:05:02.661" video="mainVideo" id=subtitle]]
[[!template text="to a PDF file." start="00:05:04.320" video="mainVideo" id=subtitle]]
[[!template text="In this case, the :file header argument is required," start="00:05:05.120" video="mainVideo" id=subtitle]]
[[!template text="so you have to provide one" start="00:05:10.077" video="mainVideo" id=subtitle]]
[[!template text="and include the file name." start="00:05:11.919" video="mainVideo" id=subtitle]]
[[!template text="Again, you can run the code and view the results." start="00:05:15.600" video="mainVideo" id=subtitle]]
[[!template text="Here it is. So now let's export this to a PDF file." start="00:05:22.160" video="mainVideo" id=subtitle]]
[[!template text="And here it is, what it generates." start="00:05:33.680" video="mainVideo" id=subtitle]]
[[!template new="1" text="Now I'm going to show you the workflow I used" start="00:05:39.680" video="mainVideo" id=subtitle]]
[[!template text="to produce music books in Emacs," start="00:05:41.716" video="mainVideo" id=subtitle]]
[[!template text="combining Lilypond and LaTeX for a" start="00:05:44.000" video="mainVideo" id=subtitle]]
[[!template text="perfect marriage." start="00:05:46.160" video="mainVideo" id=subtitle]]
[[!template text="I begin by sketching the first draft" start="00:05:48.000" video="mainVideo" id=subtitle]]
[[!template text="of the manuscript using pencil and paper." start="00:05:49.858" video="mainVideo" id=subtitle]]
[[!template text="Then I move to Emacs to input the notes" start="00:05:53.039" video="mainVideo" id=subtitle]]
[[!template text="in a git repository." start="00:05:55.039" video="mainVideo" id=subtitle]]
[[!template text="This is a typical source file." start="00:05:57.440" video="mainVideo" id=subtitle]]
[[!template text="It begins with a stylesheet" start="00:05:59.486" video="mainVideo" id=subtitle]]
[[!template text="where I set variables and layout settings," start="00:06:01.360" video="mainVideo" id=subtitle]]
[[!template text="although in general," start="00:06:03.690" video="mainVideo" id=subtitle]]
[[!template text="there's no need for tweaking the layout" start="00:06:04.875" video="mainVideo" id=subtitle]]
[[!template text="unless you have specific requirements to do so." start="00:06:07.039" video="mainVideo" id=subtitle]]
[[!template text="The easiest way to compile the file from Emacs is by pressing C-c C-l," start="00:06:11.199" video="mainVideo" id=subtitle]]
[[!template text="so let's do this now," start="00:06:15.520" video="mainVideo" id=subtitle]]
[[!template text="and the compilation buffer will tell you" start="00:06:19.280" video="mainVideo" id=subtitle]]
[[!template text="if there were any errors in the file." start="00:06:21.199" video="mainVideo" id=subtitle]]
[[!template text="Now to automate the process of" start="00:06:23.759" video="mainVideo" id=subtitle]]
[[!template text="compiling several files and building the PDF," start="00:06:25.439" video="mainVideo" id=subtitle]]
[[!template text="I use GNU Make, so all I have to do is" start="00:06:28.560" video="mainVideo" id=subtitle]]
[[!template text="open the shell and run the make command. Don't worry," start="00:06:31.280" video="mainVideo" id=subtitle]]
[[!template text="I'll provide a link to the source code" start="00:06:36.000" video="mainVideo" id=subtitle]]
[[!template text="on the last slide." start="00:06:37.840" video="mainVideo" id=subtitle]]
[[!template new="1" text="As I moved forward with the project," start="00:06:41.600" video="mainVideo" id=subtitle]]
[[!template text="I found at least two things missing." start="00:06:43.494" video="mainVideo" id=subtitle]]
[[!template text="One, I had no access to a metronome," start="00:06:46.000" video="mainVideo" id=subtitle]]
[[!template text="at least not from the editor," start="00:06:48.720" video="mainVideo" id=subtitle]]
[[!template text="so I built one for casual use" start="00:06:50.479" video="mainVideo" id=subtitle]]
[[!template text="and made it available in the MELPA repository." start="00:06:52.437" video="mainVideo" id=subtitle]]
[[!template text="I also missed bar numbers in the source file." start="00:06:55.919" video="mainVideo" id=subtitle]]
[[!template text="This is useful when going back and forth" start="00:06:59.039" video="mainVideo" id=subtitle]]
[[!template text="between input and output files without getting lost." start="00:07:00.880" video="mainVideo" id=subtitle]]
[[!template text="So I wrote a command for toggling bar numbers," start="00:07:04.479" video="mainVideo" id=subtitle]]
[[!template text="which I hope you can see on the left." start="00:07:07.290" video="mainVideo" id=subtitle]]
[[!template text="Also, some expressions are difficult or" start="00:07:10.000" video="mainVideo" id=subtitle]]
[[!template text="slow to write on the keyboard--" start="00:07:12.080" video="mainVideo" id=subtitle]]
[[!template text="accents and tuplets, for example--" start="00:07:14.160" video="mainVideo" id=subtitle]]
[[!template text="so I use template expansion extensively for this purpose," start="00:07:16.490" video="mainVideo" id=subtitle]]
[[!template text="mainly yasnippet." start="00:07:20.160" video="mainVideo" id=subtitle]]
[[!template new="1" text="So what do I think?" start="00:07:23.440" video="mainVideo" id=subtitle]]
[[!template text="Well, I think Lilypond can be a sharp paradigm shift" start="00:07:24.797" video="mainVideo" id=subtitle]]
[[!template text="for people used to GUI alternatives," start="00:07:28.080" video="mainVideo" id=subtitle]]
[[!template text="but the results are impressive." start="00:07:30.817" video="mainVideo" id=subtitle]]
[[!template text="You don't have to dive too deeply to" start="00:07:32.720" video="mainVideo" id=subtitle]]
[[!template text="start using Lilypond." start="00:07:34.639" video="mainVideo" id=subtitle]]
[[!template text="Likewise, the ability to extend the software, I think," start="00:07:36.960" video="mainVideo" id=subtitle]]
[[!template text="is especially appealing for music professionals," start="00:07:39.635" video="mainVideo" id=subtitle]]
[[!template text="enthusiasts, composers, and the academic community:" start="00:07:42.400" video="mainVideo" id=subtitle]]
[[!template text="for example, allowing users to create" start="00:07:46.560" video="mainVideo" id=subtitle]]
[[!template text="alternative notation systems" start="00:07:48.400" video="mainVideo" id=subtitle]]
[[!template text="required in non-Western music traditions" start="00:07:50.187" video="mainVideo" id=subtitle]]
[[!template text="and other non-conventional requirements." start="00:07:53.120" video="mainVideo" id=subtitle]]
[[!template text="Also, Lilypond and Emacs both have" start="00:07:56.160" video="mainVideo" id=subtitle]]
[[!template text="extensive and well-written manuals" start="00:07:58.400" video="mainVideo" id=subtitle]]
[[!template text="and active communities of users." start="00:08:00.720" video="mainVideo" id=subtitle]]
[[!template text="But if you're still not sure" start="00:08:04.639" video="mainVideo" id=subtitle]]
[[!template text="where to start and when to wedge your feet in the deep but warm pond" start="00:08:05.971" video="mainVideo" id=subtitle]]
[[!template text="of lilies, Lilypond, and Lilypond users," start="00:08:10.475" video="mainVideo" id=subtitle]]
[[!template text="I invite you to contribute to my Lilypond projects," start="00:08:13.680" video="mainVideo" id=subtitle]]
[[!template text="which you can do so from the links on the screen." start="00:08:16.960" video="mainVideo" id=subtitle]]
[[!template text="So, thank you all. I look forward to your comments," start="00:08:20.720" video="mainVideo" id=subtitle]]
[[!template text="and I hope you enjoy the rest of the conference." start="00:08:23.271" video="mainVideo" id=subtitle]]