]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/learning/tweaks.itely
Run scripts/auxiliar/update-with-convert-ly.sh
[lilypond.git] / Documentation / learning / tweaks.itely
index 9f1c5dd0b5d43c52a8746e7dbfc0a561a4286e8e..107cbaea99aa84c65834bee98043a48d1cd79567 100644 (file)
@@ -8,7 +8,7 @@
     Guide, node Updating translation committishes..
 @end ignore
 
-@c \version "2.14.0"
+@c \version "2.16.0"
 
 @node Tweaking output
 @chapter Tweaking output
@@ -214,9 +214,10 @@ level contexts, i.e., @code{Voice}, @code{ChordNames} or
 examples.  We shall see later when it must be specified.
 
 Later sections deal comprehensively with properties and their
-values, but to illustrate the format and use of these commands
-we shall use just a few simple properties and values which are
-easily understood.
+values, see @ref{Types of properties}.  But in this section we shall 
+use just a few simple properties and values which are easily
+understood in order to illustrate the format and use of these
+commands.
 
 For now, don't worry about the @code{#'}, which must precede the
 layout property, and the@tie{}@code{#}, which must precede the value.
@@ -278,22 +279,25 @@ b4 c |
 @funindex \once
 @funindex once
 
-Both the @code{\override} and the @code{\set} commands may be
-prefixed by @code{\once}.  This causes the following
-@code{\override} or @code{\set} command to be effective only
-during the current musical moment before the property reverts
-back to its default value.  Using the same example, we can
-change the color of a single note like this:
+Both the @code{\override} and the @code{\set} commands may be prefixed
+by @code{\once}.  This causes the following @code{\override} or
+@code{\set} command to be effective only during the current musical
+moment before the property reverts back to its previous value (this can
+be different from the default if another @code{\override} is still in
+effect).  Using the same example, we can change the color of a single
+note like this:
 
 @cindex color property, example
 @cindex NoteHead, example of overriding
 
 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
 c4 d
-\once \override NoteHead #'color = #red
+\override NoteHead #'color = #red
 e4 f |
 \once \override NoteHead #'color = #green
-g4 a b c |
+g4 a
+\revert NoteHead #'color
+b c |
 @end lilypond
 
 @strong{\overrideProperty command}
@@ -316,11 +320,11 @@ We mention it here for completeness, but for details see
 @funindex \tweak
 @funindex tweak
 
-The final tweaking command which is available is @code{\tweak}.
-This should be used to change the properties of objects which
-occur at the same musical moment, such as the notes within a
-chord.  Using @code{\override} would affect all the notes
-within a chord, whereas @code{\tweak} affects just the following
+The final tweaking command which is available is @code{\tweak}.  This
+should be used when several objects occur at the same musical moment,
+but you only want to change the properties of selected ones, such as a
+single note within a chord.  Using @code{\override} would affect all the
+notes within a chord, whereas @code{\tweak} affects just the following
 item in the input stream.
 
 Here's an example.  Suppose we wish to change the size of the
@@ -344,16 +348,10 @@ apply the override to all layout objects of the type specified
 which occur at the same musical moment as the @code{\override}
 command itself.
 
-The @code{\tweak} command operates in a different way.  It acts
-on the immediately following item in the input stream.  However,
-it is effective only on objects which are created directly from
-the input stream, essentially note heads and articulations;
-objects such as stems and accidentals are created later and
-cannot be tweaked in this way.  Furthermore, when it is applied
-to note heads these @emph{must} be within a chord, i.e., within
-single angle brackets, so to tweak a single note the @code{\tweak}
-command must be placed inside single angle brackets with the
-note.
+The @code{\tweak} command operates in a different way.  It acts on
+the immediately following item in the input stream.  In its simplest
+form, it is effective only on objects which are created directly
+from the following item, essentially note heads and articulations.
 
 So to return to our example, the size of the middle note of
 a chord would be changed in this way:
@@ -366,13 +364,12 @@ a chord would be changed in this way:
 <c \tweak #'font-size #-3 e g>4
 @end lilypond
 
-Note that the syntax of @code{\tweak} is different from that
-of the @code{\override} command.  Neither the context nor the
-layout object should be specified; in fact, it would generate
-an error to do so.  These are both implied by the following
-item in the input stream.  Note also that an equals sign should
-not be present.  So the general syntax of the
-@code{\tweak} command is simply
+Note that the syntax of @code{\tweak} is different from that of the
+@code{\override} command.  The context should not be specified; in
+fact, it would generate an error to do so.  Both context and layout
+object are implied by the following item in the input stream.  Note
+also that an equals sign should not be present.  So the simple form
+of the @code{\tweak} command is
 
 @example
 \tweak #'@var{layout-property} #@var{value}
@@ -391,8 +388,30 @@ a4^"Black"
 @end lilypond
 
 @noindent
-Note that the @code{\tweak} command must be preceded by an
-articulation mark as if it were an articulation itself.
+Note that the @code{\tweak} command must be preceded by an articulation
+mark since the tweaked expression needs to be applied as an articulation
+itself.  In case of multiple direction overrides (@code{^} or @code{_}),
+the leftmost override wins since it is applied last.
+
+@cindex @code{\tweak}, Accidental
+@cindex @code{\tweak}, specific layout object
+
+Objects such as stems and accidentals are created later, and not
+directly from the following event.  It is still possible to use
+@code{\tweak} on such indirectly created objects by explicitly naming
+the layout object, provided that LilyPond can trace its origin back to
+the original event:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=2]
+<\tweak Accidental #'color #red   cis4
+ \tweak Accidental #'color #green es
+                                  g>
+@end lilypond
+
+This long form of the @code{\tweak} command can be described as
+@example
+\tweak @var{layout-object} #'@var{layout-property} @var{value}
+@end example
 
 @cindex tuplets, nested
 @cindex triplets, nested
