]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/learning/tweaks.itely
make \shiftOff an assertive \override, not a \revert
[lilypond.git] / Documentation / learning / tweaks.itely
index 137a49828600a5900da1b9ffcf8bbb425a41829a..db99e027c8e7ac8b4bfe8cdf8f025a7096b475c5 100644 (file)
@@ -107,6 +107,14 @@ ending point, and maybe other properties concerned with their
 shape.  Objects with an extended shape like these are called
 @q{Spanners}.
 
+What is more, there are @q{abstract} grobs which do not print
+anything of their own, but rather collect, position and manage
+other grobs.  Common examples for this are
+@code{DynamicLineSpanner}, @code{BreakAlignment},
+@code{NoteColumn}, @code{VerticalAxisGroup},
+@code{NonMusicalPaperColumn} and similar.  We will see how some of
+these are used later.
+
 It remains to explain what @q{Interfaces} are.  Many objects, even
 though they are quite different, share common features which need to
 be processed in the same way.  For example, all grobs have a color, a
@@ -179,6 +187,7 @@ the types of objects and properties from their names.
 * The once prefix::
 * The overrideProperty command::
 * The tweak command::
+* The single prefix::
 @end menu
 
 @node The override command
@@ -450,7 +459,7 @@ the original event:
 This long form of the @code{\tweak} command can be described as
 
 @example
-\tweak @var{layout-object}.@var{layout-property} @var{value}
+\tweak @var{LayoutObject}.@var{layout-property} #@var{value}
 @end example
 
 @cindex tuplets, nested
@@ -513,6 +522,60 @@ appearance may be modified in the usual way with
 Notation Reference:
 @ruser{The tweak command}.
 
+@node The single prefix
+@unnumberedsubsubsec The @code{@bs{}single} prefix
+
+@funindex \single
+@cindex tweak, generated from override
+
+Suppose we wanted to emphasize particular note heads by coloring them
+red and increasing their size, and to make it easy suppose also we
+have defined a function to do this:
+
+@lilypond[quote,verbatim]
+emphNoteHead = {
+  \override NoteHead.color = #red
+  \override NoteHead.font-size = 2
+}
+\relative c'' {
+  c4 a \once \emphNoteHead f d |
+}
+@end lilypond
+
+The @code{\once} prefix works fine to emphasize single notes or
+complete chords, but it cannot be used to emphasize a single note
+@emph{within} a chord.  Earlier we have seen how @code{\tweak} can
+be used to do this, see
+@ref{The tweak command,,The @code{@bs{}tweak} command}.  But
+@code{\tweak} cannot be used with a function; that's where
+@code{\single} comes in:
+
+@lilypond[quote,verbatim]
+emphNoteHead = {
+  \override NoteHead.color = #red
+  \override NoteHead.font-size = 2
+}
+\relative c'' {
+   <c a \single \emphNoteHead f d>4
+}
+@end lilypond
+
+In summary, @code{\single} converts overrides into tweaks so when
+there are several objects at the same point in musical time (like
+noteheads in a chord), @code{\single} will only affect a single one,
+the one generated by the immediately following music expression, in
+contrast to @code{\once} which will affect all of those objects.
+
+By using @code{\single} in this way any shorthand function
+containing just overrides may be applied to individual notes in a
+chord.  However, @code{\single} does not convert @code{\revert},
+@code{\set} or @code{\unset} into tweaks.
+
+@seealso
+Learning Manual:
+@ref{The tweak command,,The @code{@bs{}tweak} command},
+@ref{Using variables for layout adjustments}.
+
 
 @node The Internals Reference manual
 @section The Internals Reference manual
@@ -3146,18 +3209,26 @@ do this, see @ruser{Modifying ties and slurs}.
 Here's a further example.  We see that the beams
 collide with the ties:
 
