summaryrefslogblamecommitdiffstats
path: root/2020/subtitles/emacsconf-2020--04-music-in-plain-text--jonathan-gregory.sbv
blob: 239cf0e36f72cd04478de702d3c358924f8d6a29 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                       
                                              

                       
                                     




                                      
              

                       
                                       

                       
                                         

                       
                                  




                                     
                   

                       
                                       

                       
                    




                                   
                              

                       
                                  

                       
                                       

                       
                                




                                        
                                       

                       
                                        

                       
                           

                       
                                 




                                 
                     




                                
            

                       
                                

                       
            

                       
                                      

                       
                                         

                       
          

                       
                                     

                       
                   

                       
                                       




                        
                                       

                       
                

                       
                                      

                       
                            

                       
                                    

                       
          

                       
                               

                       
        

                       
                                         

                       
                                   

                       
               

                       
                                  

                       
             

                       
                                    

                       
             




                                    
                               

                       
                                 

                       
                                     

                       
                                   




                                   
                  

                       
                                       

                       
                         

                       
                                       

                       
                 

                       
                                     

                       
                     

                       
                                      

                       
                               

                       
                                      

                       
                 

                       
                                      

                       
                                     




                              
                         

                       
                                     

                       
                                     

                       
                                       

                       
                              

                       
                                       

                       
                     

                       
                               




                           
                                   

                       
                             

                       
                                      

                       
                               

                       
                                 




                                       
          

                       
                                 

                       
                    

                       
                                  

                       
                                    

                       
                                         

                       
                                             

                       
                           

                       
                                     

                       
                               

                       
                                   

                       
                          

                       
                                   

                       
                                

                       
                               

                       
            

                       
                                        

                       
                         

                       
                                    

                       
                       

                       
                                       

                       
                               

                       
                                    

                       
               

                       
                               

                       
            

                       
                             

                       
                

                       
                                       




                         
                                  

                       
                                  

                       
         

                       
                                    

                       
                                         

                       
              

                       
                 

                       
                                         




                       
                          

                       
                                     

                       
            

                       
                        

                       
                          

                       
                                  

                       
                                        

                       
                                     

                       
                                  

                       
                 

                       
                                           

                       
                                  

                       
                                       

                       
                    

                       
                                        




                       
                                

                       
                                         







                                        
      

                       
                                        

                       
                             

                       
                     




                                        
                                     

                       
                                        

                       
                                   

                       
                                      




                       
                                      

                       
                                      

                       
                  

                       
                                      

                       
                                  

                       
                                    

                       
                             

                       
                                      

                       
                                     

                       
                                             

                       
                                        




                                      
             

                       
                                     

                       
                                              

                       
                                       

                       
                               

                       
                                          

                       
                                                

                       
                  

                       
                                 

                       
                                      

                       
                                        

                       
                           

                       
                                    

                       
                     

                       
                                   

                       
                                          

                       
                        

                       
                                        

                       
          

                       
                                     




                                        
                            

                       
                                        

                       
                                  




                                  
                                

                       
                                     

                       
                                             

                       
                                      

                       
               

                       
                                 

                       
                  




                                     
           

                       
                                         

                       
                                       

                       
                  
 
0:00:02.000,0:00:04.799
Hello, everyone, and welcome to the EmacsConf.

0:00:04.799,0:00:09.599
I am Jonathan. In this talk I'm going

0:00:07.200,0:00:10.880
to demonstrate ways of producing sheet

0:00:09.599,0:00:14.320
music in Emacs

0:00:10.880,0:00:18.400
using Lilypond, and maybe also convince

0:00:14.320,0:00:18.400
you to use Emacs for writing your scores.

0:00:18.640,0:00:22.240
I'll start with an overview of the

0:00:20.400,0:00:24.400
syntax for those who are new to using

0:00:22.240,0:00:26.800
text-based notation

0:00:24.400,0:00:28.800
as a shallow dive into the deep pond of

0:00:26.800,0:00:30.800
lilies and Lilypond,

0:00:28.800,0:00:32.960
and move on to showcase some of its

0:00:30.800,0:00:36.320
functionalities using Org Mode

0:00:32.960,0:00:40.480
and lilypond-mode. One disclaimer,

