Next: , Previous: Simultaneous notes, Up: Top


Staff notation

adding-ambiti-per-voice.ly

Ambits can be added per voice. In that case, the ambitus must be moved manually to prevent collisions.

\new Staff <<
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c'' {
    \override Ambitus #'X-offset = # 2.0
    \voiceOne
    c4 a d e f1
  }
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c' {
    \voiceTwo
	es4 f g as b1
  }
>>

[image of music]

adding-an-extra-staff.ly

You can add (possibly temporarily) an extra staff after the beginning of a piece.

\score {
	<<
		\new Staff \relative c''{ c1 c c c c }
		\new StaffGroup \relative c''{ 
			\new Staff 
			c1 c
			<< c1 \new Staff { c1 } >>
			c
		}
	>>
  	\layout {
		
		\context{
			\Score

		}
	}
}





[image of music]

adding-and-extra-staff-at-a-line-break.ly

When adding a new Staff at a line break, LilyPond will unfortunately add some extra space at the end of the line before the break (to fit in a key signature change, which will never be printed anyway). The workaround is to add a setting of Staff.explicitKeySignatureVisibility as is shown in the example. In version 2.10 and earlier, you have to do a similar setting for the time signatures, see the example.

\score {
  \new StaffGroup \relative c''{ 
    \new Staff 
    \key f \major
    c1 c^"Unwanted extra space" \break 
    << { c1 c }
       \new Staff { 
         \key f \major
         c1 c 
       } 
    >>
    c1 c^"Fixed here" \break 
    << { c1 c }
       \new Staff { 
         \once \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible 
         %The next line is not needed in 2.11.x or later:
         \once \override Staff.TimeSignature #'break-visibility = #end-of-line-invisible 
        \key f \major
         c1 c 
       } 
    >>
  }
}

[image of music]

changing-the-number-of-lines-in-a-staff.ly

The number of lines in a staff may changed by overriding line-count in the properties of StaffSymbol.

upper = \relative c'' {
  c1 d e f
}

lower = \relative c {
  c1 b a g
}

\score {
  \context PianoStaff <<
    \new Staff <<
      \upper
    >>  
    \new Staff  {
	\override Staff.StaffSymbol  #'line-count = #4 
        \clef bass
        \lower
    }
  >>

}

[image of music]

changing-the-staff-size.ly

In order to change staff sizes, both staff-space and fontSize must be scaled.

{
  \new Staff \relative c'' { \dynamicDown c8 \ff c c c c c c c } 
}

{
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol #'staff-space = #(magstep -3)
  }
  {
    \clef bass
    c8 c c c  c c c c
  }
}

[image of music]

clefs-commonly-tweaked-properties.ly

The command \clef "treble_8" is equivalent to setting clefGlyph, clefPosition (which controls the Y position of the clef), middleCPosition and clefOctavation. A clef is printed when any of these properties are changed.

Note that changing the glyph, the position of the clef, or the octavation, does not in itself change the position of subsequent notes on the staff: the position of middle C must also be specified to do this. The positional parameters are relative to the staff centre line, positive numbers displacing upwards, counting 1 for each line and space. The clefOctavation value would normally be set to 7, -7, 15 or -15, but other values are not invalid.

When a clef change takes place at a line break the new clef symbol is printed at both the end of the previous line and the beginning of the new line by default. If the warning clef at the end of the previous line is not required it can be suppressed by setting the explicitClefVisibility Staff property to the value end-of-line-invisible. The default behaviour can be recovered with \unset Staff.explicitClefVisibility.

The following examples show the possibilities when setting these properties manually. On the first line, the manual changes preserve the standard relative positioning of clefs and notes, whereas on the second line, they do not.

{
  % The default treble clef
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  \set Staff.middleCPosition = #6
  c'
  % The baritone clef
  \set Staff.clefGlyph = #"clefs.C"
  \set Staff.clefPosition = #4
  \set Staff.middleCPosition = #4
  c'
  % The standard choral tenor clef
  \set Staff.clefGlyph = #"clefs.G"
  \set Staff.clefPosition = #-2
  \set Staff.clefOctavation = #-7
  \set Staff.middleCPosition = #1
  c'
  % A non-standard clef
  \set Staff.clefPosition = #0
  \set Staff.clefOctavation = #0
  \set Staff.middleCPosition = #-4
  c' \break
  
  
  % The following clef changes do not preserve
  % the normal relationship between notes and clefs:
  
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  c'
  \set Staff.clefGlyph = #"clefs.G"
  c'
  \set Staff.clefGlyph = #"clefs.C"
  c'
  \set Staff.clefOctavation = #7
  c'
  \set Staff.clefOctavation = #0
  \set Staff.clefPosition = #0
  c'
  
  % Here we go back to the normal clef:
  
  \set Staff.middleCPosition = #4
  c'
}

[image of music]

creating-blank-staves.ly

To create blank staves, you must generate empty measures, removing also from the Score context the Bar_number_engraver, and from the Staff context the Time_signature_engraver, the Clef_engraver and the Bar_engraver.

