1
00:00:00,000 --> 00:00:20,520
36C3 preroll music
2
00:00:20,520 --> 00:00:24,180
Herald: Welcome back to the WikipakaWG,
3
00:00:24,180 --> 00:00:33,000
live from Congress, wir haben Lucas da,
Lucas is back, Lucas was just here 15
4
00:00:33,000 --> 00:00:40,041
minutes ago, and now he's going to talk
about LilyPond. LilyPond is like LaTeX but
5
00:00:40,041 --> 00:00:45,230
for music notes and I hope you will have
fun!
6
00:00:45,230 --> 00:00:52,390
Lucas: Yeah. Thank you. Yeah, so I just
want to talk a bit about LilyPond, which
7
00:00:52,390 --> 00:00:57,570
is a really cool program, in my opinion,
to turn basically plain text input, such
8
00:00:57,570 --> 00:01:02,100
as the code you can see up here, into
beautifully typeset musical scores, such
9
00:01:02,100 --> 00:01:07,300
as down here, and that's actually the
result of this code up here, so you can
10
00:01:07,300 --> 00:01:12,320
try to find what belongs to what or
something. And, yeah, it’s free software
11
00:01:12,320 --> 00:01:16,380
obviously, it takes plain text as input,
which means you can put the code in a git
12
00:01:16,380 --> 00:01:21,141
repository and add comments and stuff,
it's all very nice, the output is PDF, or
13
00:01:21,141 --> 00:01:25,940
MIDI if you want to listen back to it, or
you can even integrate it into LaTeX or
14
00:01:25,940 --> 00:01:30,940
Texinfo documents, such as these slides,
which are created with LaTeX beamer and
15
00:01:30,940 --> 00:01:36,330
LilyPond in them, which is really funny
combination and it works perfectly well.
16
00:01:36,330 --> 00:01:41,080
So let's just start with some of the
syntax elements in a LilyPond file, and
17
00:01:41,080 --> 00:01:45,660
it's pretty straightforward to make a note
with a certain note name, you write that
18
00:01:45,660 --> 00:01:49,450
note name, so this is (I think) the
American note names, I'm not sure if the
19
00:01:49,450 --> 00:01:55,170
English ones use different ones, but
ABCDEFGA are the note names, and you write
20
00:01:55,170 --> 00:02:00,050
the letter and you get a note in return,
and the relative mode here means that each
21
00:02:00,050 --> 00:02:04,320
note is going to be as close as possible
to the previous one, for example this A
22
00:02:04,320 --> 00:02:09,390
here at the beginning and the one at the
end, that's the same input, but you can
23
00:02:09,390 --> 00:02:13,680
see they resulted in different notes, so
this is one octave higher than the
24
00:02:13,680 --> 00:02:18,750
original one, because that's the note
that's closest to the preceding note, and
25
00:02:18,750 --> 00:02:23,250
to control the duration of a note, you put
a number after it, for example this is a
26
00:02:23,250 --> 00:02:27,311
quarter note, so you put a number four
after it, this is a sixteenth note, so you
27
00:02:27,311 --> 00:02:31,390
put a sixteen after it, and if it's a
dotted note, such like this one, you put a
28
00:02:31,390 --> 00:02:35,860
literal dot after it. So there's a fair
bit of ASCII art in there, which is kind
29
00:02:35,860 --> 00:02:40,001
of cute, and if it's more complicated,
like the triplets here at the end, you
30
00:02:40,001 --> 00:02:45,530
write something like this \tuplet, so
that's kind of inspired by LaTeX syntax,
31
00:02:45,530 --> 00:02:52,920
this backslashes and braces business, so
this started out, actually, as a – I
32
00:02:52,920 --> 00:02:56,900
assume horrible – hack to make actually
LaTeX produce these scores, and then
33
00:02:56,900 --> 00:03:00,640
eventually they realized that's not going
to work, we should actually write this as
34
00:03:00,640 --> 00:03:05,510
a dedicated program in C or C++ (I don't
remember which one), but the syntax kind
35
00:03:05,510 --> 00:03:09,610
of stayed similar, at least, in
remembrance of that. And let's go back to
36
00:03:09,610 --> 00:03:16,980
a bit more syntax, as I said, in relative
mode the notes try to stay close together,
37
00:03:16,980 --> 00:03:21,120
for example if I would just write C after
this G, it would be the upper C up here,
38
00:03:21,120 --> 00:03:25,040
because that's closer than the lower C
down here, and to get the lower C, which
39
00:03:25,040 --> 00:03:28,490
is correct in this melody (if you can
identify it that's an Easter Egg for you),
40
00:03:28,490 --> 00:03:32,860
I put a comma after it, and to then jump
back to the upper G instead of the lower
41
00:03:32,860 --> 00:03:36,720
one, I put an apostrophe after it, which
depending on the font – in this one it
42
00:03:36,720 --> 00:03:40,340
works really well, it's kind of the same
character, just at the bottom and at the
43
00:03:40,340 --> 00:03:44,410
top the line. In German the apostrophe is
also sometimes called the Hochkomma, the
44
00:03:44,410 --> 00:03:49,540
upper comma, so it kind of makes sense
that you have these two characters to jump
45
00:03:49,540 --> 00:03:53,260
up and down between octaves, and then you
start to get a feel eventually when you
46
00:03:53,260 --> 00:03:56,770
need them and when you don't need them.
But otherwise you can just compile your
47
00:03:56,770 --> 00:03:59,880
LilyPond code as often as you want and see
if it's right or not, because it doesn't
48
00:03:59,880 --> 00:04:06,370
take that long. And if you need to modify
the notes further, so if you have flat or
49
00:04:06,370 --> 00:04:12,610
sharp notes, you can teach LilyPond to
understand “G sharp”, for example, but no
50
00:04:12,610 --> 00:04:15,540
one will understand your score, because
the standard notation in LilyPond is to
51
00:04:15,540 --> 00:04:20,239
add either an -is or an -es to the end of
the note, which is exactly what these
52
00:04:20,239 --> 00:04:24,539
notes are called in German, which is very
convenient if you're German, like me – the
53
00:04:24,539 --> 00:04:28,819
manual says it's Dutch notation or
something – so fis means the F sharp, but
54
00:04:28,819 --> 00:04:32,590
what's important is, this doesn't
literally mean: put an F and then put a
55
00:04:32,590 --> 00:04:36,680
sharp right in front of it, it means,
logically, in the music, there's an F
56
00:04:36,680 --> 00:04:41,490
sharp, but then LilyPond can look, for
example here it just puts an F, because
57
00:04:41,490 --> 00:04:47,460
the F sharp is already part of the key
signature, this whole snippet is in B
58
00:04:47,460 --> 00:04:53,620
minor, so it has to have… no, it's in E
minor, sorry, so it has to have F sharp
59
00:04:53,620 --> 00:04:57,520
already and we don't need to put one here.
On the other hand, here we have an F, and
60
00:04:57,520 --> 00:05:02,379
in the syntax, in the input that's just an
F, but then LilyPond knows, because the
61
00:05:02,379 --> 00:05:07,139
key signature has an F sharp, it actually
needs to put a natural sign here to cancel
62
00:05:07,139 --> 00:05:12,240
that out. So what you put in is kind of
the logical, real music, so to speak, and
63
00:05:12,240 --> 00:05:16,240
then it's LilyPond’s job to figure out,
where do I need to put these accidentals,
64
00:05:16,240 --> 00:05:21,100
where do I need to put these natural
signs, and this depends even on which
65
00:05:21,100 --> 00:05:25,039
century’s style you're trying to emulate
and which instrument, like sometimes these
66
00:05:25,039 --> 00:05:29,630
things are in parentheses and sometimes
they're not, but in general all of this is
67
00:05:29,630 --> 00:05:34,009
LilyPond’s job, you put in just the music
and LilyPond makes a beautiful score for
68
00:05:34,009 --> 00:05:37,699
you, that's the job, at least. If that
doesn't work out, you can tweak the
69
00:05:37,699 --> 00:05:41,960
output, and here I have some… a bit
sillier tweaks, for example I wanted a
70
00:05:41,960 --> 00:05:47,289
larger note head, for some reason, and the
note head is a character in a special font
71
00:05:47,289 --> 00:05:51,949
which LilyPond ships and embeds in this
PDF file, and if I say, I would like to
72
00:05:51,949 --> 00:05:56,970
add 4 to the font size, then I get a
larger note head, at least for this one
73
00:05:56,970 --> 00:06:00,759
note. Or I can say I would like the color
of all the note heads to be in dark red
74
00:06:00,759 --> 00:06:06,530
now, or this tie, which would normally be
downwards, like this one, it should now go
75
00:06:06,530 --> 00:06:11,659
upwards, because I've overridden it here,
and I can even say – so this tie is
76
00:06:11,659 --> 00:06:15,860
actually a cubic Bezier curve, so it's
going to have four control points, and I
77
00:06:15,860 --> 00:06:20,949
would like to add these four pairs of
offsets to the four control points, to
78
00:06:20,949 --> 00:06:26,860
make this kind of looping shape – that's
obviously very silly, but sometimes this
79
00:06:26,860 --> 00:06:33,610
can be useful, like if you have a score
where you have a long… articulation bow
80
00:06:33,610 --> 00:06:36,610
(I'm not sure what it's called in English,
actually), but this kind of thing over a
81
00:06:36,610 --> 00:06:42,229
long period of notes, where it makes like
a Z shape or an S shape, and LilyPond
82
00:06:42,229 --> 00:06:45,939
can't figure that out by itself, then you
can tell it, I would like the curve to
83
00:06:45,939 --> 00:06:51,539
look exactly like this, and kind of tweak
the output as much as you want. And you
84
00:06:51,539 --> 00:06:55,599
can actually go even further than this –
does anyone in the audience recognize this
85
00:06:55,599 --> 00:07:01,389
kind of syntax here? This kind of –
(audience member: Lisp!) Yes! Lisp, it is
86
00:07:01,389 --> 00:07:04,999
a dialect of Lisp called Scheme, so you
can embed whole Scheme programs in your
87
00:07:04,999 --> 00:07:09,370
score, so here I've said the color of each
stem should be controlled by this lambda,
88
00:07:09,370 --> 00:07:13,030
this anonymous function, which takes a
graphical object, in this case that's
89
00:07:13,030 --> 00:07:17,919
going to be the stem, and compare the
direction of that to “up”, if it's “up”,
90
00:07:17,919 --> 00:07:22,740
then return red, otherwise return blue, so
now I have a score where all the stems are
91
00:07:22,740 --> 00:07:27,439
blue if they point down and red if they
point up, which is completely pointless,
92
00:07:27,439 --> 00:07:34,440
but it's very funny. And you can go much
further than this, like, this is some
93
00:07:34,440 --> 00:07:37,699
monstrosity I wrote because I wanted to
have this score, where you can see, in the
94
00:07:37,699 --> 00:07:44,169
right hand, here, you have the same notes
twice, once in the baseline and then one
95
00:07:44,169 --> 00:07:48,360
octave higher, and it's just always one
octave higher, and for some reason I could
96
00:07:48,360 --> 00:07:53,229
not be bothered to actually add the second
note to each of the eight chords here,
97
00:07:53,229 --> 00:07:57,559
which would have taken, like, two minutes
at most, and instead I spent, like, one
98
00:07:57,559 --> 00:08:03,059
and a half hours putting together this
code, which takes an arbitrary melody and
99
00:08:03,059 --> 00:08:09,650
goes through it and for each note creates
a copied note which is somewhere here,
100
00:08:09,650 --> 00:08:14,779
yeah, it creates a copy of the note, then
sets the pitch to something else and
101
00:08:14,779 --> 00:08:18,669
copies some of the articulations but not
others, so this has a second tie here but
102
00:08:18,669 --> 00:08:22,449
it should not have a second fermata sign,
and in the end you have this function and
103
00:08:22,449 --> 00:08:28,740
you can even put it on StackOverflow or
something, and that kind of represents
104
00:08:28,740 --> 00:08:33,029
what I really like about LilyPond, that it
represents this whole spectrum between
105
00:08:33,029 --> 00:08:37,659
just simple music transcription and full-
blown programming, so if I get home at the
106
00:08:37,659 --> 00:08:41,349
end of the day, and I'm really tired and
don't have much mental capacity, I can
107
00:08:41,349 --> 00:08:45,490
just take some public domain score and
transcribe it and just say, this is a D,
108
00:08:45,490 --> 00:08:49,740
this is an F sharp, this is a quarter
note, and so on, and it doesn't take much
109
00:08:49,740 --> 00:08:53,910
work, but if I want, if I feel up to it or
if I want to have some fun, then I can
110
00:08:53,910 --> 00:08:57,790
also do the whole programming thing and
write monsters like this and completely
111
00:08:57,790 --> 00:09:02,280
bend the score to my will, make it look
exactly how I want to, and that's what I
112
00:09:02,280 --> 00:09:07,280
find really neat about LilyPond, and if
you want to find out more about that,
113
00:09:07,280 --> 00:09:10,720
there are two manuals here, they're really
well written, I basically read them front
114
00:09:10,720 --> 00:09:14,520
to back a while ago, and they have lots of
examples as well. The LilyPond snippet
115
00:09:14,520 --> 00:09:19,260
repository is even cooler, it's just a
huge collection of tiny snippets of
116
00:09:19,260 --> 00:09:23,180
LilyPond code, and all of them are CC0, so
you can use them however you want without
117
00:09:23,180 --> 00:09:26,610
worrying about attribution or anything,
and you can even try it out in your
118
00:09:26,610 --> 00:09:30,540
browser, on lilybin.com, without
installing anything, and if you're
119
00:09:30,540 --> 00:09:33,890
wondering, “wait, doesn't that mean I'm
running arbitrary code on someone else's
120
00:09:33,890 --> 00:09:39,810
computer?” – it's not my computer,… I
don't know, knock yourself out, I guess,
121
00:09:39,810 --> 00:09:44,280
but that's all I have already, I'm out of
time, but thank you for indulging me!
122
00:09:44,280 --> 00:09:46,120
applause
123
00:09:46,120 --> 00:09:59,480
postroll music
124
00:09:59,480 --> 00:10:13,000
Subtitles created by c3subtitles.de
in the year 2020. Join, and help us!