Jan 23, 2015

Update to fonts website!

I'm proud to announce a few nice updates to fonts.openlilylib.org today! I had wanted to make some changes and add a few things since the last major update and I finally got around to it. Here are the changes:
  • Updated fonts: A few fonts had "hole" artifacts from overlapping contours when using certain programs to view the glyphs (such as Inkscape, Adobe Acrobat PDF, etc.). These have now been fixed and any future use of these glyphs should result in the proper forms. Specifically, the fonts affected by this update are: Beethoven, Improviso, LilyJAZZ, Ross, and Scorlatti. If you notice any others, let me know!

  • Font stylesheets: A few minor additions to the stylesheets have been included and on each page there is now a direct link to the respective stylesheet itself for easier viewing and downloading.

  • Font viewer: I've added a convenient way to quickly look through the main glyphs in each font and compare them to others. This is what I'd wanted to do for some time and now it's finally here. Go check it out!

  • Documentation: All documentation about installation and usage that used to be on the main page has been moved to a dedicated page to keep the landing page simpler. As always, if a link is broken, I want to hear about it.
I always am trying to improve the look-and-feel of the page, so you may see some minor changes there too. Are things working on your machine/browser? Do you like the changes? Let me know in the comments!

Jan 20, 2015

Advanced Staff Grouping

Man, I love the LSR! There are so many interesting snippets there. I had to write a quick post about this one, too:

To be honest, the big orchestral brace looks a bit ugly to me (no offense to the original creators). It uses postscript code (and that's probably the point of the snippet) and requires a bunch of unnecessary \overrides. Let's clean it (and the code) up a bit!

In this snippet, a handful of useful new contexts are created to assist in grouping things together. The main contexts that already exist are: Score, GrandStaff, StaffGroup, Staff, Voice, etc. We can create new contexts by aliasing the appropriate default contexts. For example, if we want to create a "ViolinGroup", because we'd like to give a staff to the 1st and 2nd violin groups, we can do so like this:
\layout {
  \context {
    \StaffGroup
    \name ViolinGroup
    \alias StaffGroup
    systemStartDelimiter = #'SystemStartBrace
  }
}
The ViolinGroup now behaves like a StaffGroup, but with a system brace as its group indicator. The snippet goes on to similarly create a WindGroup, but uses the default system bracket as the group indicator, inheriting from StaffGroup.

Going further, we now create a StringGroup, intended for including the ViolinGroup as well as the normal Staff for the violas, cellos, and contrabasses:
\layout {
  \context {
    \StaffGroup
    \name StringGroup
    \alias StaffGroup
    \accepts ViolinGroup
    systemStartDelimiter = #'SystemStartBracket
  }
}
Since StaffGroup already \accepts the Staff context, there is no need to repeat that here, but we do need to explicitly say "\accepts ViolinGroup" since that's a custom context. The StringGroup would then need to be accepted by the context containing it (if necessary, which it is here):
\layout {
  \context {
    \StaffGroup
    \name OrchestraGroup
    \accepts WindGroup
    \accepts StringGroup
    \remove "System_start_delimiter_engraver"
  }
}
We remove the "System_start_delimiter_engraver" because we don't want it to show up right by the system itself, so we will customize this in the instrumentName variable. For this, we're going to rotate the text "Orchestra" vertically and add a large brace to show the correct grouping:
\markup { 
  \lower #0.75 \rotate #90 "Orchestra" \hspace #1
  \left-brace #175 \hspace #5
}
The extra "\hspace" commands are just to give each element a good amount of space. The last little bit of \override-ing we need to do is for the regular instrument names:
\layout {
  \context {
    \Staff
    \override InstrumentName.font-size = #-1
    \override InstrumentName.extra-offset = #'(6 . 0)
  }
}
If we didn't do these, they will show up too far-away to the system (depending on the value of "indent", of course) and to help with spacing we decrease the font-size slightly.

Those are the main building blocks we need. Here's the full updated snippet:
\version "2.18.2"
%% http://lsr.di.unimi.it/LSR/Item?id=906

% by Kieren MacMillan and P.P.Schneider.
% => http://lists.gnu.org/archive/html/lilypond-user/2013-03/msg00260.html

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LSR workaround:
#(set! paper-alist (cons '("snippet" . (cons (* 90 mm) (* 120 mm))) paper-alist))
\paper {
  #(set-paper-size "snippet")
  tagline = ##f
}

\markup \vspace #1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%here starts the snippet:

someMusic = { 
  \tempo "Andante."
  \time 3/4
  \key c \minor
  c'2. r8 
}

\paper { 
  indent = 40 
}

\layout {
  \context {
    \Staff
    \override InstrumentName.font-size = #-1
    \override InstrumentName.extra-offset = #'(6 . 0)
  }
  \context {
    \StaffGroup
    \name ViolinGroup
    \alias StaffGroup
    systemStartDelimiter = #'SystemStartBrace
  }
  \context {
    \StaffGroup
    \name WindGroup
    \alias StaffGroup
    systemStartDelimiter = #'SystemStartBracket
    \override SystemStartBracket.collapse-height = #1
  }
  \context {
    \StaffGroup
    \name StringGroup
    \alias StaffGroup
    \accepts ViolinGroup
    systemStartDelimiter = #'SystemStartBracket
  }
  \context {
    \StaffGroup
    \name OrchestraGroup
    \accepts WindGroup
    \accepts StringGroup
    \remove "System_start_delimiter_engraver"
    instrumentName = \markup { 
      \lower #0.75 \rotate #90 "Orchestra" \hspace #1
      \left-brace #175 \hspace #5
    }
  }
  \context {
    \GrandStaff
    \remove "System_start_delimiter_engraver"
    \accepts OrchestraGroup
    \accepts StaffGroup
    \accepts VocalGroup
  }
  \context {
    \StaffGroup
    \name VocalGroup
    \alias StaffGroup
    systemStartDelimiter = #'SystemStartBracket
  }
}

\score {
  \new GrandStaff <<
    \new OrchestraGroup <<
      \new WindGroup <<
        \new Staff \with { 
          instrumentName = "Oboe" 
        } \someMusic
      >>
      \new StringGroup <<
        \new ViolinGroup <<
          \new Staff \with { 
            instrumentName = "Violino I" 
          } \someMusic
          \new Staff \with { 
            instrumentName = "Violino II" 
          } \someMusic
        >>
        \new Staff \with { 
            instrumentName = "Viola" 
          } { \clef C \someMusic }
      >>
    >>
    \new VocalGroup <<
      \new Staff \with { 
       instrumentName = "Soprano" 
      } \someMusic
      \new Staff \with { 
       instrumentName = "Alto" 
      } { \clef C \someMusic }
    >>
  >>
}
What do you think? Let me know in the comments. What other contexts have you used/created before? How have you shown grouped instruments? I'd love to hear your experiences.

Jan 5, 2015

Increasing the horizontal size of a single measure

So, I couldn't help but make a small post about this when I saw it, since I've heard numerous people ask about it. In programs like Musescore, to increase/decrease the size of a measure, there's a keyboard shortcut for that. In LilyPond, since the horizontal spacing engine makes the whitespace "springy" and compressible, it's a less straightforward process. The documented ways of adjusting the horizontal spacing are found in the Notation Reference (NR), so I won't go over them here (well, maybe later).

As I was browsing through the LilyPond Snippet Repository (LSR), looking for something completely different, I stumbled upon this little trick for adjusting measure width. Unfortunately, it is only helpful for increasing the width. Let's start with a simple score:
\new Voice \relative c' {
  \dynamicUp
  << { c1 } { s2\f s2\p } >> | \noBreak
  f4 e d c | \noBreak
  << { c1 } { s2\f s2\p } >> | \noBreak
  d2 e | \break
}
The issue we'd like to remedy is the horizontal spacing given to the dynamics in the first measure, which we will adjust in the third measure for comparison. The real trick here is to use a parallel voice that contains basically no musical information, but allows us to override some dimensions. Using a MultiMeasureRest (MMR) gives us access to a property called "minimum-length". This is what we will use to force the measure to extend in length, thus creating more space for the second dynamic marking. To make it more useful, I wrapped the code within a music function that we can reuse.
extender = #(define-music-function (parser location length music) 
            (number? ly:music?)
            #{
               <<
                 { $music }
                 \new Voice {
                   \override MultiMeasureRest.transparent = ##t
                   \override MultiMeasureRest.minimum-length = #length
                   R1
                 }
               >>
             #})
