Open main menu
This page is a translated version of the page Extension:Score and the translation is 14% complete.

Other languages:
English • ‎español • ‎français • ‎فارسی • ‎中文 • ‎日本語 • ‎한국어
OOjs UI icon advanced.svg
发布状态: 稳定版
实现 Tag
描述 允许通过LilyPond渲染乐谱
作者 Alexander Klauer, Étienne Beaulé
最新版本 0.3 (2014-03-28)
MediaWiki 1.25+
PHP 5.3+
许可协议 GNU General Public License 3.0 or later
  • $wgScoreLilyPond
  • $wgScoreAbc2Ly
  • $wgScoreFluidsynth
  • $wgScoreSoundfont
  • $wgScoreTimidity
  • $wgScoreLame
  • $wgScoreTrim
  • $wgScorePath
  • $wgScoreDirectory
  • $wgScoreFileBackend
问题 开放的工作 · 报告错误

The Score extension allows the rendering of musical scores as PNG images using LilyPond and can also transform them into audio and MIDI files.

The documentation on this page refers to the current master of the Score extension. If you download version 0.1, refer to the README file.




After setup, you can embed simple LilyPond notation into your wikitext using the score tags. For example:

<score>\relative c' { f d f a d f e d cis a cis e a g f e }</score>



You may also specify attributes to the score tags in the general form

<score attribute1="value1" attribute2="value2"></score>.


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



The following attributes are available:

Attribute Allowed values Effect
lang ABC, lilypond (default) Sets the score language. For example, to provide a score in ABC notation, you might use
<score lang="ABC">
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'|]
midi 0 (default), 1 If set to 1, the rendered image(s) will be embedded into a hyperlink to an appropriate MIDI file.
override_midi Known file name, that is, if override_midi="name" is given, [[File:name]] does not yield a red link Uses the specified MIDI file instead of generating one with LilyPond. Use this attribute together with the midi attribute (see before) or the sound attribute (see later). This attribute is useful if you already have a MIDI file whose quality is superior to what would be generated by LilyPond.
override_audio Known file name, that is, if override_audio="name" is given, [[File:Name]] does not yield a red link Embeds the media specified by the file name in the HTML after the score image(s). This is an alternative to the sound attribute (see further). It can, for example, be useful if you have a suitable audio file of superior quality compared with the auto-generated audio file. Of course, you can still omit both attributes in this case and add the file manually to the page, if you prefer.
raw 0 (default), 1 If set to 1, the score code is interpreted as a complete LilyPond file. Use this option if you want to create more complex scores. If the score language (lang attribute) is not set to lilypond, this attribute is ignored. By default (when raw=0), provided code is wrapped in a \score{...} block, along with default \layout{...} and \midi{...} blocks, if not already provided.
sound 0 (default), 1 If set to 1, an audio file will be generated for the score, provided you installed and configured Extension:TimedMediaHandler. An audio player will be embedded in the HTML after the score image(s).
vorbis 0 (default), 1 Deprecated alias for sound.

Lyrics may be added like this:

<score>\relative c'' { \time 4/4 \key c \major 
c4 g8 g a4 g r b^> c^> r \bar "|." } 
\addlyrics { Shave and a hair -- cut: two bits. }</score>


This extension uses LilyPond to render score images, so you need a working LilyPond installation. If you want the extension to trim the score files for you, you will also need ImageMagick.

The extension is also capable of creating audio files from the MIDI files generated by LilyPond. If you want to make use of this functionality, you need to have Extension:TimedMediaHandler installed.

Version 0.1 of this extension was tested with MediaWiki 1.18.0 and LilyPond 2.12.3. The current git snapshot might require a newer version of MediaWiki and/or LilyPond.

Download instructions

Use the extension distributor. You can also download a tarball from GitHub: [1]; or as a zipped file: [2]. The score master branch on GitHub works with a stable version of MediaWiki, but may not yet have the newest features in it.


  • 下载文件,并将其放置在您extensions/文件夹中的Score目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    wfLoadExtension( 'Score' );
    $wgScoreLilyPond = '/path/to/your/lilypond/executable'; /* required */
    $wgScoreAbc2Ly = '/path/to/your/abc2ly/executable'; /* if you want ABC to LilyPond conversion */
    $wgScoreFluidsynth = '/path/to/your/fluidsynth/executable'; /* if you want MIDI to audio conversion */
    $wgScoreSoundfont = '/path/to/your/soundfont/file'; /* required for Fluidsynth */
    $wgScoreTimidity = '/path/to/your/timidity/executable'; /* fallback when Fluidsynth is not installed */
    $wgScoreLame = '/path/to/your/lame/executable'; /* required to convert audio file for MP3 */
    $wgScoreTrim = true; /* Set to false if you don't want score trimming */
  • Create a subdirectory named lilypond in your $wgUploadDirectory (usually the directory named images in in your MediaWiki directory). Make sure the directory is writable by your Web server.
  •   完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。

致使用MediaWiki 1.26或更早版本的用户:

上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension() 如果您需要在早期版本(MediaWiki 1.26和更早版本)中安装此扩展,而不是wfLoadExtension( 'Score' );,您需要使用:

require_once "$IP/extensions/Score/Score.php";


Currently, the extension has the following global configuration parameters.


Set $wgScoreLilyPond to the path to your LilyPond executable (typically /usr/bin/lilypond or /usr/local/bin/lilypond).


The $wgScoreTrim is a boolean which defaults to the value of $wgUseImageMagick. If true, the resulting score PNG images are trimmed with ImageMagick. If you don't want trimming, or don't want to install ImageMagick, set $wgScoreTrim to false.


Set $wgScoreAbc2Ly to the path of your ABC to LilyPond converter executable (typically /usr/bin/abc2ly or /usr/local/bin/abc2ly).


Set $wgScoreFluidsynth to the path of your Fluidsynth executable (typically /usr/bin/fluidsynth or /usr/local/bin/fluidsynth).


Set $wgScoreSoundfont to the path of your soundfont file (typically /usr/share/sounds/sf2/FluidR3_GM.sf2 or /usr/share/sounds/sf2/FluidR3_GS.sf2).


Set $wgScoreTimidity to the path of your TiMidity++ executable (typically /usr/bin/timidity or /usr/local/bin/timidity). If $wgScoreFluidsynth does not exist, TiMidity++ will be used as fallback instead.


Set $wgScoreLame to the path of your Lame executable (typically /usr/bin/lame or /usr/local/bin/lame). Required if the generated audio file should be a MP3.


This extension runs various binaries on a shell. You may have to increase $wgMaxShellMemory if you get out of memory errors.

Finding scores

Pages with scores on them will have the "score" page property set. Using Special:PagesWithProp, you can find pages that have scores. (Example query for the English Wikipedia.)

See also

External links