Independent Meters

Nearly a year ago a post on the Finale Blog triggered a short series of posts about programmatically generating polymetric notation with LilyPond. Now it happened again, but this time with some indignation behind it. Last week I saw a post about Brian Ferneyhough visiting MakeMusic with a comment asking for “a neat way to have bar lines and meters happen by instrument”. I wrote a short comment pointing to my previously mentioned article on Scores of Beauty (although it only shows half of that wish) – and what do you think? My comment was “awaiting moderation” (the normal procedure), but apparently they decided not to “approve” it 🙁 .

I think that really stinks. While my comment of course wasn’t the type one wants to have on one’s blog, I consider it somewhat pitiful to use the tool of moderation to sweep a “minority report” under the carpet. On Scores of Beauty we only discard real spam, that is (mostly) offers to increase our web traffic or to buy cheap expensive watches etc.

Therefore I felt obliged to write a full (albeit rather short) post about yet another field where Lilypond clearly surpasses Finale: the rock solid rhythmic (re)presentation of the music, which is one of the more interesting strengths of LilyPond.

Independent meters, same measure length

OK, the request is “a neat way to have bar lines and meters happen by instrument”. This is dead simple with LilyPond and you’ll find it in the Notation Reference by following Musical Notation->Rhythms->Displaying Rhythms->Polymetric Notation or going there directly. We’ll start with the simpler case: independent meters with measures of the same length. All you need to do is to change the displayed time signature and stretch the music accordingly:

\time 4/4
\set Staff.timeSignatureFraction = 9/8
\scaleDurations 8/9 { 
  % ... music ...
}

This will set the effective time signature to 4/4, display a 9/8 instead and scale the music expression so that an entered amount of nine eighth notes (quavers) will be condensed to one whole note (semibreve). If you do this on different staves you can very easily write music like this:

same-length-polymetrics

So letting “meters happen per instrument” is actually a breeze with LilyPond. This approach is not only simple but also unintrusive: without affecting the score structure you can easily modify any given snippet of the music. But as everything in life this simplicity comes at a (small) cost: as LilyPond is typesetting music outside the effective time signature it can’t perform automatic beaming anymore, at least not in a reliable manner. So you’d have to expect doing the beams manually. If that’s a problem for you you can follow me to the (slightly) more involved approach.
[Edit: There is a solution for this problem in LilyPond, see Simon’s comment below]

Independent barlines

Timing in LilyPond is managed by something called the Timing_translator while the automatic barlines are engraved by the Default_bar_line_engraver – which live by default in the Score context. Usually you don’t see this at all, but when you want to have independent barlines you can simply tell LilyPond not to let timing be managed globally in the score but individually in the staves. Simply add this (to a) \layout block:

\layout {
  \context {
    \Score
    \remove "Timing_translator"
    \remove "Default_bar_line_engraver"
  }
  \context {
    \Staff
    \consists "Timing_translator"
    \consists "Default_bar_line_engraver"
  }
}

Now you can easily typeset this example (from the Notation Reference):

different-length-polymetrics

As you can see all simultaneous notes are perfectly aligned automatically.

Throwing it all together

Since using uncommon time signatures (like 4/20) is built-in to LilyPond and using \compoundMeter gives you easy access to all kinds of complicated time signatures, it’s easy to typeset virtually any complex rhythmic combination, for example:

(Click for full-size PDF)

(Click for full-size PDF)

You’ll notice the irregularities in the horizontal spacing, but these can’t reasonably be avoided. LilyPond ensures that the voices are perfectly aligned against each other and therefore it has to give some space to accomodate the time signatures in the other staves. You could probably tweak that to create better individual spacing by compromising the alignment, but this will probably become quite awkward. Awkward because it’s against the musical structure, not because the tool is lacking skills.

Please note that I didn’t make use of the first approach outlined above because stretching time that way would inevitably lead to ambiguity when barlines are not aligned anymore. LilyPond would effortlessly handle that too, but it simply wouldn’t make sense musically. If you want to see how that’s achieved you can inspect the LilyPond source.

Just try doing this kind of thing with Finale 🙂


