Showing posts with label measure width. Show all posts
Showing posts with label measure width. Show all posts

Feb 18, 2015

Panorama Mode

Do you come from a notation program that has a "Panarama" mode for viewing your score? Well, fear not! Such a feature exists even in LilyPond to make you feel right at home, but it's not called "Panorama". It's a layout algorithm called ly:one-line-breaking.

To have your score print on a single sheet that adjusts to the length of the score, use the following code:
\paper {
  page-breaking = #ly:one-line-breaking
}
For example, here are the first two pages from a 3-page score in "normal paper" mode:


And here's how it looks when we use the one-line-breaking algorithm (cropped slightly):


That's it! Now, there are some things to remember about using this mode (from the official docs):
  1. Each score gets its own line, but everything is on a single page.
  2. All text in the \header block is NOT typeset, which is fine since this is really more of a preview mode anyway.
  3. The width of the page will be adjusted so the longest score fits on one page.
  4. Some variables in the \paper block will be ignored (like paper-width, indent, line-width) while others will be honored (like left-margin, right-margin, etc.).
  5. The height of the page is un-changed, but honored to whatever you set it to be.
Personally, I wish the height of the page automatically fit to the scores, but oh-well.

Do you miss this mode? Do you find it useful? Let me know in the comments!

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!