Help:Score

From Wikipedia, the free encyclopedia
Jump to: navigation, search

The <score>...</score> element produces musical notation using the Lilypond (default) or ABC markup syntax; see Extension:Score.

For details on the Lilypond syntax, see its notation documentation. Pages with errors are shown in Category:Pages with score rendering errors.

Examples[edit]

Simple

<score>
{c' d' e' f' f' fes' eis' e'}
</score>

gives 
{c' d' e' f' f' fes' eis' e'}


More elaborate

<score>
  \relative c' {
  \key c \minor
  \time 4/4
    c4 e8 e g4 g          % (text after the % is just a comment)
    <c es g>2 <c es g>    % angle brackets create chords
    es4 d( ces b)         % parentheses create ties
    a4. r8 a4 a           % r creates rests
    e-- e-> e-. g\fermata % accents and other signs
    \bar "|."
  }
</score>

gives


  \relative c'{
  \key c \minor
  \time 4/4
    c4 e8 e g4 g          % (text after the % is just a comment)
    <c es g>2 <c es g>    % angle brackets create chords
    es4 d( ces b)         % parentheses create ties
    a4. r8 a4 a           % r creates rests
    e-- e-> e-. g\fermata % accents and other signs
    \bar "|."
  }
% This is just a comment line

Syntax[edit]

The score section must be surrounded by <score>...</score>. The notes must be within a set of curly braces {...}.

Comments in the markup start with a percentage sign % and end at the end of the line.

Pitch[edit]

To display a note, type the letter (a b c etc.) Separate each letter with a space.
Sharps are formed with the suffix -is (ais bis cis dis eis fis gis).
Flats are formed with the suffix -es (aes bes ces des es fes ges).

By default, each note name refers to the note below middle C. For example, c would be displayed as \new Staff \with { \remove "Time_signature_engraver" }{c} or \new Staff \with { \remove "Time_signature_engraver" }{\clef bass c}.

Use the apostrophe (') to go up an octave and a comma (,) to go an octave down. Middle C would be c' \new Staff \with { \remove "Time_signature_engraver" }{ c'}.

 <score>
  {
   a,, c, e, a,
   c e a c'
   e' a' c'' e''
   a'' c''' e''' g'''
   \bar "||"
   aes'' bes'' gis'' dis''
  }
 </score>


 {a,, c, e, a, c e a c' %Middle C
  e' a' c'' e'' a'' c''' e''' g''' \bar "||" aes'' bes'' gis'' dis''}

A much easier way is to use relative coding. If you include \relative before the braces, each note will refer to the note closest to the previous one, and the first one will refer to the note closest to one mentioned after the \relative tag. ("Closest" ignores sharps and flats.) Use ' to go up an extra octave and , to go down.

 <score>
 \relative c' {
  e f <c e g>2
  a'4( b c) c,
  d8 e f16 g a b
  c4. a8 e' f g, f r \autoBeamOff e d c
  b4 a g b-> c2.-> r4
  \bar "|."
  }
 </score>


 \relative c' {
  e f <c e g>2
  a'4( b c) c,
  d8 e f16 g a b
  c4. a8 e' f g, f r \autoBeamOff e d c
  b4 a g b-> c2.-> r4
  \bar "|."
  }

Setting the Key[edit]

By default there is no key signature (no sharps or flats). You can indicate the key with \key g \major, \key c \minor, or even a mode such as \key c \dorian or \key c \mixolydian. The key can be changed at any point.

Keep in mind that even with a key signature, you must still include sharps (-is) and flats (-es) for each individual note name. If you omit one, it will be considered a natural. For example, this is the key of C# major:

<score>
 \relative c' {
   \key cis \major
   \time 6/8

% Notes with -is suffixes indicating sharps
   cis8 dis eis fis gis ais

% Notes without accidentals (naturals)
   b c d e f g
  }
</score>


 \relative c' {
   \key cis \major
   \time 6/8
% Notes with -is suffixes indicating sharps
   cis8 dis eis fis gis ais
% Notes without accidentals (naturals)
   b c d e f g
  }

Rhythm[edit]

Note duration is indicated by a number following the pitch with no space between (a4 b8). Use the number 1 for a whole note, 2 for a half note, 4 for a quarter note (crotchet), 8 for an eighth note (quaver), and so on. If a note does not have an explicit duration, it will either default to a quarter note or use the duration of the note preceding it.

