0:00:00.000,0:00:20.520
36C3 preroll music
0:00:20.520,0:00:24.180
Herald: Welcome back to the WikipakaWG,
0:00:24.180,0:00:33.000
live from Congress, wir haben Lucas da,[br]Lucas is back, Lucas was just here 15
0:00:33.000,0:00:40.041
minutes ago, and now he's going to talk[br]about LilyPond. LilyPond is like LaTeX but
0:00:40.041,0:00:45.230
for music notes and I hope you will have[br]fun!
0:00:45.230,0:00:52.390
Lucas: Yeah. Thank you. Yeah, so I just[br]want to talk a bit about LilyPond, which
0:00:52.390,0:00:57.570
is a really cool program, in my opinion,[br]to turn basically plain text input, such
0:00:57.570,0:01:02.100
as the code you can see up here, into[br]beautifully typeset musical scores, such
0:01:02.100,0:01:07.300
as down here, and that's actually the[br]result of this code up here, so you can
0:01:07.300,0:01:12.320
try to find what belongs to what or[br]something. And, yeah, it’s free software
0:01:12.320,0:01:16.380
obviously, it takes plain text as input,[br]which means you can put the code in a git
0:01:16.380,0:01:21.141
repository and add comments and stuff,[br]it's all very nice, the output is PDF, or
0:01:21.141,0:01:25.940
MIDI if you want to listen back to it, or[br]you can even integrate it into LaTeX or
0:01:25.940,0:01:30.940
Texinfo documents, such as these slides,[br]which are created with LaTeX beamer and
0:01:30.940,0:01:36.330
LilyPond in them, which is really funny[br]combination and it works perfectly well.
0:01:36.330,0:01:41.080
So let's just start with some of the[br]syntax elements in a LilyPond file, and
0:01:41.080,0:01:45.660
it's pretty straightforward to make a note[br]with a certain note name, you write that
0:01:45.660,0:01:49.450
note name, so this is (I think) the[br]American note names, I'm not sure if the
0:01:49.450,0:01:55.170
English ones use different ones, but[br]ABCDEFGA are the note names, and you write
0:01:55.170,0:02:00.050
the letter and you get a note in return,[br]and the relative mode here means that each
0:02:00.050,0:02:04.320
note is going to be as close as possible[br]to the previous one, for example this A
0:02:04.320,0:02:09.390
here at the beginning and the one at the[br]end, that's the same input, but you can
0:02:09.390,0:02:13.680
see they resulted in different notes, so[br]this is one octave higher than the
0:02:13.680,0:02:18.750
original one, because that's the note[br]that's closest to the preceding note, and
0:02:18.750,0:02:23.250
to control the duration of a note, you put[br]a number after it, for example this is a
0:02:23.250,0:02:27.311
quarter note, so you put a number four[br]after it, this is a sixteenth note, so you
0:02:27.311,0:02:31.390
put a sixteen after it, and if it's a[br]dotted note, such like this one, you put a
0:02:31.390,0:02:35.860
literal dot after it. So there's a fair[br]bit of ASCII art in there, which is kind
0:02:35.860,0:02:40.001
of cute, and if it's more complicated,[br]like the triplets here at the end, you
0:02:40.001,0:02:45.530
write something like this \tuplet, so[br]that's kind of inspired by LaTeX syntax,
0:02:45.530,0:02:52.920
this backslashes and braces business, so[br]this started out, actually, as a – I
0:02:52.920,0:02:56.900
assume horrible – hack to make actually[br]LaTeX produce these scores, and then
0:02:56.900,0:03:00.640
eventually they realized that's not going[br]to work, we should actually write this as
0:03:00.640,0:03:05.510
a dedicated program in C or C++ (I don't[br]remember which one), but the syntax kind
0:03:05.510,0:03:09.610
of stayed similar, at least, in[br]remembrance of that. And let's go back to
0:03:09.610,0:03:16.980
a bit more syntax, as I said, in relative[br]mode the notes try to stay close together,
0:03:16.980,0:03:21.120
for example if I would just write C after[br]this G, it would be the upper C up here,
0:03:21.120,0:03:25.040
because that's closer than the lower C[br]down here, and to get the lower C, which
0:03:25.040,0:03:28.490
is correct in this melody (if you can[br]identify it that's an Easter Egg for you),
0:03:28.490,0:03:32.860
I put a comma after it, and to then jump[br]back to the upper G instead of the lower
0:03:32.860,0:03:36.720
one, I put an apostrophe after it, which[br]depending on the font – in this one it
0:03:36.720,0:03:40.340
works really well, it's kind of the same[br]character, just at the bottom and at the
0:03:40.340,0:03:44.410
top the line. In German the apostrophe is[br]also sometimes called the Hochkomma, the
0:03:44.410,0:03:49.540
upper comma, so it kind of makes sense[br]that you have these two characters to jump
0:03:49.540,0:03:53.260
up and down between octaves, and then you[br]start to get a feel eventually when you
0:03:53.260,0:03:56.770
need them and when you don't need them.[br]But otherwise you can just compile your
0:03:56.770,0:03:59.880
LilyPond code as often as you want and see[br]if it's right or not, because it doesn't
0:03:59.880,0:04:06.370
take that long. And if you need to modify[br]the notes further, so if you have flat or
0:04:06.370,0:04:12.610
sharp notes, you can teach LilyPond to[br]understand “G sharp”, for example, but no
0:04:12.610,0:04:15.540
one will understand your score, because[br]the standard notation in LilyPond is to
0:04:15.540,0:04:20.239
add either an -is or an -es to the end of[br]the note, which is exactly what these
0:04:20.239,0:04:24.539
notes are called in German, which is very[br]convenient if you're German, like me – the
0:04:24.539,0:04:28.819
manual says it's Dutch notation or[br]something – so fis means the F sharp, but
0:04:28.819,0:04:32.590
what's important is, this doesn't[br]literally mean: put an F and then put a
0:04:32.590,0:04:36.680
sharp right in front of it, it means,[br]logically, in the music, there's an F
0:04:36.680,0:04:41.490
sharp, but then LilyPond can look, for[br]example here it just puts an F, because
0:04:41.490,0:04:47.460
the F sharp is already part of the key[br]signature, this whole snippet is in B
0:04:47.460,0:04:53.620
minor, so it has to have… no, it's in E[br]minor, sorry, so it has to have F sharp
0:04:53.620,0:04:57.520
already and we don't need to put one here.[br]On the other hand, here we have an F, and
0:04:57.520,0:05:02.379
in the syntax, in the input that's just an[br]F, but then LilyPond knows, because the
0:05:02.379,0:05:07.139
key signature has an F sharp, it actually[br]needs to put a natural sign here to cancel
0:05:07.139,0:05:12.240
that out. So what you put in is kind of[br]the logical, real music, so to speak, and
0:05:12.240,0:05:16.240
then it's LilyPond’s job to figure out,[br]where do I need to put these accidentals,
0:05:16.240,0:05:21.100
where do I need to put these natural[br]signs, and this depends even on which
0:05:21.100,0:05:25.039
century’s style you're trying to emulate[br]and which instrument, like sometimes these
0:05:25.039,0:05:29.630
things are in parentheses and sometimes[br]they're not, but in general all of this is
0:05:29.630,0:05:34.009
LilyPond’s job, you put in just the music[br]and LilyPond makes a beautiful score for
0:05:34.009,0:05:37.699
you, that's the job, at least. If that[br]doesn't work out, you can tweak the
0:05:37.699,0:05:41.960
output, and here I have some… a bit[br]sillier tweaks, for example I wanted a
0:05:41.960,0:05:47.289
larger note head, for some reason, and the[br]note head is a character in a special font
0:05:47.289,0:05:51.949
which LilyPond ships and embeds in this[br]PDF file, and if I say, I would like to
0:05:51.949,0:05:56.970
add 4 to the font size, then I get a[br]larger note head, at least for this one
0:05:56.970,0:06:00.759
note. Or I can say I would like the color[br]of all the note heads to be in dark red
0:06:00.759,0:06:06.530
now, or this tie, which would normally be[br]downwards, like this one, it should now go
0:06:06.530,0:06:11.659
upwards, because I've overridden it here,[br]and I can even say – so this tie is
0:06:11.659,0:06:15.860
actually a cubic Bezier curve, so it's[br]going to have four control points, and I
0:06:15.860,0:06:20.949
would like to add these four pairs of[br]offsets to the four control points, to
0:06:20.949,0:06:26.860
make this kind of looping shape – that's[br]obviously very silly, but sometimes this
0:06:26.860,0:06:33.610
can be useful, like if you have a score[br]where you have a long… articulation bow
0:06:33.610,0:06:36.610
(I'm not sure what it's called in English,[br]actually), but this kind of thing over a
0:06:36.610,0:06:42.229
long period of notes, where it makes like[br]a Z shape or an S shape, and LilyPond
0:06:42.229,0:06:45.939
can't figure that out by itself, then you[br]can tell it, I would like the curve to
0:06:45.939,0:06:51.539
look exactly like this, and kind of tweak[br]the output as much as you want. And you
0:06:51.539,0:06:55.599
can actually go even further than this –[br]does anyone in the audience recognize this
0:06:55.599,0:07:01.389
kind of syntax here? This kind of –[br](audience member: Lisp!) Yes! Lisp, it is
0:07:01.389,0:07:04.999
a dialect of Lisp called Scheme, so you[br]can embed whole Scheme programs in your
0:07:04.999,0:07:09.370
score, so here I've said the color of each[br]stem should be controlled by this lambda,
0:07:09.370,0:07:13.030
this anonymous function, which takes a[br]graphical object, in this case that's
0:07:13.030,0:07:17.919
going to be the stem, and compare the[br]direction of that to “up”, if it's “up”,
0:07:17.919,0:07:22.740
then return red, otherwise return blue, so[br]now I have a score where all the stems are
0:07:22.740,0:07:27.439
blue if they point down and red if they[br]point up, which is completely pointless,
0:07:27.439,0:07:34.440
but it's very funny. And you can go much[br]further than this, like, this is some
0:07:34.440,0:07:37.699
monstrosity I wrote because I wanted to[br]have this score, where you can see, in the
0:07:37.699,0:07:44.169
right hand, here, you have the same notes[br]twice, once in the baseline and then one
0:07:44.169,0:07:48.360
octave higher, and it's just always one[br]octave higher, and for some reason I could
0:07:48.360,0:07:53.229
not be bothered to actually add the second[br]note to each of the eight chords here,
0:07:53.229,0:07:57.559
which would have taken, like, two minutes[br]at most, and instead I spent, like, one
0:07:57.559,0:08:03.059
and a half hours putting together this[br]code, which takes an arbitrary melody and
0:08:03.059,0:08:09.650
goes through it and for each note creates[br]a copied note which is somewhere here,
0:08:09.650,0:08:14.779
yeah, it creates a copy of the note, then[br]sets the pitch to something else and
0:08:14.779,0:08:18.669
copies some of the articulations but not[br]others, so this has a second tie here but
0:08:18.669,0:08:22.449
it should not have a second fermata sign,[br]and in the end you have this function and
0:08:22.449,0:08:28.740
you can even put it on StackOverflow or[br]something, and that kind of represents
0:08:28.740,0:08:33.029
what I really like about LilyPond, that it[br]represents this whole spectrum between
0:08:33.029,0:08:37.659
just simple music transcription and full-[br]blown programming, so if I get home at the
0:08:37.659,0:08:41.349
end of the day, and I'm really tired and[br]don't have much mental capacity, I can
0:08:41.349,0:08:45.490
just take some public domain score and[br]transcribe it and just say, this is a D,
0:08:45.490,0:08:49.740
this is an F sharp, this is a quarter[br]note, and so on, and it doesn't take much
0:08:49.740,0:08:53.910
work, but if I want, if I feel up to it or[br]if I want to have some fun, then I can
0:08:53.910,0:08:57.790
also do the whole programming thing and[br]write monsters like this and completely
0:08:57.790,0:09:02.280
bend the score to my will, make it look[br]exactly how I want to, and that's what I
0:09:02.280,0:09:07.280
find really neat about LilyPond, and if[br]you want to find out more about that,
0:09:07.280,0:09:10.720
there are two manuals here, they're really[br]well written, I basically read them front
0:09:10.720,0:09:14.520
to back a while ago, and they have lots of[br]examples as well. The LilyPond snippet
0:09:14.520,0:09:19.260
repository is even cooler, it's just a[br]huge collection of tiny snippets of
0:09:19.260,0:09:23.180
LilyPond code, and all of them are CC0, so[br]you can use them however you want without
0:09:23.180,0:09:26.610
worrying about attribution or anything,[br]and you can even try it out in your
0:09:26.610,0:09:30.540
browser, on lilybin.com, without[br]installing anything, and if you're
0:09:30.540,0:09:33.890
wondering, “wait, doesn't that mean I'm[br]running arbitrary code on someone else's
0:09:33.890,0:09:39.810
computer?” – it's not my computer,… I[br]don't know, knock yourself out, I guess,
0:09:39.810,0:09:44.280
but that's all I have already, I'm out of[br]time, but thank you for indulging me!
0:09:44.280,0:09:46.120
applause
0:09:46.120,0:09:59.480
postroll music
0:09:59.480,0:10:13.000
Subtitles created by c3subtitles.de[br]in the year 2020. Join, and help us!