Help:Score: Difference between revisions

Content deleted Content added
lang="lilypond" or "xml"
Hatnote
 
(20 intermediate revisions by 14 users not shown)
Line 1:
{{Wikipedia how-to|H:SCORE}}
{{redirect|WP:SCORE|information about how to format the score results of competitions|Wikipedia:Manual of Style/Dates and numbers#Numbers as figures or words}}
The {{tag|score}} element in wikitext displays a musical score out of GNU [[LilyPond]] (the default) or [[ABC notation|ABC]] markup syntax. It also produces a [[Help:Media (MIDI)|MIDI file]] of the music and optionally displays an audio player that plays the music. It is implemented by the [[mw:Extension:Score|Score extension]] for [[MediaWiki]], available across Wikipedia languages.
 
For details on the LilyPond syntaxresources, see its{{sectionlink||External [http://www.lilypond.org/manuals.html notation documentation]. A complete manual is [https://lilypond.org/doc/v2.22/Documentation/notation-big-page.html here in HTML] and [https://lilypond.org/doc/v2.22/Documentation/notation.pdf here as PDF]; a set of LilyPond code snippets is available [https://lilypond.org/snippets.html here]links}}. {{As of|2021|08}}, the extension on Wikipedia is using LilyPond v2.22.0 (check [[Special:Version]] for the current version). Changes to LilyPond since version 2.18 are documented [https://lilypond.org/doc/v2.20/Documentation/changes/ here]. Note that LilyPond's full syntax is available when the extension is invoked with the wikitext {{tag|score|open|attribs='''raw="1"'''}}. A plain {{tag|score|open}} invokes a simplified implementation that is not fully consistent with the LilyPond documentation..
 
== Element attributes ==
Line 50 ⟶ 51:
=== More elaborate ===
 
<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
\transpose c g \relative c' { % display G for C, etc. and one octave higher
Line 89 ⟶ 90:
[gbd']2 [gbd']2 | % square brackets create chords (not supported by abc2ly)
b (ag^e) | % parentheses create slurs
=e3/2 z/2 z/2 c/2-c % z creates rests; - creates ties
!tenuto!=B LB .B HB % see standard section "Decorations" (not supported by abc2ly)
|]
Line 102 ⟶ 103:
=== Pitch ===
To display a note, type the letter (<code>a b c</code> 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{{Music|flat}} is simply written as <code>es</code>. The simple [[Accidental (music)|accidental]]s are thus <code>ais bis cis dis eis fis gis</code> for the sharps and <code>aes bes ces des es fes ges</code> for the flats. English language editors may prefer to include the line <code>\language "english"</code> in the script, after which <code>s</code> for sharp and <code>f</code> for flat can be used: <code>as bs cs ds es fs gs</code> and <code>af bf cf df ef ff gf</code>. Double sharps are formed with the suffix <code>isis</code> and double flats with <code>eses</code>, or in English notation with <code>ss</code> or <code>x</code> and <code>ff</code>. 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, '''<code>ca</code>''' would be displayed as <score>\new Staff \with { \remove "Time_signature_engraver" }{ca}</score> or <score>\new Staff \with { \remove "Time_signature_engraver" }{\clef bass ca}</score>.
 
Use the apostrophe (<code>'</code>) to go up an octave and a comma (<code>,</code>) to go an octave down. Middle C would be '''<code>c'</code>''' <score>\new Staff \with { \remove "Time_signature_engraver" }{ c'}</score>.
 
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
{
a,, c, e, a, c e a c' % Middle C
Line 124 ⟶ 125:
</syntaxhighlight>
 
<score lang="lilypond" vorbissound="1">
{
a,, c, e, a, c e a c' %Middle C
Line 138 ⟶ 139:
A much easier way is to use relative coding. If you include <code>\relative</code> 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 <code>\relative</code> tag. ("Closest" ignores sharps and flats.) Use <code>'</code> to go up an extra octave and <code>,</code> to go down.
 
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
\relative c' {
e f <c e g>2
Line 151 ⟶ 152:
</syntaxhighlight>
 
<score lang="lilypond" vorbissound="1">
\relative c' {
e f <c e g>2
Line 166 ⟶ 167:
By default there is no key signature (no sharps or flats). You can indicate the key with <code>\key g \major</code>, <code>\key c \minor</code>, or even a [[mode (music)|mode]] such as <code>\key c \[[Dorian mode|dorian]]</code> or <code>\key c \[[Mixolydian mode|mixolydian]]</code>. 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#Gb major:
 
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
\relative c' {
\key cisges \major
\time 6/8
 
% Notes with -ises suffixes indicating sharpsflats
cis8des8 dises eisges fisaes gisbes aisces
 
% Notes without accidentals (naturals)
b c d e f g a
}
</score>
</syntaxhighlight>
<score lang="lilypond" vorbissound="1">
\relative c' {
\key cisges \major
\time 6/8
 
% Notes with -ises suffixes indicating sharpsflats
cis8 dis eis fis gis ais
des8 es ges aes bes ces
 
% Notes without accidentals (naturals)
b c d e f g a
}
</score>
Line 235 ⟶ 238:
 
'''German:'''
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1"> {
 
\overrideomit Score.TimeSignature
#'stencil = ##f
\relative c'' {
\time 4/4
Line 248 ⟶ 250:
 
'''English:'''
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1"> {
 
\overrideomit Score.TimeSignature
#'stencil = ##f
\relative c'' {
\time 4/4
Line 262 ⟶ 263:
 
'''Both result in:'''
<score lang="lilypond" vorbissound="1"> {
 
\overrideomit Score.TimeSignature
#'stencil = ##f
\relative c'' {
\time 4/4
Line 275:
==== Transpose and transposition ====
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:
<syntaxhighlight lang="LilyPondlilypond">
\transpose frompitch topitch musicexpr
</syntaxhighlight>
For example:
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">\transpose c es {
\relative c' {
\key c \major \time 4/4
Line 289:
</syntaxhighlight>
Results in:
<score lang="lilypond" vorbissound="1">\transpose c es {
\relative c' {
\key c \major \time 4/4
Line 298:
 
MIDI output can be transpositioned with the <code>\transposition <pitch></code> command. The French horn (in C) motif from the opening of Schubert's [[Symphony No. 9 (Schubert)|last symphony]], transpositioned one octave down:
<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
\relative c' { \set Staff.midiInstrument = #"french horn"
Line 324:
}
</score>
The <code>\transposition</code> command is mainly intended for scores that incolveinvolve transposing instruments not set in concert pitch.
<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
\new GrandStaff <<
Line 375:
 
=== Rhythm ===
Note duration is indicated by a number following the pitch with no space between (<code>a4 b8</code>). Use the number 1 for a whole note (brevesemibreve), 2 for a half note (semibreveminim), 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 <code>r</code> instead of a pitch. Dotted notes are formed simply by following the duration number with a period (<code>c4.</code>).
 
[[Tuplet]]s are indicated using the <code>\times</code> command, for example <code>\times 2/3 {c8 c c}</code> gives a triplet of three eight-notes (quavers).
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
\relative c''{b1 b2 b4 b8 c r4 b4. r8 \times 2/3 {a8 g f}}
</score>
</syntaxhighlight>
 
<score lang="lilypond" vorbissound="1">
\relative c''{b1 b2 b4 b8 c r4 b4. r8 \times 2/3 {a8 g f}}
</score>
Line 396:
For some music examples, removing the time signature may be desirable; the code <code>\remove "Time_signature_engraver"</code> can be used in that case:
 
<syntaxhighlight lang="LilyPondlilypond">
<score>
{
Line 420:
The software occasionally combines beamed notes in places that are not desired or look awkward. To override the automatic beams, use <code>\noBeam</code> between the notes that would otherwise be beamed: <code>g a b \noBeam g</code>. To turn off beaming for many notes, use <code>\autoBeamOff</code> and then <code>\autoBeamOn</code>.
 
<syntaxhighlight lang="LilyPondlilypond">
<score>
\relative c'' {
Line 443:
You can add lyrics to the score using <code>\addlyrics</code>. See the [http://www.lilypond.org/doc/v2.22/Documentation/learning/aligning-lyrics-to-a-melody LilyPond Manual] for more information about how to align the lyrics to the score.
 
<syntaxhighlight lang="LilyPondlilypond">
<score raw="1" lang="lilypond">
\header {
Line 502:
Chord names can be added as a separate ChordNames staff as follows:
 
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
<<
\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
}
Line 520:
</syntaxhighlight>
 
<score lang="lilypond" vorbissound="1">
<<
\new ChordNames \chordmode {
Line 535:
>>
</score>
 
Note:
 
The letter '''<code>s</code>''' can be used in the ChordNames staff in place of '''<code>r</code>''' (the code for a rest) when there is no chord.
 
An '''<code>r</code>''' will result in an explicit "No Chord" notation <score><<\new ChordNames \chordmode {r2} \new Staff \with { \remove "Time_signature_engraver" } \relative c''{c}>></score>, whereas the '''<code>s</code>''' will result in correct spacing, but no chord name notation will appear.
 
=== Adding whitespace ===
 
The letter '''<code>s</code>''' followed by a note duration adds an appropriate amount of whitespace:
 
{|
! With <code>s4</code> and <code>s1</code> || rowspan="2"|&nbsp;|| Without whitespace
|-
!<score>
\new GrandStaff <<
\time 5/4
\new Staff \with { \remove "Time_signature_engraver" \magnifyStaff 1.5 } { s4 c'1 }
\new Staff \with { \remove "Time_signature_engraver" \magnifyStaff 1.5 \clef bass } { s4 s1 } >>
</score>
!<score>
\new GrandStaff <<
\new Staff \with { \remove "Time_signature_engraver" \magnifyStaff 1.5 } { c'1 }
\new Staff \with { \remove "Time_signature_engraver" \magnifyStaff 1.5 \clef bass } { } >>
</score>
|-
! colspan="3"|Middle C centrally placed on a grand staff
|}
 
=== Accents and other symbols ===
There are a number of symbols to attach to notes, such as <code>\fermata-^</code>. There are also <code>{e-> f-- g-+ a-. b-^\fermata c-_ d-!}</code>
 
<syntaxhighlight lang="LilyPondlilypond">
<score>
\relative c' {
e-> f-- g-+ a-.
b-^\fermata c-_ d-! e\fermata-^
}
</score>
Line 558 ⟶ 578:
\relative c' {
e-> f-- g-+ a-.
b-^\fermata c-_ d-! e\fermata-^
}
</score>
 
===Color===
<syntaxhighlight lang="LilyPondlilypond">
<score lang="lilypond" vorbissound="1">
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble
Line 575 ⟶ 595:
</syntaxhighlight>
produces
<score lang="lilypond" vorbissound="1">
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble
Line 589 ⟶ 609:
*The sound of each midi-instrument supported by LilyPond can be heard at [[v:Music/Software/Lilypond/MIDI]]
{{markupv|title=From ''[[The Rite of Spring]]''
|markup=<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
\relative c'' { \set Staff.midiInstrument = #"bassoon" \clef treble \numericTimeSignature \time 4/4 \tempo "Lento" 4 = 50 \stemDown c4\fermata(_"solo ad lib." \grace { b16[( c] } b g e b' \times 2/3 { a8)\fermata } }
Line 597 ⟶ 617:
}}
{{markupv
|markup=<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
{ \new PianoStaff << \new Staff \relative c'' { \set Staff.midiInstrument = #"violin" \clef treble \tempo 8 = 126 \time 3/16 r16 <d c a fis d>\f-! r16\fermata | \time 2/16 r <d c a fis d>-! \time 3/16 r <d c a fis d>8-! | r16 <d c a fis d>8-! | \time 2/8 <d c a fis>16-! <e c bes g>->-![ <cis b aes f>-! <c a fis ees>-!] } \new Staff \relative c { \set Staff.midiInstrument = #"violin" \clef bass \time 3/16 d,16-! <bes'' ees,>-! r\fermata | \time 2/16 <d,, d,>-! <bes'' ees,>-! | \time 3/16 d16-! <ees cis>8-! | r16 <ees cis>8-! | \time 2/8 d16\sf-! <ees cis>-!->[ <d c>-! <d c>-!] } >> }
</score>
</syntaxhighlight>
|renders= {{:The Rite of Spring|sacrificialdancescore}}
|renders=<score sound="1"> { \new PianoStaff << \new Staff \relative c'' { \set Staff.midiInstrument = #"violin" \clef treble \tempo 8 = 126 \time 3/16 r16 <d c a fis d>\f-! r16\fermata | \time 2/16 r <d c a fis d>-! \time 3/16 r <d c a fis d>8-! | r16 <d c a fis d>8-! | \time 2/8 <d c a fis>16-! <e c bes g>->-![ <cis b aes f>-! <c a fis ees>-!] } \new Staff \relative c { \set Staff.midiInstrument = #"violin" \clef bass \time 3/16 d,16-! <bes'' ees,>-! r\fermata | \time 2/16 <d,, d,>-! <bes'' ees,>-! | \time 3/16 d16-! <ees cis>8-! | r16 <ees cis>8-! | \time 2/8 d16\sf-! <ees cis>-!->[ <d c>-! <d c>-!] } >> } </score>
}}
 
Line 608 ⟶ 628:
To indicate a repeated section, prefix it with <code>\repeat volta 2</code>. The MIDI and audio will only play once unless you add <code>\unfoldRepeats</code>, which will also "unfold" the score. To avoid this you must duplicate the score, once for layout and once for MIDI, for example:
{{markupv
|markup=<syntaxhighlight lang="LilyPondlilypond">
<score raw="1" sound="1">
\header { tagline = "" }
Line 641 ⟶ 661:
Metronome marks, as shown above, may be hidden with <code>\set Score.tempoHideNote = ##t</code>.
{{markupv|title=From ''[[St Matthew Passion]]''
|markup=<syntaxhighlight lang="LilyPondlilypond">
<score sound="1">
{ \new ChoirStaff <<
Line 672 ⟶ 692:
</score>
For more intricate details, see [http://lilypond.org/doc/v2.22/Documentation/notation/setting-the-staff-size "Setting the staff size"] in the LilyPond manual.
 
===Overall size===
A simpler method to change the overall size of a score is to use the [[CSS]] property <code>zoom</code>. Using <code><nowiki><div style="zoom: 70%;"></nowiki></code>, the above example renders as:
<div style="zoom: 70%;"><score sound>
{ \new ChoirStaff <<
\new Staff <<
\new Voice \relative c'' { \set Score.tempoHideNote = ##t \tempo 8 = 120 \stemUp \clef treble \key fis \minor \time 3/8 s4. | <gis' dis>8^.^( <gis dis>^. <gis dis>^.) | s4. | <fis cis>8^.^( <fis cis>^. <fis cis>^.) | s4. | fis16^( eis dis cis) <b' gis>8^. | <a fis>^. r r | s4 }
\new Voice \relative c'' { \stemDown cis8[ d] cis | bis4. | b!32_([ cis d16 cis8)] b | ais4. | b8 a![_( gis)] | a fis[_( eis)] | fis \grace { e(} d4) | cis } \addlyrics { Buß - und Reu,– Buß4 und8 Reu– knirscht das Sün- den- herz ent- zwei }
\new Staff \relative c { \clef bass \key fis \minor \time 3/8 fis4.~_"Bar 13" | fis8 gis16( fis eis dis) | eis4. | e!8 fis16( e d cis) | d8( cis b) | cis4.~ | cis8 b16( a gis fis) | eis ^"173 bars"}
>> >> }
</score></div>
 
==Image frame==
Line 687 ⟶ 718:
 
For example:
:<syntaxhighlight lang="xmlwikitext">{{Image frame
|content = <score>
\relative c' {
Line 701 ⟶ 732:
{{Image frame|content=<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 711 ⟶ 742:
<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 721 ⟶ 752:
<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 729 ⟶ 760:
 
{{tl|Image frame}} may also be used to group score images together. The text below creates the group of images to the right:
<syntaxhighlight lang="xmlwikitext">
{{Image frame|content=<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 742 ⟶ 773:
<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 752 ⟶ 783:
<score>
{
\overrideomit Score.TimeSignature #'stencil = ##f
\relative c' {
\clef treble \time 4/4
Line 761 ⟶ 792:
 
== See also ==
{{wikisourcehasWikisource-multi|caption=[[Wikisource]] has complementary help pages at|[[s:Help:Sheet music|Help:Sheet music]]LilyPond}}
* [[Wikipedia:Lyrics and poetry]]
* [[Special:PagesWithProp/score]], pages where {{Tag|score}} is used, or [[:Category:Pages using the Score extension]]
Line 770 ⟶ 801:
* [[s:de:Benutzer:Sinuhe20/Spielwiese|Sinuhe20/Spielwiese]] presents dozens of helpful examples, even for those who cannot read the German headings.
* A collection demonstrating some advanced features of LilyPond are at [[User:Michael Bednarek/LilyPond]].
* The German Tutorial [[Wikiversity:de:Kurs:Lilypond für Wikis]] waiting to be translated into English.
**[https://de-m-wikiversity-org.translate.goog/wiki/Kurs:Lilypond_f%C3%BCr_Wikis?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp Translated by Google]
 
== External links ==
* [http://www.lilypond.org/manuals.html LilyPond notation documentation]
* [https://lilypond.org/doc/v2.22/Documentation/notation-big-page.html Complete LilyPond v2.22.0 manual] – [https://lilypond.org/doc/v2.22/Documentation/notation.pdf (in PDF)].
* [https://lilypond.org/snippets.html LilyPond code snippets]
 
== References ==