This function takes two arguments. The first sets the value for "minimum-length". By definition, if the measure is already as long or longer than this value, then nothing changes. The second argument is the music expression that the spacing should apply to. There are two things to remember with this:
  1. The above code assumes the largest duration is a whole note, so you will need to change the duration of the MMR if you are using a different time signature ("R2." for 3/4 time, etc.).
  2. It's designed to extend the length of ONE measure only. Repeat as necessary.
Now, let's put it to use:
\version "2.18.2"

\paper {
  line-width = 9\cm
  indent = 0
}

extender = #(define-music-function (parser location length music) 
            (number? ly:music?)
            #{
               <<
                 { $music }
                 \new Voice {
                   \override MultiMeasureRest.transparent = ##t
                   \override MultiMeasureRest.minimum-length = #length
                   R1
                 }
               >>
             #})

\markup "Before"
\new Voice \relative c' {
  \dynamicUp
  << { c1 } { s2\f s2\p } >> | \noBreak
  f4 e d c | \noBreak
  << { c1 } { s2\f s2\p } >> | \noBreak
  d2 e | \break
}

\markup "After"
\new Voice \relative c' {
  \dynamicUp
  << { c1 } { s2\f s2\p } >> | \noBreak
  f4 e d c | \noBreak
  \extender #12 << { c1 } { s2\f s2\p } >> | \noBreak
  d2 e | \break
}


That looks better (focus is on the third measure, of course) and certainly could be adjusted further, but we'll stop there for now, having accomplished our goal.

I'm still on the lookout for a more convenient solution for "shrinking" a measure, but some of the methods in the NR (above) can help with this.

Got any other great ideas for shrinking or expanding measures to make the page look better? Share them in the comments!