@@ -2856,26 +2875,26 @@ was left looking like this:
   <<
     { c2 aes4. bes8 }
     \\
-    { aes2 f4 fes }
+    { <ees, c>2 des }
     \\
-    {
-      \voiceFour
-      <ees c>2 des
-    }
+    \\
+    { aes'2 f4 fes }
   >> |
   <c ees aes c>1 |
 }
 @end lilypond
 
 @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}, which is a
-property of @code{NoteColumn}, 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} of this note to
-0.5, ie half a note head's width to the right of the note column of
-the higher notes.
+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.  To correct this we set @code{force-hshift}, which is a property
+of @code{NoteColumn}, of this note to zero.
+
+In the second chord we prefer the F to line up with the A and the
+lowest note to be positioned slightly right to avoid a collision of
+stems.  We achieve this by setting @code{force-hshift} in the
+@code{NoteColumn} of the low D-flat to move it to the right by half
+a staff-space.
 
 Here's the final result:
 
@@ -2888,15 +2907,17 @@ Here's the final result:
   <<
     { c2 aes4. bes8 }
     \\
-    { aes2 f4 fes }
-    \\
     {
-      \voiceFour
-      \once \override NoteColumn #'force-hshift = #0
-      <ees c>2
+      <ees, c>2
       \once \override NoteColumn #'force-hshift = #0.5
       des2
     }
+    \\
+    \\
+    {
+      \override NoteColumn #'force-hshift = #0
+      aes'2 f4 fes
+    }
   >> |
   <c ees aes c>1 |
 }
@@ -2941,7 +2962,8 @@ rhMusic = \relative c'' {
         c,8~
         % Reposition the c2 to the right of the merged note
         \once \override NoteColumn #'force-hshift = #1.0
-        % Move the c2 out of the main note column so the merge will work
+        % Move the c2 out of the main note column
+        % so the merge will work
         \shiftOnn
         c2
       }
