]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/notation/changing-defaults.itely
Merge branch 'translation'
[lilypond.git] / Documentation / notation / changing-defaults.itely
index 5a364f134d1eee32ba9997d0587e8fc9228eaf6b..cb8edf2c033a272ccf7aff8124f6a4080e76e343 100644 (file)
@@ -8,7 +8,7 @@
     Guide, node Updating translation committishes..
 @end ignore
 
-@c \version "2.17.18"
+@c \version "2.17.30"
 
 @node Changing defaults
 @chapter Changing defaults
@@ -114,12 +114,57 @@ further explanation and with links to the IR.
 Contexts are arranged hierarchically:
 
 @menu
+* Output definitions - blueprints for contexts::
 * Score - the master of all contexts::
 * Top-level contexts - staff containers::
 * Intermediate-level contexts - staves::
 * Bottom-level contexts - voices::
 @end menu
 
+@node Output definitions - blueprints for contexts
+@unnumberedsubsubsec Output definitions - blueprints for contexts
+
+This section explains the relevance of output definitions when
+working with contexts.  Examples for actual output definitions are
+given later (see @ref{Changing all contexts of the same type}).
+
+@cindex output definitions
+@funindex \layout
+While music written in a file may refer to context types and
+names, contexts are created only when the music is actually being
+interpreted.  LilyPond interprets music under control of an
+@q{output definition} and may do so for several different output
+definitions, resulting in different output.  The output definition
+relevant for printing music is specified using @code{\layout}.
+
+@funindex \midi
+A much simpler output definition used for producing Midi output is
+specified using @code{\midi}.  Several other output definitions
+are used by LilyPond internally, like when using the part combiner
+(@ref{Automatic part combining}) or creating music quotes
+(@ref{Quoting other voices}).
+
+Output definitions define the relation between contexts as well as
+their respective default settings.  While most changes will
+usually be made inside of a @code{\layout} block, Midi-related
+settings will only have an effect when made within a @code{\midi}
+block.
+
+@funindex autoBeaming
+Some settings affect several outputs: for example, if
+@code{autoBeaming} is turned off in some context, beams count as
+melismata for the purpose of matching music to lyrics as described
+in @ref{Automatic syllable durations}.  This matching is done both
+for printed output as well as for Midi.  If changes made to
+@code{autoBeaming} within a context definition of a @code{\layout}
+block are not repeated in the corresponding @code{\midi} block,
+lyrics and music will get out of sync in Midi.
+
+@seealso
+Installed Files:
+@file{ly/engraver-init.ly}.
+@file{ly/performer-init.ly}.
+
 @node Score - the master of all contexts
 @unnumberedsubsubsec Score - the master of all contexts
 
@@ -130,8 +175,7 @@ such as clefs, time signatures, and key-signatures are aligned
 across staves.
 
 A Score context is instantiated implicitly when a
-@code{\score @{@dots{}@}} or @code{\layout @{@dots{}@}} block is
-processed.
+@code{\score @{@dots{}@}} block is processed.
 
 @node Top-level contexts - staff containers
 @unnumberedsubsubsec Top-level contexts - staff containers
@@ -169,8 +213,9 @@ Handles clefs, bar lines, keys, accidentals.  It can contain
 
 @strong{@emph{RhythmicStaff}}
 
-Like @code{Staff} but for printing rhythms.  Pitches are ignored;
-the notes are printed on one line.
+Like @code{Staff} but for printing rhythms.  Pitches are ignored
+when engraving; the notes are printed on one line.  The MIDI
+rendition retains pitches unchanged.
 
 @strong{@emph{TabStaff}}
 
@@ -429,7 +474,6 @@ Alternatively, variables may be employed to similar effect.  See
 @rlearning{Organizing pieces with variables}.
 
 @item
-
 @code{\context} with no name will match the first of any previously
 created contexts of the same type in the same context heirarchy,
 even one that has been given a name, and its music expression will be
@@ -456,7 +500,7 @@ when lyrics are associated with music:
 
 @example
 \new Voice = "tenor" @var{music}
-...
+@dots{}
 \new Lyrics \lyricsto "tenor" @var{lyrics}
 @end example
 
