Next: , Previous: Staff notation, Up: Top


Editorial and educational use

applying-noteheads-styles-depending-on-the-step-of-the-scale.ly

The shapeNoteStyles property gives you the ability to define various note heads styles for each step of the scale (as defined by the key signature or the "tonic" property).

This property requires a set of symbols, which can be purely arbitrary (geometrical expressions such as triangle, cross, xcircle etc. are allowed) or based on old American engraving tradition (you can use some latin note names as well).

That said, if you're trying to imitate old American song books, you may also want to try LilyPond's predefined note heads styles, through shortcut commands such as \aikenHeads or \sacredHarpHeads.

This example shows different ways to obtain shape note heads, and demonstrates the ability to transpose a melody without losing the correspondance between harmonic functions and note heads styles.

fragment = {
  \key c \major
  c1 d e f g a b c
  \break
}

\score {
  \new Staff {
    \transpose c d 
    \relative {
      \set shapeNoteStyles = ##(do re mi fa #f la ti)
      \fragment \break
    }
    
    \relative {
      \set shapeNoteStyles  = ##(cross triangle fa #f mensural xcircle diamond)
      \fragment
    }
  }
}

[image of music]

blanking-staff-lines-using-the--whiteout-command.ly

The \whiteout command underlays a white box under a markup. Since staff lines are in a lower layer than most other grobs, this white box will not overlap any other grob.

\paper
{
  ragged-right = ##t
}
{
  \override TextScript #'extra-offset = #'(2 . 4)
  c'4-\markup  { \whiteout \pad-markup #0.5 foo } c
} 

[image of music]

changing-an-individual-notes-size-in-a-chord.ly

Individual noteheads in a chord can be modified with the \tweak command inside a chord, by altering the 'font-size property.

Inside the chord (within the brackets < >), before the note to be altered, place the \tweak command, followed by #'font-size and define the proper size like #-2 (a tiny notehead).

The code for the chord example shown:

\header{
  title = "Modify an individual notehead's size in a chord"
}

Notes = \relative {
  <\tweak #'font-size #+2 c e g c \tweak #'font-size #-2 e>1^\markup{A tiny e}_\markup{A big c}
}

\score{
  \Notes
}

[image of music]

changing-the-appearance-of-a-slur-from-solid-to-dotted-or-dashed.ly

The appearance of slurs may be changed from solid to dotted or dashed.

\score{
  \relative c'{
    c( d e  c) |
    \slurDotted
    c( d e  c) |
    \slurSolid
    c( d e  c) |
    \slurDashed
    c( d e  c) |
    \slurSolid
    c( d e  c) |
  }
  \layout{ raggedright=##t }
}




[image of music]

changing-the-default-text-font-family.ly

The default font families for text can be overridden with make-pango-font-tree.

\paper {
  % change for other default global staff size. 
  myStaffSize = #20
  %{
     run
         lilypond -dshow-available-fonts blabla
     to show all fonts available in the process log.  
  %}

  #(define fonts
    (make-pango-font-tree "Times New Roman"
                          "Nimbus Sans"
                          "Luxi Mono"
;;                        "Helvetica"
;;                        "Courier"
     (/ myStaffSize 20)))
}

\relative {
  c'^\markup {
    roman: foo \bold bla \italic bar \italic \bold baz 
  }
  c'_\markup {
    \override #'(font-family . sans)
    {
      sans: foo \bold bla \italic bar \italic \bold baz
    }
  }
  c'^\markup {
    \override #'(font-family . typewriter)
    {
      mono: foo \bold bla \italic bar \italic \bold baz
    }
  }
}  

[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]

coloring-objects.ly

LilyPond gives you the ability to assign different colors to any grob in your score, such as NoteHeads, Alterations, Beams and so on, by simply overriding the #'color property and choosing your color (over 200 colors are available, see the "List of Colors" Appendix in the Manual).

\relative {
  \override Accidental #'color = #darkgreen
  \override Beam #'color = #cyan
  \override NoteHead #'color = #darkyellow
  c4
  \override NoteHead #'color = #red
  f
  \override NoteHead #'color = #darkmagenta
  g
  \override NoteHead #'color = #darkblue
  b
  \override NoteHead #'color = #green
  \override Stem #'color = #blue
  e8 es d dis e4 r
}

