WEBVTT 00:00:00.000 --> 00:00:20.520 36C3 preroll music 00:00:20.520 --> 00:00:24.180 Herald: Welcome back to the WikipakaWG, 00:00:24.180 --> 00:00:33.000 live from Congress, wir haben Lucas da, Lucas is back, Lucas was just here 15 00:00:33.000 --> 00:00:40.041 minutes ago, and now he's going to talk about LilyPond. LilyPond is like LaTeX but 00:00:40.041 --> 00:00:45.230 for music notes and I hope you will have fun! 00:00:45.230 --> 00:00:52.390 Lucas: Yeah. Thank you. Yeah, so I just want to talk a bit about LilyPond, which 00:00:52.390 --> 00:00:57.570 is a really cool program, in my opinion, to turn basically plain text input, such 00:00:57.570 --> 00:01:02.100 as the code you can see up here, into beautifully typeset musical scores, such 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 00:01:07.300 --> 00:01:12.320 try to find what belongs to what or something. And, yeah, it’s free software 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 00:01:16.380 --> 00:01:21.141 repository and add comments and stuff, it's all very nice, the output is PDF, or 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 00:01:25.940 --> 00:01:30.940 Texinfo documents, such as these slides, which are created with LaTeX beamer and 00:01:30.940 --> 00:01:36.330 LilyPond in them, which is really funny combination and it works perfectly well. 00:01:36.330 --> 00:01:41.080 So let's just start with some of the syntax elements in a LilyPond file, and 00:01:41.080 --> 00:01:45.660 it's pretty straightforward to make a note with a certain note name, you write that 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 00:01:49.450 --> 00:01:55.170 English ones use different ones, but ABCDEFGA are the note names, and you write 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 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 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 00:02:09.390 --> 00:02:13.680 see they resulted in different notes, so this is one octave higher than the 00:02:13.680 --> 00:02:18.750 original one, because that's the note that's closest to the preceding note, and 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 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 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 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 00:02:35.860 --> 00:02:40.001 of cute, and if it's more complicated, like the triplets here at the end, you 00:02:40.001 --> 00:02:45.530 write something like this \tuplet, so that's kind of inspired by LaTeX syntax, 00:02:45.530 --> 00:02:52.920 this backslashes and braces business, so this started out, actually, as a – I 00:02:52.920 --> 00:02:56.900 assume horrible – hack to make actually LaTeX produce these scores, and then 00:02:56.900 --> 00:03:00.640 eventually they realized that's not going to work, we should actually write this as 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 00:03:05.510 --> 00:03:09.610 of stayed similar, at least, in remembrance of that. And let's go back to 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, 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, 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 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), 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 00:03:32.860 --> 00:03:36.720 one, I put an apostrophe after it, which depending on the font – in this one it 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 00:03:40.340 --> 00:03:44.410 top the line. In German the apostrophe is also sometimes called the Hochkomma, the 00:03:44.410 --> 00:03:49.540 upper comma, so it kind of makes sense that you have these two characters to jump 00:03:49.540 --> 00:03:53.260 up and down between octaves, and then you start to get a feel eventually when you 00:03:53.260 --> 00:03:56.770 need them and when you don't need them. But otherwise you can just compile your 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 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 00:04:06.370 --> 00:04:12.610 sharp notes, you can teach LilyPond to understand “G sharp”, for example, but no 00:04:12.610 --> 00:04:15.540 one will understand your score, because the standard notation in LilyPond is to 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 00:04:20.239 --> 00:04:24.539 notes are called in German, which is very convenient if you're German, like me – the 00:04:24.539 --> 00:04:28.819 manual says it's Dutch notation or something – so fis means the F sharp, but 00:04:28.819 --> 00:04:32.590 what's important is, this doesn't literally mean: put an F and then put a 00:04:32.590 --> 00:04:36.680 sharp right in front of it, it means, logically, in the music, there's an F 00:04:36.680 --> 00:04:41.490 sharp, but then LilyPond can look, for example here it just puts an F, because 00:04:41.490 --> 00:04:47.460 the F sharp is already part of the key signature, this whole snippet is in B 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 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 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 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 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 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, 00:05:16.240 --> 00:05:21.100 where do I need to put these natural signs, and this depends even on which 00:05:21.100 --> 00:05:25.039 century’s style you're trying to emulate and which instrument, like sometimes these 00:05:25.039 --> 00:05:29.630 things are in parentheses and sometimes they're not, but in general all of this is 00:05:29.630 --> 00:05:34.009 LilyPond’s job, you put in just the music and LilyPond makes a beautiful score for 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 00:05:37.699 --> 00:05:41.960 output, and here I have some… a bit sillier tweaks, for example I wanted a 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 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 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 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 00:06:00.759 --> 00:06:06.530 now, or this tie, which would normally be downwards, like this one, it should now go 00:06:06.530 --> 00:06:11.659 upwards, because I've overridden it here, and I can even say – so this tie is 00:06:11.659 --> 00:06:15.860 actually a cubic Bezier curve, so it's going to have four control points, and I 00:06:15.860 --> 00:06:20.949 would like to add these four pairs of offsets to the four control points, to 00:06:20.949 --> 00:06:26.860 make this kind of looping shape – that's obviously very silly, but sometimes this 00:06:26.860 --> 00:06:33.610 can be useful, like if you have a score where you have a long… articulation bow 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 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 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 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 00:06:51.539 --> 00:06:55.599 can actually go even further than this – does anyone in the audience recognize this 00:06:55.599 --> 00:07:01.389 kind of syntax here? This kind of – (audience member: Lisp!) Yes! Lisp, it is 00:07:01.389 --> 00:07:04.999 a dialect of Lisp called Scheme, so you can embed whole Scheme programs in your 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, 00:07:09.370 --> 00:07:13.030 this anonymous function, which takes a graphical object, in this case that's 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”, 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 00:07:22.740 --> 00:07:27.439 blue if they point down and red if they point up, which is completely pointless, 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 00:07:34.440 --> 00:07:37.699 monstrosity I wrote because I wanted to have this score, where you can see, in the 00:07:37.699 --> 00:07:44.169 right hand, here, you have the same notes twice, once in the baseline and then one 00:07:44.169 --> 00:07:48.360 octave higher, and it's just always one octave higher, and for some reason I could 00:07:48.360 --> 00:07:53.229 not be bothered to actually add the second note to each of the eight chords here, 00:07:53.229 --> 00:07:57.559 which would have taken, like, two minutes at most, and instead I spent, like, one 00:07:57.559 --> 00:08:03.059 and a half hours putting together this code, which takes an arbitrary melody and 00:08:03.059 --> 00:08:09.650 goes through it and for each note creates a copied note which is somewhere here, 00:08:09.650 --> 00:08:14.779 yeah, it creates a copy of the note, then sets the pitch to something else and 00:08:14.779 --> 00:08:18.669 copies some of the articulations but not others, so this has a second tie here but 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 00:08:22.449 --> 00:08:28.740 you can even put it on StackOverflow or something, and that kind of represents 00:08:28.740 --> 00:08:33.029 what I really like about LilyPond, that it represents this whole spectrum between 00:08:33.029 --> 00:08:37.659 just simple music transcription and full- blown programming, so if I get home at the 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 00:08:41.349 --> 00:08:45.490 just take some public domain score and transcribe it and just say, this is a D, 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 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 00:08:53.910 --> 00:08:57.790 also do the whole programming thing and write monsters like this and completely 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 00:09:02.280 --> 00:09:07.280 find really neat about LilyPond, and if you want to find out more about that, 00:09:07.280 --> 00:09:10.720 there are two manuals here, they're really well written, I basically read them front 00:09:10.720 --> 00:09:14.520 to back a while ago, and they have lots of examples as well. The LilyPond snippet 00:09:14.520 --> 00:09:19.260 repository is even cooler, it's just a huge collection of tiny snippets of 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 00:09:23.180 --> 00:09:26.610 worrying about attribution or anything, and you can even try it out in your 00:09:26.610 --> 00:09:30.540 browser, on lilybin.com, without installing anything, and if you're 00:09:30.540 --> 00:09:33.890 wondering, “wait, doesn't that mean I'm running arbitrary code on someone else's 00:09:33.890 --> 00:09:39.810 computer?” – it's not my computer,… I don't know, knock yourself out, I guess, 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! 00:09:44.280 --> 00:09:46.120 applause 00:09:46.120 --> 00:09:59.480 postroll music 00:09:59.480 --> 00:10:13.000 Subtitles created by c3subtitles.de in the year 2020. Join, and help us!