@@ -472,7 +516,6 @@ musical content.  If a single context is to be modified, a @code{\with}
 block must be used, see @ref{Changing just one specific context}.
 
 @seealso
-
 Learning Manual:
 @rlearning{Organizing pieces with variables}.
 
@@ -499,12 +542,12 @@ an earlier context.
 
 There is an exception to this general rule: just one of the
 @code{Voice} contexts in a @code{Staff} context or in a
-@code{<<...>>} construct will always persist to the end of the
-enclosing @code{Staff} context or @code{<<...>>} construct, even
+@code{<<@dots{}>>} construct will always persist to the end of the
+enclosing @code{Staff} context or @code{<<@dots{}>>} construct, even
 though there may be periods when it has nothing to do.  The context
 to persist in this way will be the first one encountered in the
-first enclosed @code{@{...@}} construct, ignoring any in enclosed
-@code{<<...>>} constructs.
+first enclosed @code{@{@dots{}@}} construct, ignoring any in enclosed
+@code{<<@dots{}>>} constructs.
 
 Any context can be kept alive by ensuring it has something to do at
 every musical moment.  @code{Staff} contexts are kept alive by
@@ -675,7 +718,7 @@ modifying it,
   @emph{etc.}
 @}
 @{
-  @emph{..music..}
+  @emph{@dots{}music@dots{}}
 @}
 @end example
 
@@ -721,14 +764,16 @@ time signature.
     \new Staff \with {
       \consists "Timing_translator"
       \consists "Default_bar_line_engraver"
-    } {
+    }
+    \relative c'' {
         \time 3/4
         c4 c c c c c
     }
   \new Staff \with {
     \consists "Timing_translator"
     \consists "Default_bar_line_engraver"
-  } {
+  }
+  \relative c'' {
       \time 2/4
       c4 c c c c c
   }
@@ -804,9 +849,15 @@ default values in just one particular instance of a context.
 @funindex \context
 @funindex \layout
 
-The context settings which are to be used by default in
+The default context settings which are to be used for typesetting in
 @code{Score}, @code{Staff}, @code{Voice} and other contexts may be
-specified in a @code{\context} block within any @code{\layout} block.
+specified in a @code{\context} block within any @code{\layout}
+block.
+
+Settings for Midi output as opposed to typesetting will have to be
+separately specified in @code{\midi} blocks (see @ref{Output
+definitions - blueprints for contexts}).
+
 The @code{\layout} block should be placed within the @code{\score}
 block to which it is to apply, after the music.
 
@@ -953,14 +1004,16 @@ must be placed immediately after the @code{\new} @var{context-type}
 command:
 
 @example