[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]

forcing-rehearsal-marks-to-start-from-a-given-letter-or-number.ly

This snippet demonstrates how to obtain automatic ordered rehearsal marks, but from the letter or number you want.

\relative c''{
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark #14
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default

\break

  \set Score.markFormatter = #format-mark-numbers 
  c1 \mark #1
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark #14
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
}

[image of music]

formatting-lyrics-syllables.ly

To format single lyrics syllables, you can simply use \markup { .... } on these lyrics!

melody = \relative c'' { c4 c c c  }
lyr = \lyricmode { 
  Lyrics \markup { \italic can } \markup {\with-color #red contain } 
  \markup {\fontsize #8 \bold "Markup!" } 
}

\context Staff << 
  \context Voice = "mel" << \melody >>
  \context Lyrics \lyricsto "mel" \lyr
>>

[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]

rhythmic-slashes.ly

In "simple" lead-sheets, sometimes no actual notes are written, instead only "rhythmic patterns" and chords above the measures are noted giving the structure of a song. Such a feature is for example useful while creating/transcribing the structure of a song and also when sharing lead sheets with guitarists or jazz musicians.

The standard support for this is described in section "Measure repeats", but then the first beat has to be an ordinary note or rest.

This example shows two solutions to this problem, by redefining ordinary rests to be printed as slashes. (If the duration of each beat is not a quarter note, replace the r4 in the definitions by a rest of the appropriate duration).

% Macro to print single slash
rs = {
  \once \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash
  \once \override Rest #'thickness = #'0.48
  \once \override Rest #'slope = #'1.7
  r4
}


% Function to print a specified number of slashes
comp = #(define-music-function (parser location count) ( integer?)
  #{
    \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash
    \override Rest #'thickness = #'0.48
    \override Rest #'slope = #'1.7
    \repeat unfold $count { r4 }
    \revert Rest #'stencil
  #}
)

\score{
  \relative c'{
    c d e f | \rs \rs \rs \rs | \comp #4 |
  }
}

[image of music]

three-sided-box.ly

This example shows how to add a markup command to get a three sided box around some text (or other markup).

% New command to add a three sided box, with sides north, west and south
% Based on the box-stencil command defined in scm/stencil.scm
% Note that you use ";" to comment a line in Scheme
#(define-public (NWS-box-stencil stencil thickness padding)
  "Add a box around STENCIL, producing a new stencil."
  (let* ((x-ext (interval-widen (ly:stencil-extent stencil 0) padding))
	 (y-ext (interval-widen (ly:stencil-extent stencil 1) padding))
	 (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
	 (x-rule (make-filled-box-stencil
		  (interval-widen x-ext thickness) (cons 0 thickness))))
;    (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
    (set! stencil (ly:stencil-combine-at-edge stencil X -1 y-rule padding))
    (set! stencil (ly:stencil-combine-at-edge stencil Y 1 x-rule 0.0))  
    (set! stencil (ly:stencil-combine-at-edge stencil Y -1 x-rule 0.0))
    stencil))

% The corresponding markup command, based on the \box command defined 
% in scm/define-markup-commands.scm
#(define-markup-command (NWS-box layout props arg) (markup?)
  "Draw a box round @var{arg}.  Looks at @code{thickness},
@code{box-padding} and @code{font-size} properties to determine line
thickness and padding around the markup."
  
  (let* ((th (chain-assoc-get 'thickness props  0.1))
	 (size (chain-assoc-get 'font-size props 0))
	 (pad (* (magstep size)
		 (chain-assoc-get 'box-padding props 0.2)))
	 (m (interpret-markup layout props arg)))
    (NWS-box-stencil m th pad)))


% Test it:

\relative c'{ 
  c^\markup{ \NWS-box ABCD }
  c^\markup{\NWS-box \note #"4" #1.0 } 
}

[image of music]



Next: , Previous: Staff notation, 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.