0:00:36.320,0:00:44.079
however: I am not a Lilypond developer.

0:00:40.480,0:00:46.800
So what is Lilypond? Lilypond is

0:00:44.079,0:00:50.000
a file format and music engraving system

0:00:46.800,0:00:52.640
for producing high-quality sheet music.

0:00:50.000,0:00:55.120
It translates textual representations of

0:00:52.640,0:00:57.760
music to graphical objects.

0:00:55.120,0:01:00.000
It's similar to LaTeX in that its

0:00:57.760,0:01:01.600
input format describes the visual

0:01:00.000,0:01:03.520
layouts of the score,

0:01:01.600,0:01:05.119
using commands to define musical

0:01:03.520,0:01:07.760
expressions.

0:01:05.119,0:01:08.640
Commands begin with a backslash.

0:01:07.760,0:01:10.479
For example,

0:01:08.640,0:01:13.040
the formatter command, as shown on the

0:01:10.479,0:01:13.920
left, yields its graphical equivalents on

0:01:13.040,0:01:16.640
the right,

0:01:13.920,0:01:19.119
the fermata symbol over the low B and

0:01:16.640,0:01:21.600
so on and so forth.

0:01:19.119,0:01:23.119
It's also fully extensible, like Emacs,

0:01:21.600,0:01:25.600
allowing users to extend

0:01:23.119,0:01:26.640
and override Lilypond's functionalities

0:01:25.600,0:01:29.840
using the Scheme

0:01:26.640,0:01:31.600
scripting language. It can be used for

0:01:29.840,0:01:34.479
early and contemporary music

0:01:31.600,0:01:35.200
tablature, vocal music lead sheets, 

0:01:34.479,0:01:38.000
and so on.

0:01:35.200,0:01:38.479
Above all, it works with Emacs.

0:01:38.000,0:01:41.040
In fact,

0:01:38.479,0:01:43.119
Lilypond ships with Emacs Lisp libraries,

0:01:41.040,0:01:45.920
including a major mode for editing 

0:01:43.119,0:01:45.920
Lilypond files.

0:01:47.360,0:01:50.560
So the input files are similar to 

0:01:50.000,0:01:52.560
source files.

0:01:50.560,0:01:54.079
They contain expressions formed with

0:01:52.560,0:01:55.840
curly braces,

0:01:54.079,0:02:00.159
comments that start with the percent

0:01:55.840,0:02:00.159
sign, and the code is indented.

0:02:00.240,0:02:05.600
Notes are entered using lowercase

0:02:02.159,0:02:08.800
letters, and rests with the letter r.

0:02:05.600,0:02:11.039
In this case, the lowercase r or r4

0:02:08.800,0:02:14.000
is the equivalence of a crotchet or

0:02:11.039,0:02:16.160
quarter note rest.

0:02:14.000,0:02:18.480
Durations are entered using numbers and

0:02:16.160,0:02:20.959
dots after the note name.

0:02:18.480,0:02:22.640
If you do not specify one, the previous

0:02:20.959,0:02:24.560
duration is used.

0:02:22.640,0:02:27.360
You can also tie notes together using

0:02:24.560,0:02:30.000
the tilde symbol (~).

0:02:27.360,0:02:32.080
In fact, you can input chords, lyrics,

0:02:30.000,0:02:33.920
embellishments, and a lot more.

0:02:32.080,0:02:36.160
I encourage you to read the manual for

0:02:33.920,0:02:39.680
more information.

0:02:36.160,0:02:42.000
Now let's switch to a terminal window.

0:02:39.680,0:02:43.840
with Lilypond installed, let's create

0:02:42.000,0:02:50.560
a test file with the extension

0:02:43.840,0:02:52.400
.ly and open it in Emacs.

0:02:50.560,0:02:54.800
At the top of the file is the version

0:02:52.400,0:02:57.440
statement, which tells Lilypond which

0:02:54.800,0:03:00.959
version to use when compiling the file.

0:02:57.440,0:03:03.680
Here I'm using version 2.20.0.

0:03:00.959,0:03:04.159
I've added the clef and time signature.

0:03:04.159,0:03:07.440
Let's add some notes.

0:03:09.280,0:03:14.560
I'm going to close this now and

0:03:12.400,0:03:19.760
compile the file by running

0:03:14.560,0:03:25.040
lilypond followed by the file name.

0:03:19.760,0:03:25.040
So now let's view the output.

0:03:27.360,0:03:32.239
Okay. So here's a more complex example

0:03:29.760,0:03:34.080
for randomizing note sequences.

0:03:32.239,0:03:36.239
The idea is to create new reading

0:03:34.080,0:03:37.760
materials each time the code blocks are

0:03:36.239,0:03:40.640
evaluated.

0:03:37.760,0:03:41.840
As usual, we begin with a header.

0:03:40.640,0:03:45.200
I've added the title

0:03:41.840,0:03:47.920
and composer. Then we add the note

0:03:45.200,0:03:50.879
sequences to use in the composition.

0:03:47.920,0:03:51.200
In this case, sn is a note name just like

0:03:51.200,0:03:54.959
a b c d and so on, and stands for snare drum,

0:03:54.959,0:03:58.239
the percussion instruments.

0:03:58.879,0:04:04.080
Now here's a function that's going to

0:04:00.720,0:04:06.560
shuffle the notes in the table.

0:04:04.080,0:04:08.799
Finally, we expand the notes inside

0:04:06.560,0:04:10.799
the Lilypond source block.

0:04:08.799,0:04:13.680
So whatever the function returns is

0:04:10.799,0:04:16.479
expanded inside the drums block.

0:04:13.680,0:04:19.120
Now let's press C-c C-c to view

0:04:16.479,0:04:19.120
the results.

0:04:20.079,0:04:26.800
Okay. And if I run this again, it should

0:04:23.280,0:04:26.800
create a new composition.

0:04:26.840,0:04:31.360
Great. You can also audition a piece

0:04:29.680,0:04:34.320
using the midi command,

0:04:31.360,0:04:36.560
which creates a midi file of the score.

0:04:34.320,0:04:39.040
Note also that the ob library--

0:04:36.560,0:04:40.400
sorry, the ob-lilypond library comes

0:04:39.040,0:04:42.560
with two modes.

0:04:40.400,0:04:43.440
The one I'm using now is called

0:04:42.560,0:04:45.440
arrange mode

0:04:43.440,0:04:47.120
and is useful for assembling 

0:04:45.440,0:04:49.360
complete scores.

0:04:47.120,0:04:51.199
The basic mode on the other hand allows

0:04:49.360,0:04:53.360
you to mix text and music

0:04:51.199,0:04:55.440
by embedding Lilypond snippets and

0:04:53.360,0:04:57.840
export them using typical Org Mode

0:04:55.440,0:04:57.840
commands.

0:05:00.240,0:05:04.320
Now to demonstrate the basic mode in

0:05:02.320,0:05:05.120
action. I'm going to export this document

0:05:04.320,0:05:08.240
to a PDF file.

0:05:05.120,0:05:10.639
In this case, the

0:05:08.240,0:05:11.919
:file header argument is required, so you

0:05:10.639,0:05:15.280
have to provide one

0:05:11.919,0:05:15.280
and include the file name.

0:05:15.600,0:05:20.479
Again, you can run the code and view 

0:05:17.919,0:05:20.479
the results.

0:05:22.160,0:05:30.080
Here it is. So now let's

0:05:25.840,0:05:30.080
export this to a PDF file.

0:05:33.680,0:05:41.440
And here it is, what it generates.

0:05:39.680,0:05:44.000
Now I'm going to show you the workflow I

0:05:41.440,0:05:46.160
used to produce music books in Emacs,

0:05:44.000,0:05:48.000
combining Lilypond and LaTeX for a

0:05:46.160,0:05:50.160
perfect marriage.

0:05:48.000,0:05:53.039
I begin by sketching the first draft of the

0:05:50.160,0:05:55.039
manuscript using pencil and paper.

0:05:53.039,0:05:57.440
Then I move to Emacs to input the notes

0:05:55.039,0:06:00.080
in a git repository.

0:05:57.440,0:06:01.360
This is a typical source file. It begins

0:06:00.080,0:06:03.199
with a stylesheet

0:06:01.360,0:06:05.440
where I set variables and layout

0:06:03.199,0:06:07.039
settings, although in general, there's no

0:06:05.440,0:06:09.280
need for tweaking the layout

0:06:07.039,0:06:11.199
unless you have specific requirements to

0:06:09.280,0:06:13.360
do so.

0:06:11.199,0:06:15.520
The easiest way to compile the file from

0:06:13.360,0:06:19.280
Emacs is by pressing C-c C-l,

0:06:15.520,0:06:21.199
so let's do this now,

0:06:19.280,0:06:23.759
and the compilation buffer will tell you

0:06:21.199,0:06:26.000
if there were any errors in the file.

0:06:23.759,0:06:28.560
Now to automate the process of compiling

0:06:26.000,0:06:31.280
several files and building the PDF,

0:06:28.560,0:06:32.560
I use GNU Make, so all I have to do is

0:06:31.280,0:06:36.000
open the shell

0:06:32.560,0:06:37.840
and run the make command. Don't worry,

0:06:36.000,0:06:40.720
I'll provide a link to the source code

0:06:37.840,0:06:40.720
on the last slide.

0:06:41.600,0:06:46.000
As I moved forward with the project, I

0:06:43.600,0:06:48.720
found at least two things missing.

0:06:46.000,0:06:50.479
One, I had no access to a metronome,

0:06:48.720,0:06:52.960
at least not from the editor,

0:06:50.479,0:06:55.919
so I built one for casual use and made

0:06:52.960,0:06:58.000
it available in the MELPA repository.

0:06:55.919,0:06:59.039
I also missed bar numbers in the source file.

0:06:59.039,0:07:03.199
This is useful when going back and forth

0:07:00.880,0:07:04.479
between input and output files without

0:07:03.199,0:07:06.720
getting lost.

0:07:04.479,0:07:08.479
So I wrote a command for toggling bar

0:07:06.720,0:07:10.000
numbers, which I hope you can see on the left.

0:07:10.000,0:07:14.160
Also, some expressions are difficult or

0:07:12.080,0:07:17.039
slow to write on the keyboard--

0:07:14.160,0:07:19.199
accents and tuplets, for example--so I use

0:07:17.039,0:07:20.160
template expansion extensively for this purpose,

0:07:20.160,0:07:23.280
mainly ya-snippet.

0:07:23.440,0:07:28.080
So what do I think? Well, I think

0:07:25.680,0:07:31.039
Lilypond can be a sharp paradigm shift

0:07:28.080,0:07:32.720
for people used to GUI alternatives, but

0:07:31.039,0:07:34.639
the results are impressive.

0:07:32.720,0:07:36.960
You don't have to dive too deeply to

0:07:34.639,0:07:38.880
start using Lilypond.

0:07:36.960,0:07:40.720
Likewise, the ability to extend the

0:07:38.880,0:07:42.400
software, I think, is especially appealing

0:07:40.720,0:07:45.199
for music professionals,

0:07:42.400,0:07:46.560
enthusiasts, composers, and the academic

0:07:45.199,0:07:48.400
community:

0:07:46.560,0:07:50.800
for example, allowing users to create

0:07:48.400,0:07:53.120
alternative notation systems required in

0:07:50.800,0:07:56.160
non-Western music traditions

0:07:53.120,0:07:58.400
and other non-conventional requirements.

0:07:56.160,0:08:00.720
Also, Lilypond and Emacs both have

0:07:58.400,0:08:04.639
extensive and well-written manuals

0:08:00.720,0:08:06.400
and active communities of users.

0:08:04.639,0:08:08.800
But if you're still not sure where to

0:08:06.400,0:08:09.599
start and when to wedge your feet in the deep

0:08:09.599,0:08:13.680
but warm pond of lilies, Lilypond, and

0:08:12.160,0:08:15.680
Lilypond users,

0:08:13.680,0:08:16.960
I invite you to contribute to my 

0:08:15.680,0:08:18.800
Lilypond projects,

0:08:16.960,0:08:20.720
which you can do so from the links on

0:08:18.800,0:08:22.800
the screen.

0:08:20.720,0:08:24.639
So, thank you all. I look forward to your

0:08:22.800,0:08:27.840
comments, and I hope you enjoy the rest

0:08:24.639,0:08:27.840
of the conference.