Help:Sheet music

From Wikisource
Jump to navigation Jump to search
Sheet music

Shortcut:
H:SM

The Score extension is now deployed on Wikisource! It renders musical scores from notation in LilyPond and ABC format, and can generate a preview as a MIDI or an Ogg Vorbis audio file.

Overview

[edit]

The Score extension renders musical notation and optionally generates audio and MIDI previews.

Here's a mindlessly simple LilyPond input file, using syntax for LilyPond 2.4.:

<score sound="1">{ a b c d }</score>

When run through LilyPond, it renders the musical notation, e.g. as PostScript, or on a wiki page using the Score extension:

{ a b c d }

The generated MIDI files leave out many expressive effects, making them unsuitable to demonstrate nuances of music (notation).

A more complicated piece, again written in LilyPond notation, looks like this:

<score sound="1">
	 \relative c' { 
		e16-.->a(b gis)a-.->c(d b)c-.->e(f dis)e-.->a(b a)
		gis(b e)e,(gis b)b,(e gis)gis,(b e)e,(gis? b e)
	}
</score>

and it outputs as this:


	 \relative c' { 
		e16-.->a(b gis)a-.->c(d b)c-.->e(f dis)e-.->a(b a)
		gis(b e)e,(gis b)b,(e gis)gis,(b e)e,(gis? b e)
	}

Transcribing music

[edit]

You do not need to be able to write music yourself to be able to transcribe music from existing, published sources. Reading basic musical notation is not that difficult and once you know what the symbols mean it is usually easy to write out the appropriate code in either LilyPond or ABC.

Each note is made of one to three parts:

The parts of a musical note: note head, stem and flag. The note head is a circular dot, the stem is a vertical line connected to the head at one side and the flag is a short diagonal mark at the opposite end of the stem to the note head.
The parts of a musical note: note head, stem and flag. The note head is a circular dot, the stem is a vertical line connected to the head at one side and the flag is a short diagonal mark at the opposite end of the stem to the note head.
  1. Note head: All notes have a note head, a circular mark like a dot. Notes heads show the pitch of the note.
  2. Stem: Most notes have stems, they are the vertical lines connected to the notes head(s). Multiple note heads on one stem are a "chord".
  3. Flag: Some notes have flags, short diagonal "tails" at the end of the stem opposite to the note head. Flags show the duration of a note. Two or more notes with flags next to each other are often connected together; these connections are called "beams".

Notes are written in "bars" on a "stave" (or "staff"). A stave starts with a "clef" and will usually have five lines. A bar is a section of the stave, representing a period of time, marked by vertical lines called "bar lines".

Knowing the pitch and duration of notes is important. The pitch is shown by the vertical position of the note head. Each line and each space is a different pitch. Pitches are represented by the first seven letters of the alphabet (A, B, C, D, E, F and G), the next pitch after G is A again and the pattern repeats.

Simple guide to musical notes in sheet music: treble and bass clefs shown with names of the notes.
Simple guide to musical notes in sheet music: treble and bass clefs shown with names of the notes.

On staves with a treble clef (the first example in the diagram), the bottom line is E. The space above is F and the line above that is G; and so on until the top line, which is F. Common mnemonics that can help you to remember these are "Every Good Boy Deserves Favours" (for the pitches on the lines) and "FACE in the space" (for the pitches on the spaces between lines).

On staves with a bass clef (the second example in the diagram), the pitches are two lower than with a treble clef. The bottom line is G and the top line is A. Mnemonics that can help you to remember these are "Good Boys Deserve Favours Always" (for the pitches on the lines) and "Any Cow Eats Grass" (for the pitches on the spaces).

The duration of the note is shown by its appearance.

Basic music note values
Note Rest Description American name British name Traditional value LilyPond duration ABC length
Hollow head, no stem Whole note Semibreve 4 1 1
Hollow head, stem Half note Minim 2 2 1/2
or Full head, stem, no flags Quarter note Crotchet 1 4 1/4
One flag Eighth note Quaver 1/2 8 1/8
Two flags Sixteenth note Semiquaver 1/4 16 1/16
Three flags Thirty-second note Demisemiquaver 1/8 32 1/32
For more information, see Note value on Wikipedia.

For more complicated symbols, please refer to List of musical symbols on Wikipedia and the Wikisource help page Help:List of musical symbols.

It may also help to read parts of Music Theory on Wikibooks, especially the page "How to read Music".

General notes on writing with Score

[edit]

Score ignores excess white space, which can be useful when writing music just as it is with writing computer code. The following is perfectly functional code:

<score>\relative c { b c d e f e b c b c d e }</score>

However, with long pieces, it can be hard to read for anyone attempting to edit it (even for the original user). Pipes can be entered to indicate separate bars, for example:

<score>\relative c { b c d e | f e b c | b c d e }</score>

This is a little better because a user who has noticed a mistake in the third bar can more easily find the code the corresponds to that bar.

