<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- header_tag --> <html lang="en"> <head> <title>Fixing overlapping notation - GNU LilyPond Learning Manual</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="description" content="GNU LilyPond Learning Manual"> <meta name="generator" content="makeinfo 4.11"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Collisions-of-objects.html#Collisions-of-objects" title="Collisions of objects"> <link rel="prev" href="Moving-objects.html#Moving-objects" title="Moving objects"> <link rel="next" href="Real-music-example.html#Real-music-example" title="Real music example"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999--2007 by the authors Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } hr { border:0; height:1; color: #000000; background-color: #000000; } /* hr { border: none; height: 1px; color: #666666; background-color: #666666; } body { border-left: 1px solid #666666; border-right: 1px solid #666666; color: #332d28; margin-right: auto; margin-left: auto; width: 60em; list-style-type: square; font-family: Arial,Helvetica,sans-serif; padding-right: 1em; padding-left: 1em; } a { border-bottom: 1px dashed #344242; text-decoration: none; color: #344242; } a:link { text-decoration: none; } a:visited { border-bottom: 1px dashed #666666; color: #666666; } a:active { border-bottom: 1px solid #00cccc; color: #00cccc; } a:hover { border-bottom: 1px solid #1d7b85; color: #1d7b85; } blockquote { border: 1px solid #cccccc; padding: 3px; width: 40em; } .node { border-left: 1px solid #666666; margin: -0.5em 0px 1em; padding: 2px 1px 0px; font-style: italic; } .node a { border: none; text-decoration: underline; font-style: normal; font-weight: bold; } .verbatim { font-family: "Courier New",Courier,monospace; } .unnumberedsubsubsec { font-size: large; color: #1d7b85; } .subsubheading { font-size: large; color: #3b220d; } .contents { border: 1px dashed #339999; margin: 3px 2em; list-style-type: square; padding-right: 1em; width: 40em; background-color: #fcfff9; } .contents a { border-bottom: 1px dashed #423d34; text-decoration: none; color: #423d34; } .contents a:visited { border-bottom: 1px dashed #666666; color: #666666; } .contents a:active { border-bottom: 1px solid #f0d86d; color: #f0d86d; } .contents a:hover { border-bottom: 1px solid #3b220d; color: #3b220d; } .menu { border-left: 1px dashed #339999; margin: 3px 2em 1em; list-style-type: square; padding-left: 1.4em; width: 40em; } .unnumbered { } h2 { font-size: x-large; color: #1d7b85; } */ --></style> </head> <BODY BGCOLOR=WHITE TEXT=BLACK> <div class="node"> <p> <a name="Fixing-overlapping-notation"></a> Next: <a rel="next" accesskey="n" href="Real-music-example.html#Real-music-example">Real music example</a>, Previous: <a rel="previous" accesskey="p" href="Moving-objects.html#Moving-objects">Moving objects</a>, Up: <a rel="up" accesskey="u" href="Collisions-of-objects.html#Collisions-of-objects">Collisions of objects</a> <hr> </div> <h4 class="subsection">4.5.2 Fixing overlapping notation</h4> <p>Let's now see how the properties in the previous section can help to resolve overlapping notation. <h4 class="subheading">padding property</h4> <p><a name="index-padding-property-419"></a> The <code>padding</code> property can be set to increase (or decrease) the distance between symbols that are printed above or below notes. <blockquote> <pre class="verbatim"> c2\fermata \override Script #'padding = #3 b2\fermata </pre> <p> <a href="../7f/lily-8f6c92c3.ly"> <img align="middle" border="0" src="../7f/lily-8f6c92c3.png" alt="[image of music]"> </a> </p> </blockquote> <blockquote> <pre class="verbatim"> % This will not work, see below: \override MetronomeMark #'padding = #3 \tempo 4=120 c1 % This works: \override Score.MetronomeMark #'padding = #3 \tempo 4=80 d1 </pre> <p> <a href="../39/lily-4fe30bb7.ly"> <img align="middle" border="0" src="../39/lily-4fe30bb7.png" alt="[image of music]"> </a> </p> </blockquote> <p>Note in the second example how important it is to figure out what context handles a certain object. Since the <code>MetronomeMark</code> object is handled in the <code>Score</code> context, property changes in the <code>Voice</code> context will not be noticed. For more details, see <a name="index-Modifying-properties-420"></a><a href="../lilypond/Modifying-properties.html#Modifying-properties">Modifying properties</a>. <p>If the <code>padding</code> property of an object is increased when that object is in a stack of objects being positioned according to their <code>outside-staff-priority</code>, then that object and all objects outside it are moved. <h4 class="subheading">left-padding and right-padding</h4> <p><a name="index-left_002dpadding-property-421"></a><a name="index-right_002dpadding-property-422"></a> The <code>right-padding</code> property affects the spacing between the accidental and the note to which it applies. It is not often required, but the following example shows one situation where it is needed. Suppose we wish to show a chord containing both a B-natural and a B-flat. To avoid ambiguity we would like to precede the notes with both a natural and a flat sign. Here are a few attempts to do this: <blockquote> <pre class="verbatim"> <b bes> <b! bes> <b? bes> </pre> <p> <a href="../1c/lily-95956af5.ly"> <img align="middle" border="0" src="../1c/lily-95956af5.png" alt="[image of music]"> </a> </p> </blockquote> <p>None work, with the second two showing bad collisions between the two signs. <p>One way of achieving this is to override the accidental stencil with a markup containing the natural and flat symbols in the order we would like, like this: <blockquote> <pre class="verbatim"> naturalplusflat = \markup { \natural \flat } \relative c'' { \once \override Accidental #'stencil = #ly:text-interface::print \once \override Accidental #'text = #naturalplusflat \once \override Score.AccidentalPlacement #'right-padding = #1.5 <b bes> } </pre> <p> <a href="../f8/lily-a2d92227.ly"> <img align="middle" border="0" src="../f8/lily-a2d92227.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">This necessarily uses an override for the accidental stencil which will not be covered until later. The stencil type must be a procedure, here changed to print the contents of the <code>text</code> property of <code>Accidental</code>, which itself is set to be a natural sign followed by a flat sign. These are then moved further away from the note head by overriding <code>right-padding</code>. <p class="noindent"> <h4 class="subheading">staff-padding property</h4> <p><a name="index-staff_002dpadding-property-423"></a> <code>staff-padding</code> can be used to align objects such as dynamics along a baseline at a fixed height above the staff, rather than at a height dependent on the position of the note to which they are attached. It is not a property of <code>DynamicText</code> but of <code>DynamicLineSpanner</code>. This is because the baseline should apply equally to <strong>all</strong> dynamics, including those created as extended spanners. So this is the way to align the dynamic marks in the example taken from the previous section: <blockquote> <pre class="verbatim"> \dynamicUp % Extend width by 1 unit \override DynamicText #'extra-spacing-width = #'(-0.5 . 0.5) % Align dynamics to a base line 2 units above staff \override DynamicLineSpanner #'staff-padding = #2 a4\f b\mf c\mp b\p </pre> <p> <a href="../65/lily-f83f4cc1.ly"> <img align="middle" border="0" src="../65/lily-f83f4cc1.png" alt="[image of music]"> </a> </p> </blockquote> <h4 class="subheading">self-alignment-X property</h4> <p><a name="index-self_002dalignment_002dX-property-424"></a> The following example shows how this can resolve the collision of a string fingering object with a note's stem by aligning the right edge with the reference point of the parent note: <blockquote> <pre class="verbatim"> \voiceOne < a \2 > \once \override StringNumber #'self-alignment-X = #RIGHT < a \2 > </pre> <p> <a href="../a5/lily-a77dce44.ly"> <img align="middle" border="0" src="../a5/lily-a77dce44.png" alt="[image of music]"> </a> </p> </blockquote> <h4 class="subheading">staff-position property</h4> <p><a name="index-staff_002dposition-property-425"></a> Multimeasure rests in one voice can collide with notes in another. Since these rests are typeset centered between the bar lines, it would require significant effort for LilyPond to figure out which other notes might collide with it, since all the current collision handling between notes and between notes and rests is done only for notes and rests that occur at the same time. Here's an example of a collision of this type: <blockquote> <pre class="verbatim"> << {c c c c} \\ {R1} >> </pre> <p> <a href="../89/lily-ab454e70.ly"> <img align="middle" border="0" src="../89/lily-ab454e70.png" alt="[image of music]"> </a> </p> </blockquote> <p>The best solution here is to move the multimeasure rest down, since the rest is in voice two. The default in <code>\voiceTwo</code> (i.e. in the second voice of a <code><<{...} \\ {...}>></code> construct) is that <code>staff-position</code> is set to -4 for MultiMeasureRest, so we need to move it, say, four half-staff spaces down to <code>-8</code>. <blockquote> <pre class="verbatim"> << {c c c c} \\ \override MultiMeasureRest #'staff-position = #-8 {R1} >> </pre> <p> <a href="../7d/lily-9a348ab5.ly"> <img align="middle" border="0" src="../7d/lily-9a348ab5.png" alt="[image of music]"> </a> </p> </blockquote> <p>This is better than using, for example, <code>extra-offset</code>, because the ledger line above the rest is inserted automatically. <h4 class="subheading">extra-offset property</h4> <p><a name="index-extra_002doffset-property-426"></a> The <code>extra-offset</code> property provides complete control over the positioning of an object both horizontally and vertically. <p>In the following example, the second fingering is moved a little to the left, and 1.8 staff space downwards: <blockquote> <pre class="verbatim"> \stemUp f-5 \once \override Fingering #'extra-offset = #'(-0.3 . -1.8) f-5 </pre> <p> <a href="../da/lily-ee1d83d6.ly"> <img align="middle" border="0" src="../da/lily-ee1d83d6.png" alt="[image of music]"> </a> </p> </blockquote> <h4 class="subheading">positions property</h4> <p><a name="index-positions-property-427"></a> The <code>positions</code> property allows the position and slope of tuplets, slurs, phrasing slurs and beams to be controlled manually. Here's an example which has an ugly phrasing slur due to its trying to avoid the slur on the acciaccatura. <blockquote> <pre class="verbatim"> r4 \acciaccatura e8\( d8 c ~c d c d\) </pre> <p> <a href="../ea/lily-e7b9e52b.ly"> <img align="middle" border="0" src="../ea/lily-e7b9e52b.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">We could simply move the phrasing slur above the notes, and this would be the preferred solution: <blockquote> <pre class="verbatim"> r4 \phrasingSlurUp \acciaccatura e8\( d8 c ~c d c d\) </pre> <p> <a href="../94/lily-d2ccf3aa.ly"> <img align="middle" border="0" src="../94/lily-d2ccf3aa.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">but if there were some reason why this could not be done the other alternative would be to move the left end of the phrasing slur down a little using the <code>positions</code> property. This also resolves the rather nasty shape. <blockquote> <pre class="verbatim"> r4 \once \override PhrasingSlur #'positions = #'(-4 . -3) \acciaccatura e8\( d8 c ~c d c d\) </pre> <p> <a href="../8e/lily-3e388160.ly"> <img align="middle" border="0" src="../8e/lily-3e388160.png" alt="[image of music]"> </a> </p> </blockquote> <p>Here's a further example taken from the opening of the left-hand staff of Chopin's Prelude Op 28 No. 2. We see that the beam collides with the upper notes: <blockquote> <pre class="verbatim"> { \clef "bass" << {b,8 ais, b, g,} \\ {e, g e, g} >> << {b,8 ais, b, g,} \\ {e, g e, g} >> } </pre> <p> <a href="../c1/lily-4f061251.ly"> <img align="middle" border="0" src="../c1/lily-4f061251.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">This can be resolved by manually moving both ends of the beam up from their position at 2 staff-spaces above the center line to, say, 3: <blockquote> <pre class="verbatim"> { \clef "bass" << \override Beam #'positions = #'(3 . 3) {b,8 ais, b, g,} \\ {e, g e, g} >> << {b,8 ais, b, g,} \\ {e, g e, g} >> } </pre> <p> <a href="../e2/lily-091e44e7.ly"> <img align="middle" border="0" src="../e2/lily-091e44e7.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">Note that the override continues to apply in the first voice of the second block of quavers, but not to any of the beams in the second voice. <h4 class="subheading">force-hshift property</h4> <p><a name="index-force_002dhshift-property-428"></a><!-- FIXME: formatting stuff (ie not important right now IMO) --> <!-- @a nchor Chopin finally corrected TODOgp --> <p>We can now see how to apply the final corrections to the Chopin example introduced at the end of <a href="I_0027m-hearing-Voices.html#I_0027m-hearing-Voices">I'm hearing Voices</a>, which was left looking like this: <blockquote> <pre class="verbatim"> \new Staff \relative c'' { \key aes \major << { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { \voiceFour <ees c>2 des2 } >> | <c ees aes c>1 | } </pre> <p> <a href="../e1/lily-25bf568f.ly"> <img align="middle" border="0" src="../e1/lily-25bf568f.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">The lower two notes of the first chord (i.e, those in the third voice) should not be shifted away from the note column of the higher two notes. To correct this we set <code>force-hshift</code>, which is a property of <code>NoteColumn</code>, of these notes to zero. The lower note of the second chord is best placed just to the right of the higher notes. We achieve this by setting <code>force-hshift</code> of this note to 0.5, ie half a note head's width to the right of the note column of the higher notes. <p>Here's the final result: <blockquote> <pre class="verbatim"> \new Staff \relative c'' { \key aes \major << { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { \voiceFour \once \override NoteColumn #'force-hshift = #0 <ees c>2 \once \override NoteColumn #'force-hshift = #0.5 des2 } >> | <c ees aes c>1 | } </pre> <p> <a href="../61/lily-e6bdf50e.ly"> <img align="middle" border="0" src="../61/lily-e6bdf50e.png" alt="[image of music]"> </a> </p> </blockquote> <!-- footer_tag --><br><hr> <div class="node"> <p> Next: <a rel="next" accesskey="n" href="Real-music-example.html#Real-music-example">Real music example</a>, Previous: <a rel="previous" accesskey="p" href="Moving-objects.html#Moving-objects">Moving objects</a>, Up: <a rel="up" accesskey="u" href="Collisions-of-objects.html#Collisions-of-objects">Collisions of objects</a> </div> <div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;"> <p> <font size="-1"> This page is for LilyPond-2.11.57 (development-branch). <br> <address> Report errors to <a href="http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs">http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs</a>. </address> <br> Your <a href="http://lilypond.org/web/devel/participating/documentation-adding">suggestions for the documentation</a> are welcome. </font> </p> </div> <P> Other languages: <a href="Fixing-overlapping-notation.fr.html">français</a>, <a href="Fixing-overlapping-notation.es.html">español</a>, <a href="Fixing-overlapping-notation.de.html">deutsch</a>. <BR> </P> </BODY></html>