| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| 4.4.1 Automatic behavior | ||
| 4.4.2 Within-staff objects | ||
| 4.4.3 Outside-staff objects |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are some objects in musical notation that belong to the staff and there are other objects that should be placed outside the staff. These are called within-staff objects and outside-staff objects respectively.
Within-staff objects are those that are located on the staff – note heads, stems, accidentals, etc. The positions of these are usually fixed by the music itself – they are vertically positioned on specific lines of the staff or are tied to other objects that are so positioned. Collisions of note heads, stems and accidentals in closely set chords are normally avoided automatically. There are commands and overrides which can modify this automatic behavior, as we shall shortly see.
Objects belonging outside the staff include things such as
rehearsal marks, text and dynamic markings. LilyPond’s rule for
the vertical placement of outside-staff objects is to place them
as close to the staff as possible but not so close that they
collide with any other object. LilyPond uses the
outside-staff-priority property to determine the order in
which the objects should be placed, as follows.
First, LilyPond places all the within-staff objects.
Then it sorts the outside-staff objects according to their
outside-staff-priority. The outside-staff objects are
taken one by one, beginning with the object with the lowest
outside-staff-priority, and placed so that they do not
collide with any objects that have already been placed. That is,
if two outside-staff grobs are competing for the same space, the
one with the lower outside-staff-priority will be placed
closer to the staff. If two objects have the same
outside-staff-priority the one encountered first will be
placed closer to the staff.
In the following example all the markup texts have the same priority (since it is not explicitly set). Note that ‘Text3’ is automatically positioned close to the staff again, nestling under ‘Text2’.
c''2^"Text1" c''2^"Text2" | c''2^"Text3" c''2^"Text4" |
Staves are also positioned, by default, as closely together as possible (subject to a minimum separation). If notes project a long way towards an adjacent staff they will force the staves further apart only if an overlap of the notation would otherwise occur. The following example demonstrates this ‘nestling’ of the notes on adjacent staves:
<< \new Staff { \relative { c'4 a, } } \new Staff { \relative { c''''4 a, } } >>
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
We have already seen how the commands \voiceXXX affect the
direction of slurs, ties, fingering and everything else which depends on
the direction of the stems – see Explicitly instantiating voices.
These commands are essential when writing polyphonic music to permit
interweaving melodic lines to be distinguished. But occasionally it may
be necessary to override this automatic behavior. This can be done for
whole sections of music or even for an individual note. The property
which controls this behavior is the direction property of each
layout object. We first explain what this does, and then introduce a
number of ready-made commands which avoid your having to code explicit
overrides for the more common modifications.
Some layout objects like slurs and ties curve, bend or point
either up or down; others like stems and flags also move to
right or left when they point up or down. This is controlled
automatically when direction is set.
The direction property | ||
| Fingering |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
direction propertyThe following example shows the default positioning of slurs in the first bar, with slurs starting on high notes positioned above the notes and those starting on low notes positioned below, followed by a bar with both slurs forced down, a bar with both slurs forced up, and finally a bar with both slurs reverted back to the default behavior.
a'4( g') c''( a') | \override Slur.direction = #DOWN a'4( g') c''( a') | \override Slur.direction = #UP a'4( g') c''( a') | \revert Slur.direction a'4( g') c''( a') |
Here we have used the constants DOWN and UP.
These have the values -1 and +1 respectively, and
these numerical values may be used instead. The value 0
may also be used in some cases. It is simply treated as meaning
UP for slurs, but for some objects it means ‘center’.
There is a constant, CENTER which has the value 0.
However, these explicit overrides are not usually used, as there are simpler equivalent predefined commands available. Here is a table of the commonest. The meaning of each is stated where it is not obvious.
| Down/Left | Up/Right | Revert | Effect |
|---|---|---|---|
\arpeggioArrowDown | \arpeggioArrowUp | \arpeggioNormal | Arrow is at bottom, at top, or no arrow |
\dotsDown | \dotsUp | \dotsNeutral | Direction of movement to avoid staff lines |
\dynamicDown | \dynamicUp | \dynamicNeutral | |
\phrasingSlurDown | \phrasingSlurUp | \phrasingSlurNeutral | Note: distinct from slur commands |
\slurDown | \slurUp | \slurNeutral | |
\stemDown | \stemUp | \stemNeutral | |
\textSpannerDown | \textSpannerUp | \textSpannerNeutral | Text entered as spanner is below/above staff |
\tieDown | \tieUp | \tieNeutral | |
\tupletDown | \tupletUp | \tupletNeutral | Tuplets are below/above notes |
The neutral/normal variants of these commands are implemented
using \revert and these may not be
preceded by \once. If you wish to limit the
effect of the other commands (which are implemented using
\override) to a single timestep, you can precede them with
\once like you would do with explicit overrides.
Or, if just a single layout object needs to be forced up or down, the
direction indicators, ^ or _, may be used:
a'4( g') c''( a') | a'4^( g') c''_( a') |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The placement of fingering on single notes can also be controlled
by the direction property, but changing direction
has no effect on chords. As we shall see, there are special
commands which allow the fingering of individual notes
of chords to be controlled, with the fingering being placed
above, below, to the left or to the right of each note.
First, here’s the effect of direction on the fingering
attached to single notes. The first bar shows the default
behaviour, and the following two bars shows the effect of
specifying DOWN and UP:
\relative { c''4-5 a-3 f-1 c'-5 | \override Fingering.direction = #DOWN c4-5 a-3 f-1 c'-5 | \override Fingering.direction = #UP c4-5 a-3 f-1 c'-5 | }
However, overriding the direction property is not the
easiest way of manually setting the fingering above or below
the notes; using _ or ^ instead of - before
the fingering number is usually preferable. Here is the previous
example using this method:
\relative { c''4-5 a-3 f-1 c'-5 | c4_5 a_3 f_1 c'_5 | c4^5 a^3 f^1 c'^5 | }
The direction property is ignored for chords, but the
directional prefixes, _ and ^ do work. By default,
the fingering is automatically placed both above and below the
notes of a chord, as shown:
\relative { <c''-5 g-3>4 <c-5 g-3 e-2>4 <c-5 g-3 e-2 c-1>4 }
but this may be overridden to manually force all or any of the individual fingering numbers above or below:
\relative { <c''-5 g-3 e-2 c-1>4 <c^5 g_3 e_2 c_1>4 <c^5 g^3 e^2 c_1>4 }
Even greater control over the placement of fingering of the
individual notes in a chord is possible by using the
\set fingeringOrientations command. The format of this
command is:
\set fingeringOrientations = #'([up] [left/right] [down]) |
\set is used because fingeringOrientations is a
property of the Voice context, created and used by the
New_fingering_engraver.
The property may be set to a list of one to three values.
It controls whether fingerings may be placed above (if
up appears in the list), below (if down appears),
to the left (if left appears, or to the right
(if right appears). Conversely, if a location is not
listed, no fingering is placed there. LilyPond takes these
constraints and works out the best placement for the fingering
of the notes of the following chords. Note that left and
right are mutually exclusive – fingering may be placed
only on one side or the other, not both.
Note: To control the placement of the fingering of a single note using this command it is necessary to write it as a single note chord by placing angle brackets round it.
Here are a few examples:
\relative { \set fingeringOrientations = #'(left) <f'-2>4 <c-1 e-2 g-3 b-5>4 \set fingeringOrientations = #'(left) <f-2>4 <c-1 e-2 g-3 b-5>4 | \set fingeringOrientations = #'(up left down) <f-2>4 <c-1 e-2 g-3 b-5>4 \set fingeringOrientations = #'(up left) <f-2>4 <c-1 e-2 g-3 b-5>4 | \set fingeringOrientations = #'(right) <f-2>4 <c-1 e-2 g-3 b-5>4 }
If the fingering seems a little crowded the font-size
could be reduced. The default value can be seen from the
Fingering object in the IR to be -5, so let’s
try -7:
\relative { \override Fingering.font-size = #-7 \set fingeringOrientations = #'(left) <f'-2>4 <c-1 e-2 g-3 b-5>4 \set fingeringOrientations = #'(left) <f-2>4 <c-1 e-2 g-3 b-5>4 | \set fingeringOrientations = #'(up left down) <f-2>4 <c-1 e-2 g-3 b-5>4 \set fingeringOrientations = #'(up left) <f-2>4 <c-1 e-2 g-3 b-5>4 | \set fingeringOrientations = #'(right) <f-2>4 <c-1 e-2 g-3 b-5>4 }
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Outside-staff objects are automatically placed to avoid collisions. There are several ways to override the automatic placement if the positioning is not optimum.
The outside-staff-priority property | ||
The \textLengthOn command | ||
| Dynamics placement | ||
| Grob sizing |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
outside-staff-priority propertyObjects with the lower value of the outside-staff-priority
property are placed nearer to the staff, and other outside-staff
objects are then raised as far as necessary to avoid collisions.
The outside-staff-priority is defined in the
grob-interface and so is a property of all layout objects.
By default it is set to #f for all within-staff objects,
and to a numerical value appropriate to each outside-staff object
when the object is created. The following table shows the default
numerical values for some of the commonest outside-staff objects.
Note the unusual names for some of the objects: spanner objects
are automatically created to control the vertical positioning of
grobs which (might) start and end at different musical moments, so
changing the outside-staff-priority of the underlying grob
will have no effect. For example, changing
outside-staff-priority of the Hairpin object will
have no effect on the vertical positioning of hairpins – you must
change outside-staff-priority of the associated
DynamicLineSpanner object instead. This override must be
placed at the start of the spanner, which might include several
linked hairpins and dynamics.
| Layout Object | Priority | Controls position of: |
|---|---|---|
RehearsalMark | 1500 | Rehearsal marks |
MetronomeMark | 1000 | Metronome marks |
SostenutoPedalLineSpanner | 1000 | Pedal indication |
SustainPedalLineSpanner | 1000 | |
UnaCordaPedalLineSpanner | 1000 | |
MeasureCounter | 750 | Measure number |
VoltaBracketSpanner | 600 | Volta brackets |
InstrumentSwitch | 500 | Instrument switch text |
TextScript | 450 | Markup text |
MultiMeasureRestText | 450 | Markup text over multimeasure rests |
CombineTextScript | 450 | Part-combine text |
OttavaBracket | 400 | Ottava brackets |
TextSpanner | 350 | Text spanners |
DynamicLineSpanner | 250 | All dynamic markings |
BarNumber | 100 | Bar numbers |
TrillSpanner | 50 | Spanning trills |
AccidentalSuggestion | 0 | Annotational accidentals |
Here is an example showing the default placement of some of these.
% Set details for later Text Spanner \override TextSpanner.bound-details.left.text = \markup { \small \bold Slower } % Place dynamics above staff \dynamicUp % Start Ottava Bracket \ottava #1 c''4 \startTextSpan % Add Dynamic Text and hairpin c''4\pp\< c''4 % Add Text Script c''4^Text | c''4 c'' % Add Dynamic Text and terminate hairpin c''4\ff c'' \stopTextSpan | % Stop Ottava Bracket \ottava #0 c'4 c' c' c' |
This example also shows how to create Text Spanners –
text with extender lines above a section of music. The
spanner extends from the \startTextSpan command to
the \stopTextSpan command, and the format of the
text is defined by the \override TextSpanner command.
For more details see
(notation)Text spanners section ‘Text spanners’ in Notation Reference.
It also shows how ottava brackets are created.
If the default values of outside-staff-priority do not give you
the placing you want, the priority of any of the objects may be
overridden. Suppose we would like the ottava bracket to be placed
below the text spanner in the example above. All we need to do is to
look up the priority of OttavaBracket in the IR or in the
table above, and reduce it to a value lower than that of a
TextSpanner, remembering that OttavaBracket is created
in the Staff context:
% Set details for later Text Spanner \override TextSpanner.bound-details.left.text = \markup { \small \bold Slower } % Place dynamics above staff \dynamicUp % Place following Ottava Bracket below Text Spanners \once \override Staff.OttavaBracket.outside-staff-priority = #340 % Start Ottava Bracket \ottava #1 c''4 \startTextSpan % Add Dynamic Text c''4\pp % Add Dynamic Line Spanner c''4\< % Add Text Script c''4^Text | c''4 c'' % Add Dynamic Text c''4\ff c'' \stopTextSpan | % Stop Ottava Bracket \ottava #0 c'4 c' c' c' |
Note that some of these objects, in particular bar numbers,
metronome marks and rehearsal marks, live by default in the
Score context, so be sure to use the correct context
when these are being overriden.
Slurs by default are classed as within-staff objects, but
they often appear above the staff if the notes to
which they are attached are high on the staff. This can push
outside-staff objects such as articulations too high, as the slur
will be placed first. The avoid-slur property of the
articulation can be set to 'inside to bring the articulation
inside the slur, but the avoid-slur property is effective
only if the outside-staff-priority is also set to #f.
Alternatively, the outside-staff-priority of the slur
can be set to a numerical value to cause it to be placed along with
other outside-staff objects according to that value. Here’s an
example showing the effect of the two methods:
\relative c'' { c4( c^\markup { \tiny \sharp } d4.) c8 | c4( \once \override TextScript.avoid-slur = #'inside \once \override TextScript.outside-staff-priority = ##f c4^\markup { \tiny \sharp } d4.) c8 | \once \override Slur.outside-staff-priority = #500 c4( c^\markup { \tiny \sharp } d4.) c8 | }
Changing the outside-staff-priority can also be used to
control the vertical placement of individual objects, although
the results may not always be desirable. Suppose we would
like “Text3” to be placed above “Text4” in the example
under Automatic behavior, above (see Automatic behavior).
All we need to do is to look up the priority of TextScript
in the IR or in the tables above, and increase the priority of
“Text3” to a higher value:
c''2^"Text1" c''2^"Text2" | \once \override TextScript.outside-staff-priority = #500 c''2^"Text3" c''2^"Text4" |
This certainly lifts “Text3” above “Text4” but it also lifts it
above “Text2”, and “Text4” now drops down. Perhaps this is not
so good. What we would really like to do is to position all the
annotation at the same distance above the staff. To do this, we
clearly will need to space the notes out horizontally to make more
room for the text. This is done using the textLengthOn
command.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
\textLengthOn commandBy default, text produced by markup takes up no horizontal space
as far as laying out the music is concerned. The \textLengthOn
command reverses this behavior, causing the notes to be spaced
out as far as is necessary to accommodate the text:
\textLengthOn % Cause notes to space out to accommodate text c''2^"Text1" c''2^"Text2" | c''2^"Text3" c''2^"Text4" |
The command to revert to the default behavior is
\textLengthOff. Alternatively, \once may be used
with \textLengthOn if the effect is to be limited to just a
single musical moment.
The corresponding spacing behavior for rehearsal marks and tempo
indications is independently controlled with the commands
\markLengthOn and \markLengthOff.
Markup text will also avoid notes which project above the staff.
If this is not desired, the automatic displacement upwards may
be turned off by setting the priority to #f. Here’s an
example to show how markup text interacts with such notes.
\relative { % This markup is short enough to fit without collision c''2^"Tex" c'' | R1 | % This is too long to fit, so it is displaced upwards c,,2^"Text" c'' | R1 | % Turn off collision avoidance \once \override TextScript.outside-staff-priority = ##f c,,2^"Long Text " c'' | R1 | % Turn off collision avoidance \once \override TextScript.outside-staff-priority = ##f \textLengthOn % and turn on textLengthOn c,,2^"Long Text " % Spaces at end are honored c''2 | }
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Dynamic markings will normally be positioned beneath the
staff, but may be positioned above with the \dynamicUp
command. They will be positioned vertically relative to the
note to which they are attached, and will float below (or above)
all within-staff objects such as phrasing slurs and bar numbers.
This can give quite acceptable results, as this example
shows:
\relative { \clef "bass" \key aes \major \time 9/8 \dynamicUp bes4.~\f\< \( bes4 bes8 des4\ff\> c16 bes\! | ees,2.~\)\mf ees4 r8 | }
However, if the notes and attached dynamics are close together the automatic placement will avoid collisions by displacing later dynamic markings further away, but this may not be the optimum placement, as this rather artificial example shows:
\dynamicUp \relative { a'4\f b\mf a\mp b\p }
Should a similar situation arise in ‘real’ music, it may be
preferable to space out the notes a little further, so the dynamic
markings can all fit at the same vertical distance from the staff. We
were able to do this for markup text by using the \textLengthOn
command, but there is no equivalent command for dynamic marks. So we
shall have to work out how to do this using \override commands.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
First we must learn how grobs are sized. All grobs have a
reference point defined within them which is used to position
them relative to their parent object. This point in the grob
is then positioned at a horizontal distance, X-offset,
and at a vertical distance, Y-offset, from its parent.
The horizontal extent of the object is given by a pair of
numbers, X-extent, which say where the left and right
edges are relative to the reference point. The vertical extent
is similarly defined by a pair of numbers, Y-extent.
These are properties of all grobs which support the
grob-interface.
By default, outside-staff objects are given a width of zero so
that they may overlap in the horizontal direction. This is done
by the trick of making the leftmost extent infinity and
the rightmost extent minus infinity by setting the
extra-spacing-width to '(+inf.0 . -inf.0). To
ensure they do not overlap in the horizontal direction we
must override this value of extra-spacing-width to give them
a little extra spacing. The units are the space between two staff
lines, so moving the left edge half a unit to the left and the
right edge half a unit to the right should do it:
\override DynamicText.extra-spacing-width = #'(-0.5 . 0.5) |
Let’s see if this works in our previous example:
\dynamicUp % Extend width by 1 staff space \override DynamicText.extra-spacing-width = #'(-0.5 . 0.5) \relative { a'4\f b\mf a\mp b\p }
This looks better, but maybe we would prefer the dynamic marks
to be aligned along the same baseline rather than going up and
down with the notes. The property to do this is
staff-padding which is covered in the section on collisions
(see Collisions of objects).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by gub on July 13, 2020 using texi2html 1.82.
其他语言:català, česky, deutsch, español, français, italiano, 日本語, nederlands。
关于 自动语言选择