@c -*- coding: utf-8; mode: texinfo; -*-
@c This file is part of lilypond.tely
@ignore
    Translation of GIT committish: FILL-IN-HEAD-COMMITTISH

    When revising a translation, copy the HEAD committish of the
    version that you are working on.  See TRANSLATION for details.
@end ignore


@c A menu is needed before every deeper *section nesting of @node's; run
@c     M-x texinfo-all-menus-update
@c to automatically fill in these menus before saving changes

@node Basic notation
@chapter Basic notation

This chapter explains how to use basic notation features.

@menu
* Pitches::                     
* Rhythms::                     
* Polyphony::                   
* Staff notation::              
* Connecting notes::            
* Expressive marks::            
* Repeats::                     
@end menu



@node Pitches
@section Pitches

This section discusses how to specify the pitch of notes.

@menu
* Normal pitches::              
* Accidentals::                 
* Cautionary accidentals::      
* Micro tones::                 
* Note names in other languages::  
* Relative octaves::            
* Octave check::                
* Transpose::                   
* Rests::                       
* Skips::                       
@end menu


@node Normal pitches
@subsection Normal pitches

@cindex Pitch names
@cindex pitches

A pitch name is specified using lowercase letters @code{a} through @code{g}.
An ascending C-major scale is engraved with

@lilypond[quote,fragment,verbatim,ragged-right]
\clef bass
c d e f g a b c'
@end lilypond

The note name @code{c} is engraved one octave below middle C.

@lilypond[quote,fragment,verbatim,ragged-right]
\clef treble
c1
\clef bass
c1
@end lilypond

@funindex '
@funindex ,