[Edit]
I couldn’t resist spicing up the example even more. While I deliberately deny any musical responsibility for the “music” in it (comparable music is usually under copyright) it’s a lot of fun making up such examples.

See the following image that exposes some polyphony and (nested) polyphonic n-tuplets:

(click for full-size PDF)

(click for full-size PDF)

Actually the source file for this sample does look quite daunting by now. But in fact it’s comparably easy if you do it one by one. And you must never forget that this is handwritten source code, no chance that an input tool that is unable to cope with the input discards all your work because it thinks the number of tuplet doesn’t fit into the measure. LilyPond still has a rock solid rhythmic representation of that score and prints it with perfect alignment. Just have a look at that triplet in the second half of the upper staff: it spans one 3/4 measure, one 1/5 measure and the first 1/20 in the last measure. I would really like to see a screencast of someone entering this in Finale 🙂

But I’m still quite annoyed with the gaps in the horizontal spacing (that are due to the printed time signatures in other staves). Well, they are somewhat inherent and not LilyPond’s fault. But I still like to get rid of them. A simple solution is not to print the time signatures at all. This is achieved with one single \remove "Time_signature_engraver" in the \layout block:

(click to enlarge)

(click to enlarge)

Now look how beautifully this is laid out now, LilyPond’s well-known classical and balanced engraving, without any collisions etc. But of course one can’t play from that without any metering information. So we’re using a modified trick from the LilyPond Snippet Repository to print the time signatures in dedicated “contexts” above the respective staves. I admit this starts to become somewhat tricky and not for the faint of heart. But I repeat: LilyPond allows you to do that kind of stuff without having to pray before each click.

(Click for full-size PDF)

(Click for full-size PDF)

See how it’s done.