Rests are indicated by using the letter r instead of a pitch. Dotted notes are formed simply by following the duration number with a period (c4.).

 <score>
   \relative c''{b1 b2 b4 b8 c r4 b4. b}
 </score>


\relative c''{b1 b2 b4 b8 c r4 b4. b}

Setting The Time Signature[edit]

The default time signature is 4/4. To set another time signature, one may use the \time command. For example to set the time signature to cut-time one would use \time 2/2 and waltz time would be \time 3/4. The time signature may be changed at almost any point.


Removing The Time Signature[edit]

For some music examples, removing the time signature may be desirable; the code \remove "Time_signature_engraver" can be used in that case:

<score>
{
  \new Staff \with { \remove "Time_signature_engraver" }
  <d' fis' a'>2
}
</score>

{ \new Staff \with { \remove "Time_signature_engraver" } <d' fis' a'>2 }

Pick Up Measure[edit]

The code \partial 4 will create a pickup measure (anacrusis) of one quarter note, \partial 4*2 would create a pickup measure of two quarter notes, etc. See an example in the Adding Lyrics section of this article.

Customizing Beams[edit]


\relative c'' {
   \time 3/4
   r4. g8 a8 b8
}

The software occasionally combines beamed notes in places that are not desired or look awkward. To override the automatic beams, use \noBeam between the notes that would otherwise be beamed: g a b \noBeam g. To turn off beaming for many notes, use \autoBeamOff and then \autoBeamOn.

<score>
  \relative c'' {
     \time 3/4
     r4. g8 \noBeam a8 b8
  }
</score>


\relative c'' {
   \time 3/4
   r4. g8 \noBeam a8 b8
}


To manually beam notes, use square brackets inserting the first one after the first note to be beamed: a8 b[ c d e] f. This would beam the notes b, c, d, and e, but leave the first and last notes without beams.

 \relative c''{a8 b[ c d e] f}

Adding lyrics[edit]

You can add lyrics to the score using \addlyrics. See the LilyPond Manual for more information about how to align the lyrics to the score.

<score>
  \relative g' {
    \key g \major \time 3/4
    \partial 4 d
     e d g
     fis2 d4
     e d a'
     g2 d4
     d' b g
     fis e c'
     b g a
     g2 \fermata
     \bar "|."
   }
   \addlyrics {
     Good mor -- ning to you,
     Good mor -- ning to you,
     Good mor -- ning dear chil -- dren,
     Good mor -- ning to all.
   }
  </score>


  \relative g' {
    \key g \major \time 3/4
    \partial 4 d
     e d g
     fis2 d4
     e d a'
     g2 d4
     d' b g
     fis e c'
     b g a
     g2 \fermata
     \bar "|."
   }
   \addlyrics {
     Good mor -- ning to you,
     Good mor -- ning to you,
     Good mor -- ning dear chil -- dren,
     Good mor -- ning to all.
   }

Adding chord names[edit]

Chord names can be added as a separate ChordNames staff as follows:

<score>
<<
  \new ChordNames \chordmode {
    \set chordChanges = ##t % Only display chord when there is a change (e.g., don't repeat the Am here)
    a4:m a4:m         |% measure 1 - A7 would be a:7
    g2                |% measure 2
  }
  \new Staff \relative c''{
    \key a \dorian
    \time 2/4
    a8 a16 a a8 a16 a |% measure 1
    b8 a g4           |% measure 2
  }
>>
</score>


<<
\new ChordNames \chordmode {
  \set chordChanges = ##t
  a4:m a4:m         |% measure 1
  g2                |% measure 2
}
\new Staff \relative c''{
  \key a \dorian
  \time 2/4
  a8 a16 a a8 a16 a |% measure 1
  b8 a g4           |% measure 2
}
>>

Note:

The letter s can be used in the ChordNames staff in place of r (the code for a rest) when there is no chord.

An r will result in an explicit "No Chord" notation <<\new ChordNames \chordmode {r2} \new Staff \with { \remove "Time_signature_engraver" } \relative c''{c}>>, whereas the s will result in correct spacing, but no chord name notation will appear.

Accents and Other Symbols[edit]

There are a number of symbols to attach to notes, such as \fermata. There are also {e-> f-- g-+ a-. b-^ c-_ d-|}

<score>
  \relative c' {
  e-> f-- g-+ a-.
  b-^ c-_ d-| e\fermata
  }
</score> 

producing


  \relative c' {
  e-> f-- g-+ a-.
  b-^ c-_ d-| e\fermata
  }
.

See also[edit]