]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tweaks.itely
Update from Trevor.
[lilypond.git] / Documentation / user / tweaks.itely
index 698a7b30eade6c55c3d0ecc402c8d6f4f2d4a986..81e24fcdcb0843e24b8c0642510fa7763ecff857 100644 (file)
@@ -58,10 +58,10 @@ and constructing Tweaks.
 @node Objects and interfaces
 @subsection Objects and interfaces
 
-@cindex Objects
-@cindex Grobs
-@cindex Spanners
-@cindex Interfaces
+@cindex objects
+@cindex grobs
+@cindex spanners
+@cindex interfaces
 
 Tweaking involves modifying the internal operation and structures
 of the LilyPond program, so we must first introduce some terms
@@ -108,7 +108,7 @@ interpretation of the input file.  To simplify these internal
 operations these common actions and properties are grouped 
 together in an object called a @code{grob-interface}.  There
 are many other groupings of common properties like this, each 
-one given a name ending in @code{-interface}.  In total there
+one given a name ending in @code{interface}.  In total there
 are over 100 such interfaces.  We shall see later why this is
 of interest and use to the user.
 
@@ -169,8 +169,8 @@ We have already met the commands @code{\set} and @code{\with},
 used to change the properties of @strong{contexts} and to remove
 and add @strong{engravers}, in
 @ref{Modifying context properties} and @ref{Adding
-and removing engravers}.  We now must meet one more important
-command.
+and removing engravers}.  We now must meet some more important
+commands.
 
 The command to change the properties of @strong{layout objects} is
 @code{\override}.  Because this command has to modify
@@ -183,7 +183,8 @@ how this is done.
 The general syntax of this command is:
 
 @example
-\override @emph{context}.@emph{layout_object} #'@emph{layout_property} = #@emph{value}
+\override @emph{context}.@emph{layout_object} 
+  #'@emph{layout_property} = #@emph{value}
 @end example
 
 @noindent
@@ -198,12 +199,31 @@ level contexts, i.e., @code{Voice}, @code{ChordNames} or
 @code{Lyrics}, and we shall omit it in many of the following
 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.
+
 For now, don't worry about the @code{#'}, which must precede the
 layout property, and the @code{#}, which must precede the value.
 These must always be present in exactly this form.  This is the
 most common command used in tweaking, and most of the rest of
 this chapter will be directed to presenting examples of how it is
-used.
+used.  Here is a simple example to change the color of the
+note head:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=1]
+c d
+\override NoteHead #'color = #red
+e f g
+\override NoteHead #'color = #green
+a b c
+@end lilypond
+
+@strong{\revert command}
+
+@cindex revert command
+@funindex \revert
 
 Once overridden, the property retains its new value until it is
 overridden again or a @code{\revert} command is encountered.
@@ -218,7 +238,35 @@ commands have been issued.
 
 Again, just like @emph{context} in the @code{\override} command,
 @emph{context} is often not needed.  It will be omitted
-in many of the following examples.
+in many of the following examples.  Here we revert the color
+of the note head to the default value for the final two notes:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=1]
+c d
+\override NoteHead #'color = #red
+e f g
+\override NoteHead #'color = #green
+a
+\revert NoteHead #'color
+b c
+@end lilypond
+
+@strong{\once prefix}
+
+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:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=1]
+c d
+\once \override NoteHead #'color = #red
+e f g
+\once \override NoteHead #'color = #green
+a b c
+@end lilypond
 
 @strong{\overrideProperty command}
 
@@ -250,7 +298,8 @@ middle note (the E) in a C major chord.  Let's first see what
 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
   <c e g>4
   \once \override NoteHead #'font-size = #-3
-  <c e g>4
+  <c e g>
+  <c e g>
 @end lilypond
 
 We see the override affects @emph{all} the notes in the chord.
@@ -266,8 +315,8 @@ 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 must be within a chord, i.e., within single
-angle brackets, so to tweak a single note the @code{\tweak}
+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.
 
@@ -302,9 +351,56 @@ a ^Black
 Note that the @code{\tweak} command must be preceded by an
 articulation mark as if it were an articulation itself.
 
+@cindex tuplets, nested
+@cindex triplets, nested
+@cindex bracket, tuplet
+@cindex tuplet bracket
+@cindex triplet bracket
+@funindex TupletBracket
+
+The @code{\tweak} command must also be used to change the 
+appearance of one of a set of nested tuplets which begin at the 
+same musical moment.  In the following example, the long tuplet
+bracket and the first of the three short brackets begin at the
+same musical moment, so any @code{\override} command would apply
+to both of them.  In the example, @code{\tweak} is used to
+distinguish between them.  The first @code{\tweak} command
+specifies that the long tuplet bracket is to be placed above the
+notes and the second one specifies that the tuplet number is to be
+printed in red on the first short tuplet bracket.
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+\tweak #'direction #up
+\times 4/3 {
+  \tweak #'color #red
+  \times 2/3 { c8[ c8 c8] }
+  \times 2/3 { c8[ c8 c8] }
+  \times 2/3 { c8[ c8 c8] }
+}
+@end lilypond
+
 You can find more details of the @code{\tweak} command in
 @ruser{Objects connected to the input}.
 