-\new Staff
-\with @{
-  [context settings for this context instance only]
-@} @{
-...
+\new Staff \with @{ [context settings for this context instance only] @}
+@{
+  @dots{}
 @}
 @end example
 
+Since such a @q{context modification} is specified inside of
+music, it will affect @emph{all} outputs (typesetting @emph{and}
+Midi) as opposed to changes within an output definition.
+
 The following types of settings may be specified:
 
 @itemize
@@ -970,10 +1023,7 @@ An @code{\override} command, but with the context name omitted
 @lilypond[quote,verbatim]
 \score {
   \new Staff {
-    \new Voice
-    \with {
-      \override Stem.thickness = #4.0
-    }
+    \new Voice \with { \override Stem.thickness = #4.0 }
     {
       \relative c'' {
         a4^"Thick stems" a a a
@@ -996,10 +1046,8 @@ Directly setting a context property
         a4 a a a
       }
     }
-    \new Staff
-    \with {
-      fontSize = #-4
-    } {
+    \new Staff \with { fontSize = #-4 }
+    {
       \relative c'' {
         a4^"Smaller font" a a a
         a4 a a a
@@ -1023,11 +1071,9 @@ A predefined command such as @code{\dynamicUp}
         }
       }
     }
-    \new Staff
-    \with { \accidentalStyle dodecaphonic }
+    \new Staff \with { \accidentalStyle dodecaphonic }
     {
-      \new Voice
-      \with { \dynamicUp }
+      \new Voice \with { \dynamicUp }
       {
         \relative c'' {
           a4^"Dynamics above" a a a
@@ -1058,7 +1104,8 @@ on the context initiation statement is used,
 
 @item
 otherwise the default value taken from the most recent appropriate
-@code{\context} block in the @code{\layout} blocks is used,
+@code{\context} block in the @code{\layout} or @code{\midi} blocks
+is used,
 
 @item
 otherwise the LilyPond built-in default is used.
@@ -1073,7 +1120,7 @@ Notation Reference:
 @ref{Bottom-level contexts - voices},
 @ref{The set command},
 @ref{The override command},
-@ref{The \layout block}.
+@ref{The layout block,,The @code{@bs{}layout} block}.
 
 
 @node Defining new contexts
@@ -1114,8 +1161,7 @@ to indicate improvisation in jazz pieces,
   \consists "Pitch_squash_engraver"
   squashedPosition = #0
   \override NoteHead.style = #'slash
-  \override Stem.transparent = ##t
-  \override Flag.transparent = ##t
+  \hide Stem
   \alias Voice
 }
 \context { \Staff
@@ -1185,13 +1231,18 @@ The notes look like a slash, and have no stem,
 
 @example
 \override NoteHead.style = #'slash
-\override Stem.transparent = ##t
-\override Flag.transparent = ##t
+\hide Stem
 @end example
 
-All these plug-ins have to cooperate, and this is achieved with a
-special plug-in, which must be marked with the keyword @code{\type}.
-This should always be @code{Engraver_group}.
+All these plug-ins have to communicate under the control of the
+context.  The mechanisms with which contexts communicate are
+established by declaring the context @code{\type}.  Within a
+@code{\layout} block, most contexts will be of type
+@code{Engraver_group}.  Some special contexts and contexts in
+@code{\midi} blocks use other context types.  Copying and
+modifying an existing context definition will also fill in the
+type.  Since this example creates a definition from scratch, it
+needs to be specified explicitly.
 
 @example
 \type "Engraver_group"
@@ -1209,8 +1260,7 @@ Put together, we get
   \consists "Pitch_squash_engraver"
   squashedPosition = #0
   \override NoteHead.style = #'slash
-  \override Stem.transparent = ##t
-  \override Flag.transparent = ##t
+  \hide Stem
   \alias Voice
 @}
 @end example
@@ -1261,6 +1311,10 @@ Then the output at the start of this subsection can be entered as
 @}
 @end example
 
+To complete this example, changes affecting the context hierarchy
+should be repeated in a @code{\midi} block so that Midi output
+depends on the same context relations.
+
 @seealso
 
 Internals Reference:
@@ -2348,20 +2402,60 @@ one encountered in the input file.
 @node set versus override
 @subsection @code{\set} vs. @code{\override}
 
-@c TODO -- This section is probably unnecessary now.
-
-@ignore
-We have seen two methods of changing properties: @code{\set} and
-@code{\override}.  There are actually two different kinds of
-properties.
-
-@code{fontSize} is a special property: it is equivalent to
-entering @code{\override ... #'font-size} for all pertinent
-objects.  Since this is a common change, the special
-property (modified with @code{\set}) was created.
-
-@end ignore
+@c TODO Should't a bunch of that be explained earlier?
 
+@funindex \set
+@funindex \override
+Both @code{\set} and @code{\override} manipulate properties
+associated with contexts.  In either case, properties heed the
+hierarchy of contexts: properties not set in a context itself show
+the values of the respective parent context.
+
+Values and lifetime of context properties are dynamic and only
+available when music is being interpreted, @q{iterated}.  At the
+time of context creation, properties are initialized from the
+corresponding context definition and possible context
+modifications.  Afterwards, changes are achieved with
+property-setting commands in the music itself.
+
+Now grob definitions are a special category of context properties.
+Since their structure, bookkeeping and use is different from
+ordinary context properties, they are accessed with a different
+set of commands, and treated separately in the documentation.
+
+As opposed to plain context properties, grob definitions are
+subdivided into grob properties.  A @qq{grob} (graphical object)
+is usually created by an engraver at the time of interpreting a
+music expression and receives its initial properties from the
+current grob definition of the engraver's context.  The engraver
+(or other @q{backend} parts of LilyPond) may subsequently add or
+change properties to the grob, but that does not affect the
+context's grob definition.
+
+What we call @q{grob properties} in the context of user-level
+tweaking are actually the properties of a context's grob
+definition.  In contrast to ordinary context properties, grob
+definitions have the bookkeeping required to keep track of its
+parts, the individual grob properties (and even subproperties of
+them) separately so that it is possible to define those parts in
+different contexts and have the overall grob definition at the
+time of grob creation be assembled from pieces provided in
+different contexts among the current context and its parents.
+
+Grob definitions are manipulated using @code{\override} and
+@code{\revert} and have a name starting with a capital letter
+(like @samp{NoteHead}) whereas ordinary context properties are
+manipulated using @code{\set} and @code{\unset} and are named
+starting with a lowercase letter.
+
+@cindex tweak, relation to @code{\override}
+@funindex \tweak
+@funindex \overrideProperty
+The special commands @code{\tweak} and @code{\overrideProperty}
+change grob properties bypassing context properties completely.
+Instead they catch grobs as they are being created and then
+directly set properties on them when they originate from a tweaked
+music event or are of a particular kind, respectively.
 
 @node Modifying alists
 @subsection Modifying alists
@@ -2856,11 +2950,11 @@ Works not at all for:
 @end ignore
 
 @lilypond[verbatim,quote,relative=2]
-a~a
+a~ a
 a
 % increase the length of the tie
 -\tweak minimum-length #5
-~a
+~ a
 @end lilypond
 
 @lilypond[verbatim,quote,relative=2]
@@ -2884,15 +2978,15 @@ This override can also be used to increase the length of slurs and
 phrasing slurs:
 
 @lilypond[verbatim,quote,relative=2]
-a( a)
+a( g)
 a
 -\tweak minimum-length #5
-( a)
+( g)
 
-a\( a\)
+a\( g\)
 a
 -\tweak minimum-length #5
-\( a\)
+\( g\)
 @end lilypond
 
 For some layout objects, the @code{minimum-length} property becomes
@@ -3131,6 +3225,7 @@ considerations.
 @unnumberedsubsubsec Removing the stencil
 
 @cindex stencil, removing
+@funindex \omit
 
 Every layout object has a stencil property.  By default this is set
 to the specific function which draws that object.  If this property
@@ -3146,10 +3241,21 @@ a a
 a a a
 @end lilypond
 
+This rather common operation has a shortcut @code{\omit}:
+
+@lilypond[quote,verbatim,relative=1]
+a1 a
+\omit Score.BarLine
+a a
+\undo \omit Score.BarLine
+a a a
+@end lilypond
+
 @node Making objects transparent
 @unnumberedsubsubsec Making objects transparent
 
 @cindex transparent, making objects
+@funindex \hide
 
 Every layout object has a transparent property which by default is
 set to @code{#f}.  If set to @code{#t} the object still occupies
@@ -3161,6 +3267,14 @@ a4 a
 a a
 @end lilypond
 
+This rather common operation has a shortcut @code{\hide}:
+
+@lilypond[quote,verbatim,relative=2]
+a4 a
+\once \hide NoteHead
+a a
+@end lilypond
+
 @node Painting objects white
 @unnumberedsubsubsec Painting objects white
 
@@ -3590,6 +3704,7 @@ appearance of the printed score.
 * Vertical grouping of grobs::
 * Modifying stencils::
 * Modifying shapes::
+* Modifying broken spanners::
 * Unpure-pure containers::
 @end menu
 
@@ -3848,13 +3963,13 @@ Each type of object has its own default reference point, to which
 rehearsal marks are aligned:
 
 @lilypond[verbatim,quote,relative=1]
-% The rehearsal mark will be aligned to right edge of the Clef
+% The rehearsal mark will be aligned to the right edge of the Clef
 \override Score.RehearsalMark.break-align-symbols = #'(clef)
 \key a \major
 \clef treble
 \mark "↓"
 e1
-% The rehearsal mark will be centered above the Time Signature
+% The rehearsal mark will be aligned to the left edge of the Time Signature
 \override Score.RehearsalMark.break-align-symbols = #'(time-signature)
 \key a \major
 \clef treble
@@ -4243,6 +4358,112 @@ Internals Reference:
 @rinternals{TieColumn}.
 
 
+@node Modifying broken spanners
+@subsection Modifying broken spanners
+
+@menu
+* Using alterBroken::
+@end menu
+
+@node Using alterBroken
+@unnumberedsubsubsec Using @code{\alterBroken}
+
+@cindex spanners, modifying
+@cindex broken spanners, modifying
+@funindex \alterBroken
+
+When a spanner crosses a line break or breaks, each piece
+inherits the attributes of the original spanner.  Thus, ordinary
+tweaking of a broken spanner applies the same modifications to
+each of its segments.  In the example below, overriding
+@code{thickness} affects the slur on either side of the line
+break.
+
+@lilypond[verbatim,quote,ragged-right,relative=2]
+r2
+\once\override Slur.thickness = 10
+c8( d e f
+\break
+g8 f e d) r2
+@end lilypond
+
+Independently modifying the appearance of individual pieces
+of a broken spanner is possible with the @code{\alterBroken}
+command.  This command can produce either an @code{\override}
+or a @code{\tweak} of a spanner property.
+
+The syntax for @code{\alterBroken} is
+
+@example
+[-]@code{\alterBroken} @var{property} @var{values} @var{item}
+@end example
+
+The argument @var{values} is a list of values, one for each
+broken piece.  If @var{item} is a grob name like @code{Slur} or
+@code{Staff.PianoPedalBracket}, the result is an @code{\override}
+of the specified grob type.  If @var{item} is a music expression
+such as @qq{(} or @qq{[} the result is the same music expression
+with an appropriate tweak applied.
+
+The leading hyphen must be used with the @code{\tweak} form.  Do
+not add it when @code{\alterBroken} is used as an
+@code{\override}.
+
+In its @code{\override} usage, @code{\alterBroken} may be
+prefaced by @code{\once} or @code{\temporary} and reverted by
+using @code{\revert} with @var{property}.
+
+The following code applies an independent @code{\override} to
+each of the slur segments in the previous example:
+
+@lilypond[verbatim,quote,ragged-right,relative=2]
+r2
+\alterBroken thickness #'(10 1) Slur
+c8( d e f
+\break
+g8 f e d) r2
+@end lilypond
+
+The @code{\alterBroken} command may be used with any spanner
+object, including @code{Tie}, @code{PhrasingSlur}, @code{Beam}
+and @code{TextSpanner}.  For example, an editor preparing a
+scholarly edition may wish to indicate the absence of part of a
+phrasing slur in a source by dashing only the segment which has
+been added.  The following example illustrates how this can be
+done, in this case using the @code{\tweak} form of the command:
+
+@lilypond[verbatim,quote,ragged-right,relative=2]
+% The empty list is conveniently used below, because it is the
+% default setting of dash-definition, resulting in a solid curve.
+c2-\alterBroken dash-definition #'(() ((0 1.0 0.4 0.75))) \(e
+\break
+g2 e\)
+@end lilypond
+
+It is important to understand that @code{\alterBroken} will set
+each piece of a broken spanner to the corresponding value in
+@var{values}.  When there are fewer values than pieces, any
+additional piece will be assigned the empty list.  This may lead
+to undesired results if the layout property is not set to the
+empty list by default.  In such cases, each segment should be
+assigned an appropriate value.
+
+@knownissues
+Line breaks may occur in different places following changes in
+layout. Settings chosen for @code{\alterBroken} may be unsuitable
+for a spanner that is no longer broken or is split into more
+segments than before.  Explicit use of @code{\break} can guard
+against this situation.
+The @code{\alterBroken} command is ineffective for spanner
+properties accessed before line-breaking such as
+@code{direction}.
+
+@seealso
+Extending LilyPond:
+@rextend{Difficult tweaks}.
+
+
 @node Unpure-pure containers
 @subsection Unpure-pure containers
 
@@ -4456,12 +4677,12 @@ padText =
      \once \override TextScript.padding = #padding
    #})
 
-\relative c''' {
+\relative c'' {
   c4^"piu mosso" b a b
   \padText #1.8
-  c4^"piu mosso" d e f
+  c4^"piu mosso" b a b
   \padText #2.6
-  c4^"piu mosso" fis a g
+  c4^"piu mosso" b a b
 }
 @end lilypond