To make it even clearer, white space (including line feeds/carriage returns) can be used to break up the code into easily legible sections. For example:

<score>
  \relative c {
    b c d e
    f e b c
    b c d e
  }
</score>

Indenting sections helps show where sections begin and end, and what those sections contain.

Maintenance templates

[edit]
Missing score

Pages with missing scores can be tagged with the {{missing score}} maintenance template. This will add the page to the Texts with missing musical scores‎ tracking category.

LilyPond

[edit]
See also: Help:LilyPond

Basic LilyPond notation

[edit]

All notations must open and close with the score tags, e.g. <score>...</score>

When writing in LilyPond, "commands" start with a backslash and "expressions" are containing in curly brackets. All notations must be contained in a single musical expression. A command followed by an expression counts as a single musical expression.

For example, \relative c and \time 6/8 are commands; \relative c { ... } is a musical expression.

"Relative mode" is the simplest way to write in LilyPond notation. In this mode notes are assumed to be the closest pitch to the previous note. Absolute notes can be entered instead. The command \relative c will start in Bass C (C3, small octave).

The code so far, using relative mode and Bass C but no notes as yet, will appear as:

<score>
  \relative c {

  }
</score>

Notes can be entered as the appropriate letters, separated by spaces. LilyPond is whitespace insensitive, so it does not matter how much space is put between any element. Notes can be separated into different lines or follow each other in unbroken sequence without causing any difference.

Notes can be raised an octave by adding an apostrophe after the letter, raised two octaves by adding two apostrophes, and so forth. Similarly, notes can be lowered octaves by adding commas after the letter in the same way. This applies to the note used in relative mode as well: \relative c' is Middle C, \relative c'' is Treble C, \relative c, is Low C, etc.

The duration of notes can be specified by adding a number after the letter: 1 2 4 8 or 16. The default is 4. All subsequent notes will repeat the duration of the previous note until a new duration is specified. If raising or lowering a note as well as changing the duration, the number follows the apostrophe or comma.

For example:

<score sound="1">
  \relative c'' {
    a b c d e f g a
    a, b c2 d e
  }
</score>

  \relative c'' {
    a b c d e f g a
    a, b c2 d e
  }
Basic notation
a b c d e f g Letters separated by space(s) are notes.
a a' a, Apostrophes raise the note by an octave, commas lower the note by an octave.
a1 a2 a4 a8 a16 A number after a note indicates duration (4 is default).
| A pipe creates a bar line (this is not required).

Lyrics

[edit]

Song lyrics can be added directly to a score. They are held in a separate expression and have their own code for certain situations.

The expression for lyrics, which should be added between the same score tags, is \addlyrics { ... }. The whole score will appear something like:

<score>
  \relative c {

  }

  \addlyrics {

  }
</score>

The words of the lyrics should be places in the expression following the addlyrics command. Each syllable should be separated by a space. LilyPond will automatically assign each syllable to a different note.

Example:

<score>
  \relative c'' {
    a b c d
  }
  \addlyrics {
    foo bar baz qux
  }
</score>

  \relative c'' {
    a b c d
  }
  \addlyrics {
    foo bar baz qux
  }

The assignment of syllables to notes can be altered by code based on underscores. Multiple syllables can be aligned to the same note by connecting the syllables with underscores. Alternatively, one syllable can be aligned to multiple notes by using underscores instead of subsequent syllables (which would otherwise be assigned to those notes instead). Extender lines can be created with a double underscore (with space either side of it).

Where a word is split into syllables this is indicated with hyphens between the syllables. Hyphens can be created with a double dash in the lyrics (with spaces on either side).

More LilyPond notation

