LilyPond: Music notation for everyone
lilypond.org
lilypond.org
I ended up with a collection of macros I used for common tasks. Probably the most-used was a macro that manually overrode the positioning of an element to be more visually pleasing or less confusing. Of course, it could be argued that the need for this indicates a deficiency of the engraving engine (and this was sometimes the case), but a manual final pass makes the difference between functional and professional-looking results. LilyPond's markup language made this easy.
LilyPond's test suite taught me the value of comprehensive test-driven development: every bug starts as an addition to the test suite, and a visual diff—including a numerical value indicating the amount of change—is taken of the entire suite in between versions. In this way, regressions are quickly identified.
I started a personal folk song collection using ABC notation. For simple tunes ABC is fantastic, but now that I'm doing more choral/four-part works, I'm reaching for the more powerful tool. Yet there seems to be a huge gap between ABC (simple things done simply and in one way) and LilyPond (do literally anything you want following any format you want, dropping into Scheme as necessary). Ease-of-use/quality-of-life tooling to fill that gap is appealing.
P.S. I'd also love to hear the story of your music publishing venture. It sounds intriguing!
“Compiling” Music - https://news.ycombinator.com/item?id=30625450 - March 2022 (44 comments)
Lyp – The Lilypond Swiss Army Knife - https://news.ycombinator.com/item?id=13259590 - Dec 2016 (7 comments)
Obsessed with putting ink on paper or What's wrong with computer music notation? - https://news.ycombinator.com/item?id=1515262 - July 2010 (36 comments)
Open source typesetter for sheet music - https://news.ycombinator.com/item?id=1192289 - March 2010 (23 comments)
LilyPond architecture (music notation software in Lisp) - https://news.ycombinator.com/item?id=379234 - Nov 2008 (2 comments)
I fear something automated would be too spammy for most posts.
I don't think you should bother trying to find "meaningful" threads at all, since there is no objective definition for that in context, other than "relatedness" to the current thread. I have a browser plugin that does it, it doesn't need to be that deep. Let readers decide what is meaningful to them. You can't automate everything.
Here are the files if anyone is interested to take a peek: <https://susam.net/files/music/twinkle-twinkle-little-star/>. The .ly file has the LilyPond code. The .midi and .pdf files were generated from it automatically. The .mp3 and .ogg have the audio recording of the music played manually on an electronic keyboard.
Please note that the LilyPond code might not reflect optimal or idiomatic practices, given that I was new to both music and LilyPond at that time. Nevertheless, it was very satisfying to see the polished output generated by LilyPond. I remember getting the same kind of satisfaction when I discovered LaTeX about two decades ago and realised that I could finally render mathematical formulas beautifully that look exactly how they should look.
Nerd! ... and beautifully done. The route to a partner's heart can be fraught with danger and false turns.
I've just heard the .mp3 - very nice (sorry - only nice!)
Frescobaldi is a very nice way of getting started. It generates code that you see, you can use buttons for features you don't know yet and then you can type code directly when you know it. Frescobaldi then remains useful for at least these reasons:
- midi input and output
- the rendered view and mapping between this view and the code when you click on stuff, quite like those latex IDEs
- new feature discovery. I discovered the concept of the UI that shows you what code is generated and where recently with LuCI for OpenWrt, which shows what config file is going to be updated and how; I love it and Frescobaldi has the same quality. I find it lets you get started and then master a new complex system efficiently and painlessly.
Of course I suspect I will reach for my usual text editor at some point... and maybe I need a midi input plugin for it (Kate, if anybody happens to know something about this)
Of course storing repeated notes in variable is incredibly useful, and managing different voices on the same clef is surprisingly easier than with MuseScore.
One thing I dislike is how stuff applying to several notes need to be "opened" after the first note. I needed to do such a thing to a group of notes that was also used elsewhere and storing this group of notes in a variable was only natural but then it's difficult to open something after the first note. But this is easily overcome by using an empty chord ( <> ) to start the grouping thing. Feels hacky but seems to work, I hope it doesn't have unintended consequences. I'm sure there's a very sensible reason for this that I will discover later and will make me think that it was an obvious design choice after all.
I'm not sure it's for everyone though. MuseScore is better at this, LilyPond has started being for me at a time WYSIWYG started being frustrating and when I started wishing the UI didn't get in the way of my note input (before this, I absolutely didn't want to write code to make a music sheet - just let me click already). But I'm used to code and to please compilers. Code scares a lot of people. I wish it didn't.
(c d e f g a b c)
which indeed looks more natural because resembles the way parentheses are used in mathematics and programming.
If I remember correctly, the change happened ~20 years ago because it made the notation more consistent: everything related to the note happens after the note name (durations, staccato, marcato, slurs, etc.). I remember that it took me several months to get acquainted with the new syntax.
https://github.com/vexflow/vexflow/
OpenSheetMusicDisplay is a higher-level library that uses VexFlow to render entire MusicXML documents.
https://github.com/opensheetmusicdisplay/opensheetmusicdispl...
I write relatively simple music, though, mostly lead sheets. I always imagined LilyPond would shine in more complex scoring situations.
music21: http://web.mit.edu/music21/
mingus: http://bspaans.github.io/python-mingus/index.html
abjad: https://abjad.github.io/
music-suite: https://music-suite.github.io/docs/ref/
In the end, only LilyPond was easy and intuitive to use, due to relying on text editing that you already know, instead of incomprehensible editing paradigms where weird, invisible things happen.
I was easily able to find out how to include everything I wanted in the output, like fingering indications and chord diagrams.
Dorico, in particular, is light years ahead, having an actually useable GUI while still being able to do advanced layout stuff, some of which would take hundreds of lines of custom macros in lilypond.
I can enter 100 bars in Dorico faster than I could 5 in lilypond… 10+ years ago when I was using it at least weekly.
* What type of person uses this? I guess the intersection of people interested in composing and people able to typeset? I would have thought it wasn't that popular, but it has the polish of a popular tool. What am I missing?
* Do people typically use this to compose their own music, or are they recreating music they know?
* How similar is sheet music to source code? Does any software interpret it to output audio?
* Are there any open git repos where people collaborate on an open collection of sheet music?
* How expressive is sheet music? How constrained do you feel trying to convey your idea onto this format? Does it support abstraction, or making your own abstractions?
I have a MIDI piano so I end up using the keys to input, which can be fairly quick, depending on the piece.
(and thank you for contributing to IMSLP, one of the great commons of the internet)
* I have a background in LaTeX, so that's why I picked it up. The work I transcribed is a set of six French baroque sonatas for two violins which are commonly used in intermediate-to-advanced teaching.
* At the time I did it, there was no freely available score that showed both parts on the same page, just reproductions of the original handwritten manuscript, so I did it to have a cleaner copy where you can see both parts at the same time. I had to edit slightly because it turned out the original contained a handful of errors.'
* Very similar. Lilypond started life as LaTeX macros, and while it's now well beyond that, you can see the roots. Lilypond can output MIDIs from source.
* I don't know about git repos, but there's no reason you couldn't. I did publish the source alongside the finished PDF on IMSLP (the International Music Score Library Project, a wiki of public domain music).
* For my purposes (playing European music using the 12 tones in the traditional style from Renaissance to modern, both classical and folk), perfectly expressive. I'm not sure what you mean by abstraction in this context, but if you want to do something for which there isn't common notation, you can just write words.
I would use Lilypond without hesitation if I had a new work I wanted to publish, just as I would use LaTeX to publish a book or document. It's a typesetting system, and if you're using it, you're already committed to the form of traditional European sheet music.
--I think people who play/practice musical instruments regularly, esp. in an ensemble, esp. in classical music (where the written notes are referred to a lot); to make arrangements, transcriptions, instrument parts, etc. out of the originals to perform for fun. I'dn't be surprised if programmer folks are overrepresented in this group. (I am one of them).
* How similar is sheet music to source code? Does any software interpret it to output audio?
--I'd like to say quite similar, but upon further thought, maybe not. e.g. In sheet music, there's no ready equivalent to functions taking arguments and returning values. Maybe the similarity is with compiled/machine code (which I am not familiar with).
* How expressive is sheet music? How constrained do you feel trying to convey your idea onto this format? Does it support abstraction, or making your own abstractions?
--It is quite expressive. Most musical material that people come up with in their minds will likely be adequately represented in sheet music. I haven't seen "user-defined" sheet music notation, which I think is what you may mean by abstractions. I suppose it could be done (and supported by LilyPond).
Sounds like an interesting idea for a music major somewhere. Plus, with conductor or local condition inputs, might make for entertaining sight reading. If sunny, && morning, play notes this way : If dusk || rain, play this way : play default.
I also used it to typeset a simple song that I arranged and played at a funeral service. I could have written it by hand, but given I was a bit anxious about the performance it helped to have an extremely readable version.
Writing lilypond source code is about the same difficulty as LaTeX. The midi output helps stomping out mistakes and it's easy to follow the source as it plays. Sheet music is pretty expressive, it's a good balance between showing what to play and how, and lilypond is about 1:1 with sheet music.
That said in lilypond you can add some kind of abstraction through both macros and typesetter settings. For example it can calculate automatically which frets and strings correspond to notes, and generate guitar tablature (fret+string notation) and sheet music from the same source. Also, instead of specifying by hand how to play each note, you can basically tell lilypond "I want the left hand to be roughly here on the fretboard" and that affects the strings it tells the player to pluck.
* It's not very similar to the source code. Basically you put in note names (c d e f ...) and durations (c4 e8 g8 c2). The rest is commands and markup to deal with the remaining very complex needs music typesetting has. Think Latex for music.
* I've never seen any git repos for that, but there are sites like CPDL and IMSLP that sometimes also include Lilypond source (or other sources).
* "How expressive is sheet music": I guess the easiest way to find out is to actually play an instrument or sing? It's a bit like asking "how expressive is the written word, like books and these things".
An 11 year old work still compiles just fine ...
So its main value to me is as an intermediate output format. Because its output is amazing.
(to me, an ideal music representation should be 2-dimensional, consisting of multiple parallel data and markup channels, then each rendering should be able to select a subset)
My current workflow is vscode, with a plug-in that handles auto compile and displays a PDF in an editor pane, and handles midi input from a small keyboard I've got next to my desk
Which one are you using?
https://github.com/lhl2617/VSLilyPond
Its a bit old, but works very well. I contributed a few fixes years ago to make the midi more reliable, depending on the type of keyboard you have
You're really looking for patterns on the staff rather than the exact pedantic notes that are present in the notation.
Me? Still learn best by ear. Unfortunately this is also the slowest method....
There is also the problem that human memory has limitations, and if I stop playing something, I will forget it after a couple of weeks, so again musical notation is very helpful.
> You're really looking for patterns on the staff rather than the exact pedantic notes that are present in the notation.
Exactly. Playing the exact tune becomes boring after a while; music is a fun creative exercise for me, so the notes and chords are a general direction, not a precise roadmap. If I wanted a perfect interpretation, I'd listen to the recorded piece instead of play it.
Those aren't long, around 5 minutes each.
0: https://www.youtube.com/watch?v=qLR40BGNy68
1: https://www.youtube.com/watch?v=Nc08RhOQDR4I have been working on music notation software for almost forty years and have seen programmers come and go with their attempts to "solve" the problem of music notation. It is a very difficult problem. Once upon a time SCORE [1] was considered the best of the best on music engraving software. I worked with Leland Smith to update the program to more platforms. Sadly, the SCORE source code is not available and the rights of the source code are unclear after Leland's passing. Many music publishing companies continued to maintain systems using SCORE for quite a while.
The notation engine of my iOS music notation program Komp [2] is available here: https://github.com/SemitoneGene/notation. This code is most certainly not the best or most complete, but it is easy to read and comprehend if you want to see the complexity involved. MuseScore has also been mentioned in other posts.
If I were to do a commercial engraving of a music score, I would use Dorico. It is being developed by who I would consider the most insightful and understanding group of developers who have a real desire to make the best music engraving program.
LilyPond produces very good output but offers its own series of challenges to use. MuseScore is a nice program, but it has a long way to go to meet the demands of the high professional composition and engraving market.
[1] https://en.wikipedia.org/wiki/SCORE_(software)
A somewhat ignorant TL;DR:
- It's probably not too difficult to render simple music in a bland, ugly way, in the same way that it's not too difficult to render ASCII text documents with a monospace font.
- When notation gets complicated it is tedious but somewhat routine to render music in a way that looks like total garbage: things are awkwardly smooshed together or spaced way too far apart; some symbols look "too small" alongside others when using uniform scaling; long lines that have to travel over multiple notes end up clashing and making the score unreadable; etc etc etc.
- Actually getting things right in a general-purpose musical notation program is hard hard work. I don't have any direct experience here but I am sure it's a nightmare and takes constant testing to figure all this stuff out.
I play jazz and don't fully believe in Western music notation :) So I can't speak too directly here on the intricacy. But I would highly recommend reading Knuth's TeX Book (and skimming the WEB source of TeX itself) just to get a sense of how many different decisions a typesetting / music notation program has to make.
My friend - accomplished classical musician and now pretty well known jazz musician tells me you can't write down latin music accurately. Personally I think while written language is largely about conveying a fairly unambiguous meaning, written music is really about providing enough for the player / or conductor to be able to infer what they need to do.
I work in a much more notation-bound genre (I am an orchestra bassoon player) and I would say you would struggle a LOT to notate twinkle twinkle little star in a way that makes everyone perform it the same.
It's a grueling art form, frankly, but I love it and I wouldn't do anything else.
Context: I'm Senior Product Designer for Sibelius and founder of Music Engraving Tips on Facebook/YouTube.
I originally planned to write a python script to generate Lilypond code for all the different chords I wanted, but found that Frescobaldi made it fast enough that I was able to generate them all manually. In retrospect I’m not sure the code would have panned out all that well because some of the chords needed manual fiddling.
Then I loaded them all up into Anki and have been plugging away. If not for Lilypond I probably would have made real flashcards by hand and that would have been a big ordeal by comparison.
Executable & all.