+If nested tuplets do not begin at the same moment their
+appearance may be modified in the usual way with
+@code{\override} commands:
+
+@c NOTE Tuplet brackets collide if notes are high on staff
+@c See issue 509
+@lilypond[quote,ragged-right,verbatim,fragment,relative=1]
+\times 2/3 { c8[ c c]}
+\once \override TupletNumber 
+  #'text = #tuplet-number::calc-fraction-text
+\times 2/3 {
+  c[ c]
+  c[ c]
+  \once \override TupletNumber #'transparent = ##t
+  \times 2/3 { c8[ c c] }
+\times 2/3 { c8[ c c]}
+}
+@end lilypond
+
 
 @node The Internals Reference manual
 @section The Internals Reference manual
@@ -424,7 +520,7 @@ the context.  Let's use a very large value for the thickness
 at first, so we can be sure the command is working.  We get:
 
 @example
-  \override Slur #'thickness = #5.0
+\override Slur #'thickness = #5.0
 @end example 
 
 Don't forget the @code{#'} preceding the
@@ -519,10 +615,9 @@ repositioned as follows:
 @noindent
 Now only the first slur is made heavier.
 
-The @code{\once} command can also be used before @code{\set}
-and @code{\unset}, and before the command to be introduced
-in the following section -- @code{revert}.
+The @code{\once} command can also be used before the @code{\set}
+command.
+
 @subheading Reverting
 
 @cindex revert
@@ -662,7 +757,7 @@ Ok, so the @code{\override} command we need to print the lyrics
 in italics should be
 
 @example
-  \override LyricText #'font-shape = #'italic
+\override LyricText #'font-shape = #'italic
 @end example
 
 @noindent
@@ -687,7 +782,7 @@ lyrics which it should affect, like this:
 @noindent
 and the lyrics are all printed in italics.
 
-@subheading Specifying context in lyric mode
+@subheading Specifying the context in lyric mode
 @cindex context, specifying in lyric mode
 
 In the case of lyrics, if you try specifying the context in the 
@@ -703,7 +798,7 @@ object name, as otherwise the two names are run together and
 the interpreter cannot recognise them.  So the command should be:
 
 @example
-  \override Lyrics . LyricText #'font-shape = #'italic
+\override Lyrics . LyricText #'font-shape = #'italic
 @end example
 
 @warning{In lyrics always leave whitespace between the final
@@ -3191,15 +3286,15 @@ To be effective under all circumstances these checks must be enabled
 by placing the overrides in a Score @code{\with} block, rather than
 in-line in music, as follows:
 
-@verbatim
-\new Score \with {
+@example
+\new Score \with @{
   % Makes sure text scripts and lyrics are within the paper margins
   \override PaperColumn #'keep-inside-line = ##t
   \override NonMusicalPaperColumn #'keep-inside-line = ##t
-{
+@} @{
    ..
-}
-@end verbatim
+@}
+@end example
 
 @node Advanced tweaks with Scheme
 @subsection Advanced tweaks with Scheme
@@ -3225,33 +3320,29 @@ the staff.
 #(define (color-notehead grob)
   "Color the notehead according to its position on the staff."
   (let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7)))
-       (case mod-position  ; Set rainbow colors
-         ((1) (ly:grob-set-property! grob 'color (x11-color 'red)))
-         ((2) (ly:grob-set-property! grob 'color (x11-color 'orange)))
-         ((3) (ly:grob-set-property! grob 'color (x11-color 'yellow)))
-         ((4) (ly:grob-set-property! grob 'color (x11-color 'green)))
-         ((5) (ly:grob-set-property! grob 'color (x11-color 'blue)))
-         ((6) (ly:grob-set-property! grob 'color (x11-color 'purple)))
-         ((0) (ly:grob-set-property! grob 'color (x11-color 'violet)))
-       )
+    (case mod-position
+      ;;   Return rainbow colors
+      ((1) (x11-color 'red    ))  ; for C
+      ((2) (x11-color 'orange ))  ; for D
+      ((3) (x11-color 'yellow ))  ; for E
+      ((4) (x11-color 'green  ))  ; for F
+      ((5) (x11-color 'blue   ))  ; for G
+      ((6) (x11-color 'purple ))  ; for A
+      ((0) (x11-color 'violet ))  ; for B
+    )
   )
 )
 
-rainbow = {
-  % Override color so it is obtained from color-notehead Scheme function
-  \override NoteHead #'color = #color-notehead
-}
-
 \relative c' {
-  \rainbow {
-    c2 c' |
-    b4 g8 a b4 c |
-    c,2 a' |
-    g1 |
-  }
+  % Arrange to obtain color from color-notehead procedure
+  \override NoteHead #'color = #color-notehead
+  c2 c' | 
+  b4 g8 a b4 c | 
+  c,2 a' | 
+  g1 |
 }
 \addlyrics {
-  Some -- where o -- ver the Rain -- bow, way up high,
+  Some -- where o -- ver the Rain -- bow way up high,
 }
 @end lilypond