The <score>...</score> element in wikitext displays a musical score out of GNU LilyPond (the default) or ABC markup syntax. It also produces a MIDI file of the music and optionally displays an audio player that plays the music. It is implemented by the Score extension for MediaWiki, available across Wikipedia languages.
For LilyPond resources, see § External links. As of August 2021here. Note that LilyPond's full syntax is available when the extension is invoked with the wikitext <score raw="1">. A plain <score> invokes a simplified implementation that is not fully consistent with the LilyPond documentation.
add an audio player beneath the score image to play an automatically-generated Ogg Vorbis audio file
raw="1"
interpret the markup within the score tag as a complete LilyPond file, allowing more complex scores
midi="1"
obsolete This used to control whether the score image links to an automatically-generated MIDI file; clicking the score now always shows a JavaScript pop-up with a link to the MIDI file.
override_midi="…"
deprecated replace the automatically-generated MIDI file by the given one
override_audio="…"
deprecated replace the automatically-generated audio file by the given one
override_ogg="…"
deprecated alias for override_audio
vorbis="1"
deprecated alias for sound
If there is a MIDI file or audio file of superior quality to the MIDI or audio generated by the Score extension, you can provide a [[File::]] wikilink to it after the closing </score> tag.
<scoresound="1">\transposecg\relativec'{% display G for C, etc. and one octave higher\keyc\minor\time4/4c4e8eg4g% (text after the % is just a comment)<cesg>2<cesg>% angle brackets create chordses4d(cb)% parentheses create slursa4.r8r8a8~a4% r creates rests; ~ creates tiese--e->e-.g\fermata% accents and other signs\bar"|."}</score>
gives
Equivalent in ABC (pre-transposed due to differing semantics):
<scorelang="ABC">
K:Gm
M:4/4
L:1/4G=B/2B/2dd|% a comment[gbd']2[gbd']2|% square brackets create chords (not supported by abc2ly)b(ag^e)|% parentheses create slurs=e3/2z/2z/2c/2-c% z creates rests; – creates ties
!tenuto!=BLB.BHB% see standard section "Decorations" (not supported by abc2ly)|]</score>
To display a note, type the letter (a b c etc.) Separate each letter with a space. The bare note name refers to the natural note irrespective of key signature (see "setting the key" below).
These letters are as in English and Dutch, not as in German and many other continental languages (FYI: continental b means b flat and continental h means b – if you find that confusing, forget it).
Sharps and flats are formed by using the Dutch and German suffixes "is" and "es" respectively. To avoid "ees", the note E♭ is simply written as es. The simple accidentals are thus ais bis cis dis eis fis gis for the sharps and aes bes ces des es fes ges for the flats. English language editors may prefer to include the line \language "english" in the script, after which s for sharp and f for flat can be used: as bs cs ds es fs gs and af bf cf df ef ff gf. Double sharps are formed with the suffix isis and double flats with eses, or in English notation with ss or x and ff. Semi-sharps, -flats and sesqui-sharps and -flats are also supported in both English and German. See: #Accidentals.
By default, each note name refers to the note below middle C. For example, a would be displayed as
.
Use the apostrophe (') to go up an octave and a comma (,) to go an octave down. Middle C would be c'
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 the one mentioned after the \relative tag. ("Closest" ignores sharps and flats.) Use ' to go up an extra octave and , to go down.
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 Gb major:
<scorelang="lilypond"sound="1">\relativec'{\keyges\major\time6/8% Notes with -es suffixes indicating flatsdes8esgesaesbesces% Notes without accidentals (naturals)bcdega}</score>
Accidentals may be indicated by following the note name with the appropriate text:
♭
♮
♯
De
eses
eseh
es
eh
!
ih
is
isih
isis
En
ff
tqf
f
qf
qs
s
tqs
ss or x
Note that E♭ is "es" alone, rather than "ees". "q" and "tq" refer to "quarter" and "three-quarter" (rather than "hf" for "half flat" and "thf" for "three-half flat"), as in "quarter tone". However, the "quarter flat/sharp" is not a quarter of a flat/sharp, but instead half of a flat/sharp, and the "three-quarter flat/sharp" is 1.5 flats not 0.75 flats. Notes outside of the quarter-tone scale are not supported.
If, for some reason, a piece needs to be transposed to a different key, it is possible to do so without having to transcribe it manually. This also affects the key signature. The syntax for this is:
MIDI output can be transpositioned with the \transposition <pitch> command. The French horn (in C) motif from the opening of Schubert's last symphony, transpositioned one octave down:
The \transposition command is mainly intended for scores that involve transposing instruments not set in concert pitch.
<scoresound="1">\newGrandStaff<<\newStaff="violin"\with{instrumentName="Vln"midiInstrument="violin"}\relativec''{% not strictly necessary, but a good reminder\transpositionc'\keyc\majorg4(c8)rcrc4}\newStaff="clarinet"\with{instrumentName=\markup{Cl(B\flat)}midiInstrument="clarinet"}\relativec''{\transpositionbes\keyd\majora4(d8)rdrd4}>></score>
Note duration is indicated by a number following the pitch with no space between (a4 b8). Use the number 1 for a whole note (semibreve), 2 for a half note (minim), 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.).
Tuplets are indicated using the \times command, for example \times 2/3 {c8 c c} gives a triplet of three eight-notes (quavers).
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.
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.
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.
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.
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.
<scoreraw="1"lang="lilypond">\header{tagline=""% no footertitle="Good Morning"composer="trad."}\relativeg'{\keyg\major\time3/4\partial4dedgfis2d4eda'g2d4d'bgfisec'bgag2\fermata\bar"|."}\addlyrics{Goodmor--ningtoyou,Goodmor--ningtoyou,Goodmor--ningdearchil--dren,Goodmor--ningtoall.}</score>
Chord names can be added as a separate ChordNames staff as follows:
<scorelang="lilypond"sound="1"><<\newChordNames\chordmode{\setchordChanges=##t% Only display chord when there is a change (e.g., don't repeat the Am here)a4:ma4:m|% measure 1 – A7 would be a:7g2|% measure 2}\newStaff\relativec''{\keya\dorian\time2/4a8a16aa8a16a|% measure 1b8ag4|% measure 2}>></score>
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
whereas the s will result in correct spacing, but no chord name notation will appear.
MIDI instrument sounds can be assigned with \set Staff.midiInstrument = #"instrument" as documented in section A6 of LilyPond's Notation Reference. Trial and error may be necessary: some instruments may not work unless the # is omitted, and some may not work with or without the #.
<scoresound="1">\relativec''{\setStaff.midiInstrument=#"bassoon"\cleftreble\numericTimeSignature\time4/4\tempo"Lento"4=50\stemDownc4\fermata(_"solo ad lib."\grace{b16[(c]}bgeb'\times2/3{a8)\fermata}}</score>
To indicate a repeated section, prefix it with \repeat volta 2. The MIDI and audio will only play once unless you add \unfoldRepeats, which will also "unfold" the score. To avoid this you must duplicate the score, once for layout and once for MIDI, for example:
Markup
<scoreraw="1"sound="1">\header{tagline=""}\score{\relativec'\repeatvolta2{cdef}\layout{}}\score{% "unfold" this score copy so MIDI plays the repeated section twice\unfoldRepeats{\relativec'\repeatvolta2{cdef}}\midi{}}</score>
Individual staff sizes can be changed with \with{ \magnifyStaff #nn } . Using \with{ \magnifyStaff #2/3 } after each instance of \new Staff, the example above renders as:
{{Image frame}} may also be used to group score images together. The text below creates the group of images to the right:
{{Image frame|content=<score>{\omitScore.TimeSignature\relativec'{\cleftreble\time4/4e4^\markup{Enharmonicgenus}fehgesesabcehdesese}}</score><score>{\omitScore.TimeSignature\relativec'{\cleftreble\time4/4e4^\markup{Chromaticgenus}fgesabcdese}}</score><score>{\omitScore.TimeSignature\relativec'{\cleftreble\time4/4e4^\markup{Diatonicgenus}fgabcde}}</score>|width=300|caption=The three genera of the Dorian [[octave species]] on E}}