[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < Modifying context plug-ins ] | [ Up : Interpretation contexts ] | [ Changing all contexts of the same type > ] |
5.1.5 Changing context default settings
Context and grob properties can be changed with \set
and \override
commands, as described in
Modifying properties. These commands create music events,
making the changes take effect at the point in time the music
is being processed.
In contrast, this section explains how to change the default values of context and grob properties at the time the context is created. There are two ways of doing this. One modifies the default values in all contexts of a particular type, the other modifies the default values in just one particular instance of a context.
Changing all contexts of the same type | ||
Changing just one specific context | ||
Order of precedence |
[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < Changing context default settings ] | [ Up : Changing context default settings ] | [ Changing just one specific context > ] |
Changing all contexts of the same type
The default context settings which are to be used for typesetting in
Score
, Staff
, Voice
and other contexts may be
specified in a \context
block within any \layout
block.
Settings for Midi output as opposed to typesetting will have to be
separately specified in \midi
blocks (see Output definitions – blueprints for contexts).
The \layout
block should be placed within the \score
block to which it is to apply, after the music.
\layout { \context { \Voice [context settings for all Voice contexts] } \context { \Staff [context settings for all Staff contexts] } }
The following types of settings may be specified:
-
An
\override
command, but with the context name omitted\score { \relative { a'4^"Thicker stems" a a a a4 a a\ff a } \layout { \context { \Staff \override Stem.thickness = #4.0 } } }
-
Directly setting a context property
\score { \relative { a'4^"Smaller font" a a a a4 a a\ff a } \layout { \context { \Staff fontSize = #-4 } } }
-
A predefined command such as
\dynamicUp
or a music expression like\accidentalStyle dodecaphonic
\score { \relative { a'4^"Dynamics above" a a a a4 a a\ff a } \layout { \context { \Voice \dynamicUp } \context { \Staff \accidentalStyle dodecaphonic } } }
-
A user-defined variable containing a
\with
block; for details of the\with
block see Changing just one specific context.StaffDefaults = \with { fontSize = #-4 } \score { \new Staff { \relative { a'4^"Smaller font" a a a a4 a a a } } \layout { \context { \Staff \StaffDefaults } } }
Property-setting commands can be placed in a \layout
block
without being enclosed in a \context
block. Such settings
are equivalent to including the same property-setting commands at
the start of every context of the type specified. If no context
is specified every bottom-level context is affected
(see Bottom-level contexts – voices). The syntax of a
property-setting command in a \layout
block is the same as
the same command written in the music stream.
\score { \new Staff { \relative { a'4^"Smaller font" a a a a4 a a a } } \layout { \accidentalStyle dodecaphonic \set fontSize = #-4 \override Voice.Stem.thickness = #4.0 } }
[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < Changing all contexts of the same type ] | [ Up : Changing context default settings ] | [ Order of precedence > ] |
Changing just one specific context
The context properties of just one specific context instance can be
changed in a \with
block. All other context instances of the
same type retain the default settings built into LilyPond and modified
by any \layout
block within scope. The \with
block
must be placed immediately after the \new
context-type
command:
\new Staff \with { [context settings for this context instance only] } { … }
Alternatively, if the music is being entered using the short form of the
input mode-specifying commands, e.g. \chords
rather than
\chordmode
, the \with
command must be placed immediately
after the mode-specifying command:
\chords \with { [context settings for this (implicit) context instance only] } { … }
as it is the implicit context created by these short forms which should
be modified. The same consideration applies to the other input
mode-specifying short forms (\drums
, \figures
), see
Input modes.
Since context modifications specified in \with
blocks are inside
music, they will affect all outputs (typesetting and
Midi) as opposed to changes within an output definition.
The following types of settings may be specified:
-
An
\override
command, but with the context name omitted\score { \new Staff { \new Voice \with { \override Stem.thickness = #4.0 } { \relative { a'4^"Thick stems" a a a a4 a a a } } } }
-
Directly setting a context property
\score { << \new Staff { \relative { a'4^"Default font" a a a a4 a a a } } \new Staff \with { fontSize = #-4 } { \relative { a'4^"Smaller font" a a a a4 a a a } } >> }
-
A predefined command such as
\dynamicUp
\score { << \new Staff { \new Voice { \relative { a'4^"Dynamics below" a a a a4 a a\ff a } } } \new Staff \with { \accidentalStyle dodecaphonic } { \new Voice \with { \dynamicUp } { \relative { a'4^"Dynamics above" a a a a4 a a\ff a } } } >> }
See also
Notation Reference: Input modes.
[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < Changing just one specific context ] | [ Up : Changing context default settings ] | [ Defining new contexts > ] |
Order of precedence
The value of a property which applies at a particular time is determined as follows:
-
if an
\override
or\set
command in the input stream is in effect that value is used, -
otherwise the default value taken from a
\with
statement on the context initiation statement is used, -
otherwise the default value taken from the most recent appropriate
\context
block in the\layout
or\midi
blocks is used, - otherwise the LilyPond built-in default is used.
See also
Learning Manual: Modifying context properties.
Notation Reference:
Contexts explained,
Bottom-level contexts – voices,
The \set
command,
The \override
command,
The \layout
block.
[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < Changing just one specific context ] | [ Up : Changing context default settings ] | [ Defining new contexts > ] |