[edit]
Term Code Description Example Example code
Beam a[ b] Beaming will be created automatically by the extension by default. To force this, however, or if automatic beaming has been deactivated, beaming can be indicated manually. An open square bracket should be placed after the first note to be beamed. A closing square bracket after the last note ends the beam.
{ \relative c'' { b8[ d] d[ c b a] c b } }
<score>
{
  \relative c'' {
    b8[ d] d[ c b a] c b 
  } 
}
</score>
Chord <a b> Chords can be written much like other notes. However, all the notes in a chord should be wrapped in angle brackets. If setting the duration, a single number should be placed after the closing bracket.
{ \relative c'' { <g e> <g b d> <f a c e> <d f>8 <a' c> } }
<score>
{
  \relative c'' {
    <g e> <g b d> <f a c e> <d f>8 <a' c> 
  } 
}
</score>
Rest r Like notes, the duration of rests is set by a following number, e.g. r1 r8 r16 etc.
Full bar rests can be indicated with a capital R.
{ \relative c'' { g b d r } }
<score>
{
  \relative c'' {
    g b d r 
  } 
}
</score>
Slur a( b) Slurred notes work in a similar way to beaming, but using round brackets (parentheses). An open bracket after a note begins the slur and a closing bracket after the final note ends the slur. Slurs cannot be nested.
{ \relative c'' { g( b) d( f) } }
<score>
{
  \relative c'' {
    g( b) d( f) 
  }
}
</score>
Slur (phrasing) a\( b\) Normal slurs can be used inside phrasing slurs.
{ \relative c'' { g\( b d f\) } }
<score>
{
  \relative c'' {
    g\( b d f\)
  }
}
</score>
Spacer s Again, like notes, the duration of spaces is set by a following number, e.g. s1 s8 s16, etc.
{ \relative c'' { b4 s2 b4 } }
<score>
{
  \relative c'' {
    b4 s2 b4
  } 
}
</score>
Ties a ~ b Ties can be indicated with a tilde after the first note. (NB: Ties look similar to slurs but only occur with notes of the same pitch.)
{ \relative c'' { b~ b d~ d} }
<score>
{
  \relative c'' {
    b~ b d~ d
  } 
}
</score>

ABC notation

[edit]
See also: Help:ABC notation

The Score extension also supports ABC. This was originally designed for monophonic Western folk music, although it can be used to typeset pretty complex stuff. It's simpler to learn than LilyPond.

Here's an example of ABC notation in wiki markup

<score lang="ABC" sound="1">
X:173
L:1/4
M:6/4
K:Gm
Q:1/4=120
A|B2BB3/2c/2d|cAFFGA|BAGGAB|AGAD2A|\
B2BB3/2c/2d|c3/2B/2Ac2d|B3/2A/2GAG^F|\
G2AB3/2c/2d|B3/2A/2GA3/2G/2^F|(G3G2)|]
</score>

This produces


X:173
L:1/4
M:6/4
K:Gm
Q:1/4=120
A|B2BB3/2c/2d|cAFFGA|BAGGAB|AGAD2A|\
B2BB3/2c/2d|c3/2B/2Ac2d|B3/2A/2GAG^F|\
G2AB3/2c/2d|B3/2A/2GA3/2G/2^F|(G3G2)|]

Notes

[edit]

The pitch is usually represented by a letter. Middle C is entered as C and all the pitches up to Treble C are capital letter. Treble C and subsequent pitches are entered as lower case letters. The pitches below Middle C, to Bass C, are capitals with a following comma (as in LilyPond) and the pitches from High C upwards are lower case letters with a following apostrophe (also as in LilyPond).

This full sequence is: C, D, E, F, G, A, B, C D E F G A B c d e f g a b c' d' e' f' g' a' b'

Duration is indicated by a fraction after the pitch. For example, C1/2 is a half-length Middle C note. A numerator of 1 or a denominator of 2 can be omitted, so the same note can be represented by C/2 or just C/. If a note is entered without a duration, the default length in the header is used.

Rests are entered as note z.

Header lines

[edit]

Pieces in ABC notation start with header lines that either provides information or can affect the way the score is displayed. Each one is a capital letter, followed by a colon and the appropriate value.

For example, L is the header line for default note length. The following sets the note length for a piece at a crotchet or quarter-length note: L:1/4

List of header lines
Header Use
B Book
C Composer's name
D Discography
H History
K Key (a single letter for the pitch, followed by a lower-case "m" if minor)
L Default note length (given as a fraction, e.g. 1/8 for a quaver)
M Meter (appears like length but refers to the time signature, e.g. 4/4)
N Comment
O Origin
Q Tempo (1/4=120 indicates 120 quarter notes per minute)
T Title
R Rhythm (entered as text)
S Source
X Sequence number
Z Transcription notes (who transcribed it)

Audible output

[edit]

As well as simply allowing Wikisource users to write in musical notation, the Score extension can generate a MIDI file from the score notation and even turn this into audio that you can play on the page.

Clicking the image generated by the Score extension offers links to download the LilyPond and generated MIDI files. To enable audio playing, add sound="1" (replaces the deprecated vorbis="1" attribute) to the opening <score> tag. The extension creates a JavaScript control module below the image of the score, which can stream the generated audio file; you can play and pause and adjust the volume of the audio.

Example:

<score sound="1"> ... </score>

Additionally, you could override the MIDI and Ogg Vorbis files. With additional attributes, the Score extension can instead use a MIDI or Ogg Vorbis file uploaded to Wikisource or Wikimedia Commons (in the File: namespace as normal).

The override_ attributes are deprecated, see mw:Project:Tech News/2019#Tech_News:_2019-25. Instead you can provide wikilinks to these media files.

Examples:

<score override_midi="Example.midi"> ... </score>
<score sound="1" override_ogg="Example.ogg"> ... </score>

Merging multiple parts of score-based music from Page namespace

[edit]
See: Template:Tscore
[edit]

LilyPond

[edit]
  • Help:Score on English Wikipedia has more examples of entering LilyPond syntax in the <score> element.

ABC

[edit]