20 thoughts on “Independent Meters

  1. Joshua Nichols

    I appreciate your candor and desire to show the world that LilyPond is superior, Urs. I, too, have felt a sort of religious pushback from Finale users (especially in the universities) because, “This is the only way to do things. We have to spend that money.”

    But I think your denied comment is actually a welcome relief now: I believe that their denying that comment is actually a sign of weakness, that they don’t want people to think that there is already an easy alternative to Finale. I think that they believe that in order to keep their clientele, they must shush the competition now. THAT is our namesake now.

    We now have a good reason to keep pursuing publicity: We know that companies like MakeMusic or Avid are beginning to see just how incredible we LilyPonders are (and I don’t mean that in a egotistical way).

    BTW, this post is incredibly helpful! 🙂 I’ve never dabbled in different meters (it wasn’t a composition technique I was told to use), but this is certainly more gentle than the Notation Reference. 😉 This would become extremely helpful when re-typesetting a book like, let’s say, Hindemith’s Elementary Training for Music book.

    Reply
    1. Janek Warchoł

      Interesting point of view. BTW, maybe we should contact Brian Ferneyhough directly instead of trying to post a comment under a blog post he probably won’t read? 😉 Is there anyone in our community who knows him?

      Reply
      1. Urs Liska

        I’ve already thought about this and will probably do (I know a number of younger “complexist composers” and there will surely be someone who can pass me the contact details. But I want to wait with this until the second post is out (which is waiting for the outcome of my current LilyPond patch discussion). (But actually my comment wasn’t directed at the composer after all).

        Reply
  2. Jacob Cooper

    I have also been enjoying your posts, Urs, and have been learning a tremendous amount through this blog. But I think it’s worth saying that there’s a time and a place for LilyPond evangelism, and product-specific blogs are, frankly, not the place. For one thing, on a Finale blog, the intended audience is users of that product, whether we like the product or not. Comments that tout the extensive capabilities of LilyPond are simply not relevant to the blog managers nor the people they are speaking to, and they’re well within their rights to keep things on-topic.

    Further, problem-solving with LilyPond is a vastly different exercise than with those expensive, consumer-driven products that still command the lion’s share of the market for music engraving. Those products are designed to be easy to use first, moderately flexible and powerful second. They also have cadres of experts who’ve found solutions to all kinds of problems and a business model that, at its heart, depends on keeping people happy enough to support them. LilyPond, on the other hand, has an incredibly steep learning curve, and the degree of comfort that it demands (in two different programming languages, no less, if you consider that entering music is, essentially, programming) in order to solve occasionally simple problems is simply not what most people are interested in dealing with. Add to that the open-source nature of development and documentation which produces a daunting ocean of information, and you have a real alienation risk.

    Don’t get me wrong, I love LilyPond, and I would love to see it more widely adopted. But it can be frustrating as well, and I (partly) only stick with it because I’m not on a deadline and can afford to take the months to understand the internals well enough to fix the few issues that cause me grief. A lot of people don’t have that luxury. The most powerful evangelism will really be many more publication-level editions like your Fried songs to demonstrate how great a tool LilyPond is.

    Reply
    1. Urs Liska

      But I think it’s worth saying that there’s a time and a place for LilyPond evangelism, and product-specific blogs are, frankly, not the place. . Of course you are right about that, and I think usually we don’t do that. But take the Steinberg blog for an example. When Daniel Spreadbury started reporting on their progress with a new notation program there were a number of posts by LilyPond users that went too far (I plead guilty here too). But we managed to get that under control very soon – and Steinberg didn’t feel the necessity to censor anything…

      Reply
    2. Joshua Nichols

      I think you have a valid argument, but within one respect: Finale’s website is not an advertising space for LilyPond. However, it’s a bit more complicated than that…

      It’s complicated because when a Finale user (pseudo-me) get’s on a blog like that, I am usually looking forward to answers. When another notation program can do it, that’s not advertising: that advisement. But Finale has an enormous ego to stroke that stretches back many years; and they act like they can do it all and they sell their $600 program in that regard… but… they… can’t. That’s false advertising (which I’m willing to let slide), but when they at least can pass the word about other programs that can get the job done before they can, they don’t.

      Reply
  3. Simon Albrecht

    Automatic beaming in Lilypond actually can be adapted to work with any kind of rhythmic subdivision by setting beamExceptions as explained in Setting Automatic Beam Behavior . The syntax for this has been changed between 2.18.0 and 2.19.3. With 2.19.x, it would be something like e.g.

    \relative c' {
      \time 9/8
      c8 c c c c c c c c
      \time 4/4
      \set Staff.timeSignatureFraction = 9/8
      \set Timing.beamExceptions = \beamExceptions { 8[ 8 8 8] 8[ 8 8 8] |
                    \scaleDurations 8/9 { 8[ 8 8] 8[ 8 8] 8[ 8 8] } |
                    \scaleDurations 2/3 { 8[ 8 8] 8[ 8 8] 8[ 8 8] 8[ 8 8] } }
      \scaleDurations 8/9 {
        c8 c c c c c c c c
      }
    }

    The old syntax is explained at Setting Automatic Beam Behavior. In this case, the \set command would have been:

    \set Timing.beamExceptions = #'((end . (
      ((1 . 8) . (4 4))
      ((1 . 9) . (3 3 3))
      ((1 . 12) . (3 3 3 3))
    )))

    [which I actually find easier to type in this case… but this may be because I already knew it. And probably it’s harder to grasp at the beginning]

    Reply
    1. Janek Warchoł

      Wow, you blew my mind! I tried to do this when i saw the first example, but failed… This is awesome, thanks!

      Reply
  4. Caio Barros

    Being a former university composition student I had many oportunities to see how composers like Ferneyhough work, and I feel comfortable saying that learning and using LilyPond is a cake walk compared to such difficult tools as OpenMusic / PWGL (not to mention other sound synthesis tools that are very widespread in that community). I myself needed one week to learn Lilypond and stop using Finale. So at least in that particular case the argument of “Lilypond is for people who are not in a deadline and can have the luxury of using it” doesn’t apply. Of course this is because composers like Ferneyhough do have a lot of luxuries in that sense (and in others too). If you add the fact that OpenMusic and PWGL are actually a music dedicated and visual representations of… Scheme (it’s Lisp actually, but afaik they both support Scheme) users of those tools would actually come to LilyPond already knowing the hardest part of it.

    One thing Ferneyhough said in that post that captured my attention is his use of “layers”, meaning he first writes the rythms (for example), then adds the pitches to those rhythms, then possibly dynamics, articulations, tempi, etc. Since in a tipical score edition in LilyPond you write pitches and duration together, I will paraphrase a famous comment and ask if there is “a neat way” of dealing with rhythm and pitches separately in LilyPond.

    One final comment. I think that living in a profit/market oriented society, LilyPond tends to have the same place in music engraving as Latex has in text engraving, that is, not a literally “professional” one (maybe and academic one, I think Lilypond has great potenciality here). This is in great part because the production of musical scores is much more a process of creating a sellable commodity than it is a fun way to develop your knowledge and produce something beautiful in the process. But, since reading music is already something that not many people can afford to learn, when you look at the big picture you see that as a commodity a musical score doesn’t work very well (because it cannot be sold to many people). In that sense, unless you really created the miracle of living out of music engraving, this is a perfect place not to be worried of such market pressures and dedicate yourself to a more humane activity, LilyPond is a very good tool for that objective since it is already built as something that do not take commodity production as an objective.

    Reply
    1. Peter Bjuhr

      I find your comment about working in layers especially interesting. And I think it would be very convenient to adopt such a model when composing in LilyPond. Given that you start with the rhythm/duration layer as in your description you should even be able to compile the source between each step to see the result.

      Reply
      1. Urs Liska

        I think this would have to be a question of the editor, not a task for LilyPond. I think Denemo does offer something that resembles this, although it is not as general.

        I think an editor like Frescobaldi could be able to offer tools to do that: first a tool to enter durations (which are converted to compilable code). Then tools to enter pitches, dynamics, articulations etc. taking the entered rhythm layer as the basis.

        Reply
        1. Peter Bjuhr

          I’d like to clarify my previous comment: It was a response to the idea of composing one layer at a time (in LilyPond), which might be a good idea (not trying to do everything at once); not an answer to the question if the different layers can be kept separate (in different variables), which might be interesting too but I find that idea less inspiring.

          I’d also like to clarify that you of course also could start with the pitch layer, then every note would have the preliminary duration of a quarter. But I found the idea of starting with the duration layer particularly interesting because as I understand it that possibility (of isolated durations) was quite recently added to LilyPond (see https://code.google.com/p/lilypond/issues/detail?id=3648).

          Reply
            1. Peter Bjuhr

              Anyone interested in the workflow of first having a rhythmical layer of isolated durations and then adding the pitches, may be interested to hear that I’ve now created a Frescobaldi snippet for jumping to the next duration – https://github.com/PeterBjuhr/frescobaldi-snippets/blob/master/next-duration.xml – which makes the editing much easier.

              It can of course also be useful for other workflows of pitch editing.

              Furthermore the script could easily be adopted to make additional snippets for jumping between other elements.

              Reply
  5. Pingback: Polymetrics in Sibelius (vs. LilyPond) | Scores of Beauty

  6. Adrian Orlowski

    Thank-you very much for this post. As someone who thinks and writes polymetrically, I have looked into using Lilypond for conductor scores and parts, but handling of polymeters was previously obscure, so I was uncertain as to whether to make the investment in the Lilypond learning curve.

    I can’t believe the simplicity of \context { \Score \remove “Timing_translator” \remove “Default_bar_line_engraver” } as a solution for simple contexts – amazing!

    Likewise, the possibility of having the time sig above the staff is unusual, but one I could certainly find helpful.

    I think I will be revisiting Lilypond quite soon.

    Reply
    1. Urs Liska

      You’re welcome.

      If you are “thinking polymetrically” you should definitely give LilyPond a closer look. Of course the learning curve shouldn’t be underrated, but particularly in that area LilyPond is just so much more reliable and versatile than the GUI competitors.

      Reply
  7. mclaren

    Thanks for this article, and for articles like it. Lilypond is fantastically powerful, but the documentation is a trainwreck.
    Example: nowhere in the index for the Lilypond Learning Manual will you find the term “polymeter.” A reasonable person, browsing the index of the Lilypond Learning Manual, concludes that polymeters are not possible in Lilypond.
    What is wrong with this picture?

    Reply
  8. Wafa

    Good stuff, I’ll have to check those out! Every time I try to make MIDI into sheet music it looks like a mess hopefully these prgmaros will do better. Thanks for the info.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *