Dec 23, 2014

Merry Christmas!

To everyone out there, firstly, I want to wish the happiest of holidays, in whatever form you choose to celebrate. I truly hope these holidays are wonderful for each of you. It's a time to remember those that we love and the friendships we cherish. Hope the new year brings lots of great opportunities to each of you.

Last Sunday I performed my own arrangement of Oh, Come, All Ye Faithful for my local congregation. It turned out wonderfully and I certainly felt the spirit of Christmas as I sang it. My little brother, a very talented pianist, composer, arranger, improvisor, etc., accompanied me on the piano, though I wish we could have done it with the organ. If you're interested, here's the sheet music for your enjoyment. Feel free to download and use!


Dec 14, 2014

New Music Font: Sebastiano

So, I've actually had this done for a little while, but just hadn't released it yet. This new font is a OFL derivative of a (basically) non-public OFL-licensed font designed by engraver/composer Florian Kretlow (github source). It follows what I call the "inky" look, where internal corners (at least some of them) get "rounded" by what would have been caused by the capillary action of the liquid ink. Here's a sample (click to see a full-size PDF).



I think the font itself is quite nice. It has some inconsistencies that bother me a little, though. For example, the default flat symbol is thicker in the stem than inside the eyelet. The second f in the "sffz" ligature is different from the first. Having these inconsistencies doesn't make the font BAD, per se, just not to my taste.



Fortunately, in the source files, there were a bunch of other variants in his source files that were more to my liking. Here's the same score as above, but with my selected variants, as done in LilyPond.


The new font is available at fonts.openlilylib.org. Go get it! Here's a more extensive example: Grieg's Piano Concerto in A-minor, Second Movement.

Nov 12, 2014

Piano RH/LH Brackets

Sometimes when I'm playing the piano or organ (especially the organ, since I'm not that great with the pedals yet), I need to mark that a high note in the lower stave should be played with the right hand. Here's an example of this situation:
For me, the indicated note is easily reachable with the right hand. So, how do I mark it that way? Well, in the Notation Reference, in the Fingering Instructions section, I found an example of a custom fingering markup. Normally, if you want to indicate that a note be played with a particular finger you use the "-N" syntax where N=1, 2, etc., and you'd get something like this:

\relative c'' { 
  c4-1 d-2 f-4 e-3 
}
Pretty simple. If you need a more complex instruction (like a finger-substitution), we can use the built-in "\finger" macro that allows us to put in a "\markup" object:

\relative c'' {
  c4-1 d-2 f\finger \markup \tied-lyric #"4~3" c\finger "2 - 3"
}
Nice! Now, we take this a step further. I decided to create a bracket (or half-bracket, really) using some simple post-script commands within a "\markup" object:
lhMark = \markup { 
  \path #0.1 #'((moveto -1 0)(rlineto 0 1.5)(rlineto 0.5 0))
}
rhMark = \markup { 
  \path #0.1 #'((moveto -1 0)(rlineto 0 -1.5)(rlineto 0.5 0))
}
This is in the shape of an "L" and is designed to go on the LEFT side of the notehead. However, the default position is ABOVE the notehead (or chord, if it's part of one). So, in order to place it NEXT to the note, I need to change the "fingeringOrientations" property, like so:
\set fingeringOrientations = #'(left)
Putting these together, we get something like this:
\relative c {
  \clef bass
  \set fingeringOrientations = #'(left)
  <f, a'\finger \rhMark>4
}

Let's take this a step further. Suppose I now want to indicate "R.H." next to the bracket. This can be done pretty easily by using the "\concat" function within the "\markup" object, which concatenates two expressions, like this:
lhMarkText = \markup { 
  \concat {
    \override #'(font-encoding . latin1) \italic "L.H. " 
    \path #0.1 #'((moveto 0 -0.5)(rlineto 0 1.5)(rlineto 0.5 0))
  }
}
rhMarkText = \markup { 
  \concat {
    \override #'(font-encoding . latin1) \italic "R.H. " 
    \path #0.1 #'((moveto 0 1)(rlineto 0 -1.5)(rlineto 0.5 0))
  }
}

\relative c {
  \clef bass
  \set fingeringOrientations = #'(left)
  <f, a'\finger \rhMarkText>4
}
This can get even more involved if we need to actually bracket a section of a chord, but following the snippets above, we can do crazy things like this:
rhBracket = \markup { 
  \concat {
    \path #0.1 #'((moveto 0 -1.75)(rlineto 0.5 0)(rlineto 0 4.25)(rlineto -0.5 0))
    \override #'(font-encoding . latin1) \italic " RH" 
  }
}

lhBracket = \markup { 
  \concat {
    \path #0.1 #'((moveto 0 0.75)(rlineto 0.5 0)(rlineto 0 -3.25)(rlineto -0.5 0))
    \override #'(font-encoding . latin1) \lower #1.25 \italic " LH" 
  }
}

\new Staff \relative c, {
  \clef bass
  \set fingeringOrientations = #'(right)
  <e f bes\finger \lhBracket e\finger \rhBracket g b! dis>1\arpeggio 
}
There you go, all you piano/organ players! You may have to play around with the numbers (since there isn't a dedicated function to do this yet), but without too much effort, you should be able to get the job done.

If you are trying to do this and can't figure it out for your situation, send me an email.

Nov 6, 2014

Long, Broken (De-)Crescendo Text

Have you ever wondered how to create a dynamic marking like this:



I know I have, and as I was looking through the Chopin score above, I noticed this marking again, and having never tried to do it in LilyPond, I thought I'd figure it out.

In the LilyPond Notation Reference, under the Dynamics Section there's a subsection called "Changing text and spanner styles for text dynamics". In the example, it shows how you can customize the crescendo markings to be text instead of a hairpin and use your own markup text.

\relative c'' {
  \set crescendoText = \markup { \italic { cresc. poco } }
  \set crescendoSpanner = #'text
  \override DynamicTextSpanner.style = #'dotted-line
  a2\< a
  a2 a
  a2 a
  a2 a\mf
}

We can extend this further by using successive "\<" marks, which allows us to have as many bits of text as I want in the chain, except for the last one. To end the chain, it must end on a stand-alone dynamic. This can be created with:
do = \markup { \normal-text \italic do }
do = #(make-dynamic-script do)
or these operations can be combined:
do = #(make-dynamic-script (markup #:normal-text #:italic "do"))

Now, to create the broken-up crescendo (I'll leave the default dashed-line), we can do something like this:
\relative c'' {
  \set crescendoSpanner = #'text
  \set crescendoText = \markup \italic "cre"
  a2\< a 
  \set crescendoText = \markup \italic "scen"
  a2 a\<
  a2 a
  a2 a\do
}
So, all we need to do is put \set crescendoText = \markup \italic "some text" before the note or chord we want to attach it to and \< after it like we would normally do.

Nov 5, 2014

Vertically Centering Lyrics

Recently, I had to create one with a couple of verses with lyrics. Creating the lyrics is easy enough, but I quickly ran into a speed-bump when I wanted to make the chorus show up vertically centered in the same system as the verses. One way around this is to simply start a new system before the chorus lyrics show up, but I didn't want to do that. Doing a quick search through the LSR under the search term "lyrics" showed me that I could set up a series of temporary overrides and offset the vertical position of the lyrics:
dropLyrics = {
  \override LyricText.extra-offset = #'(0 . -4.5)
  \override LyricHyphen.extra-offset = #'(0 . -4.5)
  \override LyricExtender.extra-offset = #'(0 . -4.5)
  \override StanzaNumber.extra-offset = #'(0 . -4.5)
}

raiseLyrics = {
  \revert LyricText.extra-offset
  \revert LyricHyphen.extra-offset
  \revert LyricExtender.extra-offset
  \revert StanzaNumber.extra-offset
}
These two macros would then be used like this (in the first of the four verses):
lyricsA = \lyricmode {
  The first verse has
  \dropLyrics
  \set stanza = #"   All:"
  the com -- mon __ words
  \raiseLyrics
  used in all four.
}

This was exactly what I was looking for, but I felt like it needed to be a little more robust and customizable. So, with my limited knowledge of Scheme, I proceeded to make a function out of it:

dropLyrics =
  #(define-music-function (parser location x music)
     (number? ly:music?)
    #{
      \override LyricText.extra-offset = #(cons 0 x)
      \override LyricHyphen.extra-offset = #(cons 0 x)
      \override LyricExtender.extra-offset = #(cons 0 x)
      \override StanzaNumber.extra-offset = #(cons 0 x)
      $music
      \revert LyricText.extra-offset
      \revert LyricHyphen.extra-offset
      \revert LyricExtender.extra-offset
      \revert StanzaNumber.extra-offset
    #}
  )
Putting it in a function allows me to control the vertical alignment at the same location where I'm typing the text. Now, whenever I need to center a section of lyrics, all I need to do is something like this, adjusting for the proper height:
lyricsA = \lyricmode {
  The first verse has
  \dropLyrics #-4.5 {
    \set stanza = #"   All:"
    the com -- mon __ words
  }
  used in all four.
}
One thing I've learned is that centering lyrics between an odd-number of verses is as easy as including the single line of words in the middle verse while putting "\skip"s in all the others (only necessary if they pick up after the centered text like the example here). So, the above function is really only required for an even-number of verses, and only in the system where they appear together. If I put the centered text in the verse just above where I want to center it (i.e., the second verse if there are four), then I don't need to be explicit about the offset and it can be hard-coded:
dropLyrics =
  #(define-music-function (parser location music)
     (ly:music?)
    #{
      \override LyricText.extra-offset = #'(0 . -1.5)
      \override LyricHyphen.extra-offset = #'(0 . -1.5)
      \override LyricExtender.extra-offset = #'(0 . -1.5)
      \override StanzaNumber.extra-offset = #'(0 . -1.5)
      $music
      \revert LyricText.extra-offset
      \revert LyricHyphen.extra-offset
      \revert LyricExtender.extra-offset
      \revert StanzaNumber.extra-offset
    #}
  )