The optional octave specification takes the form of a series of
single quote (@samp{'}) characters or a series of comma
(@samp{,}) characters.  Each @samp{'} raises the pitch by one
octave; each @samp{,} lowers the pitch by an octave.

@lilypond[quote,ragged-right,fragment,verbatim]
\clef treble
c' c'' e' g d'' d' d c
\clef bass
c, c,, e, g d,, d, d c
@end lilypond

An alternate method may be used to declare which octave to
engrave a pitch; this method does not require as many
octave specifications (@code{'} and @code{,}).  See
@ref{Relative octaves}.


@node Accidentals
@subsection Accidentals

@cindex note names, Dutch
@cindex note names, default

A sharp is formed by adding @code{-is} to the end of a pitch name and
a flat is formed by adding @code{-es}.  Double sharps and double flats
are obtained by adding @code{-isis} or @code{-eses} to a note name.

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
a2 ais a aes
a2 aisis a aeses
@end lilypond

@noindent
These are the Dutch note names.  In Dutch, @code{aes} is contracted to
@code{as}, but both forms are accepted.  Similarly, both
@code{es} and @code{ees} are accepted

@lilypond[fragment,quote,ragged-right,verbatim,relative=2]
a2 as e es
@end lilypond

A natural will cancel the effect of an accidental or key signature.
However, naturals are not encoded into the note name syntax with a
suffix; a natural pitch is shown as a simple note name

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
a4 aes a2
@end lilypond

The input @code{d e f} is interpreted as @q{print a D-natural,
E-natural, and an F-natural,} regardless of the key
signature.  For more information about the distinction between
musical content and the presentation of that content, see
@ref{Accidentals and key signatures}.

@lilypond[fragment,quote,ragged-right,verbatim,relative]
\key d \major
d e f g
d e fis g
@end lilypond


@commonprop

In accordance with standard typesetting rules, a natural sign is printed
before a sharp or flat if a previous accidental needs to be
cancelled.  To change this behavior, use
@code{\set Staff.extraNatural = ##f}

@lilypond[fragment,quote,ragged-right,verbatim,relative=2]
ceses4 ces cis c
\set Staff.extraNatural = ##f
ceses4 ces cis c
@end lilypond


@seealso

Program reference: @internalsref{LedgerLineSpanner},
@internalsref{NoteHead}.


@node Cautionary accidentals
@subsection Cautionary accidentals

@cindex accidental, reminder
@cindex accidental, cautionary
@cindex accidental, parenthesized
@cindex reminder accidental
@funindex ?
@cindex cautionary accidental
@cindex parenthesized accidental
@funindex !

Normally accidentals are printed automatically, but you may also
print them manually.  A reminder accidental
can be forced by adding an exclamation mark @code{!}
after the pitch.  A cautionary accidental
(i.e., an accidental within parentheses) can be obtained by adding the
question mark @samp{?} after the pitch.  These extra accidentals
can be used to produce natural signs, too.

@lilypond[quote,ragged-right,fragment,verbatim,relative=1]
cis cis cis! cis? c c? c! c
@end lilypond


@seealso

The automatic production of accidentals can be tuned in many
ways.  For more information, see @ref{Automatic accidentals}.


@node Micro tones
@subsection Micro tones

@cindex quarter tones
@cindex semi-flats, semi-sharps

Half-flats and half-sharps are formed by adding @code{-eh} and
@code{-ih}; the following is a series of Cs with increasing pitches

@lilypond[verbatim,ragged-right,quote,relative=2,fragment]
\set Staff.extraNatural = ##f
ceseh ceh cih cisih
@end lilypond

Micro tones are also exported to the MIDI file.


@refbugs

There are no generally accepted standards for denoting
three-quarter flats, so LilyPond's symbol does not conform to any
standard.


@node Note names in other languages
@subsection Note names in other languages

There are predefined sets of note names for various other languages.
To use them, include the language specific init file.  For
example, add @code{\include "english.ly"} to the top of the input
file.  The available language files
and the note names they define are

@c  what about micro-tunes, double-sharps, and double-flats?  add
@c  more columns to the table?
@c  Oh, and should this be made into a multitable?
@cindex note names, other languages
@example
                        Note Names               sharp       flat
nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
                                               -x (double)
deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b
espanol.ly     do  re  mi  fa  sol la  sib si  -s          -b
@end example


@node Relative octaves
@subsection Relative octaves

@cindex Relative
@cindex Relative octave specification
@funindex \relative

Octaves are specified by adding @code{'} and @code{,} to pitch names.
When you copy existing music, it is easy to accidentally put a pitch
in the wrong octave and hard to find such an error.  The relative
octave mode prevents these errors by making the mistakes much
larger: a single error puts the rest of the piece off by one octave

@example
\relative @var{startpitch} @var{musicexpr}
@end example

@noindent
or

@example
\relative @var{musicexpr}
@end example

@noindent
@code{c'} is used as the default if no starting pitch is defined.

The octave of notes that appear in @var{musicexpr} are calculated as
follows: if no octave changing marks are used, the basic interval
between this and the last note is always taken to be a fourth or
less.  This distance is determined without regarding alterations; a
@code{fisis} following a @code{ceses} will be put above the
@code{ceses}.  In other words, a doubly-augmented fourth is considered
a smaller interval than a diminished fifth, even though the
doubly-augmented fourth spans seven semitones while the diminished
fifth only spans six semitones.

The octave changing marks @code{'} and @code{,} can be added to raise
or lower the pitch by an extra octave.  Upon entering relative mode,
an absolute starting pitch can be specified that will act as the
predecessor of the first note of @var{musicexpr}.  If no starting pitch
is specified, then middle C is used as a start.

Here is the relative mode shown in action
@lilypond[quote,fragment,ragged-right,verbatim]
\relative c'' {
  b c d c b c bes a
}
@end lilypond

Octave changing marks are used for intervals greater than a fourth

@lilypond[quote,ragged-right,fragment,verbatim]
\relative c'' {
  c g c f, c' a, e''
}
@end lilypond

If the preceding item is a chord, the first note of the chord is used
to determine the first note of the next chord

@lilypond[quote,ragged-right,fragment,verbatim]
\relative c' {
  c <c e g>
  <c' e g>
  <c, e' g>
}
@end lilypond

The pitch after @code{\relative} contains a note name.

The relative conversion will not affect @code{\transpose},
@code{\chordmode} or @code{\relative} sections in its argument.  To use
relative within transposed music, an additional @code{\relative} must
be placed inside @code{\transpose}.


@node Octave check
@subsection Octave check

@cindex Octave check

Octave checks make octave errors easier to correct: a note may be
followed by @code{=}@var{quotes} which indicates what its absolute
octave should be.  In the following example,

@example
\relative c'' @{ c='' b=' d,='' @}
@end example

@noindent
the @code{d} will generate a warning, because a @code{d''} is expected
(because @code{b'} to @code{d''} is only a third), but a @code{d'} is
found.  In the output, the octave is corrected to be a @code{d''} and
the next note is calculated relative to @code{d''} instead of @code{d'}.

There is also an octave check that produces no visible output.  The syntax

@example
\octave @var{pitch}
@end example

This checks that @var{pitch} (without quotes) yields @var{pitch} (with
quotes) in @code{\relative} mode compared to the note given in the
@code{\relative} command.  If not, a warning is printed, and the
octave is corrected.  The @var{pitch} is not printed as a note.

In the example below, the first check passes without incident, since
the @code{e} (in @code{relative} mode) is within a fifth of
@code{a'}.  However,
the second check produces a warning, since the @code{e} is not within
a fifth of @code{b'}.  The warning message is printed, and the octave
is adjusted so that the following notes are in the correct octave
once again.

@example
\relative c' @{
  e
  \octave a'
  \octave b'
@}
@end example


The octave of a note following an octave check is determined with
respect to the note preceding it.  In the next fragment, the last note
is an @code{a'}, above middle C.  That means that the @code{\octave}
check passes successfully, so the check could be deleted without changing
the output of the piece.

@lilypond[quote,ragged-right,verbatim,fragment]
\relative c' {
  e
  \octave b
  a
}
@end lilypond


@node Transpose
@subsection Transpose

@cindex Transpose
@cindex Transposition of pitches
@funindex \transpose

A music expression can be transposed with @code{\transpose}.  The
syntax is
@example
\transpose @var{from} @var{to} @var{musicexpr}
@end example

This means that @var{musicexpr} is transposed by the interval between
the pitches @var{from} and @var{to}: any note with pitch @code{from}
is changed to @code{to}.

For example, consider a piece written in the key of D-major.  If
this piece is a little too low for its performer, it can be
transposed up to E-major with
@example
\transpose d e @dots{}
@end example

Consider a part written for violin (a C instrument).  If
this part is to be played on the A clarinet (for which an
A is notated as a C, and which sounds a minor third lower
than notated), the following
transposition will produce the appropriate part

@example
\transpose a c @dots{}
@end example

@code{\transpose} distinguishes between enharmonic pitches: both
@code{\transpose c cis} or @code{\transpose c des} will transpose up
half a tone.  The first version will print sharps and the second
version will print flats

@lilypond[quote,ragged-right,verbatim]
mus = { \key d \major cis d fis g }
\new Staff {
  \clef "F" \mus
  \clef "G"
  \transpose c g' \mus
  \transpose c f' \mus
}
@end lilypond

@code{\transpose} may also be used to input written notes for a
transposing instrument.  Pitches are normally entered into LilyPond
in C (or @q{concert pitch}), but they may be entered in another
key.  For example, when entering music for a B-flat trumpet which
begins on concert D, one would write

@example
\transpose c bes @{ e4 @dots{} @}
@end example

To print this music in B-flat again (i.e., producing a trumpet part,
instead of a concert pitch conductor's score) you would wrap the
existing music with another @code{transpose}

@example
\transpose bes c @{ \transpose c bes @{ e4 @dots{} @} @}
@end example


@seealso

Program reference: @internalsref{TransposedMusic}.

Example: @inputfileref{input/@/test,smart@/-transpose@/.ly}.


@refbugs

If you want to use both @code{\transpose} and @code{\relative},
you must put @code{\transpose} outside of @code{\relative}, since
@code{\relative} will have no effect on music that appears inside a
@code{\transpose}.


@node Rests
@subsection Rests
@cindex Rests

@funindex \rest
@funindex r

Rests are entered like notes with the note name @code{r}

@lilypond[fragment,quote,ragged-right,verbatim]
r1 r2 r4 r8
@end lilypond

Whole bar rests, centered in middle of the bar,
must be done with multi-measure rests.  They can be used for a
single bar as well as many bars, and are discussed in
@ref{Multi measure rests}.

To explicitly specify a rest's vertical position, write a note
followed by @code{\rest}.  A rest will be placed in the position
where the note would appear,

@lilypond[fragment,quote,ragged-right,verbatim]
a'4\rest d'4\rest
@end lilypond

@noindent
This makes manual formatting of
polyphonic music much easier, since the automatic rest collision
formatter will leave these rests alone.

@seealso

Program reference: @internalsref{Rest}.


@node Skips
@subsection Skips

@cindex Skip
@cindex Invisible rest
@cindex Space note
@funindex \skip
@funindex s

An invisible rest (also called a @q{skip}) can be entered like a note
with note name @samp{s} or with @code{\skip @var{duration}}

@lilypond[fragment,quote,ragged-right,verbatim,relative=2]
a4 a4 s4 a4 \skip 1 a4
@end lilypond

The @code{s} syntax is only available in note mode and chord mode.  In
other situations, for example, when entering lyrics, you should use
the @code{\skip} command

@lilypond[quote,ragged-right,verbatim]
<<
  \relative { a'2 a2 }
  \new Lyrics \lyricmode { \skip 2 bla2 }
>>
@end lilypond

The skip command is merely an empty musical placeholder.  It does not
produce any output, not even transparent output.

The @code{s} skip command does create @internalsref{Staff} and
@internalsref{Voice} when necessary, similar to note and rest
commands.  For example, the following results in an empty staff.

@lilypond[quote,ragged-right,verbatim]
{ s4 }
@end lilypond

The fragment @code{@{ \skip 4 @} } would produce an empty page.

@seealso

Program reference: @internalsref{SkipMusic}.



@node Rhythms
@section Rhythms

This section discusses rhythms, durations, and bars.

@menu
* Durations::                   
* Augmentation dots::           
* Tuplets::                     
* Scaling durations::           
* Bar check::                   
* Barnumber check::             
* Automatic note splitting::    
@end menu


@node Durations
@subsection Durations

@cindex duration
@funindex \longa
@funindex \breve
@funindex \maxima

In Note, Chord, and Lyrics mode, durations are designated by numbers and
dots: durations are entered as their reciprocal values.  For example, a
quarter note is entered using a @code{4} (since it is a 1/4 note), while
a half note is entered using a @code{2} (since it is a 1/2 note).  For
notes longer than a whole you must use the @code{\longa} and
@code{\breve} commands

@example
c'\breve
c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
r\longa r\breve
r1 r2 r4 r8 r16 r32 r64 r64
@end example

@lilypond[quote]
\score {
\relative c'' {
    a\breve*1/2 \autoBeamOff
    a1 a2 a4 a8 a16 a32 a64 a64
   \bar "empty"
   \break
    r\longa*1/4 r\breve *1/2
    r1 r2 r4 r8 r16 r32 r64 r64
  }
  \layout {
    ragged-right = ##t
    indent=0\mm
    \context {
      \Score
        \remove "Bar_number_engraver"
    }
    \context {
      \Staff
        \remove "Clef_engraver"
        \override StaffSymbol #'transparent = ##t
        \override TimeSignature #'transparent = ##t
        \override BarLine #'transparent = ##t
        \consists "Pitch_squash_engraver"
    }
  }
}
@end lilypond

If the duration is omitted then it is set to the previously entered
duration.  The default for the first note is a quarter note.

@lilypond[quote,ragged-right,verbatim,fragment]
{ a a a2 a a4 a a1 a }
@end lilypond


@node Augmentation dots
@subsection Augmentation dots

@funindex .

To obtain dotted note lengths, simply add a dot (@samp{.}) to
the number.  Double-dotted notes are produced in a similar way.

@lilypond[quote,ragged-right,fragment,verbatim]
a'4 b' c''4. b'8 a'4. b'4.. c''8.
@end lilypond

@refcommands

Dots are normally moved up to avoid staff lines, except in polyphonic
situations.  The following commands may be used to force a particular
direction manually

@funindex \dotsUp
@code{\dotsUp},
@funindex \dotsDown
@code{\dotsDown},
@funindex \dotsNeutral
@code{\dotsNeutral}.

@seealso

Program reference: @internalsref{Dots}, and @internalsref{DotColumn}.


@node Tuplets
@subsection Tuplets

@cindex tuplets
@cindex triplets
@funindex \times

Tuplets are made out of a music expression by multiplying all durations
with a fraction

@example
\times @var{fraction} @var{musicexpr}
@end example

@noindent
The duration of @var{musicexpr} will be multiplied by the fraction.
The fraction's denominator will be printed over the notes, optionally
with a bracket.  The most common tuplet is the triplet in which 3
notes have the length of 2, so the notes are 2/3 of their written
length

@lilypond[quote,ragged-right,fragment,verbatim]
g'4 \times 2/3 {c'4 c' c'} d'4 d'4
@end lilypond

Tuplets may be nested, for example,

@lilypond[fragment,ragged-right,verbatim,relative=2]
\override TupletNumber #'text = #tuplet-number::calc-fraction-text
\times 4/6 {
  a4 a
  \times 3/5 { a a a a a }
}
@end lilypond

@refcommands

@funindex \tupletUp
@code{\tupletUp},
@funindex \tupletDown
@code{\tupletDown},
@funindex \tupletNeutral
@code{\tupletNeutral}.


@commonprop

@funindex tupletNumberFormatFunction
@cindex tuplet formatting

The property @code{tupletSpannerDuration} specifies how long each
bracket should last.  With this, you can make lots of tuplets while
typing @code{\times} only once, thus saving lots of typing.  In the next
example, there are two triplets shown, while @code{\times} was only
used once

@lilypond[quote,fragment,relative=2,ragged-right,verbatim]
\set tupletSpannerDuration = #(ly:make-moment 1 4)
\times 2/3 { c8 c c c c c }
@end lilypond

@noindent
For more information about @code{make-moment}, see
@ref{Time administration}.

The format of the number is determined by the property @code{text} in
@code{TupletNumber}.  The default prints only the denominator, but if
it is set to the function @code{tuplet-number::calc-fraction-text},
@var{num}:@var{den} will be printed instead.

To avoid printing tuplet numbers, use

@lilypond[quote,fragment,relative=2,ragged-right,verbatim]
\times 2/3 { c8 c c } \times 2/3 { c8 c c }
\override TupletNumber #'transparent = ##t
\times 2/3 { c8 c c } \times 2/3 { c8 c c }
@end lilypond

Tuplet brackets can be made to run to prefatory matter or
the next note

@lilypond[ragged-right]
\new RhythmicStaff {
  \set tupletFullLength = ##t
  \time 4/4
  \times 4/5 {
    c4 c1
  }
  \set tupletFullLengthNote = ##t
  \time 2/4
  \times 2/3 {
    c4 c c 
  }
  \time 3/4
  c4 
}
@end lilypond


@seealso

Program reference: @internalsref{TupletBracket},
@internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.



@node Scaling durations
@subsection Scaling durations

You can alter the length of duration by a fraction @var{N/M}
appending @samp{*@var{N/M}} (or @samp{*@var{N}} if @var{M=1}).  This
will not affect the appearance of the notes or rests produced.

In the following example, the first three notes take up exactly two
beats, but no triplet bracket is printed.
@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
\time 2/4
a4*2/3 gis4*2/3 a4*2/3
a4 a4 a4*2
b16*4 c4
@end lilypond


@seealso

This manual: @ref{Tuplets}


@node Bar check
@subsection Bar check

@cindex Bar check
@funindex barCheckSynchronize
@funindex |

Bar checks help detect errors in the durations.  A bar check is
entered using the bar symbol, @samp{|}.  Whenever it is encountered
during interpretation, it should fall on a measure boundary.  If it
does not, a warning is printed.  In the next example, the second bar
check will signal an error
@example
\time 3/4 c2 e4 | g2 |
@end example

Bar checks can also be used in lyrics, for example

@example
\lyricmode @{
  \time 2/4
  Twin -- kle | Twin -- kle
@}
@end example

Failed bar checks are caused by entering incorrect
durations.  Incorrect durations often completely garble up the score,
especially if the score is polyphonic, so a good place to start correcting
input is by scanning for failed bar checks and incorrect durations.

@funindex |
@funindex pipeSymbol

It is also possible to redefine the meaning of @code{|}.  This is done
by assigning a music expression to @code{pipeSymbol},

@lilypond[quote,ragged-right,verbatim]
pipeSymbol = \bar "||"

{ c'2 c' | c'2 c' }
@end lilypond


@node Barnumber check
@subsection Barnumber check

When copying large pieces of music, it can be helpful to check that
the LilyPond bar number corresponds to the original that you are
entering from.  This can be checked with @code{\barNumberCheck}, for
example,

@verbatim
\barNumberCheck #123
@end verbatim

@noindent
will print a warning if the @code{currentBarNumber} is not 123 when it
is processed.


@node Automatic note splitting
@subsection Automatic note splitting

Long notes can be converted automatically to tied notes.  This is done
by replacing the @internalsref{Note_heads_engraver} by the
@internalsref{Completion_heads_engraver}.
In the following examples, notes crossing the bar line are split and tied.

@lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
\new Voice \with {
  \remove "Note_heads_engraver"
  \consists "Completion_heads_engraver"
} {
  c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
}
@end lilypond

This engraver splits all running notes at the bar line, and inserts
ties.  One of its uses is to debug complex scores: if the measures are
not entirely filled, then the ties exactly show how much each measure
is off.

If you want to allow line breaking on the bar lines where
@internalsref{Completion_heads_engraver} splits notes, you must
also remove @internalsref{Forbid_line_breaks_engraver}.


@refbugs

Not all durations (especially those containing tuplets) can be
represented exactly with normal notes and dots, but the engraver will
not insert tuplets.

@code{Completion_heads_engraver} only affects notes; it does not split
rests.


@seealso

Program reference: @internalsref{Completion_heads_engraver}.


@node Polyphony
@section Polyphony

Polyphony in music refers to having more than one voice occurring in
a piece of music.  Polyphony in LilyPond refers to having more than
one voice on the same staff.

@menu
* Chords::                      
* Stems::                       
* Basic polyphony::             
* Explicitly instantiating voices::  
* Collision Resolution::        
@end menu


@node Chords
@subsection Chords

@cindex Chords

A chord is formed by a enclosing a set of pitches between @code{<}
and @code{>}.  A chord may be followed by a duration, and a set of
articulations, just like simple notes

@lilypond[verbatim,ragged-right,fragment,quote,relative=1]
<c e g>4 <c>8
@end lilypond

For more information about chords, see @ref{Chord names}.


@node Stems
@subsection Stems

Whenever a note is found, a @internalsref{Stem} object is created
automatically.  For whole notes and rests, they are also created but
made invisible.

@refcommands

@funindex \stemUp
@code{\stemUp},
@funindex \stemDown
@code{\stemDown},
@funindex \stemNeutral
@code{\stemNeutral}.


@commonprop

To change the direction of stems in the middle of the staff, use

@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
a4 b c b
\override Stem #'neutral-direction = #up
a4 b c b
\override Stem #'neutral-direction = #down
a4 b c b
@end lilypond


@node Basic polyphony
@subsection Basic polyphony

@cindex polyphony

The easiest way to enter fragments with more than one voice on a staff
is to enter each voice as a sequence (with @code{@{...@}}), and combine
them simultaneously, separating the voices with @code{\\}

@funindex \\

@lilypond[quote,verbatim,fragment]
\new Staff \relative c' {
  c16 d e f
  <<
    { g4 f e | d2 e2 } \\
    { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
    { s2. | s4 b4 c2 }
  >>
}
@end lilypond

The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
voices are sometimes called @q{layers} in other notation packages}
@cindex layers
to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
each of these contexts, vertical direction of slurs, stems, etc., is set
appropriately.

These voices are all separate from the voice that contains the notes just
outside the @code{<< \\ >>} construct.  This should be noted when making
changes at the voice level.  This also means that slurs and ties cannot go
into or out of a @code{<< \\ >>} construct.  Conversely, parallel voices
from separate @code{<< \\ >>} constructs on the same staff are the the
same voice.  Here is the same example, with different noteheads for each
voice.  Note that the change to the note-head style in the main voice does
not affect
the inside of the @code{<< \\ >>} constructs.  Also, the change to the
second
voice in the first @code{<< \\ >>} construct is effective in the second
@code{<< \\ >>}, and the voice is tied across the two constructs.

@cindex note heads, styles

@lilypond[quote,verbatim,fragment]
\new Staff \relative c' {
  \override NoteHead #'style = #'cross
  c16 d e f
  <<
    { g4 f e } \\
    { \override NoteHead #'style = #'triangle
    r8 e4 d c8 ~ }
  >> |
  <<
    { d2 e2 } \\
    { c8 b16 a b8 g ~ g2 } \\
    { \override NoteHead #'style = #'slash s4 b4 c2 }
  >>
}
@end lilypond

Polyphony does not change the relationship of notes within a
@code{\relative @{ @}} block.  Each note is calculated relative
to the note immediately preceding it.

@example
\relative @{ noteA << noteB \\ noteC >> noteD @}
@end example

@code{noteC} is relative to @code{noteB}, not @code{noteA};
@code{noteD} is relative to @code{noteC}, not @code{noteB} or
@code{noteA}.


@node Explicitly instantiating voices
@subsection Explicitly instantiating voices

@internalsref{Voice} contexts can also be instantiated manually
inside a @code{<< >>} block to create polyphonic music, using
@code{\voiceOne}, up to @code{\voiceFour} to assign stem directions
and a horizontal shift for each part.

Specifically,
@example
<< \upper \\ \lower >>
@end example

@noindent
is equivalent to

@example
<<
  \new Voice = "1" @{ \voiceOne \upper @}
  \new Voice = "2" @{ \voiceTwo \lower @}
>>
@end example

The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
articulations, text annotations, augmentation dots of dotted
notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
make them point downwards.
The command @code{\oneVoice} will revert back to the normal setting.

An expression that appears directly inside a @code{<< >>} belongs to
the main voice.  This is useful when extra voices appear while the main
voice is playing.  Here is a more correct rendition of the example from
the previous section.  The crossed noteheads demonstrate that the main
melody is now in a single voice context.

@lilypond[quote,ragged-right,verbatim]
\new Staff \relative c' {
  \override NoteHead #'style = #'cross
  c16 d e f
  \voiceOne
  <<
    { g4 f e | d2 e2 }
    \new Voice="1" { \voiceTwo
      r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
      \oneVoice
    }
    \new Voice { \voiceThree
      s2. | s4 b4 c2
      \oneVoice
    }
  >>
  \oneVoice
}
@end lilypond

The correct definition of the voices allows the melody to be slurred.
@lilypond[quote,ragged-right,verbatim]
\new Staff \relative c' {
  c16^( d e f
  \voiceOne
  <<
    { g4 f e | d2 e2) }
    \context Voice="1" { \voiceTwo
      r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
      \oneVoice
    }
    \new Voice { \voiceThree
      s2. s4 b4 c2
      \oneVoice
    }
  >>
  \oneVoice
}
@end lilypond

Avoiding the @code{\\} separator also allows nesting polyphony
constructs, which in some case might be a more natural way to typeset
the music.

@lilypond[quote,ragged-right,verbatim]
\new Staff \relative c' {
  c16^( d e f
  \voiceOne
  <<
    { g4 f e | d2 e2) }
    \context Voice="1" { \voiceTwo
      r8 e4 d c8 ~ |
      <<
        {c8 b16 a b8 g ~ g2}
        \new Voice { \voiceThree
          s4 b4 c2
          \oneVoice
        }
      >>
    \oneVoice
    }
  >>
  \oneVoice
}
@end lilypond

In some instances of complex polyphonic music, you may need additional
voices to avoid collisions between notes.  Additional voices are added
by defining an identifier, as shown below:

@lilypond[quote,verbatim,ragged-right,relative=2]
voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)

\relative c''' <<
  { \voiceOne g4 ~  \stemDown g32[ f( es d c b a b64 )g] } \\
  { \voiceThree  b4} \\
  { \voiceFive d,} \\
  { \voiceTwo g,}
>>
@end lilypond


@node Collision Resolution
@subsection Collision Resolution

Normally, note heads with a different number of dots are not merged, but
when the object property @code{merge-differently-dotted} is set in
the @internalsref{NoteCollision} object, they are merged:

@lilypond[quote,verbatim,fragment,ragged-right,relative=2]
\new Voice << {
  g8 g8
  \override Staff.NoteCollision
    #'merge-differently-dotted = ##t
  g8 g8
} \\ { g8.[ f16] g8.[ f16] } >>
@end lilypond

Similarly, you can merge half note heads with eighth notes, by setting
@code{merge-differently-headed}:

@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
\new Voice << {
  c8 c4.
  \override Staff.NoteCollision
    #'merge-differently-headed = ##t
c8 c4. } \\ { c2 c2 } >>
@end lilypond

@noindent
@code{merge-differently-headed} and @code{merge-differently-dotted}
only apply to opposing stem directions (ie. Voice 1 & 2).

LilyPond also vertically shifts rests that are opposite of a stem,
for example

@lilypond[quote,ragged-right,fragment,verbatim]
\new Voice << c''4 \\ r4 >>
@end lilypond

If three or more notes line up in the same column,
@code{merge-differently-headed} cannot
successfully complete the merge of the two notes that should be merged.
To allow the merge to work properly, apply a @code{\shift} to the note that
should not be merged.  In the first measure of following example,
@code{merge-differently-headed} does not work (the half-note head is
solid).  In the second measure, @code{\shiftOn} is applied to move the
top @code{g} out of the column, and @code{merge-differently-headed}
works properly.

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\override Staff.NoteCollision #'merge-differently-headed = ##t
<<
  { d=''2 g2 } \\
  { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
  { \voiceFour e,,2 e'2}
>>
<<
  { d'=''2 \shiftOn g2 } \\ 
  { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
  { \voiceFour e,,2 e'2}
>>
@end lilypond


@refcommands

@funindex \oneVoice
@code{\oneVoice},
@funindex \voiceOne
@code{\voiceOne},
@funindex \voiceTwo
@code{\voiceTwo},
@funindex \voiceThree
@code{\voiceThree},
@funindex \voiceFour
@code{\voiceFour}.

@funindex \shiftOn
@code{\shiftOn},
@funindex \shiftOnn
@code{\shiftOnn},
@funindex \shiftOnnn
@code{\shiftOnnn},
@funindex \shiftOff
@code{\shiftOff}: these commands specify the
degree to which chords of the current voice should be shifted.
The outer voices (normally: voice one and
two) have @code{\shiftOff}, while the inner voices (three and four)
have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
further shift levels.

When LilyPond cannot cope, the @code{force-hshift}
property of the @internalsref{NoteColumn} object and pitched rests can
be used to override typesetting decisions.

@lilypond[quote,verbatim,ragged-right]
\relative <<
{
  <d g>
  <d g>
} \\ {
  <b f'>
  \once \override NoteColumn #'force-hshift = #1.7
  <b f'>
} >>
@end lilypond


@seealso

Program reference: the objects responsible for resolving collisions are
@internalsref{NoteCollision} and @internalsref{RestCollision}.


@refbugs

When using @code{merge-differently-headed} with an upstem eighth or a
shorter note, and a downstem half note, the eighth note gets the wrong
offset.

There is no support for clusters where the same note occurs with
different accidentals in the same chord.  In this case, it is
recommended to use enharmonic transcription, or to use special cluster
notation (see @ref{Clusters}).



@node Staff notation
@section Staff notation

@cindex Staff notation

This section describes music notation that occurs on staff level,
such as key signatures, clefs and time signatures.

@menu
* Clef::                        
* Key signature::               
* Time signature::              
* Partial measures::            
* Bar lines::                   
* Unmetered music::             
* System start delimiters::     
* Staff symbol::                
* Writing music in parallel::   
@end menu


@node Clef
@subsection Clef

@funindex \clef

The clef indicates which lines of the staff correspond to which
pitches.  The clef is set with the @code{\clef} command

@lilypond[quote,ragged-right,fragment,verbatim]
{ c''2 \clef alto g'2 }
@end lilypond

@cindex treble clef
@cindex violin clef
@cindex alto clef
@cindex tenor clef
@cindex bass clef
@cindex french clef
@cindex soprano clef
@cindex mezzosoprano clef
@cindex baritone clef
@cindex varbaritone clef
@cindex subbass clef

Supported clefs include

@multitable @columnfractions .33 .66
@headitem Clef @tab Position
@item @code{treble}, violin, G, G2 @tab
G clef on 2nd line
@item @code{alto, C} @tab
C clef on 3rd line
@item @code{tenor} @tab
C clef on 4th line.
@item @code{bass, F} @tab
F clef on 4th line
@item @code{french} @tab
G clef on 1st line, so-called French violin clef
@item @code{soprano} @tab
C clef on 1st line
@item @code{mezzosoprano} @tab
C clef on 2nd line
@item @code{baritone} @tab
C clef on 5th line
@item @code{varbaritone} @tab
F clef on 3rd line
@item @code{subbass} @tab
F clef on 5th line
@item @code{percussion} @tab
percussion clef
@item @code{tab} @tab
tablature clef
@end multitable

By adding @code{_8} or @code{^8} to the clef name, the clef is
transposed one octave down or up, respectively, and @code{_15} and
@code{^15} transposes by two octaves.  The argument @var{clefname}
must be enclosed in quotes when it contains underscores or digits.  For
example,

@cindex choral tenor clef
@lilypond[quote,ragged-right,verbatim,fragment,relative=1]
\clef "G_8" c4
@end lilypond


@commonprop

The command @code{\clef "treble_8"} is equivalent to setting
@code{clefGlyph},
@code{clefPosition} (which controls the Y position of the clef),
@code{middleCPosition} and @code{clefOctavation}.  A clef is printed
when any of these properties are changed.  The following example shows
possibilities when setting properties manually.

@lilypond[quote,ragged-right,verbatim]
{
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  c'4
  \set Staff.clefGlyph = #"clefs.G"
  c'4
  \set Staff.clefGlyph = #"clefs.C"
  c'4
  \set Staff.clefOctavation = #7
  c'4
  \set Staff.clefOctavation = #0
  \set Staff.clefPosition = #0
  c'4
  \clef "bass"
  c'4
  \set Staff.middleCPosition = #4
  c'4
}
@end lilypond


@seealso

Manual: @ref{Grace notes}.

Program reference: @internalsref{Clef}.


@node Key signature
@subsection Key signature

@cindex Key signature
@funindex \key

The key signature indicates the tonality in which a piece is played.  It
is denoted by a set of alterations (flats or sharps) at the start of the
staff.

Setting or changing the key signature is done with the @code{\key}
command

@example
@code{\key} @var{pitch} @var{type}
@end example

@funindex \minor
@funindex \major
@funindex \minor
@funindex \ionian
@funindex \locrian
@funindex \aeolian
@funindex \mixolydian
@funindex \lydian
@funindex \phrygian
@funindex \dorian
@cindex church modes

Here, @var{type} should be @code{\major} or @code{\minor} to get
@var{pitch}-major or @var{pitch}-minor, respectively.  You may also
use the standard mode names (also called @q{church modes}): @code{\ionian},
@code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
@code{\phrygian}, and @code{\dorian}.

This command sets the context property
@code{Staff.keySignature}.  Non-standard key signatures
can be specified by setting this property directly.

Accidentals and key signatures often confuse new users, because
unaltered notes get natural signs depending on the key signature.  For
more information, see @ref{Accidentals} or @ref{Accidentals and key signatures}.

@lilypond[quote,ragged-right,verbatim,relative=2,fragment]
\key g \major
f1
fis
@end lilypond


@commonprop

A natural sign is printed to cancel any previous accidentals.  This
can be suppressed by setting the @code{Staff.printKeyCancellation}
property.

@lilypond[quote,fragment,ragged-right,fragment,verbatim,relative=2]
\key d \major
a b cis d
\key g \minor
a bes c d
\set Staff.printKeyCancellation = ##f
\key d \major
a b cis d
\key g \minor
a bes c d
@end lilypond


@seealso

Program reference: @internalsref{KeyCancellation},
@internalsref{KeySignature}.


@node Time signature
@subsection Time signature

@cindex Time signature
@cindex meter
@funindex \time

Time signature indicates the metrum of a piece: a regular pattern of
strong and weak beats.  It is denoted by a fraction at the start of the
staff.

The time signature is set with the @code{\time} command

@lilypond[quote,ragged-right,fragment,verbatim]
\time 2/4 c'2 \time 3/4 c'2.
@end lilypond

@commonprop

The symbol that is printed can be customized with the @code{style}
property.  Setting it to @code{#'()} uses fraction style for 4/4 and
2/2 time,

@lilypond[fragment,quote,ragged-right,verbatim]
\time 4/4 c'1
\time 2/2 c'1
\override Staff.TimeSignature #'style = #'()
\time 4/4 c'1
\time 2/2 c'1
@end lilypond

There are many more options for its layout.  See @ref{Ancient time
signatures} for more examples.

@code{\time} sets the property @code{timeSignatureFraction},
@code{beatLength} and @code{measureLength} in the @code{Timing}
context, which is normally aliased to @internalsref{Score}.  The
property @code{measureLength} determines where bar lines should be
inserted, and how automatic beams should be generated.  Changing the
value of @code{timeSignatureFraction} also causes the symbol to be
printed.

More options are available through the Scheme function
@code{set-time-signature}.  In combination with the
@internalsref{Measure_grouping_engraver}, it will create
@internalsref{MeasureGrouping} signs.  Such signs ease reading
rhythmically complex modern music.  In the following example, the 9/8
measure is subdivided in 2, 2, 2 and 3.  This is passed to
@code{set-time-signature} as the third argument @code{(2 2 2 3)}

@lilypond[quote,ragged-right,verbatim]
\score {
  \relative c'' {
    #(set-time-signature 9 8 '(2 2 2 3))
    g8[ g] d[ d] g[ g] a8[( bes g]) |
    #(set-time-signature 5 8 '(3 2))
    a4. g4
  }
  \layout {
    \context {
      \Staff
      \consists "Measure_grouping_engraver"
    }
  }
}
@end lilypond


@seealso

Program reference: @internalsref{TimeSignature}, and
@internalsref{Timing_translator}.

Examples: @inputfileref{input/@/test,compound@/-time@/.ly}.


@refbugs

Automatic beaming does not use the measure grouping specified with
@code{set-time-signature}.


@node Partial measures
@subsection Partial measures

@cindex anacrusis
@cindex upbeat
@cindex partial measure
@cindex measure, partial
@cindex shorten measures
@funindex \partial

Partial measures, such as an anacrusis or upbeat, are entered using the

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\partial 16*5 c16 cis d dis e | a2. c,4 | b2
@end lilypond

The syntax for this command is

@example
\partial @var{duration}
@end example

where @code{duration} is the rhythmic length to be added before
the next bar.

This is internally translated into

@example
\set Timing.measurePosition = -@var{length of duration}
@end example

The property @code{measurePosition} contains a rational number
indicating how much of the measure has passed at this point.  Note
that this is a negative number; @code{\partial 4} is internally
translated to mean @qq{there is a quarter note left in the bar.}


@refbugs

This command does not take into account grace notes at the start of
the music.  When a piece starts with graces notes in the pickup, then
the @code{\partial} should follow the grace notes

@lilypond[verbatim,quote,ragged-right,relative,fragment]
\grace f16
\partial 4
g4
a2 g2
@end lilypond

@code{\partial} is only intended to be used at the beginning of a
piece.  If you use it after the beginning, some odd warnings may
occur.


@node Bar lines
@subsection Bar lines

@cindex Bar lines
@funindex \bar
@cindex measure lines
@cindex repeat bars

Bar lines delimit measures, but are also used to indicate
repeats.  Normally they are inserted automatically.  Line
breaks may only happen on bar lines.

Special types of bar lines can be forced with the @code{\bar} command

@lilypond[quote,ragged-right,relative=2,fragment,verbatim]
c4 \bar "|:" c4
@end lilypond

The following bar types are available

@lilypondfile[ragged-right,quote]{bar-lines.ly}

In addition, you can specify @code{"||:"}, which is equivalent to 
@code{"|:"} except at line breaks, where it gives a double bar line at
the end of the line and a start repeat at the beginning of the next
line. 

To allow a line break where there is no visible bar line, use

@example
\bar ""
@end example

@noindent
This will insert an invisible bar line and allow line breaks at this
point (without increasing the bar number counter).

In scores with many staves, a @code{\bar} command in one staff is
automatically applied to all staves.  The resulting bar lines are
connected between different staves of a @code{StaffGroup},
@code{PianoStaff}, or @code{ChoirStaff}.

@lilypond[quote,ragged-right,fragment,verbatim]
<<
  \new StaffGroup <<
    \new Staff {
      e'4 d'
      \bar "||"
      f' e'
    }
    \new Staff { \clef bass c4 g e g }
  >>
  \new Staff { \clef bass c2 c2 }
>>
@end lilypond


@commonprop

@funindex whichBar
@funindex repeatCommands
@funindex defaultBarType

The command @code{\bar }@var{bartype} is a short cut for doing
@code{\set Timing.whichBar = }@var{bartype}.  Whenever @code{whichBar}
is set to a string, a bar line of that type is created.

A bar line is created whenever the @code{whichBar} property is set.
At the start of a measure it is set to the contents of
@code{Timing.defaultBarType}.  The contents of @code{repeatCommands} are
used
to override default measure bars.

You are encouraged to use @code{\repeat} for repetitions.  See
@ref{Repeats}.


@seealso

In this manual: @ref{Repeats}, @ref{System start delimiters}.

Program reference: @internalsref{BarLine} (created at
@internalsref{Staff} level), @internalsref{SpanBar} (across staves).


@node Unmetered music
@subsection Unmetered music

@cindex cadenza
@funindex \cadenzaOn
@funindex \cadenzaOff

Bar lines and bar numbers are calculated automatically.  For unmetered
music (cadenzas, for example), this is not desirable.  To turn off
automatic bar lines and bar numbers, use the commands @code{\cadenzaOn}
and @code{\cadenzaOff}.

@lilypond[verbatim,quote,ragged-right,relative=2,fragment]
c4 d e d
\cadenzaOn
c4 c d8 d d f4 g4.
\cadenzaOff
\bar "|"
d4 e d c
@end lilypond


@refbugs

LilyPond will only insert line breaks and page breaks at a
barline.  Unless the unmetered music ends before the end of
the staff line, you will need to insert
invisible bar lines

@example
\bar ""
@end example

@noindent
to indicate where breaks can occur.


@node System start delimiters
@subsection System start delimiters

@cindex start of system
@cindex Staff, multiple
@cindex bracket, vertical
@cindex brace, vertical
@cindex grand staff
@cindex staff group
@cindex staff, choir

Many scores consist of more than one staff.  These staves can be
joined in four different ways

@itemize @bullet
@item The group is started with a brace at the left, and bar lines are
connected.  This is done with the @internalsref{GrandStaff} context.

@lilypond[verbatim,ragged-right,quote]
\new GrandStaff
\relative <<
  \new Staff { c1 c }
  \new Staff { c c }
>>
@end lilypond

@item The group is started with a bracket, and bar lines are connected.
This is done with the
@internalsref{StaffGroup} context

@lilypond[verbatim,ragged-right,quote]
\new StaffGroup
\relative <<
  \new Staff { c1 c }
  \new Staff { c c }
>>
@end lilypond

@item The group is started with a bracket, but bar lines are not
connected.  This is done with the @internalsref{ChoirStaff} context.

@lilypond[verbatim,ragged-right,quote]
\new ChoirStaff
\relative <<
  \new Staff { c1 c }
  \new Staff { c c }
>>
@end lilypond

@item The group is started with a vertical line.  Bar lines are not
connected.  This is the default for the score.

@lilypond[verbatim,ragged-right,quote]
\relative <<
  \new Staff { c1 c }
  \new Staff { c c }
>>
@end lilypond
@end itemize


@seealso

The bar lines at the start of each system are
@internalsref{SystemStartBar}, @internalsref{SystemStartBrace}, and
@internalsref{SystemStartBracket}.  Only one of these types is created
in every context, and that type is determined by the property
@internalsref{systemStartDelimiter}.


@commonprop

System start delimiters may be deeply nested,

@lilypond[quote,ragged-right,verbatim]
\new StaffGroup 
\relative <<
  \set StaffGroup.systemStartDelimiterHierarchy
    = #'(SystemStartSquare (SystemStartBracket a (SystemStartSquare b)) d)
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
>>
@end lilypond


@node Staff symbol
@subsection Staff symbol

@cindex adjusting staff symbol

Notes, dynamic signs, etc., are grouped
with a set of horizontal lines, called a staff (plural @q{staves}).  In
LilyPond, these lines are drawn using a separate layout object called
@code{staff symbol}.

The staff symbol may be tuned in the number, thickness and distance
of lines, using properties.  This is demonstrated in the example files
@inputfileref{input/@/test,staff@/-lines@/.ly},
@inputfileref{input/@/test,staff@/-size@/.ly}.

In addition, staves may be started and stopped at will. This is done
with @code{\startStaff} and @code{\stopStaff}.

@lilypond[verbatim,relative=2,fragment]
b4 b
\override Staff.StaffSymbol #'line-count = 2
\stopStaff \startStaff
b b
\revert Staff.StaffSymbol #'line-count
\stopStaff \startStaff
b b
@end lilypond

In combination with Frenched staves, this may be used to typeset ossia
sections. An example is shown here

@cindex ossia

@lilypondfile{ossia.ly}

@cindex staff lines, setting number of
@cindex staff lines, setting thickness of
@cindex thickness of staff lines, setting
@cindex number of staff lines, setting

@seealso

Program reference: @internalsref{StaffSymbol}.

Examples: @inputfileref{input/@/test,staff@/-lines@/.ly},
@inputfileref{input/@/test@/,ossia.ly},
@inputfileref{input/@/test,staff@/-size@/.ly},
@lsr{staff,staff-line-positions.ly}


@node Writing music in parallel
@subsection Writing music in parallel

@cindex Writing music in parallel
@cindex Interleaved music

Music for multiple parts can be interleaved

@lilypond[quote,fragment,verbatim]
\parallelMusic #'(voiceA voiceB) {
  r8     g'16[ c''] e''[ g' c'' e''] r8     g'16[ c''] e''[ g' c'' e''] |
  c'2                                c'2                                |
  r8     a'16[ d''] f''[ a' d'' f''] r8     a'16[ d''] f''[ a' d'' f''] |
  c'2                                c'2                                |
}
\new StaffGroup <<
  \new Staff \new Voice \voiceA
  \new Staff \new Voice \voiceB
>>
@end lilypond

This works quite well for piano music

@lilypond[quote,verbatim]
music = {
  \key c \major
  \time 4/4
  \parallelMusic #'(voiceA voiceB voiceC voiceD) {
    % Bar 1
    r8  g'16[ c''] e''[ g' c'' e''] r8  g'16[ c''] e''[ g' c''
e''] |
    c'2                                 c'2 |
    r8  a16[ d'] f'[ a d' f']       r8  a16[ d'] f'[ a d' f'] |
    c2                                  c2 |

    % Bar 2
    a'8 b'      c'' d''    e'' f''    g'' a'' |
    d'4         d'         d'         d' |
    c16 d e f   d e f g    e f g a    f g a b |
    a,4         a,4        a,4        a,4 |

    % Bar 3 ...
  }
}

\score {
  \new PianoStaff <<
    \music
    \new Staff <<
      \voiceA \\
      \voiceB
    >>
    \new Staff {
      \clef bass
      <<
        \voiceC \\
        \voiceD
      >>
    }
  >>
}
@end lilypond


@node Connecting notes
@section Connecting notes

This section deals with notation that affects groups of notes.

@menu
* Ties::                        
* Slurs::                       
* Phrasing slurs::              
* Laissez vibrer ties::         
* Automatic beams::             
* Manual beams::                
* Grace notes::                 
@end menu


@node Ties
@subsection Ties

@cindex tie
@funindex ~

A tie connects two adjacent note heads of the same pitch.  The tie in
effect extends the length of a note.  Ties should not be confused with
slurs, which indicate articulation, or phrasing slurs, which indicate
musical phrasing.  A tie is entered using the tilde symbol @samp{~}

@lilypond[quote,ragged-right,fragment,verbatim]
e' ~ e' <c' e' g'> ~ <c' e' g'>
@end lilypond

When a tie is applied to a chord, all note heads whose pitches match
are connected.  When no note heads match, no ties will be created.  Chords
may be partially tied by placing the tie inside the chord,

@lilypond[quote,ragged-right,fragment,verbatim,relative=1]
<c~ e g~ b> <c e g b>
@end lilypond

A tie is just a way of extending a note duration, similar to the
augmentation dot.  The following example shows two ways of notating
exactly the same concept

@lilypond[quote,fragment,ragged-right]
\time 3/4 c'2. c'2 ~ c'4
@end lilypond

@noindent
Ties are used either when the note crosses a bar line, or when dots
cannot be used to denote the rhythm.  When using ties, larger note
values should be aligned to subdivisions of the measure, such as

@lilypond[fragment,quote,ragged-right]
\relative {
  r8 c8 ~ c2 r4 | r8^"not" c2 ~ c8 r4
}
@end lilypond

If you need to tie a lot of notes over bars, it may be easier to use
automatic note splitting (see @ref{Automatic note splitting}).  This
mechanism automatically splits long notes, and ties them across bar
lines.

@funindex \repeatTie

When a second alternative of a repeat starts with a tied note, you
have to repeat the tie. This can be achieved with @code{\repeatTie},

@lilypond[fragment,quote,ragged-right,relative=2]
r <c e g>\repeatTie
@end lilypond

@cindex repeating ties
@cindex volta brackets and ties

@commonprop

Ties are sometimes used to write out arpeggios.  In this case, two tied
notes need not be consecutive.  This can be achieved by setting the
@code{tieWaitForNote} property to true. The same feature is also useful,
for example, to tie a tremolo to a chord. For example,

@lilypond[fragment,verbatim,relative=1,ragged-right,quote]
\set tieWaitForNote = ##t
\grace { c16[~ e~ g]~ } <c, e g>2
\repeat "tremolo" 8 { c32~ c'~ } <c c,>1
e8~ c~ a~ f~ <e' c a f>2
@end lilypond

Ties may be engraved manually by changing the @code{tie-configuration}
property.  The first number indicates the distance from the center
of the staff in staff-spaces, and the second number indicates the
direction (1=up, -1=down).

@lilypond[fragment,verbatim,relative=1,ragged-right,quote]
<c e g>2~ <c e g> |
\override TieColumn #'tie-configuration =
  #'((0.0 . 1) (-2.0 . 1) (-4.0 . 1))
<c e g>~ <c e g> |
@end lilypond


@refcommands


@funindex \tieUp
@code{\tieUp},
@funindex \tieDown
@code{\tieDown},
@funindex \tieNeutral
@code{\tieNeutral},
@funindex \tieDotted
@code{\tieDotted},
@funindex \tieDashed
@code{\tieDashed},
@funindex \tieSolid
@code{\tieSolid}.


@seealso

In this manual: @ref{Automatic note splitting}.

Program reference: @internalsref{Tie}.


@refbugs

Switching staves when a tie is active will not produce a slanted tie.

Changing clefs or octavations during a tie is not really
well-defined.  In these cases, a slur may be preferable.


@node Slurs
@subsection Slurs

@cindex Slurs

A slur indicates that notes are to be played bound or
@emph{legato}.  They are entered using parentheses

@lilypond[quote,ragged-right,relative=2,fragment,verbatim]
f( g a) a8 b( a4 g2 f4)
<c e>2( <b d>2)
@end lilypond

The direction of a slur can be specified with
@code{\slur@emph{DIR}}, where @code{@emph{DIR}} is
either @code{Up}, @code{Down}, or @code{Neutral} (automatically
selected).

However, there is a convenient shorthand for forcing slur
directions.  By adding @code{_} or @code{^} before the opening
parentheses, the direction is also set.  For example,

@lilypond[relative=2,ragged-right,quote,verbatim,fragment]
c4_( c) c^( c)
@end lilypond

Only one slur can be printed at once.  If you need to print a long
slur over a few small slurs, please see @ref{Phrasing slurs}.


@commonprop

Some composers write two slurs when they want legato chords.  This can
be achieved in LilyPond by setting @code{doubleSlurs},

@lilypond[verbatim,ragged-right,relative,fragment,quote]
\set doubleSlurs = ##t
<c e>4 ( <d f> <c e> <d f> )
@end lilypond


@refcommands

@funindex \slurUp
@code{\slurUp},
@funindex \slurDown
@code{\slurDown},
@funindex \slurNeutral
@code{\slurNeutral},
@funindex \slurDashed
@code{\slurDashed},
@funindex \slurDotted
@code{\slurDotted},
@funindex \slurSolid
@code{\slurSolid}.

@seealso

Program reference: @seeinternals{Slur}.


@node Phrasing slurs
@subsection Phrasing slurs

@cindex phrasing slurs
@cindex phrasing marks

A phrasing slur (or phrasing mark) connects notes and is used to
indicate a musical sentence.  It is written using @code{\(} and @code{\)}
respectively

@lilypond[quote,ragged-right,fragment,verbatim,relative=1]
\time 6/4 c'\( d( e) f( e) d\)
@end lilypond

Typographically, the phrasing slur behaves almost exactly like a
normal slur.  However, they are treated as different objects.  A
@code{\slurUp} will have no effect on a phrasing slur; instead, use
@code{\phrasingSlurUp}, @code{\phrasingSlurDown}, and
@code{\phrasingSlurNeutral}.

You cannot have simultaneous phrasing slurs.


@refcommands

@funindex \phrasingSlurUp
@code{\phrasingSlurUp},
@funindex \phrasingSlurDown
@code{\phrasingSlurDown},
@funindex \phrasingSlurNeutral
@code{\phrasingSlurNeutral}.


@seealso

Program reference: @internalsref{PhrasingSlur}.


@node Laissez vibrer ties
@subsection Laissez vibrer ties
@cindex Laissez vibrer
@cindex Ties, laissez vibrer

L.v. ties (laissez vibrer) indicate that notes must not be damped at the
end. It is used in notation for piano, harp and other string and
percussion instruments. They can be entered using @code{\laissezVibrer},

@lilypond[fragment,ragged-right,verbatim,relative=1]
<c f g>\laissezVibrer
@end lilypond

@seealso

Program reference:
@internalsref{LaissezVibrerTie}
@internalsref{LaissezVibrerTieColumn}

Example files:
@lsr{connecting,laissez-vibrer-ties.ly}


@node Automatic beams
@subsection Automatic beams

LilyPond inserts beams automatically

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
@end lilypond

When these automatic decisions are not good enough, beaming can be
entered explicitly.  It is also possible to define beaming patterns
that differ from the defaults.  See @ref{Setting automatic beam behavior}
for details.

Individual notes may be marked with @code{\noBeam} to prevent them
from being beamed

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\time 2/4 c8 c\noBeam c c
@end lilypond


@seealso

Program reference: @internalsref{Beam}.


@node Manual beams
@subsection Manual beams

@cindex beams, manual
@funindex ]
@funindex [

In some cases it may be necessary to override the automatic beaming
algorithm.  For example, the autobeamer will not put beams over rests
or bar lines.  Such beams are specified manually by marking the begin
and end point with @code{[} and @code{]}

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
{
  r4 r8[ g' a r8] r8 g[ | a] r8
}
@end lilypond


@commonprop

@funindex stemLeftBeamCount
@funindex stemRightBeamCount

Normally, beaming patterns within a beam are determined automatically.
If necessary, the properties @code{stemLeftBeamCount} and
@code{stemRightBeamCount} can be used to override the defaults.  If
either property is set, its value will be used only once, and then it
is erased

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
{
   f8[ r16
      f g a]
   f8[ r16
   \set stemLeftBeamCount = #1
      f g a]
}
@end lilypond

The property @code{subdivideBeams} can be set in order to subdivide
all 16th or shorter beams at beat positions, as defined by the
@code{beatLength} property.

@lilypond[fragment,quote,relative=2,verbatim]
c16[ c c c c c c c]
\set subdivideBeams = ##t
c16[ c c c c c c c]
\set Score.beatLength = #(ly:make-moment 1 8)
c16[ c c c c c c c]
@end lilypond
@funindex subdivideBeams

@noindent
For more information about @code{make-moment}, see
@ref{Time administration}.

Line breaks are normally forbidden when beams cross bar lines.  This
behavior can be changed by setting @code{breakable}.

@funindex breakable

@cindex beams and line breaks
@cindex beams, kneed
@cindex kneed beams
@cindex auto-knee-gap


@refbugs

Kneed beams are inserted automatically when a large gap is detected
between the note heads.  This behavior can be tuned through the object.

Automatically kneed cross-staff beams cannot be used together with
hidden staves.  See @ref{Hiding staves}.

Beams do not avoid collisions with symbols around the notes, such as
texts and accidentals.


@node Grace notes
@subsection Grace notes

@funindex \grace
@cindex ornaments
@cindex grace notes
@cindex appoggiatura
@cindex acciaccatura

Grace notes are ornaments that are written out.  The most common ones
are acciaccatura, which should be played as very short.  It is denoted
by a slurred small note with a slashed stem.  The appoggiatura is a
grace note that takes a fixed fraction of the main note, and is
denoted as a slurred note in small print without a slash.  They
are entered with the commands @code{\acciaccatura} and
@code{\appoggiatura}, as demonstrated in the following example

@lilypond[quote,ragged-right,relative=2,verbatim,fragment]
b4 \acciaccatura d8 c4 \appoggiatura e8 d4
\acciaccatura { g16[ f] } e4
@end lilypond

Both are special forms of the @code{\grace} command.  By prefixing this
keyword to a music expression, a new one is formed, which will be
printed in a smaller font and takes up no logical time in a measure.

@lilypond[quote,ragged-right,relative=2,verbatim,fragment]
c4 \grace c16 c4
\grace { c16[ d16] } c2 c4
@end lilypond

@noindent
Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
@code{\grace} command does not start a slur.

Internally, timing for grace notes is done using a second, @q{grace}
timing.  Every point in time consists of two rational numbers: one
denotes the logical time, one denotes the grace timing.  The above
example is shown here with timing tuples

@lilypond[quote,ragged-right]
<<
  \relative c''{
    c4 \grace c16 c4 \grace {
    c16[ d16] } c2 c4
  }
  \new Lyrics \lyricmode {
    \override LyricText #'font-family = #'typewriter

    \markup { (0,0) } 4
    \grace { \markup {
      ( \fraction 1 4 , \fraction -1 16 ) } 16 }
    \markup { (\fraction 1 4 , 0 ) } 4
    \grace {
      \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
      \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
    }
    \markup { ( \fraction 2 4 , 0 ) }
  }
>>
@end lilypond

The placement of grace notes is synchronized between different staves.
In the following example, there are two sixteenth grace notes for
every eighth grace note

@lilypond[quote,ragged-right,relative=2,verbatim,fragment]
<< \new Staff { e4 \grace { c16[ d e f] } e4 }
   \new Staff { c4 \grace { g8[ b] } c4 } >>
@end lilypond

@funindex \afterGrace

If you want to end a note with a grace, use the @code{\afterGrace}
command.  It takes two arguments: the main note, and the grace notes
following the main note.

@lilypond[ragged-right, verbatim,relative=2,fragment]
c1 \afterGrace d1 { c16[ d] } c4
@end lilypond

This will put the grace notes after a @q{space} lasting 3/4 of the
length of the main note.  The fraction 3/4 can be changed by setting
@code{afterGraceFraction}, ie.

@example
afterGraceFraction = #(cons 7 8)
@end example

@noindent
will put the grace note at 7/8 of the main note.

The same effect can be achieved manually by doing

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\new Voice {
  << { d1^\trill_( }
     { s2 \grace { c16[ d] } } >>
  c4)
}
@end lilypond

@noindent
By adjusting the duration of the skip note (here it is a half-note),
the space between the main-note and the grace is adjusted.

A @code{\grace} section will introduce special typesetting settings,
for example, to produce smaller type, and set directions.  Hence, when
introducing layout tweaks, they should be inside the grace section,
for example,

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\new Voice {
  \acciaccatura {
    \stemDown
    f16->
    \stemNeutral
  }
  g4
}
@end lilypond

@noindent
The overrides should also be reverted inside the grace section.

The layout of grace sections can be changed throughout the music using
the function @code{add-grace-property}.  The following example
undefines the @code{Stem} direction for this grace, so
that stems do not always point up.

@example
\new Staff @{
  #(add-grace-property 'Voice 'Stem 'direction '())
  @dots{}
@}
@end example

@noindent
Another option is to change the variables @code{startGraceMusic},
@code{stopGraceMusic}, @code{startAcciaccaturaMusic},
@code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
@code{stopAppoggiaturaMusic}.  More information is in the file
@file{ly/@/grace@/-init@/.ly}.

@noindent
The slash through the stem in acciaccaturas can be obtained
in other situations by @code{\override Stem  #'stroke-style = #"grace"}.


@commonprop

Grace notes may be forced to use floating spacing,

@lilypond[relative=2,ragged-right]
<<
  \override Score.SpacingSpanner #'strict-grace-spacing = ##t
  \new Staff {
     c'4
     \afterGrace
     c'4
     { c'16[ c'8 c'16] }
     c'4
  }  
  \new Staff {
     c'16[ c'16 c'16 c'16]
     c'16[ c'16 c'16 c'16]
     c'4
  }
>>
@end lilypond


@seealso

Program reference: @internalsref{GraceMusic}.


@refbugs

A score that starts with a @code{\grace} section needs an explicit
@code{\new Voice} declaration, otherwise the main note and the grace
note end up on different staves.

Grace note synchronization can also lead to surprises.  Staff notation,
such as key signatures, bar lines, etc., are also synchronized.  Take
care when you mix staves with grace notes and staves without, for example,

@lilypond[quote,ragged-right,relative=2,verbatim,fragment]
<< \new Staff { e4 \bar "|:" \grace c16 d4 }
   \new Staff { c4 \bar "|:" d4 } >>
@end lilypond

@noindent
This can be remedied by inserting grace skips of the corresponding
durations in the other staves. For the above example

@example
\new Staff @{ c4 \bar "|:" \grace s16 d4 @}
@end example

Grace sections should only be used within sequential music
expressions.  Nesting or juxtaposing grace sections is not supported,
and might produce crashes or other errors.



@node Expressive marks
@section Expressive marks

Expressive marks help musicians to bring more to the music than simple
notes and rhythms.

@menu
* Articulations::               
* Fingering instructions::      
* Dynamics::                    
* Breath marks::                
* Trills::                      
* Glissando::                   
* Arpeggio::                    
* Falls and doits::             
@end menu


@node Articulations
@subsection Articulations

@cindex Articulations
@cindex scripts
@cindex ornaments

A variety of symbols can appear above and below notes to indicate
different characteristics of the performance.  They are added to a note
by adding a dash and the character signifying the
articulation.  They are demonstrated here

@lilypondfile[quote,ragged-right]{script-abbreviations.ly}

The meanings of these shorthands can be changed.  See
@file{ly/@/script@/-init@/.ly} for examples.

The script is automatically placed, but the direction can be forced as
well.  Like other pieces of LilyPond code, @code{_} will place them
below the staff, and @code{^} will place them above.

@lilypond[quote,ragged-right,fragment,verbatim]
c''4^^ c''4_^
@end lilypond

Other symbols can be added using the syntax
@var{note}@code{\}@var{name}.  Again, they
can be forced up or down using @code{^} and @code{_},
e.g.,

@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
c\fermata c^\fermata c_\fermata
@end lilypond

@cindex accent
@cindex marcato
@cindex staccatissimo
@cindex espressivo
@cindex fermata
@cindex stopped
@cindex staccato
@cindex portato
@cindex tenuto
@cindex upbow
@cindex downbow
@cindex foot marks
@cindex organ pedal marks
@cindex turn
@cindex open
@cindex flageolet
@cindex reverseturn
@cindex trill
@cindex prall
@cindex mordent
@cindex prallprall
@cindex prallmordent
@cindex prall, up
@cindex prall, down
@cindex mordent
@cindex thumb marking
@cindex segno
@cindex coda
@cindex varcoda

Here is a chart showing all scripts available,

@lilypondfile[ragged-right,quote]{script-chart.ly}


@commonprop

The vertical ordering of scripts is controlled with the
@code{script-priority} property.  The lower this number, the closer it
will be put to the note.  In this example, the
@internalsref{TextScript} (the sharp symbol) first has the lowest
priority, so it is put lowest in the first example.  In the second, the
prall trill (the @internalsref{Script}) has the lowest, so it is on the
inside.  When two objects have the same priority, the order in which
they are entered decides which one comes first.

@lilypond[verbatim,relative=3,ragged-right,fragment,quote]
\once \override TextScript #'script-priority = #-100
a4^\prall^\markup { \sharp }

\once \override Script #'script-priority = #-100
a4^\prall^\markup { \sharp }
@end lilypond


@seealso

Program reference: @internalsref{Script}.


@refbugs

These signs appear in the printed output but have no effect on the
MIDI rendering of the music.


@node Fingering instructions
@subsection Fingering instructions

@cindex fingering
@cindex finger change

Fingering instructions can be entered using
@example
@var{note}-@var{digit}
@end example
For finger changes, use markup texts

@lilypond[quote,verbatim,ragged-right,fragment,relative=1]
c4-1 c-2 c-3 c-4
c^\markup { \finger "2 - 3" }
@end lilypond

You can use the thumb-script to indicate that a note should be
played with the thumb (e.g., in cello music)
@lilypond[quote,verbatim,ragged-right,fragment,relative=2]
<a_\thumb a'-3>8 <b_\thumb b'-3>
@end lilypond

Fingerings for chords can also be added to individual notes
of the chord by adding them after the pitches
@lilypond[quote,verbatim,ragged-right,fragment,relative=2]
< c-1 e-2 g-3 b-5 >4
@end lilypond


@commonprop

You may exercise greater control over fingering chords by
setting @code{fingeringOrientations}

@lilypond[quote,verbatim,ragged-right,fragment,relative=1]
\set fingeringOrientations = #'(left down)
<c-1 es-2 g-4 bes-5 > 4
\set fingeringOrientations = #'(up right down)
<c-1 es-2 g-4 bes-5 > 4
@end lilypond

Using this feature, it is also possible to put fingering instructions
very close to note heads in monophonic music,

@lilypond[verbatim,ragged-right,quote,fragment]
\set fingeringOrientations = #'(right)
<es'-2>4
@end lilypond


@seealso

Program reference: @internalsref{Fingering}.

Examples: @lsr{expressive,fingering-chords.ly}


@node Dynamics
@subsection Dynamics

@cindex Dynamics
@funindex \pppp
@funindex \ppp
@funindex \pp
@funindex \p
@funindex \mp
@funindex \mf
@funindex \f
@funindex \ff
@funindex \fff
@funindex \ffff
@funindex \fp
@funindex \sf
@funindex \sff
@funindex \sp
@funindex \spp
@funindex \sfz
@funindex \rfz

Absolute dynamic marks are specified using a command after a note
@code{c4\ff}.  The available dynamic marks are @code{\ppppp},
@code{\pppp}, @code{\ppp},
@code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
@code{\fff}, @code{\ffff}, @code{\fp}, @code{\sf}, @code{\sff},
@code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.

@lilypond[quote,verbatim,ragged-right,fragment,relative=2]
c\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
c2\fp c\sf c\sff c\sp c\spp c\sfz c\rfz
@end lilypond

@funindex \<
@funindex \>
@funindex \!

A crescendo mark is started with @code{\<} and terminated with
@code{\!} or an absolute dynamic.  A decrescendo is started with
@code{\>} and is also terminated with @code{\!} or an absolute
dynamic.  @code{\cr} and @code{\decr} may be used instead of
@code{\<} and @code{\>}.  Because these marks are bound to notes, you must
use spacer notes if multiple marks are needed during one note

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
c\< c\! d\> e\!
<< f1 { s4 s4\< s4\! \> s4\! } >>
@end lilypond

@noindent
A hairpin normally starts at the left edge of the beginning note
and ends on the right edge of the ending note.  If the ending
note falls on the downbeat, the hairpin ends on the immediately
preceding barline. This may be modified by setting the
@code{hairpinToBarline} property,

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\set hairpinToBarline = ##f
c4\< c2. c4\!
@end lilypond

In some situations the @code{\espressivo} articulation mark may
be suitable to indicate a crescendo and decrescendo on the one note,

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
c2 b4 a g1\espressivo
@end lilypond

This may give rise to very short hairpins.  Use @code{minimum-length}
in @internalsref{Voice}.@internalsref{Hairpin} to lengthen them, for
example

@example
\override Voice.Hairpin #'minimum-length = #5
@end example

@cindex al niente
@cindex niente, al

Hairpins may be printed with a circled tip (al niente notation) by
setting the @code{circled-tip} property,

@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
\override Hairpin #'circled-tip = ##t
c2\< c\!
c4\> c\< c2\!
@end lilypond


@cindex crescendo
@cindex decrescendo
@cindex diminuendo

You can also use text saying @emph{cresc.} instead of hairpins

@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
\setTextCresc
c\< d e f\!
\setHairpinCresc
e\> d c b\!
\setTextDecresc
c\> d e f\!
\setTextDim
e\> d c b\!
@end lilypond

You can also supply your own texts
@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
\set crescendoText = \markup { \italic "cresc. poco" }
\set crescendoSpanner = #'dashed-line
a'2\< a a a\!\mf
@end lilypond

To create new dynamic marks or text that should be aligned
with dynamics, see @ref{New dynamic marks}.


@commonprop

Dynamics that occur at, begin on, or end on, the same note
will be vertically aligned.  If you want to ensure that dynamics
are aligned when they do not occur on the same note, you can
increase the @code{staff-padding} property.

@example
\override DynamicLineSpanner #'staff-padding = #4
@end example

You may also use this property if the dynamics are colliding
with other notation.

Crescendi and decrescendi that end on the first note of a
new line are not printed.  To change this behavior, use

@example
\override Score.Hairpin #'after-line-breaking = ##t
@end example

Text style dynamic changes (such as @emph{cresc.} and @emph{dim.})
are printed with a
dashed line showing their extent.  To surpress printing this line, use

@example
\override DynamicTextSpanner #'dash-period = #-1.0
@end example


@refcommands

@funindex \dynamicUp
@code{\dynamicUp},
@funindex \dynamicDown
@code{\dynamicDown},
@funindex \dynamicNeutral
@code{\dynamicNeutral}.


@seealso

Program reference: @internalsref{DynamicText}, @internalsref{Hairpin}.
Vertical positioning of these symbols is handled by
@internalsref{DynamicLineSpanner}.


@node Breath marks
@subsection Breath marks

Breath marks are entered using @code{\breathe}

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
c'4 \breathe d4
@end lilypond


@commonprop

The glyph of the breath mark can be tuned by overriding the
@code{text} property of the @code{BreathingSign} layout object with
any markup text.  For example,
@lilypond[quote,ragged-right,fragment,verbatim,relative=1]
c'4
\override BreathingSign #'text
  = #(make-musicglyph-markup "scripts.rvarcomma")
\breathe
d4
@end lilypond

@seealso

Program reference: @internalsref{BreathingSign}.

Examples: @lsr{expressive,breathing-sign.ly}


@node Trills
@subsection Trills

Short trills are printed like normal articulation; see @ref{Articulations}.

Long running trills are made with @code{\startTrillSpan} and
@code{\stopTrillSpan},

@lilypond[verbatim,ragged-right,relative=2,quote,fragment]
\new Voice {
  << { c1 \startTrillSpan }
     { s2. \grace { d16[\stopTrillSpan e] } } >>
  c4 }
@end lilypond

@cindex Pitched trills

Trills that should be executed on an explicitly specified pitch can be
typeset with the command @code{pitchedTrill},

@lilypond[ragged-right,verbatim,fragment,relative=1,quote]
\pitchedTrill c4\startTrillSpan fis
f\stopTrillSpan
@end lilypond

The first argument is the main note.  The pitch of the second
is printed as a stemless note head in parentheses.


@refcommands

@code{\startTrillSpan},
@funindex \startTrillSpan
@code{\stopTrillSpan}.
@funindex \stopTrillSpan


@seealso

Program reference: @internalsref{TrillSpanner}.


@node Glissando
@subsection Glissando

@cindex Glissando
@funindex \glissando

A glissando is a smooth change in pitch.  It is denoted by a line or a
wavy line between two notes.  It is requested by attaching
@code{\glissando} to a note

@lilypond[quote,ragged-right,fragment,relative=2,verbatim]
c2\glissando c'
\override Glissando #'style = #'zigzag
c2\glissando c,
@end lilypond


@seealso

Program reference: @internalsref{Glissando}.

Example files:
@lsr{expressive,glissando.ly}, @lsr{expressive,line-styles.ly}



@refbugs

Printing text over the line (such as @emph{gliss.}) is not supported.


@node Arpeggio
@subsection Arpeggio

@cindex Arpeggio
@cindex broken chord
@funindex \arpeggio

You can specify an arpeggio sign (also known as broken chord) on a
chord by attaching an @code{\arpeggio} to a chord

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
<c e g c>\arpeggio
@end lilypond

A square bracket on the left indicates that the player should not
arpeggiate the chord

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
\arpeggioBracket
<c' e g c>\arpeggio
@end lilypond

The direction of the arpeggio is sometimes denoted by adding an
arrowhead to the wiggly line

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
\new Voice {
  \arpeggioUp
  <c e g c>\arpeggio
  \arpeggioDown
  <c e g c>\arpeggio
}
@end lilypond


@commonprop

When an arpeggio crosses staves, you may attach an arpeggio to the chords
in both staves and set
@internalsref{PianoStaff}.@code{connectArpeggios}

@lilypond[quote,ragged-right,fragment,relative=1,verbatim]
\new PianoStaff <<
  \set PianoStaff.connectArpeggios = ##t
  \new Staff { <c' e g c>\arpeggio }
  \new Staff { \clef bass <c,, e g>\arpeggio }
>>
@end lilypond


@refcommands

@code{\arpeggio},
@funindex \arpeggioUp
@code{\arpeggioUp},
@funindex \arpeggioDown
@code{\arpeggioDown},
@funindex \arpeggioNeutral
@code{\arpeggioNeutral},
@funindex \arpeggioBracket
@code{\arpeggioBracket}.


@seealso

Notation manual: @ref{Ties}, for writing out arpeggios.

Program reference: @internalsref{Arpeggio}.


@refbugs

It is not possible to mix connected arpeggios and unconnected
arpeggios in one @internalsref{PianoStaff} at the same point in time.


@node Falls and doits
@subsection Falls and doits

Falls and doits can be added to notes using the @code{\bendAfter}
command,

@lilypond[fragment,ragged-right,relative=2]
\override Score.SpacingSpanner #'shortest-duration-space = #3.0
c4-\bendAfter #+5
c4-\bendAfter #-3
@end lilypond


@node Repeats
@section Repeats

Repetition is a central concept in music, and multiple notations exist
for repetitions.

@menu
* Repeat types::                
* Repeat syntax::               
* Repeats and MIDI::            
* Manual repeat commands::      
* Tremolo repeats::             
* Tremolo subdivisions::        
* Measure repeats::             
@end menu


@node Repeat types
@subsection Repeat types

@cindex repeats
@funindex \repeat

The following types of repetition are supported

@table @code
@item unfold
Repeated music is fully written (played) out.  This is useful when
entering repetitious music.  This is the only kind of repeat that
is included in MIDI output.

@item volta
Repeats are not written out, but alternative endings (volte) are
printed, left to right with brackets.  This is the standard notation
for repeats with alternatives.  These are not played in MIDI output by
default.


@item tremolo
Make tremolo beams.  These are not played in MIDI output by default.

@item percent
Make beat or measure repeats.  These look like percent signs.  These
are not played in MIDI output by default.  Percent repeats must be
declared within a @code{Voice} context.

@end table


@node Repeat syntax
@subsection Repeat syntax

@cindex volta
@cindex prima volta
@cindex seconda volta

LilyPond has one syntactic construct for specifying different types of
repeats.  The syntax is

@example
\repeat @var{variant} @var{repeatcount} @var{repeatbody}
@end example

If you have alternative endings, you may add
@funindex \alternative
@example
\alternative @{
  @var{alternative1}
  @var{alternative2}
  @var{alternative3}
  @dots{}
@}
@end example

@noindent
where each @var{alternative} is a music expression.  If you do not
give enough alternatives for all of the repeats, the first alternative
is assumed to be played more than once.

Standard repeats are used like this

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
c1
\repeat volta 2 { c4 d e f }
\repeat volta 2 { f e d c }
@end lilypond

With alternative endings

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
c1
\repeat volta 2 {c4 d e f}
\alternative { {d2 d} {f f,} }
@end lilypond

In the following example, the first ending is not a complete
bar (it only had 3 beats).  The beginning of the second ending
contains the 4th beat from the first ending.  This @q{extra}
beat in the second ending is due to the first time ending,
and has nothing to do with the @code{\partial} at the
beginning of the example.

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
\new Staff {
  \partial 4
  \repeat volta 4 { e | c2 d2 | e2 f2 | }
  \alternative { { g4 g g } { a | a a a a | b2. } }
}
@end lilypond

@funindex \repeatTie

Ties may be added to a second ending,

@lilypond[quote,ragged-right,fragment,verbatim,relative=2]
c1
\repeat volta 2 {c4 d e f ~ }
\alternative { {f2 d} {f\repeatTie f,} }
@end lilypond

It is possible to shorten volta brackets
by setting @code{voltaSpannerDuration}.  In the next example, the
bracket only lasts one measure, which is a duration of 3/4.

@lilypond[verbatim,ragged-right,quote]
\relative c''{
  \time 3/4
  c c c
  \set Staff.voltaSpannerDuration = #(ly:make-moment 3 4)
  \repeat "volta" 5 { d d d }
  \alternative { { e e e f f f }
  { g g g } }
}
@end lilypond


@seealso

Examples:

Brackets for the repeat are normally only printed over the topmost
staff.  This can be adjusted by setting the @code{voltaOnThisStaff}
property; see

@lsr{repeats,volta@/-multi@/-staff@/.ly}.


@refbugs

@cindex repeat, ambiguous

A nested repeat like

@example
\repeat @dots{}
\repeat @dots{}
\alternative
@end example

@noindent
is ambiguous, since it is is not clear to which @code{\repeat} the
@code{\alternative} belongs.  This ambiguity is resolved by always
having the @code{\alternative} belong to the inner @code{\repeat}.
For clarity, it is advisable to use braces in such situations.

Timing information is not remembered at the start of an alternative,
so after a repeat timing information must be reset by hand; for
example, by setting @code{Score.measurePosition} or entering
@code{\partial}.  Similarly, slurs or ties are also not repeated.

Volta brackets are not vertically aligned.


@node Repeats and MIDI
@subsection Repeats and MIDI

@cindex expanding repeats
@funindex \unfoldRepeats

With a little bit of tweaking, all types of repeats can be present
in the MIDI output.  This is achieved by applying the
@code{\unfoldRepeats} music function.  This function changes all
repeats to unfold repeats.

@lilypond[quote,verbatim,fragment,line-width=8.0\cm]
\unfoldRepeats {
  \repeat tremolo 8 {c'32 e' }
  \repeat percent 2 { c''8 d'' }
  \repeat volta 2 {c'4 d' e' f'}
  \alternative {
    { g' a' a' g' }
    {f' e' d' c' }
  }
}
\bar "|."
@end lilypond

When creating a score file using @code{\unfoldRepeats} for MIDI,
it is necessary to make two @code{\score} blocks: one for MIDI (with
unfolded repeats) and one for notation (with volta, tremolo, and
percent repeats).  For example,

@example
\score @{
  @var{..music..}
  \layout @{ .. @}
@}
\score @{
  \unfoldRepeats @var{..music..}
  \midi @{ .. @}
@}
@end example


@node Manual repeat commands
@subsection Manual repeat commands

@funindex repeatCommands

The property @code{repeatCommands} can be used to control the layout of
repeats.  Its value is a Scheme list of repeat commands.

@table @asis
@item @code{start-repeat}
Print a @code{|:} bar line.

@item @code{end-repeat}
Print a @code{:|} bar line.

@item @code{(volta @var{text})}
Print a volta bracket saying @var{text}: The text can be specified as
a text string or as a markup text, see @ref{Text markup}.  Do not
forget to change the font, as the default number font does not contain
alphabetic characters;

@item @code{(volta #f)}
Stop a running volta bracket.
@end table

@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
c4
  \set Score.repeatCommands = #'((volta "93") end-repeat)
c4 c4
  \set Score.repeatCommands = #'((volta #f))
c4 c4
@end lilypond


@seealso

Program reference: @internalsref{VoltaBracket},
@internalsref{RepeatedMusic},
@internalsref{VoltaRepeatedMusic},
@internalsref{UnfoldedRepeatedMusic}, and
@internalsref{FoldedRepeatedMusic}.


@node Tremolo repeats
@subsection Tremolo repeats

@cindex tremolo beams

To place tremolo marks between notes, use @code{\repeat} with tremolo
style
@lilypond[quote,verbatim,ragged-right]
\new Voice \relative c' {
  \repeat "tremolo" 8 { c16 d16 }
  \repeat "tremolo" 4 { c16 d16 }
  \repeat "tremolo" 2 { c16 d16 }
}
@end lilypond

Tremolo marks can also be put on a single note.  In this case, the
note should not be surrounded by braces.
@lilypond[quote,verbatim,ragged-right]
\repeat "tremolo" 4 c'16
@end lilypond

Similar output is obtained using the tremolo subdivision, described in
@ref{Tremolo subdivisions}.


@seealso

In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.

Program reference: @internalsref{Beam}, @internalsref{StemTremolo}.


@node Tremolo subdivisions
@subsection Tremolo subdivisions

@cindex tremolo marks
@funindex tremoloFlags

Tremolo marks can be printed on a single note by adding
@q{@code{:}[@var{number}]} after the note.  The number indicates the
duration of the subdivision, and it must be at least 8.  A
@var{length} value of 8 gives one line across the note stem.  If the
length is omitted, the last value (stored in @code{tremoloFlags}) is
used

@lilypond[quote,ragged-right,verbatim,fragment]
c'2:8 c':32 | c': c': |
@end lilypond


@refbugs

Tremolos entered in this way do not carry over into the MIDI output.


@seealso

In this manual: @ref{Tremolo repeats}.

Elsewhere: @internalsref{StemTremolo}.


@node Measure repeats
@subsection Measure repeats

@cindex percent repeats
@cindex measure repeats

In the @code{percent} style, a note pattern can be repeated.  It is
printed once, and then the pattern is replaced with a special sign.
Patterns of one and two measures are replaced by percent-like signs,
patterns that divide the measure length are replaced by slashes.
Percent repeats must be declared within a @code{Voice} context.

@lilypond[quote,verbatim,ragged-right]
\new Voice \relative c' {
  \repeat "percent" 4 { c4 }
  \repeat "percent" 2 { c2 es2 f4 fis4 g4 c4 }
}
@end lilypond

Measure repeats of more than 2 measures get a counter, if you switch
on the @code{countPercentRepeats} property,

@lilypond[relative=2,fragment,quote,verbatim,ragged-right]
\new Voice {
\set countPercentRepeats = ##t
  \repeat "percent" 4 { c1 }
}
@end lilypond



Isolated percents can also be printed. This is done by putting a
multi-measure rest with a different print function,

@lilypond[fragment,verbatim,quote]
\override MultiMeasureRest #'stencil
  = #ly:multi-measure-rest::percent
R1
@end lilypond




@seealso

Program reference: @internalsref{RepeatSlash},
@internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
@internalsref{DoublePercentRepeatCounter},
@internalsref{PercentRepeatCounter},
@internalsref{PercentRepeatedMusic}.



