Hi,

Since the question came up about organizing LilyPond code for score and parts, 
I thought I would make a quick demo of what I believe to be the standard way to 
do it. Somehow I pieced these ideas together from LP code that I found online 
(Mozart Horn Concerto, as I recall), but I don't remember finding a compact 
example.

I used a few bars from a recent woodwind trio, because it uses some notational 
features that you would like to be handled automatically -- and which *are* 
handled automatically using these techniques:

- Multi-measure rests
- Meter changes
- Tempo markings (at the top of the score only, and in all parts)
- Clef changes in one part, independent of the others
- Transposing instruments

Comments are in the file, but to summarize briefly:

- A "global" variable holds any elements that need to be shared across all 
parts. Spacer ("s") rests set the number of bars between tempo changes, meter 
or key changes, rehearsal marks, double barlines etc.

- Each instrument has a variable containing notes, rests, dynamics etc. Clef 
changes go into these variables (because they are specific to each part).

- The score creates staves for each instrument and fills them with simultaneous 
music expressions: << \global \instrumentNotes >>.

- A part is a "\score" containing one staff, using only the instrument's notes. 
If the part is for a multi-staff instrument, like piano, the \score would hold 
a PianoStaff or StaffGroup.

- \compressFullBarRests in the parts does what you think it should do. 
Multi-measure rests should get broken by rehearsal marks etc. (the "global" 
things), and that's exactly what happens. I also use the \override because I 
don't like Kirchenpausen.

In the real piece, I have a score.ly file that \include's the global and 
instrument variables, and separate oboe.ly, clarinet.ly etc. files that 
\include only what's needed for each part. For the demo, it's easier to send 
just one ly file but you wouldn't do it that way in real life.

/Theme and Variations/ is released under CC-BY-NC-SA 4.0; please don't steal 
the notes :)

Comments welcome. Hope this is helpful.

hjh

\version "2.18.2"
\language "english"


% "global" contains meter, key, and tempo changes,
% and any rehearsal marks or markups that need to appear in all parts

global = {
  \numericTimeSignature
  \tempo 2 = 88
  \time 2/2 s1*3
  \tempo \markup { \fontsize #-2 { \note #"2" #1 "=" \note #"4." #1 } }
  \time 6/8 s2.
  \tempo \markup { \fontsize #-2 { \note #"4." #1 "=" \note #"2" #1 } }
  \time 2/2 s1*2
}


% Just the notes -- no need to copy anything from "global"

obNotes = \relative c'' {
  R1*3
  e8.\mp\< ( d16 ) f8 ~ ( f16 e ) g8. ( f16\! )
  R1*2
}

% entered in C (I prefer to think in concert pitch)
clNotes = \relative c {
  e4\f d8 ( e f4 ) e8 ( d
  e4 ) cs2 e4
  d8 ( e f4 ) g2
  R2.
  e4\f d8 ( e f4 ) g ~
  g\> f d'4. ( c8\! )
}

bsnNotes = \relative c {
  \clef bass
  r4 bf\f af g
  fs e g f
  af g bf a
  \clef tenor
  g''8\mp\< ( f ) e-. d-. cs4->\!
  \clef bass
  r2 bf,4\f a
  bf\> g a8 ( bf c4\! )
}

\paper {
  left-margin = 1.8\cm
  line-width = 18.2\cm
  right-margin = 1\cm
  ragged-bottom = ##t
  ragged-last-bottom = ##t
}

\header {
  title = "Demo: Score and parts organization in LilyPond"
  subtitle = \markup { Excerpt from \italic "Theme and Variations" }
  composer = "H. James Harkins"
  copyright = "Licensed under Creative Commons CC-BY-NC-SA 4.0"
  poet = "Score in C"
}

\score {
  \new StaffGroup <<
    \new Staff \with {
      instrumentName = "Oboe"
      shortInstrumentName = "Ob."
    }
    % this expression runs "global" simultaneously with the oboe notes
    << \global \obNotes >>
    
    \new Staff \with {
      instrumentName = "Clar. in A"
      shortInstrumentName = "Cl."
    }
    << \global \clNotes >>
    
    \new Staff \with {
      instrumentName = "Bassoon"
      shortInstrumentName = "Bsn."
    }
    << \global \bsnNotes >>
  >>
  \layout {
    % This won't matter for this excerpt,
    % but I generally like to "French" my scores
    \context { \Staff \RemoveEmptyStaves }
  }
}

\pageBreak

\markup {
  \column {
    \vspace #2
    \bold "Oboe part"
    \vspace #1
  }
}

% The part then consists of just a single staff,
% using only the required notes.
% It should be clear in the PDF what \compressFullBarRests does.
% The \override forces the horizontal bar for rests of two bars or more,
% instead of using LilyPond's default Kirchenpausen.
% It's not shown here, but LilyPond will automatically break
% multi-measure rests for key/tempo/meter changes etc. in "global."

\score {
  \new Staff <<
    \global
    {
      \compressFullBarRests
      \override MultiMeasureRest.expand-limit = #1
      \obNotes
    }
  >>
}


\markup {
  \column {
    \vspace #2
    \bold "Clarinet in A part"
    \vspace #1
  }
}


% ... and the \transpose function handles non-C instruments

\score {
  \new Staff << \global \transpose a, c \clNotes >>
}


\markup {
  \column {
    \vspace #2
    \bold "Bassoon part"
    \vspace #1
  }
}

\score {
  \new Staff << \global \bsnNotes >>
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to