From bfb6755059e69e1f48eb08f9e791fce132fdf59f Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sun, 20 Dec 2020 00:26:59 -0500 Subject: Add transcript for 04 --- 2020/info/04.md | 118 ++++++++++++++++++++++++++++++++++++++++++- 2020/organizers-notebook.org | 52 ++++++++++++++++++- 2 files changed, 168 insertions(+), 2 deletions(-) diff --git a/2020/info/04.md b/2020/info/04.md index b0cffc2d..67affc3d 100644 --- a/2020/info/04.md +++ b/2020/info/04.md @@ -2,7 +2,8 @@ Jonathan Gregory [[!template id=vid 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) +[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) +[Transcript](#transcript) LilyPond is an extensible program for producing high-quality sheet music engraved with traditional layout rules. Similar to LaTeX and @@ -61,3 +62,118 @@ No. - The contrast between background and foreground is a little too weak. - Uses LilyPond-mode, flycheck. - + + + + + +Hello, everyone, and welcome to the EmacsConf. I am Jonathan. In this +talk, I'm going to demonstrate ways of producing sheet music in Emacs +using Lilypond, and maybe also convince you to use Emacs for writing +your scores. I'll start with an overview of the syntax for those who +are new to using text-based notation as a shallow dive into the deep +pond of lilies and Lilypond, and move on to showcase some of its +functionalities using Org Mode and lilypond-mode. One disclaimer, +however: I am not a Lilypond developer. + +So what is Lilypond? Lilypond is a file format and music engraving +system for producing high-quality sheet music. It translates textual +representations of music to graphical objects. It's similar to LaTeX +in that its input format describes the visual layouts of the score, +using commands to define musical expressions. Commands begin with a +backslash. For example, the formatter command, as shown on the left, +yields its graphical equivalents on the right, the fermata symbol over +the low B and so on and so forth. It's also fully extensible, like +Emacs, allowing users to extend and override Lilypond's +functionalities using the Scheme scripting language. It can be used +for early and contemporary music tablature, vocal music lead sheets, +and so on. Above all, it works with Emacs. In fact, Lilypond ships +with Emacs Lisp libraries, including a major mode for editing Lilypond +files. + +So the input files are similar to source files. They contain +expressions formed with curly braces, comments that start with the +percent sign, and the code is indented. Notes are entered using +lowercase letters, and rests with the letter r. In this case, the +lowercase r or r4 is the equivalence of a crotchet or quarter note +rest. Durations are entered using numbers and dots after the note +name. If you do not specify one, the previous duration is used. You +can also tie notes together using the tilde symbol (~). In fact, you +can input chords, lyrics, embellishments, and a lot more. I encourage +you to read the manual for more information. Now let's switch to a +terminal window. With Lilypond installed, let's create a test file +with the extension .ly and open it in Emacs. + +At the top of the file is the version statement, which tells Lilypond +which version to use when compiling the file. Here I'm using version +2.20.0. I've added the clef and time signature. Let's add some notes. +I'm going to close this now and compile the file by running lilypond +followed by the file name. So now let's view the output. Okay. + +So here's a more complex example for randomizing note sequences. The +idea is to create new reading materials each time the code blocks are +evaluated. As usual, we begin with a header. I've added the title and +composer. Then we add the note sequences to use in the composition. In +this case, sn is a note name just like a b c d and so on, and stands +for snare drum, the percussion instruments. Now here's a function +that's going to shuffle the notes in the table. Finally, we expand the +notes inside the Lilypond source block. So whatever the function +returns is expanded inside the drums block. Now let's press C-c C-c to +view the results. Okay. And if I run this again, it should create a +new composition. Great. You can also audition a piece using the midi +command, which creates a midi file of the score. + +Note also that the ob library-- sorry, the ob-lilypond library comes +with two modes. The one I'm using now is called arrange mode and is +useful for assembling complete scores. The basic mode on the other +hand allows you to mix text and music by embedding Lilypond snippets +and export them using typical Org Mode commands. + +Now to demonstrate the basic mode in action. I'm going to export this +document to a PDF file. In this case, the :file header argument is +required, so you have to provide one and include the file name. Again, +you can run the code and view the results. Here it is. So now let's +export this to a PDF file. And here it is, what it generates. + +Now I'm going to show you the workflow I used to produce music books +in Emacs, combining Lilypond and LaTeX for a perfect marriage. I begin +by sketching the first draft of the manuscript using pencil and paper. +Then I move to Emacs to input the notes in a git repository. This is a +typical source file. It begins with a stylesheet where I set variables +and layout settings, although in general, there's no need for tweaking +the layout unless you have specific requirements to do so. The easiest +way to compile the file from Emacs is by pressing C-c C-l, so let's do +this now, and the compilation buffer will tell you if there were any +errors in the file. Now to automate the process of compiling several +files and building the PDF, I use GNU Make, so all I have to do is +open the shell and run the make command. Don't worry, I'll provide a +link to the source code on the last slide. + +As I moved forward with the project, I found at least two things +missing. One, I had no access to a metronome, at least not from the +editor, so I built one for casual use and made it available in the +MELPA repository. I also missed bar numbers in the source file. This +is useful when going back and forth between input and output files +without getting lost. So I wrote a command for toggling bar numbers, +which I hope you can see on the left. Also, some expressions are +difficult or slow to write on the keyboard-- accents and tuplets, for +example--so I use template expansion extensively for this purpose, +mainly yasnippet. + +So what do I think? Well, I think Lilypond can be a +sharp paradigm shift for people used to GUI alternatives, but the +results are impressive. You don't have to dive too deeply to start +using Lilypond. Likewise, the ability to extend the software, I think, +is especially appealing for music professionals, enthusiasts, +composers, and the academic community: for example, allowing users to +create alternative notation systems required in non-Western music +traditions and other non-conventional requirements. Also, Lilypond and +Emacs both have extensive and well-written manuals and active +communities of users. But if you're still not sure where to start and +when to wedge your feet in the deep but warm pond of lilies, Lilypond, +and Lilypond users, I invite you to contribute to my Lilypond +projects, which you can do so from the links on the screen. So, thank +you all. I look forward to your comments, and I hope you enjoy the +rest of the conference. + + diff --git a/2020/organizers-notebook.org b/2020/organizers-notebook.org index f2a1e707..142ac539 100644 --- a/2020/organizers-notebook.org +++ b/2020/organizers-notebook.org @@ -7,7 +7,8 @@ [[!toc levels=4]] #+end_export -[[elisp:(progn (org-md-export-to-markdown) (org-babel-tangle))][Export and tangle]] +- [[elisp:(progn (org-md-export-to-markdown) (org-babel-tangle))][Export and tangle]] +- [[elisp:(org-babel-execute-buffer)][Execute buffer]] * Tasks ** Manually transcribe @@ -802,6 +803,55 @@ Take advantage of provided scripts or autogenerated files and run [[file:subtitles/fix.py]] like this: =fix.py emacsconf-2020--04-music-in-plain-text--jonathan-gregory.sbv=. +*** Add transcript sections + +#+begin_src emacs-lisp :eval no :tangle no +(defvar conf/wiki-directory "~/vendor/emacsconf-wiki" "Directory that has the public conference wiki.") + +(defmacro conf/with-talk-info-file (talk &rest body) + "Evaluate BODY in the info file for TALK. +If TALK is not specified, do it in the current buffer." + (declare (indent 1)) + `(if ,talk + (with-current-buffer + (find-file-noselect + (expand-file-name (format "%d/info/%s.md" conf/year + (plist-get talk :talk-id)) + conf/wiki-directory)) + ,@body) + ,@body)) + +(defun conf/add-transcript (&optional talk) + "Try to add transcript for the current talk." + (interactive) + (conf/with-talk-info-file talk + (goto-char (point-min)) + (let (subtitles subed-auto-find-video all) + (while (re-search-forward "subtitles=\"/\\(.+?\\)\"" nil t) + (setq subtitles (cons (match-string 1 subtitles) subtitles))) + (when subtitles + (mapc + (lambda (subtitle-file) + (with-current-buffer (find-file-noselect (expand-file-name subtitle-file conf/wiki-directory)) + (goto-char (point-min)) + (subed-mode) + (let (text) + (while (subed-forward-subtitle-text) + (setq text (cons (subed-subtitle-text) text))) + (setq all (mapconcat 'identity (reverse text) "\n")))) + (if (re-search-forward (format "[ \t]*\n\\([.\r\n]*?\\)" (regexp-quote subtitle-file)) nil t) + (progn + (goto-char (match-beginning 1)) + (delete-region (match-beginning 1) (match-end 1))) + (goto-char (point-max)) + (insert (format "\n\n\n\n" subtitle-file)) + (save-excursion (insert "\n\n\n"))) + (save-excursion (insert all))) + (reverse subtitles)))))) + +;; (conf/add-transcript (conf/find-talk "03")) + +#+end_src * Other useful tidbits ** Restarting ikiwiki manually -- cgit v1.2.3