-@lilypond[quote,verbatim,fragment,ragged-right]
+@lilypond[quote,verbatim,fragment,ragged-right,relative=1]
 {
   \time 4/2
   <<
-    { c'1 ~ 2. e'8 f' }
+    { c1~ 2. e8 f }
     \\
-    { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
+    {
+      e'8 e e e
+      e e e e
+      f2 g
+    }
   >>
   <<
-    { c'1 ~ 2. e'8 f' }
+    { c,,1~ 2. e8 f }
     \\
-    { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
+    {
+      e'8 e e e
+      e e e e
+      f2 g
+    }
   >>
 }
 @end lilypond
@@ -3170,29 +3241,37 @@ say, 1:
 @cindex Beam, example of overriding
 @cindex positions property, example
 
-@lilypond[quote,verbatim,fragment,ragged-right]
+@lilypond[quote,verbatim,ragged-right,relative=1]
 {
   \time 4/2
   <<
-    { c'1 ~ 2. e'8 f' }
+    { c1~ 2. e8 f }
     \\
     {
       \override Beam.positions = #'(-1 . -1)
-      e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g''
+      e'8 e e e
+      e e e e
+      f2 g
     }
   >>
   <<
-    { c'1 ~ 2. e'8 f' }
+    { c,,1~ 2. e8 f }
     \\
-    { e''8 e'' e'' e''  e'' e'' e'' e''  f''2 g'' }
+    {
+      e'8 e e e
+      e e e e
+      f2 g
+      \revert Beam.positions
+    }
   >>
 }
 @end lilypond
 
 @noindent
-Note that the override continues to apply in the first voice of
+Note that the override continues to apply in the second voice of
 the second measure of eighth notes, but not to any of the beams in the
-second voice.
+first voice, even those in the later second measure.  As soon as the
+override should no longer apply it should be reverted, as shown.
 
 @node The force-hshift property
 @unnumberedsubsubsec The @code{force-hshift} property
@@ -3219,10 +3298,7 @@ was left looking like this:
 @noindent
 The inner note of the first chord (i.e. the A-flat in the fourth
 Voice) need not be shifted away from the note column of the higher
-note.  We might expect to correct this by using @code{\shiftOff}, but
-this will cause warnings about clashing note columns.  Instead, we
-set @code{force-hshift}, which is a property of @code{NoteColumn},
-of this note to zero.
+note, so we use @code{\shiftOff}.
 
 In the second chord we prefer the F to line up with the A-flat and
 the lowest note to be positioned slightly right to avoid a collision
@@ -3248,8 +3324,7 @@ Here's the final result:
     { <ees, c>2 \once \override NoteColumn.force-hshift = 0.5 des }
     \\
     \\
-    { \once \override NoteColumn.force-hshift = 0 aes'2
-      \once \override NoteColumn.force-hshift = 0 f4 fes }
+    { \once \shiftOff aes'2 \once \shiftOff f4 fes }
   >> |
   <c ees aes c>1 |
 }
@@ -3795,56 +3870,38 @@ lhMusic = \relative c' {
 * Simulating a fermata in MIDI::
 @end menu
 
-@cindex transparent property, use of
-@cindex objects, making invisible
 @cindex removing objects
 @cindex objects, removing
-@cindex hiding objects
-@cindex objects, hiding
-@cindex invisible objects
-@cindex objects, invisible
 
 @node Tying notes across voices
 @unnumberedsubsubsec Tying notes across voices
 
 @cindex tying notes across voices
 
-The following example demonstrates how to connect notes in
-different voices using ties.  Normally, only two notes in the
-same voice can be connected with ties.  By using two voices,
-with the tied notes in one of them
+The following example demonstrates how to connect notes in different
+voices using ties.  Normally, only notes in the same voice can be
+connected with ties.  By using two voices, with the tied notes in one
+of them
 
 @lilypond[quote,fragment,relative=2]
 << { b8~ 8\noBeam } \\ { b8[ g] } >>
 @end lilypond
 
 @noindent
-and blanking the first up-stem in that voice, the tie appears to
-cross voices:
-
-@cindex Stem, example of overriding
-@cindex transparent property, example
-
-@lilypond[quote,fragment,relative=2,verbatim]
-<<
-  {
-    \tweak Stem.transparent ##t
-    b8~ 8\noBeam
-  }
-\\
-  { b8[ g] }
->>
-@end lilypond
+and removing the first up-stem and its flag in that voice, the tie
+appears to cross voices:
 
-To make sure that the just-blanked stem doesn't squeeze the tie
-too much, we can lengthen the stem by setting the
-@code{length} to @code{8},
+@funindex \omit
+@cindex Stem, example of removing
+@cindex Flag, example of removing
+@cindex @code{\omit}, example
+@cindex example of @code{\omit}
 
 @lilypond[quote,fragment,relative=2,verbatim]
 <<
   {
-    \tweak Stem.transparent ##t
-    \tweak Stem.length #8
+    \once \omit Stem
+    \once \omit Flag
     b8~ 8\noBeam
   }
 \\
@@ -3852,34 +3909,11 @@ too much, we can lengthen the stem by setting the
 >>
 @end lilypond
 
-@funindex \single
-@cindex tweak, generated from override
-Now for @emph{overriding} the transparency of a graphical object,
-we could have used the shorthand @code{\hide} as explained above.
-Tweaking is a different operation, affecting only properties
-generated from a single music expression.  It turns out that we
-can convert overrides into tweaks using @code{\single}, making it
-possible to rewrite the above example as
-
-@lilypond[quote,fragment,relative=2,verbatim]
-<<
-  {
-    \single \hide Stem
-    \single \hide Flag
-    \tweak Stem.length #8
-    b8~ 8\noBeam
-  }
-\\
-  { b8[ g] }
->>
-@end lilypond
+@seealso
+Learning Manual:
+@ref{The once prefix,,The @code{@bs{}once} prefix},
+@ref{The stencil property}.
 
-In this particular case, the difference to @code{\once \hide} is
-not apparent.  It is important when there are several objects at
-the same point in musical time (like noteheads in a chord).  In
-that case, @code{\once} will affect all of those objects while
-@code{\single} will only affect a single one, the one generated by
-the immediately following music expression.
 
 @node Simulating a fermata in MIDI
 @unnumberedsubsubsec Simulating a fermata in MIDI