@@ -2951,7 +2973,8 @@ rhMusic = \relative c'' {
         % Stem on the d2 must be down to permit merging
         \stemDown
         % Stem on the d2 should be invisible
-        \once \override Stem #'transparent = ##t
+        \tweak Stem #'transparent ##t
+        \tweak Flag #'transparent ##t
         d2
       }
       \new Voice {
@@ -3301,7 +3324,8 @@ rhMusic = \relative c'' {
       { c,8 d fis bes a }  % continuation of main voice
       \new Voice {
         \voiceTwo
-        % Move the c2 out of the main note column so the merge will work
+        % Move the c2 out of the main note column
+        % so the merge will work
         c,8~ \shiftOnn c2
       }
       \new Voice {
@@ -3373,7 +3397,8 @@ rhMusic = \relative c'' {
         c,8~
         % Reposition the c2 to the right of the merged note
         \once \override NoteColumn #'force-hshift = #1.0
-        % Move the c2 out of the main note column so the merge will work
+        % Move the c2 out of the main note column
+        % so the merge will work
         \shiftOnn
         c2
       }
@@ -3383,7 +3408,8 @@ rhMusic = \relative c'' {
         % Stem on the d2 must be down to permit merging
         \stemDown
         % Stem on the d2 should be invisible
-        \once \override Stem #'transparent = ##t
+        \tweak Stem #'transparent ##t
+        \tweak Flag #'transparent ##t
         d2
       }
       \new Voice {
@@ -3465,7 +3491,8 @@ cross voices:
 @lilypond[quote,fragment,relative=2,verbatim]
 <<
   {
-    \once \override Stem #'transparent = ##t
+    \tweak Stem #'transparent ##t
+    \tweak Flag #'transparent ##t
     b8~ b\noBeam
   }
 \\
@@ -3480,8 +3507,9 @@ too much, we can lengthen the stem by setting the
 @lilypond[quote,fragment,relative=2,verbatim]
 <<
   {
-    \once \override Stem #'transparent = ##t
-    \once \override Stem #'length = #8
+    \tweak Stem #'transparent ##t
+    \tweak Flag #'transparent ##t
+    \tweak Stem #'length #8
     b8~ b\noBeam
   }
 \\
@@ -3628,7 +3656,7 @@ VerseOne = \lyrics {
 }
 
 VerseTwo = \lyricmode {
-  O | \emphasize Christ, \normal whose voice the | wa -- ters heard,
+  O | \once \emphasize Christ, whose voice the | wa -- ters heard,
 }
 
 VerseThree = \lyricmode {
@@ -3676,19 +3704,17 @@ the parts with all the @code{#()}.  This is explained in
 @lilypond[quote,verbatim,ragged-right]
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #{ \markup { \hspace #0
+               \translate #'(5 . 0)
+               \line { \dynamic "mp"
+                       \text \italic "dolce" } }
+  #})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #{ ^\markup \bold \box #string #})
 
 \relative c'' {
   \tempo 4=50
@@ -3700,32 +3726,28 @@ inst =
 }
 @end lilypond
 
-There are some problems with overlapping output; we'll fix those using
-the techniques in @ref{Moving objects}.  But let's also
-do something about the @code{mpdolce} and @code{inst}
-definitions.  They produce the output we desire, but we might want
-to use them in another piece.  We could simply copy-and-paste them
-at the top of every file, but that's an annoyance.  It also leaves
-those definitions in our input files, and I personally find all
-the @code{#()} somewhat ugly.  Let's hide them in another file:
+Let's do something about the @code{mpdolce} and @code{inst} definitions.
+They produce the output we desire, but we might want to use them in
+another piece.  We could simply copy-and-paste them at the top of every
+file, but that's an annoyance.  It also leaves those definitions in our
+input files, and I personally find all the @code{#()} somewhat ugly.
+Let's hide them in another file:
 
 @example
 %%% save this to a file called "definitions.ily"
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #@{ \markup @{ \hspace #0
+               \translate #'(5 . 0)
+               \line @{ \dynamic "mp"
+                       \text \italic "dolce" @} @}
+  #@})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #@{ ^\markup \bold \box #string #@})
 @end example
 
 We will refer to this file using the @code{\include} command near
@@ -3753,19 +3775,17 @@ Now let's modify our music (let's save this file as @file{music.ly}).
 @lilypond[quote,ragged-right]
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #{ \markup { \hspace #0
+               \translate #'(5 . 0)
+               \line { \dynamic "mp"
+                       \text \italic "dolce" } }
+  #})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #{ ^\markup \bold \box #string #})
 
 \relative c'' {
   \tempo 4=50
@@ -3790,19 +3810,17 @@ with this:
 %%%  definitions.ily
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #@{ \markup @{ \hspace #0
+               \translate #'(5 . 0)
+               \line @{ \dynamic "mp"
+                       \text \italic "dolce" @} @}
+  #@})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #@{ ^\markup \bold \box #string #@})
 
 \layout@{
   \context @{
@@ -3825,19 +3843,17 @@ inst =
 @lilypond[quote,ragged-right]
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #{ \markup { \hspace #0
+               \translate #'(5 . 0)
+               \line { \dynamic "mp"
+                       \text \italic "dolce" } }
+  #})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #{ ^\markup \bold \box #string #})
 
 \layout{
   \context {
@@ -3878,19 +3894,17 @@ overall size of the output.
 %%%  definitions.ily
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #@{ \markup @{ \hspace #0
+               \translate #'(5 . 0)
+               \line @{ \dynamic "mp"
+                       \text \italic "dolce" @} @}
+  #@})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #@{ ^\markup \bold \box #string #@})
 
 #(set-global-staff-size 23)
 
@@ -3914,19 +3928,17 @@ inst =
 @lilypond[quote,ragged-right]
 mpdolce =
 #(make-dynamic-script
-  (markup #:hspace 0
-          #:translate '(5 . 0)
-          #:line (#:dynamic "mp"
-                  #:text #:italic "dolce")))
+  #{ \markup { \hspace #0
+               \translate #'(5 . 0)
+               \line { \dynamic "mp"
+                       \text \italic "dolce" } }
+  #})
 
 inst =
 #(define-music-function
      (parser location string)
      (string?)
-   (make-music
-    'TextScriptEvent
-    'direction UP
-    'text (markup #:bold (#:box string))))
+   #{ ^\markup \bold \box #string #})
 
 #(set-global-staff-size 23)
 
@@ -3997,22 +4009,27 @@ first find the directory appropriate to your system.  The location
 of this directory depends (a) on whether you obtained LilyPond
 by downloading a precompiled binary from lilypond.org
 or whether you installed it from a package manager (i.e.
-distributed with Linux, or installed under fink or cygwin) or
+distributed with GNU/Linux, or installed under fink or cygwin) or
 compiled it from source, and (b) on which operating system it is
 being used:
 
 @strong{Downloaded from lilypond.org}
 
 @itemize @bullet
-@item Linux
+@item GNU/Linux
 
 Navigate to
+@example
 @file{@var{INSTALLDIR}/lilypond/usr/@/share/lilypond/current/}
+@end example
 
 @item MacOS X
 
 Navigate to
+@example
 @file{@var{INSTALLDIR}/LilyPond.app/Contents/@/Resources/share/lilypond/current/}
+@end example
+
 by either @code{cd}-ing into this directory from the
 Terminal, or control-clicking on the LilyPond application and
 selecting @q{Show Package Contents}.
@@ -4020,7 +4037,9 @@ selecting @q{Show Package Contents}.
 @item Windows
 
 Using Windows Explorer, navigate to
+@example
 @file{@var{INSTALLDIR}/LilyPond/usr/@/share/lilypond/current/}
+@end example
 
 @end itemize