#(set-global-staff-size 20)

\score {
  { 
    \repeat unfold 12 { s1 \break } 
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove Time_signature_engraver
      \remove Clef_engraver
      \remove Bar_engraver
    }
    \context {
      \Score
      \remove Bar_number_engraver
    }
  }
}

\paper {
  #(set-paper-size "letter")
  raggedlastbottom = ##f
  linewidth = 7.5\in
  leftmargin = 0.5\in
  bottommargin = 0.25\in
  topmargin = 0.25\in
}

[image of music]

inserting-score-fragments-above-the-staff,-as-markups.ly

The \markup command is quite versatile. In this snippet, it contains a \score bloc instead of texts or marks.

\relative {
    \time 4/8
    \times 2/3 { c'8 d e } \times 2/3 {c d e}
    \times 2/3 { c8 d e } \times 2/3 {c d e}
    g8 a8 g8 a 
    g8 a8 g8 a 
}

[image of music]

non-traditional-key-signatures.ly

The commonly used \key command sets the keySignature property, in the Staff context. However, non-standard key signatures can be specified by setting this property directly. The format of this command is a list: \set Staff.keySignature = #'(((octave . step) . alter) ((octave . step) . alter) ...) where, for each element in the list, octave specifies the octave (0 being the octave from middle C to the B above), step specifies the note within the octave (0 means C and 6 means B), and alter is ,SHARP ,FLAT ,DOUBLE-SHARP etc. (Note the leading comma.)

However, for each item in the list, you can also use the alternative format (step . alter), which specifies that the same alteration should hold in all octaves.

Here is an example of a possible key signature for generating a whole-tone scale:

\relative c' {
  \set Staff.keySignature =
    #`(((0 .  3) . ,SHARP) ((0 . 5) . ,FLAT) ((0 . 6) . ,FLAT))
  c d e fis aes bes c2
}

[image of music]

quoting-another-voice-with-transposition.ly

Quotations take into account the transposition of both source and target. In this example, all instruments play sounding central C, the target is a instrument in F. The target part may be \transposed. In this case, all the pitches (including the quoted ones) will transposed as well.

\addQuote clarinet  {
    \transposition bes
    d'16 d'16 d'8 
    d'16 d'16 d'8 
    d'16 d'16 d'8 
    d'16 d'16 d'8 
}

\addQuote sax  {
    \transposition es'
    a8 a a a a a  a a 
}

quoteTest = {
    \transposition f  % french horn
    
    g'4
    << \quoteDuring #"clarinet" { \skip 4 } s4^"clar" >> 
    << \quoteDuring #"sax" { \skip 4 } s4^"sax" >> 
}

<< \quoteTest
   \new Staff
   << \transpose c' d' \quoteTest
     s4_"up 1 tone"
  >>
>>

[image of music]

quoting-another-voice.ly

With \quote, fragments of previously entered music may be quoted. quotedEventTypes will determines what things are quoted. In this example, a 16th rest is not quoted, since rest-event is not in quotedEventTypes.

quoteMe = \relative c' { fis4 r16  a8.-> b4-\ff c }

\addQuote quoteMe \quoteMe 
original = \relative c'' { c8 d s2 es8 gis8 }

<<
    \new Staff {
	\set Staff.instrumentName = "quoteMe"
	\quoteMe
    }
    \new Staff {
	\set Staff.instrumentName = "orig"
	\original
    }
    \new Staff \relative c'' <<
	\set Staff.instrumentName = "orig+quote"	
	\set Staff.quotedEventTypes = #'(note-event articulation-event)
	\original
	\new Voice {
	    s4
	    \set fontSize = #-4
	    \override Stem #'length-fraction = #(magstep -4)
	    \quoteDuring #"quoteMe" { \skip 2. }
	}
    >>
>>

[image of music]

time-signature-in-parentheses.ly

You may put the time signature in parentheses.

tsMarkup = \markup  {
  \number {
    \bracket \column { "2" "4" }
  }
}

\score {
  \relative c'' {

% FIXME: Gee, it doesn't work with 2.10 -vv

%{

  \override Staff.TimeSignature   #'print-function = #Text_interface::print
  \override Staff.TimeSignature   #'text = #tsMarkup

%}

  \time 2/4

    a4 b8 c |
  }
}

[image of music]

volta-multi-staff.ly

By adding Volta_engraver, repeat brackets can be put over staves other than the topmost one in a score.

vmus = \relative c'' {
  \repeat volta 2 c1 \alternative { d e } 
} 

<<
  \new StaffGroup <<
    \context Staff \vmus
    \new Staff \vmus
  >>
  \new StaffGroup <<
    \new Staff \with { \consists Volta_engraver }
      \vmus
    \new Staff \vmus
  >>
>>

[image of music]



Next: , Previous: Simultaneous notes, Up: Top

This page is for LilyPond-2.11.40 (development-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Your suggestions for the documentation are welcome.