And to use it now, we move the centered text to the second verse and add \skipFour to the first one:
lyricsA = \lyricmode {
  The first verse has
  \skipFour
  used in all four.
}

lyricsB = \lyricmode { 
  In stan -- za two,  
  \dropLyrics {
    \set stanza = #"   All:"
    the com -- mon __ "words  "
  }
  al -- so ap -- pear. 
}
The only catch to this is that the text will only look for collisions between surrounding characters, so it may be necessary to add additional spaces to the first/last words (as I've done with "   All:" and "words  "). Maybe it would be more useful now to call the function "centerLyrics" instead, but whatever.

Nov 3, 2014

No Music Font Industry?

You may know of my involvement with designing alternative music fonts for LilyPond. Ever since I was able to get these fonts to work, I have often wondered why there aren't more music notation fonts out there. The most common seem to be:
  • Maestro (Finale)
  • Petrucci (Finale)
  • Opus (Sibelius)
  • Helsinki (Sibelius)
  • Jazz & Swing (Sigler)
  • Sonata (Adobe)
  • Bravura (Steinberg)
There are definitely others out there, but as I've looked through the various notation software, most have one, maybe two, music fonts. There is an ocean of text fonts, but not for music fonts. Why is this? I can only speculate that it is because of a couple of reasons:
  1. No common character set standard (like Unicode or ASCII). Most music fonts have followed the mnemonic approach of Sonata, like putting the treble clef in the "&" character spot, the sharp accidental in the "#" character spot, etc. Recently, Steinberg's Daniel Spreadbury has been hard at work trying to change this and create a complete music glyph standard that will support nearly any conceivable notation element, ancient and modern. This standard is called the "Standard Music Font Layout" or SMuFL. If this catches on, it could open up the door to a host of designers.
  2. A relatively small user base. Let's face it, there are more people who are going to type up a document with words in it (I'll call them "typesetters") than there are people who are going to type up a document with music in it (I'll call them "engravers"). Since the proportion of engravers to typesetters is extremely small, there doesn't appear to be the same kind of demand for original music typefaces, so high quality designers don't spend much time in it.
  3. Typeface styles/Contextual Purpose. In text, there are so many variants and they all have their own usefulness (light, book, italic, bold, black, serif, sans-serif, monospace, etc.). However, music notation has a specific utility for conveying performance instructions to musicians. The music font (as well as the rest of the score) must be clear so that the musician can play it correctly. Musicians expect this and get quite frustrated when the music is not clear. Since notational elements already vary widely in weight and shape, it is hard to find a correlation to the very many text typeface variants. In that sense, and in my experience, music fonts are MUCH easier to design because there is pretty much just the one glyph set. The only variants to be found are the text-related ones like tuplet numbers. The two main font styles that seem to exist for music fonts are "engraved" and "handwritten". The handwritten fonts tend to be associated with a "jazzy" feel, and basically everything else gets the classic engraved look. 
Well, that's all I can think of for now. Maybe the industry will change, especially as there are more and more self-publishers who may seek a less generic look for their scores. In any case, creating music fonts for LilyPond has given me a chance to contribute to the small pool of high quality music font industry. Who knows where that will lead me?

Oct 20, 2014

Let the posts begin!

Welcome to the new blog for all things LilyPond. I hope that this can be a useful place for users to come to learn little tricks and helpful hints to make life easier and more enjoyable. Why? Because LilyPond's results are absolutely incredible and gorgeous! I've used several of the most popular music notation applications and I have never saved so much time than when I stopped using them and only engraved using LilyPond. Now, that sounds pretty ruthless and there are plenty of people out there that would come back with flaming rebuttals. That's ok. If LilyPond isn't for you, then no worries! But if you are willing to try something a little different, the results will more than speak for themselves.

It can sometimes be a challenge to switch from a graphical interface, where you click on the screen or enter the music with a MIDI keyboard, to a text-based input system. The beautiful thing about this is the change in focus. LilyPond changes the effort from the tedious task of laying out what you want to see on the page to structure and description of the actual music. LilyPond's algorithms are carefully crafted to evaluate many, many different scenarios for laying out the score on the page and finally picks the best one it can find. It's not perfect and it doesn't think of everything, but it sure comes close!

As scores get more complex, then there will certainly be opportunities to tweak the position of objects on the page, but I have yet to find another piece of software that can compare to LilyPond's default output. Don't believe me? I'd love for you to provide me with a score's DEFAULT output in another notation program (i.e., no tweaks allowed) and let me score it up with LilyPond (with no tweaks). I am quite confident you will be impressed at the difference. And if there is something you don't like, there are ways to tweak the default output to suit your needs.

In the upcoming posts. I'll go through some of the basics of LilyPond syntax, leading into (hopefully) helpful tips and tricks. I'll also showcase new and upcoming music and text fonts I'm working on. Stay tuned!